Mercurial > public > ostc4
diff Discovery/Src/ostc.c @ 981:c6c781a2e85b default
Merge into default
| author | heinrichsweikamp |
|---|---|
| date | Tue, 11 Feb 2025 18:12:00 +0100 |
| parents | 8d3f3a635397 |
| children | 33b91584d827 |
line wrap: on
line diff
--- a/Discovery/Src/ostc.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/ostc.c Tue Feb 11 18:12:00 2025 +0100 @@ -46,13 +46,14 @@ UART_HandleTypeDef UartIR_HUD_Handle; __IO ITStatus UartReady = RESET; +__IO ITStatus UartReadyHUD = RESET; /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private variables with external access via get_xxx() function -------------*/ - +static uint8_t hardwareDisplay = 0; //< either OSTC4 LCD (=0) or new Screen (=1) /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ @@ -91,6 +92,42 @@ HAL_SPI_Init(&cpu2DmaSpi); } + +void MX_GPIO_Backlight_max_static_only_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct; + TIM_BACKLIGHT_GPIO_ENABLE(); + + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */ + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + + GPIO_InitStruct.Pin = TIM_BACKLIGHT_PIN; + HAL_GPIO_Init(TIM_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct); + + HAL_GPIO_WritePin(TIM_BACKLIGHT_GPIO_PORT,TIM_BACKLIGHT_PIN,GPIO_PIN_SET); +} + + +void MX_GPIO_One_Button_only_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct; + BUTTON_NEXT_GPIO_ENABLE(); + + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */ + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + + GPIO_InitStruct.Pin = BUTTON_NEXT_PIN; + HAL_GPIO_Init(BUTTON_NEXT_GPIO_PORT, &GPIO_InitStruct); +} + + +GPIO_PinState MX_GPIO_Read_The_One_Button(void) +{ + return HAL_GPIO_ReadPin(BUTTON_NEXT_GPIO_PORT, BUTTON_NEXT_PIN); +} + void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; @@ -101,6 +138,7 @@ SMALLCPU_CSB_GPIO_ENABLE(); OSCILLOSCOPE_GPIO_ENABLE(); OSCILLOSCOPE2_GPIO_ENABLE(); + BLE_UBLOX_DSR_GPIO_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; @@ -193,6 +231,13 @@ GPIO_InitStruct.Pin = BLE_NENABLE_PIN; HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); HAL_GPIO_WritePin(BLE_NENABLE_GPIO_PORT,BLE_NENABLE_PIN,GPIO_PIN_RESET); + + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + GPIO_InitStruct.Pin = BLE_UBLOX_DSR_PIN; + HAL_GPIO_Init(BLE_UBLOX_DSR_GPIO_PORT, &GPIO_InitStruct); + HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); } @@ -203,6 +248,7 @@ GPIO_InitStruct.Pin = BLE_NENABLE_PIN; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); + HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); } @@ -228,6 +274,26 @@ #endif } + +void MX_SmallCPU_NO_Reset_Helper(void) +{ +#ifdef SMALLCPU_NRESET_PIN + GPIO_InitTypeDef GPIO_InitStruct; + + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + + SMALLCPU_NRESET_GPIO_ENABLE(); + HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); + HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_SET); +// HAL_Delay(100); +// GPIO_InitStruct.Mode = GPIO_MODE_INPUT; +// HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); +#endif +} + + void MX_SmallCPU_Reset_To_Standard(void) { #ifdef SMALLCPU_NRESET_PIN @@ -248,6 +314,23 @@ #endif } + +uint8_t MX_UART_ButtonAdjust(uint8_t *array) +{ +#ifdef USART_PIEZO + uint8_t answer[4]; + HAL_UART_Transmit(&UartPiezoTxHandle,array,4,1000); + HAL_UART_Receive(&UartPiezoTxHandle,answer,4,2000); + if( (answer[0] == array[0]) + &&(answer[1] == array[1]) + &&(answer[2] == array[2]) + &&(answer[3] == array[3])) + return 1; +#endif + return 0; +} + + void MX_UART_Init(void) { /*##-1- Configure the UART peripheral ######################################*/ @@ -311,7 +394,10 @@ else if(huart == &UartIR_HUD_Handle) { +#ifndef BOOTLOADER_STANDALONE tCCR_SetRXIndication(); +#endif + UartReadyHUD = SET; } } @@ -336,7 +422,22 @@ HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct); #endif } - +void SetDisplayVersion(uint8_t version) +{ + if(version < 2) + { + hardwareDisplay = version; + } +} +uint8_t isNewDisplay() +{ + uint8_t ret = 0; + if(hardwareDisplay == DISPLAY_VERSION_NEW) + { + ret = 1; + } + return ret; +} #ifndef BOOTLOADER_STANDALONE void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
