diff --git a/mk4-bootloader/Core/Inc/main.h b/mk4-bootloader/Core/Inc/main.h index 0a64c0c..5e2d75d 100644 --- a/mk4-bootloader/Core/Inc/main.h +++ b/mk4-bootloader/Core/Inc/main.h @@ -66,6 +66,7 @@ extern "C" { #define bSegDecode7 0b0000011100 #define bSegDecode8 0b0111111100 #define bSegDecode9 0b0110111100 +#define bSegDecodeU 0b0011111000 #define bCat0 0b1111000000000000 #define bCat1 0b1110001000000000 @@ -94,6 +95,9 @@ extern "C" { #define ERR_UNKNOWN bSegDecode9 +// User request bootloader hang for backup USB stack +#define ERR_USER bSegDecodeU + /* USER CODE END EC */ /* Exported macro ------------------------------------------------------------*/ diff --git a/mk4-bootloader/Core/Src/main.c b/mk4-bootloader/Core/Src/main.c index 70d91d6..046ec18 100644 --- a/mk4-bootloader/Core/Src/main.c +++ b/mk4-bootloader/Core/Src/main.c @@ -402,6 +402,11 @@ int main(void) // debug force reload // new_fw_crc=0; + // Hinge TX connection shorted to ground - force bootloader to hang + if ((GPIOA->IDR & (1<<2))==0) { + hang_error(ERR_USER); + } + if (loaded_fw_crc == byteswap32(*(uint32_t*)(FLASH_BASE + BOOT_SIZE + APP_SIZE -4)) ) { // loaded firmware valid @@ -717,6 +722,15 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + /**USART2 GPIO Configuration + PA2 ------> USART2_TX + PA3 ------> USART2_RX + */ + GPIO_InitStruct.Pin = GPIO_PIN_2; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2 |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6