Update usart dir
This commit is contained in:
parent
fc7211c4a1
commit
1f41c5d920
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
#define F_CPU 8000000UL
|
#define F_CPU 8000000UL
|
||||||
#include "../../src/mrf24j.h"
|
#include "../../src/mrf24j.h"
|
||||||
#include "../usart.h"
|
#include "../usart/src/usart.h"
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
|
@ -28,34 +28,36 @@ int main() {
|
||||||
// This is _our_ address
|
// This is _our_ address
|
||||||
mrf.address16_write(0x4202);
|
mrf.address16_write(0x4202);
|
||||||
mrf.handlers(&handle_rx, &handle_tx);
|
mrf.handlers(&handle_rx, &handle_tx);
|
||||||
mrf.turbo();
|
//mrf.turbo();
|
||||||
|
|
||||||
sei();
|
sei();
|
||||||
|
printf("Started");
|
||||||
while(1) {
|
while(1) {
|
||||||
//printf("txxxing...\n\r");
|
//printf("txxxing...\n\r");
|
||||||
//mrf.send16(0x4201, "abcd");
|
//mrf.send16(0x4201, "abcd");
|
||||||
_delay_ms(5000);
|
//_delay_ms(5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void handle_rx() {
|
void handle_rx() {
|
||||||
|
printf("------------------------------------------------------\n\r");
|
||||||
printf("received a packet %i bytes long\n\r", mrf.get_rxinfo()->frame_length);
|
printf("received a packet %i bytes long\n\r", mrf.get_rxinfo()->frame_length);
|
||||||
|
|
||||||
if(mrf.get_bufferPHY()){
|
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++) {
|
for (int i = 0; i < mrf.get_rxinfo()->frame_length; i++) {
|
||||||
printf("%x", mrf.get_rxbuf()[i]);
|
printf("%x", mrf.get_rxbuf()[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("\r\nASCII data (relevant data):\n\r");
|
printf("\r\nASCII data (relevant data): ");
|
||||||
// for (int i = 0; i < mrf.rx_datalength(); i++) {
|
for (int i = 0; i < mrf.rx_datalength(); i++) {
|
||||||
// usart::put(mrf.get_rxinfo()->rx_data[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);
|
printf("%i/%i\n\r", mrf.get_rxinfo()->lqi, mrf.get_rxinfo()->rssi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#define F_CPU 8000000UL
|
#define F_CPU 8000000UL
|
||||||
#include "../../src/mrf24j.h"
|
#include "../../src/mrf24j.h"
|
||||||
#include "../usart.h"
|
#include "../usart/src/usart.h"
|
||||||
#include "../../src/driver.h"
|
#include "../../src/driver.h"
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
@ -32,15 +32,20 @@ int main() {
|
||||||
mrf.address16_write(0x4201);
|
mrf.address16_write(0x4201);
|
||||||
mrf.handlers(&handle_rx, &handle_tx);
|
mrf.handlers(&handle_rx, &handle_tx);
|
||||||
//mrf.enable_wake();
|
//mrf.enable_wake();
|
||||||
mrf.set_bufferPHY(true);
|
//mrf.set_bufferPHY(true);
|
||||||
mrf.turbo();
|
//mrf.turbo();
|
||||||
mrf.set_power(0b1100000);
|
//mrf.set_power(0b1100000);
|
||||||
//mrf.sleep();
|
//mrf.sleep();
|
||||||
sei();
|
sei();
|
||||||
|
printf("Started\n\r");
|
||||||
|
int i = 0;
|
||||||
|
char tmp[20];
|
||||||
while(1) {
|
while(1) {
|
||||||
printf("txxxing...\n\r");
|
printf("txxxing...\n\r");
|
||||||
//mrf.wake();
|
//mrf.wake();
|
||||||
mrf.send16(0x4202, "Tx Hello");
|
|
||||||
|
sprintf(tmp,"Received %i\n\r", i++);
|
||||||
|
mrf.send16(0x4202, tmp);
|
||||||
|
|
||||||
_delay_ms(2000);
|
_delay_ms(2000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue