找回密码
 注册
搜索
查看: 1777|回复: 0

[讨论] GPIO模拟SPI

[复制链接]
发表于 2013-9-9 08:44:48 | 显示全部楼层 |阅读模式
MTK(mediatek)-驱动-交流         QQ群  14180674


  spi协议数据采样和数据输出不是要隔半个时钟吗?为什么linux内核用spio模拟spi协议时,数据发送和接收没有延时函数模拟那半个时钟呢?
104 bitbang_txrx_be_cpha0(struct spi_device *spi,
105 unsigned nsecs, unsigned cpol,
106 u32 word, u8 bits)
107 {
108 /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */
109  
110 /* clock starts at inactive polarity */
111 for (word <<= (32 - bits); likely(bits); bits--) {
112  
113 /* setup MSB (to slave) on trailing edge */
114 setmosi(spi, word & (1 << 31));
115 spidelay(nsecs); /* T(setup) */
116  
117 setsck(spi, !cpol);118 spidelay(nsecs);
119  
120 /* sample MSB (from slave) on leading edge */
121 word <<= 1;
122 word |= getmiso(spi);
123 setsck(spi, cpol);124 }
125 return word;
126 }


MTK(mediatek)-驱动-交流         QQ群  14180674
高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-12-23 14:30 , Processed in 0.084445 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表