From a7f626f29f1a359f462369985a0b737a48e20867 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 29 Aug 2014 04:50:40 +0000 Subject: [PATCH] switches and leds driver working git-svn-id: https://svn.code.sf.net/p/freetel/code@1820 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/stm32/src/adcdac_ut.c | 2 +- codec2-dev/stm32/src/sm1000_leds_switches.c | 36 +++++++++---------- .../stm32/src/sm1000_leds_switches_ut.c | 1 + 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/codec2-dev/stm32/src/adcdac_ut.c b/codec2-dev/stm32/src/adcdac_ut.c index 5901eea7..f18693ec 100644 --- a/codec2-dev/stm32/src/adcdac_ut.c +++ b/codec2-dev/stm32/src/adcdac_ut.c @@ -53,7 +53,7 @@ int main(void) { /* keep DAC FIFOs topped up */ - while(adc1_read(buf, SINE_SAMPLES) == -1); + while(adc2_read(buf, SINE_SAMPLES) == -1); dac2_write(buf, SINE_SAMPLES); } diff --git a/codec2-dev/stm32/src/sm1000_leds_switches.c b/codec2-dev/stm32/src/sm1000_leds_switches.c index b37a7a90..ae68525a 100644 --- a/codec2-dev/stm32/src/sm1000_leds_switches.c +++ b/codec2-dev/stm32/src/sm1000_leds_switches.c @@ -25,13 +25,13 @@ along with this program; if not, see . */ -#define LED_PWR 12 -#define LED_PTT 13 -#define LED_RT 14 -#define LED_ERR 15 -#define SWITCH_PTT 7 -#define SWITCH_SELECT 0 -#define SWITCH_BACK 1 +#define LED_PWR GPIO_Pin_12 +#define LED_PTT GPIO_Pin_13 +#define LED_RT GPIO_Pin_14 +#define LED_ERR GPIO_Pin_15 +#define SWITCH_PTT GPIO_Pin_7 +#define SWITCH_SELECT GPIO_Pin_0 +#define SWITCH_BACK GPIO_Pin_1 #include #include @@ -62,40 +62,40 @@ void sm1000_leds_switches_init(void) { void led_pwr(int state) { if (state) - GPIOD->ODR = (1 << LED_PWR); + GPIOD->ODR |= (1 << 12); else - GPIOD->ODR &= ~(1 << LED_PWR); + GPIOD->ODR &= ~(1 << 12); } void led_ptt(int state) { if (state) - GPIOD->ODR = (1 << LED_PTT); + GPIOD->ODR |= (1 << 13); else - GPIOD->ODR &= ~(1 << LED_PTT); + GPIOD->ODR &= ~(1 << 13); } void led_rt(int state) { if (state) - GPIOD->ODR = (1 << LED_RT); + GPIOD->ODR |= (1 << 14); else - GPIOD->ODR &= ~(1 << LED_RT); + GPIOD->ODR &= ~(1 << 14); } void led_err(int state) { if (state) - GPIOD->ODR = (1 << LED_ERR); + GPIOD->ODR |= (1 << 15); else - GPIOD->ODR &= ~(1 << LED_ERR); + GPIOD->ODR &= ~(1 << 15); } int switch_ptt(void) { - return GPIOA->IDR & SWITCH_PTT; + return GPIOD->IDR & (1 << 7); } int switch_select(void) { - return GPIOA->IDR & SWITCH_SELECT; + return GPIOD->IDR & (1 << 0); } int switch_back(void) { - return GPIOA->IDR & SWITCH_BACK; + return GPIOD->IDR & (1 << 1); } diff --git a/codec2-dev/stm32/src/sm1000_leds_switches_ut.c b/codec2-dev/stm32/src/sm1000_leds_switches_ut.c index 32813ff5..ae0e8fe7 100644 --- a/codec2-dev/stm32/src/sm1000_leds_switches_ut.c +++ b/codec2-dev/stm32/src/sm1000_leds_switches_ut.c @@ -30,6 +30,7 @@ int main(void) { sm1000_leds_switches_init(); + while(1) { led_pwr(switch_select()); led_ptt(switch_ptt()); -- 2.25.1