unsigned rxcnt; /* No. of received bytes for msg_act */
spi_dev_t *spi_devs; /* Pointer to table holding information about SPI devices bound to the interface */
uint32_t transfer_ctrl; /* Transfer configuration -- upper 16 bits of SPIDAT1 register */
+ /* TODO: Add FMT description here if we need different formats */
} spi_tms570_iface_t;
//extern spi_tms570_iface_t spi_tms570_ifcs[4];
ENA register is set even on SPI devices which do not have it --
this should not be an issue
*/
-void spiInit(spiBASE_compat_t *spiREG)
+static void spiInit(spiBASE_compat_t *spiREG)
{
/** bring SPI out of reset */
spiREG->GCR0 = 1U;
| 0; /* C2EDELAY */
/** - Data Format 0 */
+ /* TODO: Set the formats from spi_tms570_iface_t if we need different formats */
spiREG->FMT0 = (0 << 24) /* wdelay */
| (0 << 23) /* parity Polarity */
| (0 << 22) /* parity enable */
while (iface->reg->FLG & SPI_FLG_RXINT_m) {
rx_data = iface->reg->BUF;
- if (msg->rx_buf && (rxcnt < rq_len))
+ if (msg->rx_buf && (rxcnt < rq_len)) {
+ /* This relies on all FMTs having 8 bit CHARLEN */
msg->rx_buf[rxcnt++] = rx_data & 0xFF;
- //FIXME how to make sure we got only 8 bits
- else
+ } else
rxcnt++;
}
break;
/* Make it possible to write "empty data"
for "read transfers" */
- if (msg->tx_buf)
+ if (msg->tx_buf) {
+ /* This relies on all FMTs having 8 bit CHARLEN */
val_to_wr = msg->tx_buf[txcnt++];
- else {
+ } else {
val_to_wr = 0x00;
txcnt++;
}
- if (txcnt == rq_len) /* Disable CS for the last byte of the transfer */
+ if (txcnt == rq_len) /* Disable CS after last byte of the transfer */
iface->transfer_ctrl &= ~SPI_DAT1_CSHOLD_m;
iface->reg->DAT1 =