Skip to content

Instantly share code, notes, and snippets.

/spi.h Secret

Created June 23, 2014 19:42
Show Gist options
  • Save anonymous/1c8aa22fbf4e512204ce to your computer and use it in GitHub Desktop.
Save anonymous/1c8aa22fbf4e512204ce to your computer and use it in GitHub Desktop.
spi enum example
typedef enum {
SPI_CLOCK_DIV_2 = ((1<<SPI2X) | (0<<SPR1) | (0<<SPR0)),
SPI_CLOCK_DIV_4 = ((0<<SPI2X) | (0<<SPR1) | (0<<SPR0)),
SPI_CLOCK_DIV_8 = ((1<<SPI2X) | (0<<SPR1) | (1<<SPR0)),
SPI_CLOCK_DIV_16 = ((0<<SPI2X) | (0<<SPR1) | (1<<SPR0)),
SPI_CLOCK_DIV_32 = ((1<<SPI2X) | (1<<SPR1) | (0<<SPR0)),
SPI_CLOCK_DIV_64 = ((0<<SPI2X) | (1<<SPR1) | (0<<SPR0)),
SPI_CLOCK_DIV_128 = ((0<<SPI2X) | (1<<SPR1) | (1<<SPR0))
} spi_clock_freq;
typedef enum {
SPI_MODE_0 = ((0<<CPOL) | (0<<CPHA)),
SPI_MODE_1 = ((0<<CPOL) | (1<<CPHA)),
SPI_MODE_2 = ((1<<CPOL) | (0<<CPHA)),
SPI_MODE_3 = ((1<<CPOL) | (1<<CPHA))
} spi_mode_number;
typedef enum {
SPI_LSB = (1<<DORD),
SPI_MSB = (0<<DORD)
} spi_data_order;
typedef enum {
SPI_MASTER = (1<<MSTR),
SPI_SLAVE = (0<<MSTR)
} spi_mode_type;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment