00001 00038 #ifndef BOARD_SPI_H_INCLUDED 00039 #define BOARD_SPI_H_INCLUDED 00040 00041 #include <gpio.h> 00042 00044 enum board_spi_select_id { 00045 BOARD_DATAFLASH_SS = 13, // PORTB pin 5 00046 BOARD_XMEGA_SS = 8, // PORTB pin 0 00047 }; 00048 00050 typedef enum board_spi_select_id board_spi_select_id_t; 00051 00053 struct board_spi_select { 00055 gpio_pin_t pin; 00056 }; 00057 00064 static inline void board_spi_select_device(struct spi_master *master, 00065 struct board_spi_select *sel) 00066 { 00067 gpio_set_value(sel->pin, false); 00068 } 00069 00076 static inline void board_spi_deselect_device(struct spi_master *master, 00077 struct board_spi_select *sel) 00078 { 00079 gpio_set_value(sel->pin, true); 00080 } 00081 00088 static inline void board_spi_init_select(struct board_spi_select *sel, 00089 board_spi_select_id_t sel_id) 00090 { 00091 sel->pin = sel_id; 00092 port_select_gpio_pin(sel_id, GPIO_DIR_OUTPUT | GPIO_INIT_HIGH); 00093 } 00094 00095 #endif /* BOARD_SPI_H_INCLUDED */
1.6.3