Moved baudrates to config
This commit is contained in:
parent
36e2597539
commit
b09de011c1
@ -107,6 +107,17 @@ config_read(&config);
|
||||
#define SYSTICK_FREQ_HZ 12000000
|
||||
#define EEPROM_TIMEOUT_MAX_MS_INV 200
|
||||
|
||||
/*
|
||||
* Variables
|
||||
*/
|
||||
|
||||
extern const uint32_t config_baudrates[];
|
||||
extern const uint8_t config_baudrates_length;
|
||||
|
||||
/*
|
||||
* Type definitions
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* LED CONFIG */
|
||||
@ -124,7 +135,7 @@ typedef struct
|
||||
uint32_t baudrate_index;
|
||||
} config_t;
|
||||
|
||||
/* IMPORTANT: baudrates must be defined in main.c and the default value must be at index 0*/
|
||||
|
||||
/* const uint32_t baudrates [] = {19200, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 76800, 115200}; */
|
||||
|
||||
int8_t config_read(config_t *config);
|
||||
|
@ -7,6 +7,27 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/*
|
||||
* Variables
|
||||
*/
|
||||
/* Baudrates - STM32L0xx can do baudrates from 1200 to 115200
|
||||
* - 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
|
||||
};
|
||||
const uint8_t config_baudrates_length = 12;
|
||||
|
||||
/* Function to lock the EEPROM */
|
||||
static int8_t eeprom_lock(void);
|
||||
/* Function to unlock the EEPROM */
|
||||
|
@ -101,9 +101,6 @@ enum
|
||||
REGISTER_NUM_SERIAL_NUMBER = 30014
|
||||
} identification_registers_numbers;
|
||||
|
||||
/* Baudrates - STM32L0xx can do baudrates from 1200 to 115200 */
|
||||
const uint32_t baudrates [] = {19200, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 76800, 115200};
|
||||
const uint8_t baudrates_length = 12;
|
||||
/* Variables to store the measured data */
|
||||
int CO2, T_SCD4x, RH_SCD4x;
|
||||
int T_SHT4x, RH_SHT4x;
|
||||
@ -490,7 +487,7 @@ static void MX_LPUART1_UART_Init(void)
|
||||
/* USER CODE BEGIN LPUART1_Init 1 */
|
||||
|
||||
/* USER CODE END LPUART1_Init 1 */
|
||||
LPUART_InitStruct.BaudRate = baudrates[sensor_config.baudrate_index];
|
||||
LPUART_InitStruct.BaudRate = config_baudrates[sensor_config.baudrate_index];
|
||||
LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_9B;
|
||||
LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1;
|
||||
LPUART_InitStruct.Parity = LL_LPUART_PARITY_EVEN;
|
||||
@ -709,7 +706,7 @@ int8_t modbus_slave_callback(modbus_transaction_t *transaction)
|
||||
sensor_config.modbus_addr = (uint16_t) transaction->holding_registers[0];
|
||||
break;
|
||||
case REGISTER_NUM_BAUDRATE:
|
||||
if (transaction->holding_registers[0] < baudrates_length)
|
||||
if (transaction->holding_registers[0] < config_baudrates_length)
|
||||
{
|
||||
sensor_config.baudrate_index = (uint16_t) (transaction->holding_registers[0]);
|
||||
baudrate_changed = 1;
|
||||
@ -749,7 +746,7 @@ int8_t modbus_slave_callback(modbus_transaction_t *transaction)
|
||||
sensor_config.modbus_addr = (uint16_t) transaction->holding_registers[i];
|
||||
break;
|
||||
case REGISTER_NUM_BAUDRATE:
|
||||
if (transaction->holding_registers[0] < baudrates_length)
|
||||
if (transaction->holding_registers[0] < config_baudrates_length)
|
||||
{
|
||||
sensor_config.baudrate_index = (uint16_t) (transaction->holding_registers[i]);
|
||||
baudrate_changed = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user