git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1279 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2009-11-10 16:43:04 +00:00
parent 727ba84c9b
commit 3077b40452
9 changed files with 169 additions and 122 deletions

View File

@ -153,13 +153,14 @@
uninit -> stop [label="spiObjectInit()"]; uninit -> stop [label="spiObjectInit()"];
stop -> ready [label="spiStart()"]; stop -> ready [label="spiStart()"];
ready -> ready [label="spiStart()"]; ready -> ready [label="spiStart()"];
ready -> ready [label="spiIgnore()"];
ready -> stop [label="spiStop()"]; ready -> stop [label="spiStop()"];
stop -> stop [label="spiStop()"]; stop -> stop [label="spiStop()"];
ready -> active [label="spiSelect()"]; ready -> active [label="spiSelect()"];
active -> active [label="spiSelect()"]; active -> active [label="spiSelect()"];
active -> ready [label="spiUnselect()"]; active -> ready [label="spiUnselect()"];
ready -> ready [label="spiUnselect()"]; ready -> ready [label="spiUnselect()"];
active -> active [label="spiExchange()\nspiSend()\nspiReceive()"]; active -> active [label="spiIgnore()\nspiExchange()\nspiSend()\nspiReceive()"];
} }
* @enddot * @enddot
* *

View File

@ -155,14 +155,13 @@ static uint8_t send_command(MMCDriver *mmcp, uint8_t cmd, uint32_t arg) {
*/ */
static bool_t get_data(MMCDriver *mmcp, uint8_t *buf) { static bool_t get_data(MMCDriver *mmcp, uint8_t *buf) {
int i; int i;
uint8_t ignored[2];
for (i = 0; i < MMC_WAIT_DATA; i++) { for (i = 0; i < MMC_WAIT_DATA; i++) {
spiReceive(mmcp->mmc_spip, 1, buf); spiReceive(mmcp->mmc_spip, 1, buf);
if (buf[0] == 0xFE) { if (buf[0] == 0xFE) {
spiReceive(mmcp->mmc_spip, 512, buf); spiReceive(mmcp->mmc_spip, 512, buf);
/* CRC ignored. */ /* CRC ignored. */
spiReceive(mmcp->mmc_spip, 2, ignored); spiIgnore(mmcp->mmc_spip, 2);
return FALSE; return FALSE;
} }
} }
@ -228,7 +227,7 @@ void mmcStart(MMCDriver *mmcp, const MMCConfig *config) {
} }
/** /**
* @brief Deactivates the MMC peripheral. * @brief Disables the MMC peripheral.
* *
* @param[in] mmcp pointer to the @p MMCDriver object * @param[in] mmcp pointer to the @p MMCDriver object
*/ */
@ -238,7 +237,8 @@ void mmcStop(MMCDriver *mmcp) {
chSysLock(); chSysLock();
chDbgAssert((mmcp->mmc_state != MMC_UNINIT) && chDbgAssert((mmcp->mmc_state != MMC_UNINIT) &&
(mmcp->mmc_state != MMC_RUNNING), (mmcp->mmc_state != MMC_READING) &&
(mmcp->mmc_state != MMC_WRITING),
"mmcStop(), #1", "mmcStop(), #1",
"invalid state"); "invalid state");
if (mmcp->mmc_state != MMC_STOP) { if (mmcp->mmc_state != MMC_STOP) {
@ -277,6 +277,7 @@ bool_t mmcConnect(MMCDriver *mmcp) {
if (mmcp->mmc_state == MMC_INSERTED) { if (mmcp->mmc_state == MMC_INSERTED) {
/* Slow clock mode and 128 clock pulses.*/ /* Slow clock mode and 128 clock pulses.*/
spiStart(mmcp->mmc_spip, mmcp->mmc_lscfg); spiStart(mmcp->mmc_spip, mmcp->mmc_lscfg);
spiIgnore(mmcp->mmc_spip, 16);
/* SPI mode selection.*/ /* SPI mode selection.*/
i = 0; i = 0;
@ -331,7 +332,7 @@ bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk) {
chSysUnlock(); chSysUnlock();
return TRUE; return TRUE;
} }
mmcp->mmc_state = MMC_RUNNING; mmcp->mmc_state = MMC_READING;
chSysUnlock(); chSysUnlock();
spiSelect(mmcp->mmc_spip); spiSelect(mmcp->mmc_spip);
@ -339,7 +340,7 @@ bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk) {
if (recvr1() != 0x00) { if (recvr1() != 0x00) {
spiUnselect(mmcp->mmc_spip); spiUnselect(mmcp->mmc_spip);
chSysLock(); chSysLock();
if (mmcp->mmc_state == MMC_RUNNING) if (mmcp->mmc_state == MMC_READING)
mmcp->mmc_state = MMC_READY; mmcp->mmc_state = MMC_READY;
chSysUnlock(); chSysUnlock();
return TRUE; return TRUE;
@ -359,26 +360,29 @@ bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk) {
*/ */
bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer) { bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer) {
int i; int i;
uint8_t ignored[2];
chDbgCheck((mmcp != NULL) && (buffer != NULL), "mmcSequentialRead"); chDbgCheck((mmcp != NULL) && (buffer != NULL), "mmcSequentialRead");
if (mmcp->mmc_state != MMC_RUNNING) chSysLock();
if (mmcp->mmc_state != MMC_READING) {
chSysUnlock();
return TRUE; return TRUE;
}
chSysUnlock();
for (i = 0; i < MMC_WAIT_DATA; i++) { for (i = 0; i < MMC_WAIT_DATA; i++) {
spiReceive(mmcp->mmc_spip, 1, buf); spiReceive(mmcp->mmc_spip, 1, buf);
if (buf[0] == 0xFE) { if (buf[0] == 0xFE) {
spiReceive(mmcp->mmc_spip, 512, buf); spiReceive(mmcp->mmc_spip, 512, buf);
/* CRC ignored. */ /* CRC ignored. */
spiReceive(mmcp->mmc_spip, 2, ignored); spiIgnore(mmcp->mmc_spip, 2);
return FALSE; return FALSE;
} }
} }
/* Timeout.*/ /* Timeout.*/
spiUnselect(mmcp->mmc_spip); spiUnselect(mmcp->mmc_spip);
chSysLock(); chSysLock();
if (mmcp->mmc_state == MMC_RUNNING) if (mmcp->mmc_state == MMC_READING)
mmcp->mmc_state = MMC_READY; mmcp->mmc_state = MMC_READY;
chSysUnlock(); chSysUnlock();
return TRUE; return TRUE;
@ -397,10 +401,17 @@ bool_t mmcStopSequentialRead(MMCDriver *mmcp) {
chDbgCheck(mmcp != NULL, "mmcStopSequentialRead"); chDbgCheck(mmcp != NULL, "mmcStopSequentialRead");
if (mmcp->mmc_state != MMC_RUNNING) chSysLock();
if (mmcp->mmc_state != MMC_READING) {
chSysUnlock();
return TRUE; return TRUE;
}
chSysUnlock();
mmcp->mmc_state = MMC_READY; chSysLock();
if (mmcp->mmc_state == MMC_READING)
mmcp->mmc_state = MMC_READY;
chSysUnlock();
return FALSE; return FALSE;
} }

View File

@ -88,7 +88,8 @@ typedef enum {
MMC_WAIT = 2, /**< @brief Waiting card. */ MMC_WAIT = 2, /**< @brief Waiting card. */
MMC_INSERTED = 3, /**< @brief Card inserted. */ MMC_INSERTED = 3, /**< @brief Card inserted. */
MMC_READY = 4, /**< @brief Card ready. */ MMC_READY = 4, /**< @brief Card ready. */
MMC_RUNNING = 5 /**< @brief Reading or writing. */ MMC_READING = 5, /**< @brief Reading. */
MMC_WRITING = 6 /**< @brief Writing. */
} mmcstate_t; } mmcstate_t;
/** /**

View File

@ -202,7 +202,7 @@ void spi_lld_init(void) {
/** /**
* @brief Configures and activates the SPI peripheral. * @brief Configures and activates the SPI peripheral.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spi_lld_start(SPIDriver *spip) { void spi_lld_start(SPIDriver *spip) {
@ -233,24 +233,12 @@ void spi_lld_start(SPIDriver *spip) {
/* DMA setup.*/ /* DMA setup.*/
spip->spd_dmarx->CPAR = (uint32_t)&spip->spd_spi->DR; spip->spd_dmarx->CPAR = (uint32_t)&spip->spd_spi->DR;
spip->spd_dmatx->CPAR = (uint32_t)&spip->spd_spi->DR; spip->spd_dmatx->CPAR = (uint32_t)&spip->spd_spi->DR;
/*
* If specified in the configuration then emits a pulses train on
* the SPI clock line without asserting any slave.
*/
if (spip->spd_config->spc_initcnt > 0) {
spip->spd_dmarx->CCR = DMA_CCR1_TCIE | DMA_CCR1_TEIE;
spip->spd_dmatx->CCR = DMA_CCR1_DIR | DMA_CCR1_TEIE;
dma_start(spip, (size_t)spip->spd_config->spc_initcnt,
&dummyrx, &dummytx);
(void) spi_start_wait(spip);
}
} }
/** /**
* @brief Deactivates the SPI peripheral. * @brief Deactivates the SPI peripheral.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spi_lld_stop(SPIDriver *spip) { void spi_lld_stop(SPIDriver *spip) {
@ -278,7 +266,7 @@ void spi_lld_stop(SPIDriver *spip) {
/** /**
* @brief Asserts the slave select signal and prepares for transfers. * @brief Asserts the slave select signal and prepares for transfers.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spi_lld_select(SPIDriver *spip) { void spi_lld_select(SPIDriver *spip) {
@ -289,28 +277,46 @@ void spi_lld_select(SPIDriver *spip) {
* @brief Deasserts the slave select signal. * @brief Deasserts the slave select signal.
* @details The previously selected peripheral is unselected. * @details The previously selected peripheral is unselected.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spi_lld_unselect(SPIDriver *spip) { void spi_lld_unselect(SPIDriver *spip) {
palSetPad(spip->spd_config->spc_ssport, spip->spd_config->spc_sspad); palSetPad(spip->spd_config->spc_ssport, spip->spd_config->spc_sspad);
} }
/**
* @brief Ignores data on the SPI bus.
* @details This function transmits a series of idle words on the SPI bus and
* ignores the received data. This function can be invoked even
* when a slave select signal has not been yet asserted.
*
* @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to be ignored
*
* @return The operation status is returned.
* @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure.
*/
msg_t spi_lld_ignore(SPIDriver *spip, size_t n) {
spip->spd_dmarx->CCR = DMA_CCR1_TCIE | DMA_CCR1_TEIE;
spip->spd_dmatx->CCR = DMA_CCR1_DIR | DMA_CCR1_TEIE;
dma_start(spip, n, &dummyrx, &dummytx);
return spi_start_wait(spip);
}
/** /**
* @brief Exchanges data on the SPI bus. * @brief Exchanges data on the SPI bus.
* @details This function performs a simultaneous transmit/receive operation. * @details This function performs a simultaneous transmit/receive operation.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to exchange * @param[in] n number of words to be exchanged
* @param[in] txbuf the pointer to the transmit buffer. Note that the buffer is * @param[in] txbuf the pointer to the transmit buffer
* organized as an uint8_t array for data sizes below or equal * @param[out] rxbuf the pointer to the receive buffer
* to 8 bits else it is organized as an uint16_t array. *
* @param[out] rxbuf the pointer to the receive buffer. Note that the buffer is
* organized as an uint8_t array for data sizes below or equal
* to 8 bits else it is organized as an uint16_t array.
* @return The operation status is returned. * @return The operation status is returned.
* @retval RDY_OK operation complete. * @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure. * @retval RDY_RESET hardware failure.
* *
* @note The buffers are organized as uint8_t arrays for data sizes below or * @note The buffers are organized as uint8_t arrays for data sizes below or
* equal to 8 bits else it is organized as uint16_t arrays. * equal to 8 bits else it is organized as uint16_t arrays.
@ -326,14 +332,13 @@ msg_t spi_lld_exchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf) {
/** /**
* @brief Sends data ever the SPI bus. * @brief Sends data ever the SPI bus.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to send * @param[in] n number of words to send
* @param[in] txbuf the pointer to the transmit buffer. Note that the buffer is * @param[in] txbuf the pointer to the transmit buffer
* organized as an uint8_t array for data sizes below or equal *
* to 8 bits else it is organized as an uint16_t array.
* @return The operation status is returned. * @return The operation status is returned.
* @retval RDY_OK operation complete. * @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure. * @retval RDY_RESET hardware failure.
* *
* @note The buffers are organized as uint8_t arrays for data sizes below or * @note The buffers are organized as uint8_t arrays for data sizes below or
* equal to 8 bits else it is organized as uint16_t arrays. * equal to 8 bits else it is organized as uint16_t arrays.
@ -349,14 +354,13 @@ msg_t spi_lld_send(SPIDriver *spip, size_t n, void *txbuf) {
/** /**
* @brief Receives data from the SPI bus. * @brief Receives data from the SPI bus.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to receive * @param[in] n number of words to receive
* @param[out] rxbuf the pointer to the receive buffer. Note that the buffer is * @param[out] rxbuf the pointer to the receive buffer
* organized as an uint8_t array for data sizes below or equal *
* to 8 bits else it is organized as an uint16_t array.
* @return The operation status is returned. * @return The operation status is returned.
* @retval RDY_OK operation complete. * @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure. * @retval RDY_RESET hardware failure.
* *
* @note The buffers are organized as uint8_t arrays for data sizes below or * @note The buffers are organized as uint8_t arrays for data sizes below or
* equal to 8 bits else it is organized as uint16_t arrays. * equal to 8 bits else it is organized as uint16_t arrays.

View File

@ -101,11 +101,6 @@
* @brief Driver configuration structure. * @brief Driver configuration structure.
*/ */
typedef struct { typedef struct {
/**
* @brief Clock pulses to be generated after initialization.
*/
cnt_t spc_initcnt;
/* End of the mandatory fields.*/
/** /**
* @brief The chip select line port. * @brief The chip select line port.
*/ */
@ -186,6 +181,7 @@ extern "C" {
void spi_lld_stop(SPIDriver *spip); void spi_lld_stop(SPIDriver *spip);
void spi_lld_select(SPIDriver *spip); void spi_lld_select(SPIDriver *spip);
void spi_lld_unselect(SPIDriver *spip); void spi_lld_unselect(SPIDriver *spip);
msg_t spi_lld_ignore(SPIDriver *spip, size_t n);
msg_t spi_lld_exchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf); msg_t spi_lld_exchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf);
msg_t spi_lld_send(SPIDriver *spip, size_t n, void *txbuf); msg_t spi_lld_send(SPIDriver *spip, size_t n, void *txbuf);
msg_t spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf); msg_t spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf);

View File

@ -38,7 +38,7 @@ void spiInit(void) {
/** /**
* @brief Initializes the standard part of a @p SPIDriver structure. * @brief Initializes the standard part of a @p SPIDriver structure.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spiObjectInit(SPIDriver *spip) { void spiObjectInit(SPIDriver *spip) {
@ -54,8 +54,8 @@ void spiObjectInit(SPIDriver *spip) {
/** /**
* @brief Configures and activates the SPI peripheral. * @brief Configures and activates the SPI peripheral.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] config pointer to the @p SPIConfig object * @param[in] config pointer to the @p SPIConfig object
*/ */
void spiStart(SPIDriver *spip, const SPIConfig *config) { void spiStart(SPIDriver *spip, const SPIConfig *config) {
@ -74,7 +74,7 @@ void spiStart(SPIDriver *spip, const SPIConfig *config) {
/** /**
* @brief Deactivates the SPI peripheral. * @brief Deactivates the SPI peripheral.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spiStop(SPIDriver *spip) { void spiStop(SPIDriver *spip) {
@ -92,7 +92,7 @@ void spiStop(SPIDriver *spip) {
/** /**
* @brief Asserts the slave select signal and prepares for transfers. * @brief Asserts the slave select signal and prepares for transfers.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spiSelect(SPIDriver *spip) { void spiSelect(SPIDriver *spip) {
@ -112,7 +112,7 @@ void spiSelect(SPIDriver *spip) {
* @brief Deasserts the slave select signal. * @brief Deasserts the slave select signal.
* @details The previously selected peripheral is unselected. * @details The previously selected peripheral is unselected.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spiUnselect(SPIDriver *spip) { void spiUnselect(SPIDriver *spip) {
@ -128,18 +128,44 @@ void spiUnselect(SPIDriver *spip) {
chSysUnlock(); chSysUnlock();
} }
/**
* @brief Ignores data on the SPI bus.
* @details This function transmits a series of idle words on the SPI bus and
* ignores the received data. This function can be invoked even
* when a slave select signal has not been yet asserted.
*
* @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to be ignored
*
* @return The operation status is returned.
* @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure.
*/
msg_t spiIgnore(SPIDriver *spip, size_t n) {
chDbgCheck((spip != NULL) && (n > 0), "spiIgnore");
chDbgAssert((spip->spd_state == SPI_READY) || (spip->spd_state == SPI_ACTIVE),
"spiIgnore(), #1",
"not active");
return spi_lld_ignore(spip, n);
}
/** /**
* @brief Exchanges data on the SPI bus. * @brief Exchanges data on the SPI bus.
* @details This function performs a simultaneous transmit/receive operation. * @details This function performs a simultaneous transmit/receive operation.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to be exchanged * @param[in] n number of words to be exchanged
* @param[in] txbuf the pointer to the transmit buffer. Note that the buffer is * @param[in] txbuf the pointer to the transmit buffer
* organized as an uint8_t array for data sizes below or equal * @param[out] rxbuf the pointer to the receive buffer
* to 8 bits else it is organized as an uint16_t array. *
* @param[out] rxbuf the pointer to the receive buffer. Note that the buffer is * @return The operation status is returned.
* organized as an uint8_t array for data sizes below or equal * @retval RDY_OK operation complete.
* to 8 bits else it is organized as an uint16_t array. * @retval RDY_RESET hardware failure.
*
* @note The buffers are organized as uint8_t arrays for data sizes below or
* equal to 8 bits else it is organized as uint16_t arrays.
*/ */
msg_t spiExchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf) { msg_t spiExchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf) {
@ -155,14 +181,13 @@ msg_t spiExchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf) {
/** /**
* @brief Sends data ever the SPI bus. * @brief Sends data ever the SPI bus.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to send * @param[in] n number of words to send
* @param[in] txbuf the pointer to the transmit buffer. Note that the buffer is * @param[in] txbuf the pointer to the transmit buffer
* organized as an uint8_t array for data sizes below or equal *
* to 8 bits else it is organized as an uint16_t array.
* @return The operation status is returned. * @return The operation status is returned.
* @retval RDY_OK operation complete. * @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure. * @retval RDY_RESET hardware failure.
* *
* @note The buffers are organized as uint8_t arrays for data sizes below or * @note The buffers are organized as uint8_t arrays for data sizes below or
* equal to 8 bits else it is organized as uint16_t arrays. * equal to 8 bits else it is organized as uint16_t arrays.
@ -181,14 +206,13 @@ msg_t spiSend(SPIDriver *spip, size_t n, void *txbuf) {
/** /**
* @brief Receives data from the SPI bus. * @brief Receives data from the SPI bus.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to receive * @param[in] n number of words to receive
* @param[out] rxbuf the pointer to the receive buffer. Note that the buffer is * @param[out] rxbuf the pointer to the receive buffer
* organized as an uint8_t array for data sizes below or equal *
* to 8 bits else it is organized as an uint16_t array.
* @return The operation status is returned. * @return The operation status is returned.
* @retval RDY_OK operation complete. * @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure. * @retval RDY_RESET hardware failure.
* *
* @note The buffers are organized as uint8_t arrays for data sizes below or * @note The buffers are organized as uint8_t arrays for data sizes below or
* equal to 8 bits else it is organized as uint16_t arrays. * equal to 8 bits else it is organized as uint16_t arrays.
@ -210,7 +234,7 @@ msg_t spiReceive(SPIDriver *spip, size_t n, void *rxbuf) {
* @details This function tries to gain ownership to the SPI bus, if the bus * @details This function tries to gain ownership to the SPI bus, if the bus
* is already being used then the invoking thread is queued. * is already being used then the invoking thread is queued.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* *
* @note This function is only available when the @p SPI_USE_MUTUAL_EXCLUSION * @note This function is only available when the @p SPI_USE_MUTUAL_EXCLUSION
* option is set to @p TRUE. * option is set to @p TRUE.
@ -229,7 +253,7 @@ void spiAcquireBus(SPIDriver *spip) {
/** /**
* @brief Releases exclusive access to the SPI bus. * @brief Releases exclusive access to the SPI bus.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* *
* @note This function is only available when the @p SPI_USE_MUTUAL_EXCLUSION * @note This function is only available when the @p SPI_USE_MUTUAL_EXCLUSION
* option is set to @p TRUE. * option is set to @p TRUE.

View File

@ -59,6 +59,7 @@ extern "C" {
void spiStop(SPIDriver *spip); void spiStop(SPIDriver *spip);
void spiSelect(SPIDriver *spip); void spiSelect(SPIDriver *spip);
void spiUnselect(SPIDriver *spip); void spiUnselect(SPIDriver *spip);
msg_t spiIgnore(SPIDriver *spip, size_t n);
msg_t spiExchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf); msg_t spiExchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf);
msg_t spiSend(SPIDriver *spip, size_t n, void *txbuf); msg_t spiSend(SPIDriver *spip, size_t n, void *txbuf);
msg_t spiReceive(SPIDriver *spip, size_t n, void *rxbuf); msg_t spiReceive(SPIDriver *spip, size_t n, void *rxbuf);

View File

@ -49,7 +49,7 @@ void spi_lld_init(void) {
/** /**
* @brief Configures and activates the SPI peripheral. * @brief Configures and activates the SPI peripheral.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spi_lld_start(SPIDriver *spip) { void spi_lld_start(SPIDriver *spip) {
@ -62,7 +62,7 @@ void spi_lld_start(SPIDriver *spip) {
/** /**
* @brief Deactivates the SPI peripheral. * @brief Deactivates the SPI peripheral.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spi_lld_stop(SPIDriver *spip) { void spi_lld_stop(SPIDriver *spip) {
@ -71,7 +71,7 @@ void spi_lld_stop(SPIDriver *spip) {
/** /**
* @brief Asserts the slave select signal and prepares for transfers. * @brief Asserts the slave select signal and prepares for transfers.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spi_lld_select(SPIDriver *spip) { void spi_lld_select(SPIDriver *spip) {
@ -81,27 +81,41 @@ void spi_lld_select(SPIDriver *spip) {
* @brief Deasserts the slave select signal. * @brief Deasserts the slave select signal.
* @details The previously selected peripheral is unselected. * @details The previously selected peripheral is unselected.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
*/ */
void spi_lld_unselect(SPIDriver *spip) { void spi_lld_unselect(SPIDriver *spip) {
} }
/**
* @brief Ignores data on the SPI bus.
* @details This function transmits a series of idle words on the SPI bus and
* ignores the received data. This function can be invoked even
* when a slave select signal has not been yet asserted.
*
* @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to be ignored
*
* @return The operation status is returned.
* @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure.
*/
msg_t spi_lld_ignore(SPIDriver *spip, size_t n) {
}
/** /**
* @brief Exchanges data on the SPI bus. * @brief Exchanges data on the SPI bus.
* @details This function performs a simultaneous transmit/receive operation. * @details This function performs a simultaneous transmit/receive operation.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to exchange * @param[in] n number of words to be exchanged
* @param[in] txbuf the pointer to the transmit buffer. Note that the buffer is * @param[in] txbuf the pointer to the transmit buffer
* organized as an uint8_t array for data sizes below or equal * @param[out] rxbuf the pointer to the receive buffer
* to 8 bits else it is organized as an uint16_t array. *
* @param[out] rxbuf the pointer to the receive buffer. Note that the buffer is
* organized as an uint8_t array for data sizes below or equal
* to 8 bits else it is organized as an uint16_t array.
* @return The operation status is returned. * @return The operation status is returned.
* @retval RDY_OK operation complete. * @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure. * @retval RDY_RESET hardware failure.
* *
* @note The buffers are organized as uint8_t arrays for data sizes below or * @note The buffers are organized as uint8_t arrays for data sizes below or
* equal to 8 bits else it is organized as uint16_t arrays. * equal to 8 bits else it is organized as uint16_t arrays.
@ -113,14 +127,13 @@ msg_t spi_lld_exchange(SPIDriver *spip, size_t n, void *rxbuf, void *txbuf) {
/** /**
* @brief Sends data ever the SPI bus. * @brief Sends data ever the SPI bus.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to send * @param[in] n number of words to send
* @param[in] txbuf the pointer to the transmit buffer. Note that the buffer is * @param[in] txbuf the pointer to the transmit buffer
* organized as an uint8_t array for data sizes below or equal *
* to 8 bits else it is organized as an uint16_t array.
* @return The operation status is returned. * @return The operation status is returned.
* @retval RDY_OK operation complete. * @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure. * @retval RDY_RESET hardware failure.
* *
* @note The buffers are organized as uint8_t arrays for data sizes below or * @note The buffers are organized as uint8_t arrays for data sizes below or
* equal to 8 bits else it is organized as uint16_t arrays. * equal to 8 bits else it is organized as uint16_t arrays.
@ -132,14 +145,13 @@ msg_t spi_lld_send(SPIDriver *spip, size_t n, void *txbuf) {
/** /**
* @brief Receives data from the SPI bus. * @brief Receives data from the SPI bus.
* *
* @param[in] spip pointer to the @p SPIDriver object * @param[in] spip pointer to the @p SPIDriver object
* @param[in] n number of words to receive * @param[in] n number of words to receive
* @param[out] rxbuf the pointer to the receive buffer. Note that the buffer is * @param[out] rxbuf the pointer to the receive buffer
* organized as an uint8_t array for data sizes below or equal *
* to 8 bits else it is organized as an uint16_t array.
* @return The operation status is returned. * @return The operation status is returned.
* @retval RDY_OK operation complete. * @retval RDY_OK operation complete.
* @retval RDY_RESET hardware failure. * @retval RDY_RESET hardware failure.
* *
* @note The buffers are organized as uint8_t arrays for data sizes below or * @note The buffers are organized as uint8_t arrays for data sizes below or
* equal to 8 bits else it is organized as uint16_t arrays. * equal to 8 bits else it is organized as uint16_t arrays.

View File

@ -50,11 +50,7 @@
* @brief Driver configuration structure. * @brief Driver configuration structure.
*/ */
typedef struct { typedef struct {
/**
* @brief Clock pulses to be generated after initialization.
*/
cnt_t spc_initcnt;
/* End of the mandatory fields.*/
} SPIConfig; } SPIConfig;
/** /**
@ -94,6 +90,7 @@ extern "C" {
void spi_lld_stop(SPIDriver *spip); void spi_lld_stop(SPIDriver *spip);
void spi_lld_select(SPIDriver *spip); void spi_lld_select(SPIDriver *spip);
void spi_lld_unselect(SPIDriver *spip); void spi_lld_unselect(SPIDriver *spip);
msg_t spi_lld_ignore(SPIDriver *spip, size_t n);
msg_t spi_lld_exchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf); msg_t spi_lld_exchange(SPIDriver *spip, size_t n, void *txbuf, void *rxbuf);
msg_t spi_lld_send(SPIDriver *spip, size_t n, void *txbuf); msg_t spi_lld_send(SPIDriver *spip, size_t n, void *txbuf);
msg_t spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf); msg_t spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf);