tweaking _send checking and holding, Im not sure _send should actually block, this probably should be handled by application code
This commit is contained in:
parent
1933bc70d5
commit
5fd28a946f
2 changed files with 13 additions and 4 deletions
|
|
@ -98,7 +98,7 @@
|
||||||
|
|
||||||
#define ERR_LOR_VERSION_MISMATCH (01)
|
#define ERR_LOR_VERSION_MISMATCH (01)
|
||||||
|
|
||||||
#define LORA32_DEFAULT_CONFIG() {\
|
#define LORA32_DEFAULT_CONFIG() (lora32_cfg_t){\
|
||||||
.bandwidth = 7,\
|
.bandwidth = 7,\
|
||||||
.codingRate = 5,\
|
.codingRate = 5,\
|
||||||
.frequency = 915000000,\
|
.frequency = 915000000,\
|
||||||
|
|
@ -134,6 +134,7 @@ typedef void (*cadDetectedCallback)(lora32_cfg_t *lora);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
EventGroupHandle_t state;
|
EventGroupHandle_t state;
|
||||||
|
void *driver;
|
||||||
} lora32_handle_t;
|
} lora32_handle_t;
|
||||||
|
|
||||||
typedef struct lora32_modem_status_t {
|
typedef struct lora32_modem_status_t {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ uint8_t lora32_read_reg(lora32_cfg_t *lora, uint8_t address) {
|
||||||
|
|
||||||
ESP_ERROR_CHECK(spi_device_transmit(lora->spi, &t));
|
ESP_ERROR_CHECK(spi_device_transmit(lora->spi, &t));
|
||||||
|
|
||||||
ESP_LOGV(TAG, "<%2X<%2X", address, t.rx_data[1]);
|
ESP_LOGV(TAG, "<%02X<%02X", address, t.rx_data[1]);
|
||||||
|
|
||||||
xSemaphoreGive(spi_semaphore);
|
xSemaphoreGive(spi_semaphore);
|
||||||
|
|
||||||
|
|
@ -150,9 +150,17 @@ void lora32_enable_tx(lora32_cfg_t *lora) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lora32_send(lora32_cfg_t *lora, uint8_t *data, uint8_t len) {
|
void lora32_send(lora32_cfg_t *lora, uint8_t *data, uint8_t len) {
|
||||||
if(lora == NULL) return;
|
if(lora == NULL) {
|
||||||
|
ESP_LOGE(TAG, "lora NULL");
|
||||||
|
|
||||||
xEventGroupWaitBits(lora->handle.state, MODE_ALL ^ MODE_TX, true, false, portMAX_DELAY);
|
return;
|
||||||
|
} else {
|
||||||
|
ESP_LOGD(TAG, "lora: %p", lora);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((xEventGroupGetBits(lora->handle.state) & MODE_TX) == MODE_TX) {
|
||||||
|
xEventGroupWaitBits(lora->handle.state, MODE_ALL ^ MODE_TX, true, false, portMAX_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
ESP_ERROR_CHECK(spi_device_acquire_bus(lora->spi, portMAX_DELAY));
|
ESP_ERROR_CHECK(spi_device_acquire_bus(lora->spi, portMAX_DELAY));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue