Update usart dir

This commit is contained in:
CVR 2021-09-13 11:02:29 +12:00
parent fc7211c4a1
commit 1f41c5d920
2 changed files with 21 additions and 14 deletions

View File

@ -8,7 +8,7 @@
*/
#define F_CPU 8000000UL
#include "../../src/mrf24j.h"
#include "../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 "../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);
}