4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-19 11:13:31 +08:00

Update drv_spi.c

Bug Fixed : clock division cannot been adjusted as expected due to wrong register configuration.
This commit is contained in:
马浩然 2021-01-17 23:33:48 +08:00 committed by GitHub
parent a18714b04a
commit 902fe8bd5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2020-10-28 0xcccccccccccc Initial Version * 2020-10-28 0xcccccccccccc Initial Version
* 2021-01-17 0xcccccccccccc Bug Fixed : clock division cannot been adjusted as expected due to wrong register configuration.
*/ */
/** /**
* @addtogroup ls2k * @addtogroup ls2k
@ -21,11 +22,11 @@
#ifdef RT_USING_SPI #ifdef RT_USING_SPI
static void spi_init(uint8_t spre_spr, uint8_t copl, uint8_t cpha) static void spi_init(uint8_t spre_spr, uint8_t copl, uint8_t cpha)
{ {
SET_SPI(SPSR, 0xc0 | (spre_spr & 0b00000011)); SET_SPI(SPSR, 0xc0);
SET_SPI(PARAM, 0x40); SET_SPI(PARAM, 0x40);
SET_SPI(PARAM2, 0x01); SET_SPI(PARAM2, 0x01);
SET_SPI(SPER, (spre_spr & 0b00001100) >> 2); SET_SPI(SPER, (spre_spr & 0b00001100) >> 2);
SET_SPI(SPCR, 0x50 | copl << 3 | cpha << 2); SET_SPI(SPCR, 0x50 | copl << 3 | cpha << 2 | (spre_spr & 0b00000011));
SET_SPI(SOFTCS, 0xff); SET_SPI(SOFTCS, 0xff);
} }