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 
00050 //Set output pin for sipo
00051 #define SCK_OUT            (DDRB |= BV(PB1))  // Shift register clock input pin
00052 #define SOUT_OUT           (DDRB |= BV(PB2))  // Serial data input pin
00053 #define SLOAD_OUT          (DDRB |= BV(PB3))  // Storage register clock input pin
00054 #define OE_OUT             (DDRG |= BV(PG3))  // Output enable pin
00055 
00056 //Define output level
00057 #define SCK_HIGH           (PORTB |= BV(PB1))
00058 #define SCK_LOW            (PORTB &= ~BV(PB1))
00059 #define SOUT_OUT_HIGH      (PORTB |= BV(PB2))
00060 #define SOUT_OUT_LOW       (PORTB &= ~BV(PB2))
00061 #define SLOAD_OUT_HIGH     (PORTB |= BV(PB3))
00062 #define SLOAD_OUT_LOW      (PORTB &= ~BV(PB3))
00063 #define OE_LOW             (PORTG &= BV(PG3))
00064 
00069 #define SIPO_SI_HIGH()    SOUT_OUT_HIGH
00070 #define SIPO_SI_LOW()     SOUT_OUT_LOW
00071 
00076 #define SIPO_SI_CLOCK() \
00077     do{ \
00078         SCK_HIGH; \
00079         SCK_LOW; \
00080     }while(0)
00081 
00085 #define SIPO_LOAD() \
00086     do { \
00087         SLOAD_OUT_HIGH; \
00088         SLOAD_OUT_LOW; \
00089     }while(0)
00090 
00094 #define SIPO_ENABLE() OE_LOW;
00095 
00096 
00100 #define SIPO_INIT_PIN() \
00101     do { \
00102         OE_OUT; \
00103         SOUT_OUT; \
00104         SCK_OUT; \
00105         SLOAD_OUT; \
00106         SIPO_ENABLE(); \
00107     } while(0)
00108 
00109 
00110 #endif /* HW_SIPO_H */