Skip to content
Permalink
Browse files

fix gpio pin reading

  • Loading branch information...
conorpp committed May 9, 2019
1 parent aca28fd commit 30cfa46186780f5afc3c35c0c7e866f278eb3569
Showing with 7 additions and 15 deletions.
  1. +7 −13 targets/stm32l432/src/sense.c
  2. +0 −2 targets/stm32l432/src/sense.h
@@ -5,9 +5,6 @@
#include "stm32l4xx_ll_gpio.h"
#include "stm32l4xx_hal_tsc.h"

int _run_sense_app = 0;
static int _has_init = 0;

#define ELECTRODE_0 TSC_GROUP2_IO1
#define ELECTRODE_1 TSC_GROUP2_IO2

@@ -130,18 +127,15 @@ uint32_t tsc_read_button(uint32_t index)
int tsc_sensor_exists()
{
int does;
LL_GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = LL_GPIO_PIN_1;
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = 0;
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
LL_GPIO_SetPinMode(GPIOB, (1 << 1), LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinPull(GPIOB, (1 << 1), LL_GPIO_PULL_UP);

does = (LL_GPIO_ReadInputPort(GPIOB) & 1) == 0;
// Short delay before reading pin
asm("nop"); asm("nop"); asm("nop"); asm("nop");

GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
does = (LL_GPIO_ReadInputPort(GPIOB) & (1 << 1)) == 0;

LL_GPIO_SetPinPull(GPIOB, 1, LL_GPIO_PULL_NO);

return does;
}
@@ -3,8 +3,6 @@

#include <stdint.h>

extern int _run_sense_app;

void tsc_init();

int tsc_sensor_exists();

0 comments on commit 30cfa46

Please sign in to comment.
You can’t perform that action at this time.