Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around for 200 series #528

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/asic/include/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ void SERIAL_init(void);
void SERIAL_debug_rx(void);
int16_t SERIAL_rx(uint8_t *, uint16_t, uint16_t);
void SERIAL_clear_buffer(void);
void SERIAL_set_baud(int baud);
void SERIAL_set_baud(int baud, bool wait);

#endif /* SERIAL_H_ */
8 changes: 5 additions & 3 deletions components/asic/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ void SERIAL_init(void)
uart_driver_install(UART_NUM_1, BUF_SIZE * 2, BUF_SIZE * 2, 0, NULL, 0);
}

void SERIAL_set_baud(int baud)
void SERIAL_set_baud(int baud, bool wait)
{
ESP_LOGI(TAG, "Changing UART baud to %i", baud);

// Make sure that we are done writing before setting a new baudrate.
uart_wait_tx_done(UART_NUM_1, 1000 / portTICK_PERIOD_MS);
if (wait) {
// Make sure that we are done writing before setting a new baudrate.
uart_wait_tx_done(UART_NUM_1, 1000 / portTICK_PERIOD_MS);
}

uart_set_baudrate(UART_NUM_1, baud);
}
Expand Down
5 changes: 4 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ void app_main(void)

SERIAL_init();
(*GLOBAL_STATE.ASIC_functions.init_fn)(GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value, GLOBAL_STATE.asic_count);
SERIAL_set_baud((*GLOBAL_STATE.ASIC_functions.set_max_baud_fn)());

// Temporary work around for older boards.
bool wait_for_tx = GLOBAL_STATE.board_version >= 300;
SERIAL_set_baud((*GLOBAL_STATE.ASIC_functions.set_max_baud_fn)(), wait_for_tx);
SERIAL_clear_buffer();

GLOBAL_STATE.ASIC_initalized = true;
Expand Down
6 changes: 5 additions & 1 deletion main/self_test/self_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ void self_test(void * pvParameters)

int baud = (*GLOBAL_STATE->ASIC_functions.set_max_baud_fn)();
vTaskDelay(10 / portTICK_PERIOD_MS);
SERIAL_set_baud(baud);


// Temporary work around for older boards.
bool wait_for_tx = GLOBAL_STATE->board_version >= 300;
SERIAL_set_baud(baud, wait_for_tx);

vTaskDelay(1000 / portTICK_PERIOD_MS);

Expand Down