cc2538: spi: Add support for dynamic instances
Previously, only constants could be used to pass SPI instances to the SPI driver. This change makes it possible to use SPI instances from variables. Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
This commit is contained in:
parent
0e5b18635b
commit
c76b8235f4
|
@ -57,6 +57,8 @@
|
||||||
*/
|
*/
|
||||||
#define SSI0_BASE 0x40008000 /**< Base address for SSI0 */
|
#define SSI0_BASE 0x40008000 /**< Base address for SSI0 */
|
||||||
#define SSI1_BASE 0x40009000 /**< Base address for SSI1 */
|
#define SSI1_BASE 0x40009000 /**< Base address for SSI1 */
|
||||||
|
/** Base address of the \c dev instance of the SSI */
|
||||||
|
#define SSI_BASE(dev) (SSI0_BASE + (dev) * (SSI1_BASE - SSI0_BASE))
|
||||||
/** @} */
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** \name SSI register offsets
|
/** \name SSI register offsets
|
||||||
|
|
|
@ -109,17 +109,17 @@
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* New API macros */
|
/* New API macros */
|
||||||
#define SPIX_WAITFORTxREADY(spi) do { \
|
#define SPIX_WAITFORTxREADY(spi) do { \
|
||||||
while(!(REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_SR) & SSI_SR_TNF)) ; \
|
while(!(REG(SSI_BASE(spi) + SSI_SR) & SSI_SR_TNF)) ; \
|
||||||
} while(0)
|
} while(0)
|
||||||
#define SPIX_BUF(spi) REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_DR)
|
#define SPIX_BUF(spi) REG(SSI_BASE(spi) + SSI_DR)
|
||||||
#define SPIX_WAITFOREOTx(spi) do { \
|
#define SPIX_WAITFOREOTx(spi) do { \
|
||||||
while(REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_SR) & SSI_SR_BSY) ; \
|
while(REG(SSI_BASE(spi) + SSI_SR) & SSI_SR_BSY) ; \
|
||||||
} while(0)
|
} while(0)
|
||||||
#define SPIX_WAITFOREORx(spi) do { \
|
#define SPIX_WAITFOREORx(spi) do { \
|
||||||
while(!(REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_SR) & SSI_SR_RNE)) ; \
|
while(!(REG(SSI_BASE(spi) + SSI_SR) & SSI_SR_RNE)) ; \
|
||||||
} while(0)
|
} while(0)
|
||||||
#define SPIX_FLUSH(spi) do { \
|
#define SPIX_FLUSH(spi) do { \
|
||||||
while(REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_SR) & SSI_SR_RNE) { \
|
while(REG(SSI_BASE(spi) + SSI_SR) & SSI_SR_RNE) { \
|
||||||
SPIX_BUF(spi); \
|
SPIX_BUF(spi); \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
Loading…
Reference in a new issue