Driver for SX1272 connected to Pulga devices using only DIO0 pins and polling (error states and timeout).
Dependents: pulga-mbed-lorawan-gps mbed-lorawan-pulga mbed-lorawan-pulga-testing-channel mbed-lorawan-pulga-serial_rx ... more
Diff: SX1272/SX1272_LoRaRadio.cpp
- Revision:
- 2:6c5853c2fd72
- Parent:
- 1:3bdd6f917bf5
- Child:
- 3:bca9a8ee555d
diff -r 3bdd6f917bf5 -r 6c5853c2fd72 SX1272/SX1272_LoRaRadio.cpp --- a/SX1272/SX1272_LoRaRadio.cpp Thu Nov 12 21:35:41 2020 +0000 +++ b/SX1272/SX1272_LoRaRadio.cpp Thu Nov 12 22:09:59 2020 +0000 @@ -199,9 +199,6 @@ } radio_is_active = false; - - trace_timer.reset(); - trace_timer.start(); #ifdef MBED_CONF_RTOS_PRESENT irq_thread.start(mbed::callback(this, &SX1272_LoRaRadio::rf_irq_task)); @@ -241,8 +238,6 @@ */ void SX1272_LoRaRadio::init_radio(radio_events_t *events) { - push_trace(SX1272_init_radio); - _radio_events = events; // Reset the radio transceiver @@ -279,7 +274,6 @@ bool SX1272_LoRaRadio::check_rf_frequency(uint32_t frequency) { // Implement check. Currently all frequencies are supported ? What band ? - push_trace(SX1272_check_rf_frequency); return true; } @@ -288,7 +282,6 @@ */ void SX1272_LoRaRadio::set_channel(uint32_t freq) { - push_trace(SX1272_set_channel); _rf_settings.channel = freq; freq = (uint32_t) ((float) freq / (float) FREQ_STEP); write_to_register(REG_FRFMSB, (uint8_t) ((freq >> 16) & 0xFF)); @@ -301,7 +294,6 @@ */ uint8_t SX1272_LoRaRadio::get_status(void) { - push_trace(SX1272_get_status); return _rf_settings.state; } @@ -311,8 +303,6 @@ void SX1272_LoRaRadio::sleep() { - push_trace(SX1272_sleep); - // stop timers tx_timeout_timer.detach(); rx_sync_timer.detach(); @@ -328,8 +318,6 @@ */ void SX1272_LoRaRadio::set_operation_mode(uint8_t mode) { - push_trace(SX1272_set_operation_mode); - if (mode == RF_OPMODE_SLEEP) { set_low_power_mode(true); } else { @@ -348,8 +336,6 @@ */ void SX1272_LoRaRadio::set_modem(uint8_t modem) { - push_trace(SX1272_set_modem); - if ((read_register(REG_OPMODE) & RFLR_OPMODE_LONGRANGEMODE_ON) != 0 ) { _rf_settings.modem = MODEM_LORA; } else { @@ -397,7 +383,6 @@ */ void SX1272_LoRaRadio::radio_reset() { - push_trace(SX1272_radio_reset); _reset_ctl.output(); _reset_ctl = 0; wait_ms(2); @@ -418,7 +403,6 @@ bool crc_on, bool freq_hop_on, uint8_t hop_period, bool iq_inverted, bool rx_continuous) { - push_trace(SX1272_set_rx_config); set_modem(modem); switch (modem) { @@ -548,7 +532,6 @@ uint8_t hop_period, bool iq_inverted, uint32_t timeout) { - push_trace(SX1272_set_tx_config); set_modem(modem); set_rf_tx_power(power); @@ -668,8 +651,6 @@ uint32_t SX1272_LoRaRadio::time_on_air(radio_modems_t modem, uint8_t pkt_len) { uint32_t airtime = 0; - - push_trace(SX1272_time_on_air); switch (modem) { case MODEM_FSK: { @@ -731,8 +712,6 @@ void SX1272_LoRaRadio::send(uint8_t *buffer, uint8_t size) { uint32_t tx_timeout = 0; - - push_trace(SX1272_send); switch (_rf_settings.modem) { case MODEM_FSK: @@ -816,8 +795,6 @@ */ void SX1272_LoRaRadio::transmit(uint32_t timeout) { - push_trace(SX1272_transmit); - switch (_rf_settings.modem) { case MODEM_FSK: @@ -905,8 +882,6 @@ */ void SX1272_LoRaRadio::receive(void) { - push_trace(SX1272_receive); - switch (_rf_settings.modem) { case MODEM_FSK: // DIO0=PayloadReady @@ -1037,8 +1012,6 @@ */ void SX1272_LoRaRadio::set_max_payload_length(radio_modems_t modem, uint8_t max) { - push_trace(SX1272_set_max_payload_length); - set_modem(modem); switch (modem) { @@ -1060,8 +1033,6 @@ */ void SX1272_LoRaRadio::set_public_network(bool enable) { - push_trace(SX1272_set_public_network); - set_modem(MODEM_LORA); _rf_settings.lora.public_network = enable; @@ -1091,8 +1062,6 @@ bool status = true; int16_t rssi = 0; - push_trace(SX1272_perform_carrier_sense); - set_modem(modem); set_channel(freq); set_operation_mode(RF_OPMODE_RECEIVER); @@ -1128,8 +1097,6 @@ { uint8_t reg_val; - push_trace(SX1272_start_cad); - switch (_rf_settings.modem) { case MODEM_FSK: break; @@ -1164,8 +1131,6 @@ uint16_t time) { uint8_t reg_val; - - push_trace(SX1272_set_tx_continuous_wave); set_channel(freq); set_tx_config(MODEM_FSK, power, 0, 0, 4800, 0, 5, false, false, 0, 0, 0, time * 1000); @@ -1186,7 +1151,6 @@ */ void SX1272_LoRaRadio::standby( void ) { - push_trace(SX1272_standby); tx_timeout_timer.detach(); rx_sync_timer.detach(); lora_cad_timer.detach(); @@ -1209,8 +1173,6 @@ { uint8_t i; uint32_t rnd = 0; - - push_trace(SX1272_random); // Set LoRa modem ON set_modem(MODEM_LORA); @@ -1758,8 +1720,6 @@ void SX1272_LoRaRadio::handle_dio0_irq() { volatile uint8_t irqFlags = 0; - - push_trace(SX1272_dio0_irq); switch (_rf_settings.state) { case RF_RX_RUNNING: @@ -1936,8 +1896,6 @@ void SX1272_LoRaRadio::handle_dio1_irq() { - push_trace(SX1272_dio1_irq); - switch(_rf_settings.state ) { case RF_RX_RUNNING: @@ -2004,8 +1962,6 @@ void SX1272_LoRaRadio::handle_dio2_irq(void) { - push_trace(SX1272_dio2_irq); - switch(_rf_settings.state ) { case RF_RX_RUNNING: @@ -2064,7 +2020,6 @@ void SX1272_LoRaRadio::handle_timeout_irq() { - push_trace(SX1272_timeout_irq); tx_timeout_timer.detach(); if (_rf_settings.state == RF_TX_RUNNING) { @@ -2109,8 +2064,6 @@ } else { - push_trace(SX1272_rxsymb_irq); - // Sync time out _rf_settings.state = RF_IDLE; @@ -2184,23 +2137,3 @@ } } } - -bool SX1272_LoRaRadio::pop_trace(SX1272_Trace &trace) -{ - if (trace_buf.empty()) { - return false; - } - trace_buf.pop(trace); - return true; -} - -void SX1272_LoRaRadio::push_trace(uint32_t state) -{ - SX1272_Trace trace; - - trace.state = state; - trace.interval = trace_timer.read_us(); - trace_timer.reset(); - - trace_buf.push(trace); -}