|
|
|
@ -40,8 +40,8 @@ static esp_err_t sx127x_write_config(sx127x_t *hndl) {
@@ -40,8 +40,8 @@ static esp_err_t sx127x_write_config(sx127x_t *hndl) {
|
|
|
|
|
SX127X_ERROR_CHECK(ret); |
|
|
|
|
|
|
|
|
|
// set auto AGC
|
|
|
|
|
ret = |
|
|
|
|
sx127x_write_register(hndl, SX127X_REG_MODEM_CONFIG_3, SX127X_CONFIG3_AUTO_AGC); |
|
|
|
|
ret = sx127x_write_register(hndl, SX127X_REG_MODEM_CONFIG_3, |
|
|
|
|
SX127X_CONFIG3_AUTO_AGC); |
|
|
|
|
SX127X_ERROR_CHECK(ret); |
|
|
|
|
|
|
|
|
|
ret = sx127x_set_tx_power(hndl, config->tx_power, true); |
|
|
|
@ -179,8 +179,8 @@ static void sx127x_do_tx(sx127x_t *hndl, sx127x_packet_t *packet) {
@@ -179,8 +179,8 @@ static void sx127x_do_tx(sx127x_t *hndl, sx127x_packet_t *packet) {
|
|
|
|
|
_TX_CHECK(sx127x_read_register(hndl, SX127X_REG_IRQ_FLAGS, &irq_flags)); |
|
|
|
|
if (irq_flags & SX127X_IRQ_TX_DONE_MASK) { |
|
|
|
|
// clear tx done bit
|
|
|
|
|
_TX_CHECK( |
|
|
|
|
sx127x_write_register(hndl, SX127X_REG_IRQ_FLAGS, SX127X_IRQ_TX_DONE_MASK)); |
|
|
|
|
_TX_CHECK(sx127x_write_register(hndl, SX127X_REG_IRQ_FLAGS, |
|
|
|
|
SX127X_IRQ_TX_DONE_MASK)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_TX_CHECK(sx127x_read_register(hndl, SX127X_REG_MODEM_CONFIG_2, &config_2)); |
|
|
|
@ -209,8 +209,8 @@ static void sx127x_do_tx(sx127x_t *hndl, sx127x_packet_t *packet) {
@@ -209,8 +209,8 @@ static void sx127x_do_tx(sx127x_t *hndl, sx127x_packet_t *packet) {
|
|
|
|
|
vTaskDelay(1); |
|
|
|
|
} |
|
|
|
|
// clear tx done bit
|
|
|
|
|
_TX_CHECK( |
|
|
|
|
sx127x_write_register(hndl, SX127X_REG_IRQ_FLAGS, SX127X_IRQ_TX_DONE_MASK)); |
|
|
|
|
_TX_CHECK(sx127x_write_register(hndl, SX127X_REG_IRQ_FLAGS, |
|
|
|
|
SX127X_IRQ_TX_DONE_MASK)); |
|
|
|
|
|
|
|
|
|
error: |
|
|
|
|
if (ret != ESP_OK) { |
|
|
|
@ -223,7 +223,7 @@ error:
@@ -223,7 +223,7 @@ error:
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void sx127x_do_rx(sx127x_t *hndl) { |
|
|
|
|
uint8_t irq_flags, packet_len; |
|
|
|
|
uint8_t irq_flags, packet_len, rx_fifo_addr; |
|
|
|
|
sx127x_rx_packet_t packet; |
|
|
|
|
esp_err_t ret; |
|
|
|
|
BaseType_t pdRet; |
|
|
|
@ -245,9 +245,11 @@ static void sx127x_do_rx(sx127x_t *hndl) {
@@ -245,9 +245,11 @@ static void sx127x_do_rx(sx127x_t *hndl) {
|
|
|
|
|
SX127X_LONG_RANGE | SX127X_MODE_STDBY); |
|
|
|
|
|
|
|
|
|
// TODO: implicit header receive?
|
|
|
|
|
_TX_CHECK(sx127x_read_register(hndl, SX127X_REG_FIFO_RX_CURRENT_ADDR, |
|
|
|
|
&rx_fifo_addr)); |
|
|
|
|
_TX_CHECK( |
|
|
|
|
sx127x_write_register(hndl, SX127X_REG_FIFO_ADDR_PTR, rx_fifo_addr)); |
|
|
|
|
_TX_CHECK(sx127x_read_register(hndl, SX127X_REG_RX_NB_BYTES, &packet_len)); |
|
|
|
|
_TX_CHECK(sx127x_write_register(hndl, SX127X_REG_FIFO_ADDR_PTR, |
|
|
|
|
SX127X_REG_FIFO_RX_CURRENT_ADDR)); |
|
|
|
|
|
|
|
|
|
packet.data_len = packet_len; |
|
|
|
|
packet.data = heap_caps_malloc( |
|
|
|
|