论坛元老
 
- 积分
- 7140
- 金钱
- 7140
- 注册时间
- 2015-1-23
- 在线时间
- 106 小时
|
发表于 2015-7-24 14:38:57
|
显示全部楼层
GPIO_ResetBits(GPIOB, GPIO_Pin_14); //CS 低 使能
simulation_spi(0x00);
simulation_spi(data_h);
simulation_spi(data_l);
GPIO_SetBits(GPIOB, GPIO_Pin_14); //CS 高
void simulation_spi(u8 data)
{
signed i=0;
for(i=7; i>=0; i--)
{
if((data>>i)&0x01) //先发高
{
GPIO_SetBits(GPIOB, DI); //DI
for_delay(5);
GPIO_ResetBits(GPIOB, SCK);
for_delay(5);
GPIO_SetBits(GPIOB, SCK);
}
else
{
GPIO_ResetBits(GPIOB, DI);
for_delay(5);
GPIO_ResetBits(GPIOB, SCK);
for_delay(5);
GPIO_SetBits(GPIOB, SCK);
}
}
} |
|