diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-01-21 21:31:09 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-01-21 21:31:09 +0100 |
commit | 9c7d2bf918da26d65a06f0c6b58f5626ee3d8136 (patch) | |
tree | a03c58e6959ebdfd50a4715af624db39bad10c9d | |
parent | 8cd367276e0a032fb1317a4fea3c406b2d6b3dc1 (diff) | |
download | glutte-o-matic-9c7d2bf918da26d65a06f0c6b58f5626ee3d8136.tar.gz glutte-o-matic-9c7d2bf918da26d65a06f0c6b58f5626ee3d8136.tar.bz2 glutte-o-matic-9c7d2bf918da26d65a06f0c6b58f5626ee3d8136.zip |
Distinguish pullup and nonpullup in PIO
-rw-r--r-- | src/fsm/pio.c | 13 | ||||
-rw-r--r-- | src/fsm/pio.h | 13 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/fsm/pio.c b/src/fsm/pio.c index a4033a9..fba7ddc 100644 --- a/src/fsm/pio.c +++ b/src/fsm/pio.c @@ -57,12 +57,19 @@ void pio_init() #endif GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_Pin = GPIOC_INPUT_PINS; + GPIO_InitStructure.GPIO_Pin = GPIOC_INPUT_PU_PINS; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; + GPIO_InitStructure.GPIO_Pin = GPIOC_INPUT_PINS; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_Init(GPIOC, &GPIO_InitStructure); + xTaskCreate( read_fsm_input_task, "TaskPIO", @@ -81,7 +88,11 @@ void read_fsm_input_task(void *pvParameters) { while (1) { pio_signals.qrp = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_QRP_n) ? 0 : 1; +#if INVERTED_1750 + pio_signals.tone_1750 = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_1750) ? 0 : 1; +#else pio_signals.tone_1750 = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_1750) ? 1 : 0; +#endif pio_signals.carrier = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_RX_n) ? 0 : 1; pio_signals.discrim_u = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_U_n) ? 0 : 1; pio_signals.discrim_d = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_D_n) ? 0 : 1; diff --git a/src/fsm/pio.h b/src/fsm/pio.h index ed9fd9c..181b08d 100644 --- a/src/fsm/pio.h +++ b/src/fsm/pio.h @@ -33,6 +33,8 @@ /* See pio.txt for PIO allocation details */ +#define INVERTED_1750 0 + /* On GPIO C */ #define GPIO_PIN_QRP_n GPIO_Pin_1 #define GPIO_PIN_LED_red GPIO_Pin_2 @@ -52,12 +54,13 @@ #define GPIOC_OPENDRAIN_PINS 0 +#define GPIOC_INPUT_PINS 0 -#define GPIOC_INPUT_PINS GPIO_PIN_QRP_n | \ - GPIO_PIN_1750 | \ - GPIO_PIN_RX_n | \ - GPIO_PIN_U_n | \ - GPIO_PIN_D_n +#define GPIOC_INPUT_PU_PINS GPIO_PIN_QRP_n | \ + GPIO_PIN_U_n | \ + GPIO_PIN_D_n | \ + GPIO_PIN_RX_n | \ + GPIO_PIN_1750 void pio_init(void); |