Skip to content

Commit

Permalink
Update based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
eandersson committed Nov 9, 2024
1 parent c5563bd commit 5989053
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/asic/bm1370.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void _send_BM1370(uint8_t header, uint8_t * data, uint8_t data_len, bool
}

// send serial data
if (SERIAL_send(buf, total_length, debug) == 0) {
if (SERIAL_send(buf, total_length, debug) != ESP_OK) {
ESP_LOGE(TAG, "Failed to send data to BM1370");
}

Expand Down
2 changes: 1 addition & 1 deletion components/asic/include/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define SERIAL_BUF_SIZE 16
#define CHUNK_SIZE 1024

int SERIAL_send(uint8_t *, int, bool);
esp_err_t SERIAL_send(uint8_t *, int, bool);
void SERIAL_init(void);
void SERIAL_debug_rx(void);
int16_t SERIAL_rx(uint8_t *, uint16_t, uint16_t);
Expand Down
14 changes: 11 additions & 3 deletions components/asic/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,26 @@ void SERIAL_set_baud(int baud)
uart_set_baudrate(UART_NUM_1, baud);
}

int SERIAL_send(uint8_t *data, int len, bool debug)
esp_err_t SERIAL_send(uint8_t *data, int len, bool debug)
{
int written = uart_write_bytes(UART_NUM_1, (const char *)data, len);
uart_wait_tx_done(UART_NUM_1, portMAX_DELAY);

if (debug)
{
printf("tx: ");
prettyHex((unsigned char *)data, len);
printf("\n");
}

return written;
if (written == 0) {
return ESP_FAIL;
}

if (uart_wait_tx_done(UART_NUM_1, 1000 / portTICK_PERIOD_MS) != ESP_OK) {
return ESP_FAIL;
}

return ESP_OK;
}

/// @brief waits for a serial response from the device
Expand Down
2 changes: 2 additions & 0 deletions sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ CONFIG_SPIFFS_OBJ_NAME_LEN=64
CONFIG_HTTPD_MAX_URI_LEN=2048
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP_WIFI_11KV_SUPPORT=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF=y
CONFIG_FREERTOS_HZ=1000

0 comments on commit 5989053

Please sign in to comment.