examples/triface/hw/hw_sipo.h
Go to the documentation of this file.00001
00043 #ifndef HW_SIPO_H
00044 #define HW_SIPO_H
00045
00046 #include <cfg/macros.h>
00047
00048 #include <avr/io.h>
00049
00054 typedef enum SipoMap
00055 {
00056 TRIFACE_DOUT = 0,
00057
00058 SIPO_CNT
00059 } SipoMap;
00060
00061
00062
00063
00064 #define SCK_OUT (DDRB |= BV(PB1)) // Shift register clock input pin
00065 #define SOUT_OUT (DDRB |= BV(PB2)) // Serial data input pin
00066 #define SLOAD_OUT (DDRB |= BV(PB3)) // Storage register clock input pin
00067 #define OE_OUT (DDRG |= BV(PG3)) // Output enable pin
00068
00069
00070 #define SCK_HIGH (PORTB |= BV(PB1))
00071 #define SCK_LOW (PORTB &= ~BV(PB1))
00072 #define SOUT_OUT_HIGH (PORTB |= BV(PB2))
00073 #define SOUT_OUT_LOW (PORTB &= ~BV(PB2))
00074 #define SLOAD_OUT_HIGH (PORTB |= BV(PB3))
00075 #define SLOAD_OUT_LOW (PORTB &= ~BV(PB3))
00076 #define OE_LOW (PORTG &= BV(PG3))
00077
00082 #define SIPO_SI_HIGH() SOUT_OUT_HIGH
00083 #define SIPO_SI_LOW() SOUT_OUT_LOW
00084
00089 #define SIPO_SI_CLOCK(clk_pol) \
00090 do{ \
00091 (void)clk_pol; \
00092 SCK_HIGH; \
00093 SCK_LOW; \
00094 }while(0)
00095
00099 #define SIPO_LOAD(device, load_pol) \
00100 do { \
00101 (void)device; \
00102 (void)load_pol; \
00103 SLOAD_OUT_HIGH; \
00104 SLOAD_OUT_LOW; \
00105 }while(0)
00106
00110 #define SIPO_ENABLE() OE_LOW;
00111
00115 #define SIPO_SET_LD_LEVEL(device, load_pol) \
00116 do { \
00117 (void)device; \
00118 if(load_pol) \
00119 SLOAD_OUT_HIGH; \
00120 else \
00121 SLOAD_OUT_LOW; \
00122 } while (0)
00123
00124
00128 #define SIPO_SET_CLK_LEVEL(clock_pol) \
00129 do { \
00130 if(clock_pol) \
00131 SCK_HIGH; \
00132 else \
00133 SCK_LOW; \
00134 } while (0)
00135
00136 #define SIPO_SET_SI_LEVEL() SIPO_SI_LOW()
00137
00141 #define SIPO_INIT_PIN() \
00142 do { \
00143 OE_OUT; \
00144 SOUT_OUT; \
00145 SCK_OUT; \
00146 SLOAD_OUT; \
00147 SIPO_ENABLE(); \
00148 } while(0)
00149
00150
00151 #endif