[AVR] SPI driver updated for 3.0 + removed weird slave interface support

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7247 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
utzig 2014-09-04 18:49:07 +00:00
parent 147426d333
commit b6814edfd2
2 changed files with 15 additions and 35 deletions

View File

@ -136,19 +136,10 @@ void spi_lld_start(SPIDriver *spip) {
/* SPI enable, SPI interrupt enable */ /* SPI enable, SPI interrupt enable */
SPCR |= ((1 << SPE) | (1 << SPIE)); SPCR |= ((1 << SPE) | (1 << SPIE));
switch (spip->config->role) { SPCR |= (1 << MSTR);
case SPI_ROLE_SLAVE: DDR_SPI1 |= ((1 << SPI1_MOSI) | (1 << SPI1_SCK));
SPCR &= ~(1 << MSTR); /* master mode */ DDR_SPI1 &= ~(1 << SPI1_MISO);
DDR_SPI1 |= (1 << SPI1_MISO); /* output */
DDR_SPI1 &= ~((1 << SPI1_MOSI) | (1 << SPI1_SCK) | (1 << SPI1_SS)); /* input */
break;
case SPI_ROLE_MASTER: /* fallthrough */
default:
SPCR |= (1 << MSTR); /* slave mode */
DDR_SPI1 |= ((1 << SPI1_MOSI) | (1 << SPI1_SCK)); /* output */
DDR_SPI1 &= ~(1 << SPI1_MISO); /* input */
spip->config->ssport->dir |= (1 << spip->config->sspad); spip->config->ssport->dir |= (1 << spip->config->sspad);
}
switch (spip->config->bitorder) { switch (spip->config->bitorder) {
case SPI_LSB_FIRST: case SPI_LSB_FIRST:
@ -250,7 +241,7 @@ void spi_lld_stop(SPIDriver *spip) {
void spi_lld_select(SPIDriver *spip) { void spi_lld_select(SPIDriver *spip) {
/** /**
* NOTE: This should only be called in master mode * NOTE: This should only be called in master mode.
*/ */
spip->config->ssport->out &= ~(1 << spip->config->sspad); spip->config->ssport->out &= ~(1 << spip->config->sspad);
@ -267,7 +258,7 @@ void spi_lld_select(SPIDriver *spip) {
void spi_lld_unselect(SPIDriver *spip) { void spi_lld_unselect(SPIDriver *spip) {
/** /**
* NOTE: This should only be called in master mode * NOTE: This should only be called in master mode.
*/ */
spip->config->ssport->out |= (1 << spip->config->sspad); spip->config->ssport->out |= (1 << spip->config->sspad);

View File

@ -31,10 +31,6 @@
/* Driver constants. */ /* Driver constants. */
/*===========================================================================*/ /*===========================================================================*/
/** @brief SPI Mode (Polarity/Phase) */
#define SPI_ROLE_MASTER 0
#define SPI_ROLE_SLAVE 1
/** @brief SPI Mode (Polarity/Phase) */ /** @brief SPI Mode (Polarity/Phase) */
#define SPI_CPOL0_CPHA0 0 #define SPI_CPOL0_CPHA0 0
#define SPI_CPOL0_CPHA1 1 #define SPI_CPOL0_CPHA1 1
@ -103,10 +99,6 @@ typedef void (*spicallback_t)(SPIDriver *spip);
* architecture dependent, fields. * architecture dependent, fields.
*/ */
typedef struct { typedef struct {
/**
* @brief Role: Master or Slave
*/
uint8_t role;
/** /**
* @brief Port used of Slave Select * @brief Port used of Slave Select
*/ */
@ -152,21 +144,18 @@ struct SPIDriver {
/** /**
* @brief Waiting thread. * @brief Waiting thread.
*/ */
Thread *thread; thread_reference_t thread;
#endif /* SPI_USE_WAIT */ #endif /* SPI_USE_WAIT */
#if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__) #if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
#if CH_USE_MUTEXES || defined(__DOXYGEN__)
/** /**
* @brief Mutex protecting the bus. * @brief Mutex protecting the bus.
*/ */
Mutex mutex; mutex_t mutex;
#elif CH_USE_SEMAPHORES
Semaphore semaphore;
#endif
#endif /* SPI_USE_MUTUAL_EXCLUSION */ #endif /* SPI_USE_MUTUAL_EXCLUSION */
#if defined(SPI_DRIVER_EXT_FIELDS) #if defined(SPI_DRIVER_EXT_FIELDS)
SPI_DRIVER_EXT_FIELDS SPI_DRIVER_EXT_FIELDS
#endif #endif
/* End of the mandatory fields.*/
/** /**
* @brief Pointer to the buffer with data to send. * @brief Pointer to the buffer with data to send.
*/ */