|
50 | 50 |
|
51 | 51 | static uint16_t fill_word = SPI_FILL_WORD;
|
52 | 52 |
|
53 |
| -#define SPI_LEAST_ACTIVE_SLEEPMODE EM0 |
| 53 | +#define SPI_LEAST_ACTIVE_SLEEPMODE EM1 |
54 | 54 | #define USE_UINT16_BUFFER
|
55 | 55 |
|
56 | 56 | static inline CMU_Clock_TypeDef spi_get_clock_tree(spi_t *obj)
|
@@ -125,7 +125,6 @@ void spi_preinit(spi_t *obj, PinName mosi, PinName miso, PinName clk, PinName cs
|
125 | 125 | {
|
126 | 126 | obj->spi.spi = serial_uart_allocate(UART_TYPE_USART);
|
127 | 127 | MBED_ASSERT(obj->spi.spi);
|
128 |
| - SPIName spi_cs = (SPIName) pinmap_peripheral(cs, PinMap_SPI_CS); |
129 | 128 | if (cs != NC) { /* Slave mode */
|
130 | 129 | obj->spi.master = false;
|
131 | 130 | } else {
|
@@ -1173,6 +1172,8 @@ uint32_t spi_irq_handler_asynch(spi_t* obj)
|
1173 | 1172 | void* tx_pointer = (char*)obj->tx_buff.buffer + obj->tx_buff.pos;
|
1174 | 1173 | uint32_t tx_length = obj->tx_buff.length - obj->tx_buff.pos;
|
1175 | 1174 |
|
| 1175 | + /* Wait previous transmit to complete */ |
| 1176 | + while(!(obj->spi.spi->STATUS & USART_STATUS_TXC)); |
1176 | 1177 | /* Begin transfer. Rely on spi_activate_dma to split up the transfer further. */
|
1177 | 1178 | spi_activate_dma(obj, obj->rx_buff.buffer, tx_pointer, tx_length, obj->rx_buff.length);
|
1178 | 1179 |
|
@@ -1347,9 +1348,13 @@ void spi_abort_asynch(spi_t *obj)
|
1347 | 1348 | // Determine whether we're running DMA or interrupt
|
1348 | 1349 | if (obj->spi.dmaOptionsTX.dmaUsageState == DMA_USAGE_ALLOCATED || obj->spi.dmaOptionsTX.dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED) {
|
1349 | 1350 | // Cancel the DMA transfers
|
| 1351 | +#ifdef LDMA_PRESENT |
| 1352 | + LDMA_StopTransfer(obj->spi.dmaOptionsTX.dmaChannel); |
| 1353 | + LDMA_StopTransfer(obj->spi.dmaOptionsRX.dmaChannel); |
| 1354 | +#else |
1350 | 1355 | DMA_ChannelEnable(obj->spi.dmaOptionsTX.dmaChannel, false);
|
1351 | 1356 | DMA_ChannelEnable(obj->spi.dmaOptionsRX.dmaChannel, false);
|
1352 |
| - |
| 1357 | +#endif |
1353 | 1358 | /* Release the dma channels if they were opportunistically allocated */
|
1354 | 1359 | if (obj->spi.dmaOptionsTX.dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED) {
|
1355 | 1360 | dma_channel_free(obj->spi.dmaOptionsTX.dmaChannel);
|
|
0 commit comments