Add Texas Instruments TLV5618 DAC driver.
[bertos.git] / examples / triface / hw / hw_sipo.h
index 70136b529d539886806d161ebb37be9db5155d14..87e5736a642d053c7bca384108dca06f9b3a27b9 100644 (file)
@@ -26,7 +26,7 @@
  * invalidate any other reasons why the executable file might be covered by
  * the GNU General Public License.
  *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2003, 2004, 2006, 2009 Develer S.r.l. (http://www.develer.com/)
  * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
  *
  * -->
@@ -36,6 +36,7 @@
  *
  * \version $Id$
  *
+ * \author Andrea Grandi <andrea@develer.com>
  * \author Daniele Basile <asterix@develer.com>
  */
 
 
 #include <avr/io.h>
 
+/**
+ * Mapping sipo connection on board.
+ * See schematics for 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
@@ -62,8 +76,8 @@
 #define OE_LOW             (PORTG &= BV(PG3))
 
 /**
- * Define the procedure to set one bit low/hight to
- * serial input in sipo device.
+ * Define the macros needed to set the serial input bit of SIPO device
+ * low or high.
  */
 #define SIPO_SI_HIGH()    SOUT_OUT_HIGH
 #define SIPO_SI_LOW()     SOUT_OUT_LOW
@@ -72,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 anything that needed to init sipo pins.
+ * Do everything needed in order to init the SIPO pins.
  */
 #define SIPO_INIT_PIN() \
        do { \