SPI driver definition for megaRF.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | BAUD_RATE_MASK 0x03 |
#define | DOUBLE_SPEED_MASK 0x04 |
#define | SPI_CLK2X_bm 0x01 /* Enable Double Speed bit mask. */ |
#define | SPI_CLK2X_bp 0 /* Enable Double Speed bit position. */ |
#define | SPI_CPHA_bm 0x04 /* SPI Clock phase bit 1 mask. */ |
#define | SPI_CPHA_bp 2 /* SPI Clock phase bit 1 position. */ |
#define | SPI_CPOL_bm 0x08 /* SPI Clock polarity bit 1 mask. */ |
#define | SPI_CPOL_bp 3 /* SPI Clock polarity bit 1 position. */ |
#define | SPI_DORD_bm 0x20 /* Data Order Setting bit mask. */ |
#define | SPI_DORD_bp 5 /* Data Order Setting bit position. */ |
#define | SPI_ENABLE_bm 0x40 /* Enable Module bit mask. */ |
#define | SPI_ENABLE_bp 6 /* Enable Module bit position. */ |
#define | SPI_IF_bm 0x80 /* Interrupt Flag bit mask. */ |
#define | SPI_IF_bp 7 /* Interrupt Flag bit position. */ |
#define | SPI_MASTER_bm 0x10 /* Master Operation Enable bit mask. */ |
#define | SPI_MASTER_bp 4 /* Master Operation Enable bit position. */ |
#define | SPI_MODE0 0 |
#define | SPI_MODE1 (SPI_CPHA) |
#define | SPI_MODE2 (SPI_CPOL) |
#define | SPI_MODE3 (SPI_CPOL | SPI_CPHA) |
#define | SPI_MODE_gm 0x0C /* SPI Mode group mask. */ |
#define | SPI_MODE_gp 2 /* SPI Mode group position. */ |
#define | SPI_PRESCALER0_bm (1 << 0) /* Prescaler bit 0 mask. */ |
#define | SPI_PRESCALER0_bp 0 /* Prescaler bit 0 position. */ |
#define | SPI_PRESCALER1_bm (1 << 1) /* Prescaler bit 1 mask. */ |
#define | SPI_PRESCALER1_bp 1 /* Prescaler bit 1 position. */ |
#define | SPI_PRESCALER_gm 0x03 /* Prescaler group mask. */ |
#define | SPI_PRESCALER_gp 0 /* Prescaler group position. */ |
#define | SPI_SPIE_bm 0x80 /* Interrupt Enable bit mask. */ |
#define | SPI_SPIE_bp 7 /* Interrupt Enable bit position. */ |
#define | SPI_WRCOL_bm 0x40 /* Write Collision bit mask. */ |
#define | SPI_WRCOL_bp 6 /* Write Collision bit position. */ |
Typedefs | |
typedef void(* | spi_int_callback_t )(void) |
Interrupt event callback function type. More... | |
typedef enum SPI_PRESCALER_enum | SPI_PRESCALER_t |
Enumerations | |
enum | SPI_PRESCALER_enum { SPI_PRESCALER_DIV4_gc = (0x00 << 0), SPI_PRESCALER_DIV16_gc = (0x01 << 0), SPI_PRESCALER_DIV64_gc = (0x02 << 0), SPI_PRESCALER_DIV128_gc = (0x03 << 0) } |
Functions | |
static void | spi_disable (volatile void *spi) |
Disables the SPI. More... | |
static void | spi_disable_interrupt (volatile void *spi) |
Disables the SPI's interrupt. More... | |
static void | spi_double_speed_disable (volatile void *spi) |
Disable SPI Double Speed. More... | |
static void | spi_double_speed_enable (volatile void *spi) |
Enable SPI Double Speed. More... | |
static void | spi_enable (volatile void *spi) |
Enables the SPI. More... | |
static void | spi_enable_interrupt (volatile void *spi) |
Enables the SPI in interrupt mode. More... | |
static void | spi_enable_master_mode (volatile void *spi) |
Activate SPI master mode of a SPI peripheral. More... | |
static void | spi_enable_slave_mode (volatile void *spi) |
Activate SPI slave mode of a SPI peripheral. More... | |
static uint8_t | spi_get (volatile void *spi) |
Get one data byte from SPI peripheral. More... | |
static bool | spi_is_enabled (volatile void *spi) |
Tests if the SPI is enabled. More... | |
static bool | spi_is_tx_ok (volatile void *spi) |
Tests if the SPI transfer is complete. More... | |
static bool | spi_is_wc_flag_set (volatile void *spi) |
Tests if the Write collision occurs during SPI transfer. More... | |
static void | spi_put (volatile void *spi, uint8_t data) |
Put one data byte to SPI peripheral. More... | |
int8_t | spi_set_baud_div (volatile void *spi, uint32_t baudrate, uint32_t clkper_hz) |
Calculates the SPI baudrate divider. More... | |
static void | spi_set_clock_mode (volatile void *spi, uint8_t mode) |
Set SPI clock mode. More... | |
static void | spi_set_clock_phase (volatile void *spi, bool polarity) |
Set Data Capture Phase. More... | |
static void | spi_set_clock_polarity (volatile void *spi, bool polarity) |
Set clock default state. More... | |
static void | spi_set_dord_lsb (volatile void *spi) |
Set SPI data order to LSB first. More... | |
static void | spi_set_dord_msb (volatile void *spi) |
Set SPI data order to MSB first. More... | |
void | spi_set_interrupt_callback (spi_int_callback_t callback) |
Set SPI interrupt callback function. More... | |