summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/short-test/src/main.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/short-test/src/main.c b/src/short-test/src/main.c
index ee1fedb..902a98b 100644
--- a/src/short-test/src/main.c
+++ b/src/short-test/src/main.c
@@ -94,8 +94,7 @@ void configure_all_as_input(GPIO_TypeDef* GPIOx, uint16_t GPIO_Test_Pins)
/* Configure all pins as input. XXX do all pins (0xffff) instead of just GPIO_Test_Pins? */
GPIO_InitStruct.Pin = GPIO_Test_Pins;
- //GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT; /* XXX does GPIO_PULLDOWN work with GPIO_MODE_INPUT? */
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
HAL_GPIO_Init(GPIOx, &GPIO_InitStruct);
@@ -168,6 +167,12 @@ void test_for_shorts(char port, GPIO_TypeDef* GPIOx, uint16_t GPIO_Test_Pins)
HAL_GPIO_WritePin(GPIOx, Test_Pin, GPIO_PIN_SET);
+ /* Slight delay after setting the output pin. Without this, the Test_Pin
+ bit might read as zero, as it is only sampled once every AHB1 clock cycle.
+ Reference manual DM00031020 section 8.3.1.
+ */
+ HAL_Delay(1);
+
/* Read all input GPIOs from port at once. XXX check all pins, not just GPIO_Test_Pins? */
read = GPIOx->IDR & GPIO_Test_Pins;