Baudrate change done
This commit is contained in:
@@ -14,19 +14,17 @@
|
||||
* - default value has index 0 */
|
||||
const uint32_t config_baudrates[] = {
|
||||
19200, // 0
|
||||
1200, // 1
|
||||
2400, // 2
|
||||
4800, // 3
|
||||
9600, // 4
|
||||
14400, // 5
|
||||
19200, // 6
|
||||
28800, // 7
|
||||
38400, // 8
|
||||
57600, // 9
|
||||
76800, // 10
|
||||
115200 // 11
|
||||
4800, // 1
|
||||
9600, // 2
|
||||
14400, // 3
|
||||
19200, // 4
|
||||
28800, // 5
|
||||
38400, // 6
|
||||
57600, // 7
|
||||
76800, // 8
|
||||
115200 // 9
|
||||
};
|
||||
const uint8_t config_baudrates_length = 12;
|
||||
const uint8_t config_baudrates_length = 10;
|
||||
|
||||
/* Function to lock the EEPROM */
|
||||
static int8_t eeprom_lock(void);
|
||||
|
||||
@@ -228,6 +228,7 @@ int main(void)
|
||||
/* SPS30 Init Time: max 30000 ms (datasheet pg. 2) */
|
||||
LL_mDelay(1000);
|
||||
|
||||
static uint32_t new_baud;
|
||||
|
||||
/* Enter the main loop */
|
||||
while (1)
|
||||
@@ -264,11 +265,21 @@ int main(void)
|
||||
}
|
||||
if (baudrate_changed)
|
||||
{
|
||||
/* TODO: TEST */
|
||||
// LL_LPUART_Disable(LPUART1);
|
||||
// MX_LPUART1_UART_Init();
|
||||
// LL_LPUART_Enable(LPUART1);
|
||||
while (!LL_LPUART_IsActiveFlag_TXE(LPUART1));
|
||||
LL_LPUART_Disable(LPUART1);
|
||||
LL_LPUART_DisableIT_IDLE(LPUART1);
|
||||
LL_LPUART_EnableIT_RXNE(LPUART1);
|
||||
|
||||
LL_LPUART_SetBaudRate(LPUART1, SYSTICK_FREQ_HZ, config_baudrates[sensor_config.baudrate_index]);
|
||||
|
||||
LL_LPUART_Enable(LPUART1);
|
||||
LL_LPUART_EnableIT_IDLE(LPUART1);
|
||||
LL_LPUART_EnableIT_RXNE(LPUART1);
|
||||
LL_LPUART_EnableDirectionRx(LPUART1);
|
||||
LL_LPUART_EnableDirectionTx(LPUART1);
|
||||
baudrate_changed = 0;
|
||||
|
||||
new_baud = LL_LPUART_GetBaudRate(LPUART1, SYSTICK_FREQ_HZ);
|
||||
}
|
||||
|
||||
/* It is time for measurement */
|
||||
|
||||
Reference in New Issue
Block a user