Added SPI driver for CC2538

This uses the core/dev/spi.h header and implements the spi_init()
function and the various macros for SPI operation. ssi.h contains all of
the register locations and information.

This implementation is not very versatile, mostly because I don't how to
make it flexible in the contiki system. It supports pin muxing for the
four spi pins, but other than that picks sensible defaults.

The SPI macros (like SPI_READ()) are defined in
cpu/cc2538/spi-arch.h. In order to use the SPI driver, add the following
includes to your project:

    #include "spi-arch.h
    #include "dev/spi.h"
This commit is contained in:
Brad Campbell 2013-09-05 14:59:56 -04:00
parent 55686d7ca2
commit e2af903d05
6 changed files with 364 additions and 1 deletions

View file

@ -185,6 +185,14 @@ typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin);
* in this category
*/
#define GPIO_PIN_MASK(PIN) (1 << PIN)
/**
* \brief Converts a port number to the port base address
* \param The port number in the range 0 - 3. Likely GPIO_X_NUM.
* \return The base address for the registers corresponding to that port
* number.
*/
#define GPIO_PORT_TO_BASE(PORT) (GPIO_A_BASE + (PORT << 12))
/** @} */
/*---------------------------------------------------------------------------*/
/** \name GPIO Register offset declarations