Mercurial > public > ostc4
changeset 872:5e027b0f7475 Evo_2_23
Added first time initialization for new bluetooth module:
The serial numbers are not defined when the electonic is connected to power for the first time. This event is used to run a initialization sequence which sets the defaults for the bluetooth modul. At the end the module may be accessed using a default name.
author | Ideenmodellierer |
---|---|
date | Wed, 14 Aug 2024 14:41:04 +0200 |
parents | bc6c90e20d9e |
children | e373e90a48db |
files | BootLoader/Src/base_bootlader.c Discovery/Inc/ostc_hw2.h Discovery/Inc/tComm.h Discovery/Src/tComm.c |
diffstat | 4 files changed, 84 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/BootLoader/Src/base_bootlader.c Mon Aug 12 22:25:46 2024 +0200 +++ b/BootLoader/Src/base_bootlader.c Wed Aug 14 14:41:04 2024 +0200 @@ -513,9 +513,6 @@ if((i == 0) && (callForUpdate == 0)) firmware_JumpTo_Application(); - - - MX_Bluetooth_PowerOn(); MX_SPI_Init(); SDRAM_Config(); HAL_Delay(100); @@ -707,19 +704,26 @@ textVersion[ptr++] = '\020'; textVersion[ptr] = 0; + TIM_init(); + MX_UART_Init(); + MX_Bluetooth_PowerOn(); + tComm_init(); + tInfo_button_text("Exit","","Sleep"); tInfo_newpage("Bootloader 240812"); tInfo_write("start bluetooth"); tInfo_write(""); tInfo_write(textVersion); - tInfo_write(""); - - TIM_init(); - MX_UART_Init(); - MX_Bluetooth_PowerOn(); - tComm_Set_Bluetooth_Name(0); - tComm_init(); - tComm_StartBlueModConfig(); + if(tComm_Set_Bluetooth_Name(0) == 0xFF) + { + tInfo_write("Init bluetooth"); + tComm_StartBlueModBaseInit(); + } + else + { + tInfo_write(""); + tComm_StartBlueModConfig(); + } set_globalState_Base();
--- a/Discovery/Inc/ostc_hw2.h Mon Aug 12 22:25:46 2024 +0200 +++ b/Discovery/Inc/ostc_hw2.h Wed Aug 14 14:41:04 2024 +0200 @@ -197,4 +197,11 @@ #define RESET_LOGIC_ALLES_OK_GPIO_PORT GPIOB #define RESET_LOGIC_ALLES_OK_GPIO_ENABLE() __GPIOB_CLK_ENABLE() +/* new OSTC5 */ +#define BLE_UBLOX_DSR_PIN GPIO_PIN_12 +#define BLE_UBLOX_DSR_GPIO_PORT GPIOC +#define BLE_UBLOX_DSR_GPIO_ENABLE() __GPIOC_CLK_ENABLE() + + + #endif // OSTC_HW2_H
--- a/Discovery/Inc/tComm.h Mon Aug 12 22:25:46 2024 +0200 +++ b/Discovery/Inc/tComm.h Wed Aug 14 14:41:04 2024 +0200 @@ -42,7 +42,22 @@ BM_CONFIG_BAUD, BM_CONFIG_SILENCE, BM_CONFIG_DONE, - BM_CONFIG_RETRY + BM_CONFIG_RETRY, +#ifdef BOOTLOADER_STANDALONE + BM_INIT_TRIGGER_ON = 100, + BM_INIT_TRIGGER_OFF, + BM_INIT_FACTORY, + BM_INIT_MODE, + BM_INIT_BLE, + BM_INIT_NAME, + BM_INIT_SSP_IDO_OFF, + BM_INIT_SSP_IDO_ON, + BM_INIT_SSP_ID1_OFF, + BM_INIT_SSP_ID1_ON, + BM_INIT_STORE, + BM_INIT_RESTART, + BM_INIT_DONE +#endif } BlueModTmpConfig_t; /* Exported functions --------------------------------------------------------*/ @@ -53,6 +68,7 @@ void tComm_exit(void); void tComm_verlauf(uint8_t percentage_complete); uint8_t tComm_Set_Bluetooth_Name(uint8_t force); +void tComm_StartBlueModBaseInit(void); void tComm_StartBlueModConfig(void); void tComm_RequestBluetoothStrength(void);
--- a/Discovery/Src/tComm.c Mon Aug 12 22:25:46 2024 +0200 +++ b/Discovery/Src/tComm.c Wed Aug 14 14:41:04 2024 +0200 @@ -111,7 +111,7 @@ #define UART_TIMEOUT_SECONDS (120u) /* Timeout for keeping connection open and waiting for data */ #define UART_TIMEOUT_LARGE_BLOCK (6000u) /* Timeout (ms) for reception of an 16K data block (typical RX time ~4,5seconds) */ -#define UART_CMD_BUF_SIZE (20u) /* size of buffer for command exchange */ +#define UART_CMD_BUF_SIZE (30u) /* size of buffer for command exchange */ const uint8_t id_Region1_firmware = 0xFF; const uint8_t id_RTE = 0xFE; @@ -370,6 +370,13 @@ hardware_programmPrimaryBluetoothNameSet(); #endif } + else /* no serial set at all => do default configuration of the module */ + { +#define NINAB22103B00 +#ifdef NINAB22103B00 + answer = 0xFF; +#endif + } return answer; } @@ -2141,6 +2148,10 @@ } } +void tComm_StartBlueModBaseInit() +{ + BmTmpConfig = BM_INIT_TRIGGER_ON; +} void tComm_StartBlueModConfig() { uint8_t answer = HAL_OK; @@ -2192,6 +2203,39 @@ ConfigRetryCnt = 0; RestartModule = 1; break; +#ifdef BOOTLOADER_STANDALONE + case BM_INIT_TRIGGER_ON: HAL_Delay(2000); + HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); + BmTmpConfig++; + break; + case BM_INIT_TRIGGER_OFF: HAL_Delay(1); + HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_SET); + HAL_Delay(2000); + BmTmpConfig++; + break; + case BM_INIT_FACTORY: sprintf(TxBuffer,"AT+UFACTORY\r"); /*Set to factory defined configuration */ + break; + case BM_INIT_MODE: sprintf(TxBuffer,"AT+UMSM=1\r"); /* start in Data mode */ + break; + case BM_INIT_BLE: sprintf(TxBuffer,"AT+UBTLE=2\r"); /* Bluetooth low energy Peripheral */ + break; + case BM_INIT_NAME: sprintf(TxBuffer,"AT+UBTLN=OSTC4-12345\r"); /* Bluetooth name */ + break; + case BM_INIT_SSP_IDO_OFF: sprintf(TxBuffer,"AT+UDSC=0,0\r"); /* Disable SPP Server on ID0 */ + break; + case BM_INIT_SSP_IDO_ON: sprintf(TxBuffer,"AT+UDSC=0,3\r"); /* SPP Server on ID0 */ + break; + case BM_INIT_SSP_ID1_OFF: sprintf(TxBuffer,"AT+UDSC=1,0\r"); /* Disable SPS Server on ID1 */ + break; + case BM_INIT_SSP_ID1_ON: sprintf(TxBuffer,"AT+UDSC=1,6\r"); /* SPS Server on ID1 */ + break; + case BM_INIT_STORE: sprintf(TxBuffer,"AT&W\r"); /* write settings into eeprom */ + break; + case BM_INIT_RESTART: sprintf(TxBuffer,"AT+CPWROFF\r"); /* reboot module */ + break; + case BM_INIT_DONE: BmTmpConfig = BM_CONFIG_ECHO; + break; +#endif default: break; }