

Go to the source code of this file.
Functions | |
unsigned | ssp1_dma_transfer_block (unsigned char *pBuffer, uint32_t num_bytes, char is_write_op) |
Function Documentation
unsigned ssp1_dma_transfer_block | ( | unsigned char * | pBuffer, |
uint32_t | num_bytes, | ||
char | is_write_op | ||
) |
Transfers data over SPI (SSP#1)
- Parameters
-
pBuffer The read or write buffer num_bytes The length of the transfer in bytes is_write_op Non-zero for Write-operation, zero for read operation
- Note
- If is_write_op is true:
- SPI data is sent from pBuffer
- SPI data is copied from SSP DR to dummy buffer and discarded If is_write_op is false (read operation) :
- SPI data is copied from SSP DR to pBuffer
- 0xFF is sent out for each byte transfered
- Returns
- 0 upon success, or non-zero upon failure.
TO DO : Optimize SSP1 DMA
- Try setting source and destination burst size to 4
- Try setting 16-bit SPI, and source and destination width to 1 WORD
LPC_SSP1->CR0 : B3:B0. 0b0111 = 8-bit and 0b1111 = 16-bit LPC_SSP1->CR0 |= (1<<3); // 16-bit LPC_SSP1->CR0 &= ~(1<<3); // 8-bit
Bits of DMACCControl: Transfer size: B11:B0 Source Burst Size: B14:B12 - 0:1, 1:4, 2:8, 3:16 bytes Dest. Burst Size: B17:B15 - 0:1, 1:4, 2:8, 3:16 bytes Source Width: B20:B18 - 0:Byte, 1:Word, 2:DWORD Dest. Width: B23:B21 - 0:Byte, 1:Word, 2:DWORD Source increment: B26 Destination increment: B27 Terminal count interrupt enable: B31
Bits of DMACCConfig: Enable: B0 Source Peripheral: B5:B1 (ignored if source is memory) Dest. Peripheral: B10:B6 (ignored if dest. is memory) Transfer type: B13:B11 - See below Interrupt Error Mask: B14 Terminal Count Interrupt : B15
Bits for transfer type: 000 - Memory to Memory 001 - Memory to Peripheral 010 - Peripheral to Memory 011 - Source peripheral to destination peripheral
Clear existing terminal count and error interrupts otherwise DMA will not start.
From SPI to buffer: For write operation :
- Receive data into dummy buffer
- Don't increment destination For read operation:
- Read data into pBuffer
- Increment destination
From buffer to SPI : For write operation :
- Source data is pBuffer
- Increment source data For read operation:
- Source data is buffer with 0xFF
- Don't increment source data
Channel must be fully configured and then enabled separately. Setting DMACR's Rx/Tx bits should trigger the DMA