Comply to new sipo drv.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 3 Jun 2009 14:11:55 +0000 (14:11 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 3 Jun 2009 14:11:55 +0000 (14:11 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2702 38d2e660-2303-0410-9eaa-f027e97ec537

examples/triface/hw/hw_sipo.h
examples/triface/protocol.c

index f31497f27543a68448cf41f95e0d72f44689a5ae..b8c020a78db5dbeb4cdd9a5d13e9de51859ab1f1 100644 (file)
 
 #include <avr/io.h>
 
+/**
+ *  * Mapping sipo connection on board.
+ *   * See scheme to more info.
+ *    */
+typedef enum SipoMap
+{
+       TRIFACE_DOUT = 0,
+
+       SIPO_CNT
+} SipoMap;
+
+
+
 //Set output pin for sipo
 #define SCK_OUT            (DDRB |= BV(PB1))  // Shift register clock input pin
 #define SOUT_OUT           (DDRB |= BV(PB2))  // Serial data input pin
@@ -73,8 +86,9 @@
  * Drive pin to load the bit, presented in serial-in pin,
  * into sipo shift register.
  */
-#define SIPO_SI_CLOCK() \
+#define SIPO_SI_CLOCK(clk_pol) \
        do{ \
+               (void)clk_pol; \
                SCK_HIGH; \
                SCK_LOW; \
        }while(0)
 /**
  * Clock the content of shift register to output.
  */
-#define SIPO_LOAD() \
+#define SIPO_LOAD(device, load_pol) \
        do { \
+               (void)device; \
+               (void)load_pol; \
                SLOAD_OUT_HIGH; \
                SLOAD_OUT_LOW; \
        }while(0)
  */
 #define SIPO_ENABLE() OE_LOW;
 
+/**
+ * Set logic level for load signal
+ */
+#define SIPO_SET_LD_LEVEL(device, load_pol) \
+       do { \
+               (void)device; \
+               if(load_pol) \
+                       SLOAD_OUT_HIGH; \
+               else \
+                       SLOAD_OUT_LOW; \
+       } while (0)
+
+
+/**
+ * Sel logic level for clock signal
+ */
+#define SIPO_SET_CLK_LEVEL(clock_pol) \
+       do { \
+               if(clock_pol) \
+                       SCK_HIGH; \
+               else \
+                       SCK_LOW; \
+       } while (0)
+
+#define SIPO_SET_SI_LEVEL()     SIPO_SI_LOW()
 
 /**
  * Do everything needed in order to init the SIPO pins.
index c00219bd4967201c08306f582bef81c0b59c430d..254880e5657287ffb19dd9fde352940559a6f7a1 100644 (file)
@@ -360,6 +360,11 @@ static void protocol_registerCmds(void)
 void protocol_init(KFile *fd)
 {
        /* SPI Port Initialization */
+       fd_sipo.load_device = TRIFACE_DOUT;
+       fd_sipo.bit_order = SIPO_DATAORDER_LSB;
+       fd_sipo.clock_pol = SIPO_START_LOW;
+       fd_sipo.load_pol = SIPO_LOW_TO_HIGH;
+
        sipo_init(&fd_sipo);
 
        interactive = FORCE_INTERACTIVE;