Compare commits

...

6 Commits

Author SHA1 Message Date
CVR 479d07c63f Remove usart files 2021-09-13 11:04:53 +12:00
CVR e23c008cc2 Add usart lib 2021-09-13 11:04:30 +12:00
CVR 1f41c5d920 Update usart dir 2021-09-13 11:02:29 +12:00
CVR fc7211c4a1 Update usart dir 2021-09-13 11:01:14 +12:00
CVR 56c244883b Add usart lib 2021-09-09 12:27:24 +12:00
CVR 7e5acdd896 Add usart lib 2021-09-09 12:27:09 +12:00
5 changed files with 26 additions and 15 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "test/usart"]
path = test/usart
url = https://git.chch.tech/avr/usart.git

View File

@ -6,7 +6,7 @@ CC=avr-g++
OBJCOPY=avr-objcopy
CFLAGS=-Wall -g -mmcu=${MCU} -DF_CPU=${F_CPU} -I.
TARGET=main
SRCS= src/*.cpp $(wildcard lib/*/src/*.cpp)
SRCS= $(wildcard src/*.cpp) test/usart/src/usart.cpp
all: build flash

View File

@ -8,7 +8,7 @@
*/
#define F_CPU 8000000UL
#include "../../src/mrf24j.h"
#include "../../lib/usart/src/usart.h"
#include "../usart/src/usart.h"
#include <avr/interrupt.h>
#include <util/delay.h>
@ -28,34 +28,36 @@ int main() {
// This is _our_ address
mrf.address16_write(0x4202);
mrf.handlers(&handle_rx, &handle_tx);
mrf.turbo();
//mrf.turbo();
sei();
printf("Started");
while(1) {
//printf("txxxing...\n\r");
//mrf.send16(0x4201, "abcd");
_delay_ms(5000);
//_delay_ms(5000);
}
}
void handle_rx() {
printf("------------------------------------------------------\n\r");
printf("received a packet %i bytes long\n\r", mrf.get_rxinfo()->frame_length);
if(mrf.get_bufferPHY()){
printf("Packet data (PHY Payload):\n\r");
printf("Packet data (PHY Payload): ");
for (int i = 0; i < mrf.get_rxinfo()->frame_length; i++) {
printf("%x", mrf.get_rxbuf()[i]);
}
}
// printf("\r\nASCII data (relevant data):\n\r");
// for (int i = 0; i < mrf.rx_datalength(); i++) {
// usart::put(mrf.get_rxinfo()->rx_data[i]);
// }
printf("\r\nASCII data (relevant data): ");
for (int i = 0; i < mrf.rx_datalength(); i++) {
usart::put(mrf.get_rxinfo()->rx_data[i]);
}
printf("\r\nLQI/RSSI=");
printf("LQI/RSSI=");
printf("%i/%i\n\r", mrf.get_rxinfo()->lqi, mrf.get_rxinfo()->rssi);
}

View File

@ -9,7 +9,7 @@
#define F_CPU 8000000UL
#include "../../src/mrf24j.h"
#include "../../lib/usart/src/usart.h"
#include "../usart/src/usart.h"
#include "../../src/driver.h"
#include <avr/interrupt.h>
#include <util/delay.h>
@ -32,15 +32,20 @@ int main() {
mrf.address16_write(0x4201);
mrf.handlers(&handle_rx, &handle_tx);
//mrf.enable_wake();
mrf.set_bufferPHY(true);
mrf.turbo();
mrf.set_power(0b1100000);
//mrf.set_bufferPHY(true);
//mrf.turbo();
//mrf.set_power(0b1100000);
//mrf.sleep();
sei();
printf("Started\n\r");
int i = 0;
char tmp[20];
while(1) {
printf("txxxing...\n\r");
//mrf.wake();
mrf.send16(0x4202, "Tx Hello");
sprintf(tmp,"Received %i\n\r", i++);
mrf.send16(0x4202, tmp);
_delay_ms(2000);
}

1
test/usart Submodule

@ -0,0 +1 @@
Subproject commit 05034f925671f06abe15097326b05eceeef0bc1e