cc2538: spi: Add enable and disable functions
This makes it possible to reduce the power consumption when the SPI is unused. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
This commit is contained in:
parent
b134e35450
commit
e8a8870d1d
2 changed files with 30 additions and 2 deletions
|
@ -74,8 +74,7 @@
|
||||||
void
|
void
|
||||||
spi_init(void)
|
spi_init(void)
|
||||||
{
|
{
|
||||||
/* Enable the SSI peripheral */
|
spi_enable();
|
||||||
REG(SYS_CTRL_RCGCSSI) |= 1;
|
|
||||||
|
|
||||||
/* Start by disabling the peripheral before configuring it */
|
/* Start by disabling the peripheral before configuring it */
|
||||||
REG(SSI0_BASE + SSI_CR1) = 0;
|
REG(SSI0_BASE + SSI_CR1) = 0;
|
||||||
|
@ -110,4 +109,18 @@ spi_init(void)
|
||||||
/* Enable the SSI */
|
/* Enable the SSI */
|
||||||
REG(SSI0_BASE + SSI_CR1) |= SSI_CR1_SSE;
|
REG(SSI0_BASE + SSI_CR1) |= SSI_CR1_SSE;
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
spi_enable(void)
|
||||||
|
{
|
||||||
|
/* Enable the clock for the SSI peripheral */
|
||||||
|
REG(SYS_CTRL_RCGCSSI) |= 1;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
spi_disable(void)
|
||||||
|
{
|
||||||
|
/* Gate the clock for the SSI peripheral */
|
||||||
|
REG(SYS_CTRL_RCGCSSI) &= ~1;
|
||||||
|
}
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -57,6 +57,21 @@
|
||||||
#define SPI_WAITFOREORx() do { \
|
#define SPI_WAITFOREORx() do { \
|
||||||
while(!(REG(SSI0_BASE + SSI_SR) & SSI_SR_RNE)); \
|
while(!(REG(SSI0_BASE + SSI_SR) & SSI_SR_RNE)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/** \name Arch-specific SPI functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \brief Enables the SPI peripheral
|
||||||
|
*/
|
||||||
|
void spi_enable(void);
|
||||||
|
|
||||||
|
/** \brief Disables the SPI peripheral
|
||||||
|
* \note Call this function to save power when the SPI is unused.
|
||||||
|
*/
|
||||||
|
void spi_disable(void);
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
#endif /* SPI_ARCH_H_ */
|
#endif /* SPI_ARCH_H_ */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue