双线SPI, 是只有sck, sdio 模式吗
在ch57x 系列的soc上可以按照下面方式来实现:
//初始化
//sck0 初始化
GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA);
//MISO 作为sdio初始化
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PD);
SPI0_MasterDefInit( );
//32 分频,主频32M 时候, 这里为1M,半双工下不建议速度太快,因为是软件控制,太快可能出现sdio PP输出打架的现象
R8_SPI0_CLOCK_DIV = 32;
//发送一个byte
R32_PA_DIR |= GPIO_Pin_15;
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
R8_SPI0_CTRL_MOD |= RB_SPI_MISO_OE;
//R8_SPI0_CTRL_MOD = 0X34;
R8_SPI0_BUFFER = data_tx;
while( !(R8_SPI0_INT_FLAG & RB_SPI_FREE) );
//接收一个byte
R32_PA_DIR &= ~GPIO_Pin_15;
R8_SPI0_CTRL_MOD &= ~RB_SPI_MISO_OE;
R8_SPI0_CTRL_MOD |= RB_SPI_FIFO_DIR;
R8_SPI0_BUFFER = 0xFF; // 启动传输
while( !(R8_SPI0_INT_FLAG & RB_SPI_FREE) );
data_rx= R8_SPI0_BUFFER;
双线SPI, 是只有sck, sdio 模式吗
在ch57x 系列的soc上可以按照下面方式来实现:
//初始化
//sck0 初始化
GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA);
//MISO 作为sdio初始化
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PD);
SPI0_MasterDefInit( );
//32 分频,主频32M 时候, 这里为1M,半双工下不建议速度太快,因为是软件控制,太快可能出现sdio PP输出打架的现象
R8_SPI0_CLOCK_DIV = 32;
//发送一个byte
R32_PA_DIR |= GPIO_Pin_15;
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
R8_SPI0_CTRL_MOD |= RB_SPI_MISO_OE;
//R8_SPI0_CTRL_MOD = 0X34;
R8_SPI0_BUFFER = data_tx;
while( !(R8_SPI0_INT_FLAG & RB_SPI_FREE) );
//接收一个byte
R32_PA_DIR &= ~GPIO_Pin_15;
R8_SPI0_CTRL_MOD &= ~RB_SPI_MISO_OE;
R8_SPI0_CTRL_MOD |= RB_SPI_FIFO_DIR;
R8_SPI0_BUFFER = 0xFF; // 启动传输
while( !(R8_SPI0_INT_FLAG & RB_SPI_FREE) );
data_rx= R8_SPI0_BUFFER;
举报