| @@ -1373,6 +1373,7 @@ uint8_t PlsrTestFlashNeedsStartupRecovery( | |||
| #define PLSR_FREQUENCY_VERIFY_AB_AUX_IRQ (2U) | |||
| #define PLSR_QUEUE_WRITE_GUARD_COUNTS (64UL) | |||
| #define PLSR_FINITE_WRITE_GUARD_COUNTS (128UL) | |||
| #define PLSR_INPUT_RETRIGGER_BLOCK_MS (5UL) | |||
| #define PLSR_FLASH_ERASE_NONE (0U) | |||
| #define PLSR_FLASH_ERASE_SECTOR_A (1U) | |||
| #define PLSR_FLASH_ERASE_SECTOR_B (2U) | |||
| @@ -1581,6 +1582,8 @@ static volatile uint16_t PlsrFiniteStepIndex[4]; | |||
| static volatile uint16_t PlsrFiniteBoundaryReadIndex[4]; | |||
| static volatile uint16_t PlsrFiniteCompletedStepCount[4]; | |||
| static volatile uint16_t PlsrPlatformFaultPending; | |||
| static uint32_t PlsrInputLastAcceptedTick[2]; | |||
| static uint8_t PlsrInputAcceptedValidMask; | |||
| static void PlsrHandleTimerIrq(uint8_t pulseOutput); | |||
| static void PlsrCounterSuspend(uint8_t pulseOutput); | |||
| @@ -2949,6 +2952,9 @@ uint8_t PlsrPlatformInit(void) | |||
| HAL_GPIO_Init(GPIOB, &gpio); | |||
| gpio.Pin = GPIO_PIN_12; | |||
| HAL_GPIO_Init(GPIOG, &gpio); | |||
| PlsrInputLastAcceptedTick[0] = 0UL; | |||
| PlsrInputLastAcceptedTick[1] = 0UL; | |||
| PlsrInputAcceptedValidMask = 0U; | |||
| __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_5 | GPIO_PIN_12); | |||
| HAL_NVIC_SetPriority(EXTI9_5_IRQn, 2U, 0U); | |||
| HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); | |||
| @@ -4441,6 +4447,28 @@ uint8_t PlsrPlatformReadInput(uint8_t inputSelection) | |||
| return 0U; | |||
| } | |||
| static uint8_t PlsrInputExtiAccept(uint8_t inputSelection) | |||
| { | |||
| uint32_t now; | |||
| uint8_t bit; | |||
| if (inputSelection > 1U) | |||
| { | |||
| return 0U; | |||
| } | |||
| now = HAL_GetTick(); | |||
| bit = (uint8_t)(1U << inputSelection); | |||
| if (((PlsrInputAcceptedValidMask & bit) != 0U) | |||
| && ((uint32_t)(now - PlsrInputLastAcceptedTick[inputSelection]) | |||
| < PLSR_INPUT_RETRIGGER_BLOCK_MS)) | |||
| { | |||
| return 0U; | |||
| } | |||
| PlsrInputLastAcceptedTick[inputSelection] = now; | |||
| PlsrInputAcceptedValidMask |= bit; | |||
| return 1U; | |||
| } | |||
| uint8_t PlsrPlatformTakeInputExtiPending(uint8_t inputSelection) | |||
| { | |||
| uint16_t pin; | |||
| @@ -4462,7 +4490,7 @@ uint8_t PlsrPlatformTakeInputExtiPending(uint8_t inputSelection) | |||
| return 0U; | |||
| } | |||
| __HAL_GPIO_EXTI_CLEAR_IT(pin); | |||
| return 1U; | |||
| return PlsrInputExtiAccept(inputSelection); | |||
| } | |||
| uint8_t PlsrPlatformLoad(PLSR_PERSIST_PAYLOAD *payload) | |||
| @@ -5082,7 +5110,10 @@ void EXTI9_5_IRQHandler(void) | |||
| if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_5) != RESET) | |||
| { | |||
| __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_5); | |||
| PlsrWaitInputExtiIrq(0U); | |||
| if (PlsrInputExtiAccept(0U) != 0U) | |||
| { | |||
| PlsrWaitInputExtiIrq(0U); | |||
| } | |||
| } | |||
| } | |||
| @@ -5091,7 +5122,10 @@ void EXTI15_10_IRQHandler(void) | |||
| if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_12) != RESET) | |||
| { | |||
| __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_12); | |||
| PlsrWaitInputExtiIrq(1U); | |||
| if (PlsrInputExtiAccept(1U) != 0U) | |||
| { | |||
| PlsrWaitInputExtiIrq(1U); | |||
| } | |||
| } | |||
| } | |||