| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /*
- / _____) _ | |
- ( (____ _____ ____ _| |_ _____ ____| |__
- \____ \| ___ | (_ _) ___ |/ ___) _ \
- _____) ) ____| | | || |_| ____( (___| | | |
- (______/|_____)_|_|_| \__)_____)\____)_| |_|
- (C)2013 Semtech
- Description: Implements the generic SPI driver
- License: Revised BSD License, see LICENSE.TXT file include in the project
- Maintainer: Miguel Luis and Gregory Cristian
- */
- #ifndef __SPI_H__
- #define __SPI_H__
- #include "spi-board.h"
- /*!
- * SPI object type definition
- */
- typedef struct Spi_s Spi_t;
- /*!
- * \brief Initializes the SPI object and MCU peripheral
- *
- * \remark When NSS pin is software controlled set the pin name to NC otherwise
- * set the pin name to be used.
- *
- * \param [IN] obj SPI object
- * \param [IN] mosi SPI MOSI pin name to be used
- * \param [IN] miso SPI MISO pin name to be used
- * \param [IN] sclk SPI SCLK pin name to be used
- * \param [IN] nss SPI NSS pin name to be used
- */
- void SpiInit( Spi_t *obj, PinNames mosi, PinNames miso, PinNames sclk, PinNames nss );
- /*!
- * \brief De-initializes the SPI object and MCU peripheral
- *
- * \param [IN] obj SPI object
- */
- void SpiDeInit( Spi_t *obj );
- /*!
- * \brief Configures the SPI peripheral
- *
- * \remark Slave mode isn't currently handled
- *
- * \param [IN] obj SPI object
- * \param [IN] bits Number of bits to be used. [8 or 16]
- * \param [IN] cpol Clock polarity
- * \param [IN] cpha Clock phase
- * \param [IN] slave When set the peripheral acts in slave mode
- */
- void SpiFormat( Spi_t *obj, int8_t bits, int8_t cpol, int8_t cpha, int8_t slave );
- /*!
- * \brief Sets the SPI speed
- *
- * \param [IN] obj SPI object
- * \param [IN] hz SPI clock frequency in hz
- */
- void SpiFrequency( Spi_t *obj, uint32_t hz );
- /*!
- * \brief Sends outData and receives inData
- *
- * \param [IN] obj SPI object
- * \param [IN] outData Byte to be sent
- * \retval inData Received byte.
- */
- uint16_t SpiInOut( Spi_t *obj, uint16_t outData );
- #endif // __SPI_H__
|