switches and leds driver working
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 29 Aug 2014 04:50:40 +0000 (04:50 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 29 Aug 2014 04:50:40 +0000 (04:50 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1820 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/stm32/src/adcdac_ut.c
codec2-dev/stm32/src/sm1000_leds_switches.c
codec2-dev/stm32/src/sm1000_leds_switches_ut.c

index 5901eea755e40bf4d1bd0b9ebe0a968394586597..f18693ec9504381377de7cdb798f5fefcf3c864e 100644 (file)
@@ -53,7 +53,7 @@ int main(void) {
 \r
         /* keep DAC FIFOs topped up */\r
 \r
-        while(adc1_read(buf, SINE_SAMPLES) == -1);\r
+        while(adc2_read(buf, SINE_SAMPLES) == -1);\r
         dac2_write(buf, SINE_SAMPLES);\r
     }\r
    \r
index b37a7a901fa5c0cdc56f4e348e2c6ef32b5200d4..ae68525a00df9b14b4d85f31fbb5d6b41673bc4d 100644 (file)
   along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#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 <stm32f4xx.h>
 #include <stm32f4xx_gpio.h>
@@ -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);
 }
index 32813ff5f5a595126044ffa009c66586ad2c07be..ae0e8fe7c3f5cf1bf0c16d91f5758d9654f214c4 100644 (file)
@@ -30,6 +30,7 @@
 \r
 int main(void) {\r
     sm1000_leds_switches_init();\r
+\r
     while(1) {\r
         led_pwr(switch_select());\r
         led_ptt(switch_ptt());\r