Baudrate change done
This commit is contained in:
parent
33e70f5baf
commit
d26079f722
@ -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 */
|
||||
|
@ -32,7 +32,7 @@ CO2_alert_limit_1 = 1000
|
||||
CO2_alert_limit_2 = 2000
|
||||
SCD4x_temperature_offset = 0
|
||||
MODBUS_address = 254
|
||||
baudrate = 1
|
||||
baudrate = 0
|
||||
registers = [LED_on, LED_brightness, LED_smooth, CO2_alert_limit_1, CO2_alert_limit_2, SCD4x_temperature_offset, MODBUS_address, baudrate]
|
||||
# write to holding registers
|
||||
print('---- Writing to multiple holding registers ----')
|
||||
|
Loading…
Reference in New Issue
Block a user