kendryte / kendryte-standalone-sdk

Standalone SDK for kendryte K210
https://kendryte.com
Apache License 2.0
445 stars 162 forks source link

"spi_send_data_normal_dma" with "SPI_TRANS_CHAR" problem. #27

Closed jimaobian closed 5 years ago

jimaobian commented 5 years ago

https://github.com/kendryte/kendryte-standalone-sdk/blob/d13b38098a3598b0018c38590387e43953efd140/lib/drivers/spi.c#L332

uint8_t data = 0x34;
spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_DEVICE_0, SPI_CHIP_SELECT_0, data, 1, SPI_TRANS_CHAR);

The code above will send "0x00 0x00 0x00 0x34" instead of "0x34", which is not reasonable.

zzxcanaan commented 5 years ago

you should use "spi_init" to change the configuration of spi. spi_init(SPI_DEVICE_0, SPI_WORK_MODE_0, SPI_FF_STANDARD, 8, 0); uint8_t data = 0x34; spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_DEVICE_0, SPI_CHIP_SELECT_0, data, 1, SPI_TRANS_CHAR)

jimaobian commented 5 years ago

You are right, Got it.