support for SM2000 Port E tx/rx +12V control
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 18 Jun 2016 00:05:16 +0000 (00:05 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 18 Jun 2016 00:05:16 +0000 (00:05 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2822 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/stm32/inc/debugblinky.h
codec2-dev/stm32/src/debugblinky.c

index 0561272c2b623e188f3fa697533a3423167a86f6..f2bb2daf62da47aa5fa3acbe435ed96a74aeaa28 100644 (file)
@@ -4,7 +4,8 @@
   AUTHOR......: David Rowe
   DATE CREATED: 12 August 2014
 
-  Configures GPIO pins used for debug blinkies
+  Configures Port E GPIO pins used for debug blinkies, and control lines
+  for SM2000 +12V switching.
 
 \*---------------------------------------------------------------------------*/
 
@@ -29,5 +30,6 @@
 #define __DEBUGBLINKY__
 
 void init_debug_blinky(void);
+void txrx_12V(int state);
 
 #endif
index 171cd5cc7785a9503db5dfadafa73c5e98e2c55e..992c8b051aa92a196ce7f064d3e0e6ae702bfd96 100644 (file)
 void init_debug_blinky(void) {
     GPIO_InitTypeDef GPIO_InitStruct;
 
-    /* PE0-3 used to indicate activity */
+    /* PE0-3 used to indicate activity, PE4-5 for SM2000 +12V rail switching */
 
     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
 
-    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;
+    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;
     GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
     GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
     GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
     GPIO_Init(GPIOE, &GPIO_InitStruct);
+}
 
+/* SM2000: 0 for +12V RX power, 1 for +12V TX power  */
+
+void txrx_12V(int state) {
+    if (state) {
+        GPIOE->ODR &= ~(1 << 5); /* +12VRXENB off */
+        GPIOE->ODR |=  (1 << 4); /* +12VTXENB on */
+    }
+    else {
+        GPIOE->ODR &= ~(1 << 4); /* +12VTXENB off */
+        GPIOE->ODR |=  (1 << 5); /* +12VRXENB on */
+    }
 }