Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: pulga-lorawan-drv SX1272
main.cpp
- Committer:
- pancotinho
- Date:
- 2021-03-31
- Revision:
- 9:cf555a570349
- Parent:
- 8:856f7a8cc20c
- Child:
- 10:f6ff8ec221ec
File content as of revision 9:cf555a570349:
#include "mbed.h"
#include "serial.h"
#include "lora.h"
///////////////////////////////////////
// Globals variables
///////////////////////////////////////
//declaracoes gerais
InterruptIn dio0(P0_12);
DigitalIn button1(P1_11);
EventQueue queue;
void serial_post_to_queue(void);
void serial_rx(){
if(pc.readable()){
pc.printf("rx: %c\n", pc.getc());
}
pc.attach(&serial_post_to_queue, RawSerial::RxIrq);
return;
}
void serial_post_to_queue(void){
//disable serial rx interrupt
pc.attach(NULL, RawSerial::RxIrq);
//enqueue the serial rx reception as a normal task
queue.call(SerialRx);
//queue.event(&SerialRx);
return;
}
int main(void) {
///////////////////////////////////////
// Configuration
///////////////////////////////////////
pc.printf("init\n");
pc.baud(9600);
pc.printf("config9600\n");
//enable serial rx interrupt
//pc.attach(&serial_post_to_queue, RawSerial::RxIrq);
wait_ms(250);
//____Configuration Lora
Thread eventThread;
eventThread.start(callback(&queue, &EventQueue::dispatch_forever));
dio0.rise(queue.event(&print_packet)); //configure interrupt rotine ro recieve packet
pc.attach(&SerialRx, RawSerial::RxIrq);
setup(); //configura sx1272
sx1272.writeRegister(REG_OP_MODE,133); //leitura continua
sx1272.writeRegister(REG_IRQ_FLAGS_MASK,187);//configure interrupt mask to interrupt only when a packet receive and packet envied
while(1){
if (!button1){
pc.printf("SENDING PING\n");
send_data(PING);
}
wait_ms(50);
}
}