|
- #define SD_SPI_CLK_PIN gpio_fm_i2c_scl_pin//gpio18
- #define SD_SPI_DIN_PIN gpio_fm_i2c_sda_pin//gpio19
- #define SD_SPI_DOUT_PIN gpio_double_sim_switch_pin//gpio17
- #define SD_SPI_CS_PIN gpio_sim_eint_pin//gpio15
- /*GPIO 22 18*/
- //#define SD_SPI_CLK_OFFSET 0x10 //(SD_SPI_CLK_PIN>>4)<<4
- #define SD_SPI_CLK_SHIFT 0x4 //0x40 //1<<(SD_SPI_CLK_PIN-SD_SPI_CLK_OFFSET<<4)
- #define SD_SPI_CLK_ADDR_S 0x801200D4 //GPIO_DOUT1_SET+SD_SPI_CLK_OFFSET
- #define SD_SPI_CLK_ADDR_C 0X801200D8 //GPIO_DOUT1_CLR+SD_SPI_CLK_OFFSET
- /*GPIO 42 17*/
- //#define SD_SPI_DATA_OFFSET 0x20 //(SD_SPI_DIN_PIN>>4)<<4
- #define SD_SPI_DATA_SHIFT 0x2 //0x400 //1<<(SD_SPI_DIN_PIN-SD_SPI_DATA_OFFSET<<4)
- #define SD_SPI_DATA_ADDR_S 0x801200D4 //0x801200E4 //GPIO_DOUT1_SET+SD_SPI_DATA_OFFSET
- #define SD_SPI_DATA_ADDR_C 0X801200D8 //0X801200E8 //GPIO_DOUT1_CLR+SD_SPI_DATA_OFFSET
- /*GPIO 43 19*/
- //#define SD_SPI_READ_OFFSET 0x20 //(SD_SPI_DOUT_PIN>>4)<<4
- #define SD_SPI_READ_MASK 0x8 //0x800 //1<<(SD_SPI_DOUT_PIN-SD_SPI_READ_OFFSET<<4)
- #define SD_SPI_READ_ADDR 0x80120110 //0x80120120 //GPIO_DIN1+SD_SPI_READ_OFFSET
- #define SD_SET_CLK_HIGH DRV_WriteReg(SD_SPI_CLK_ADDR_S,SD_SPI_CLK_SHIFT)
- #define SD_SET_CLK_LOW DRV_WriteReg(SD_SPI_CLK_ADDR_C,SD_SPI_CLK_SHIFT)
- #define SD_SET_DATA_HIGH DRV_WriteReg(SD_SPI_DATA_ADDR_S,SD_SPI_DATA_SHIFT)
- #define SD_SET_DATA_LOW DRV_WriteReg(SD_SPI_DATA_ADDR_C,SD_SPI_DATA_SHIFT)
- #define SD_GET_DATA() ((DRV_Reg(SD_SPI_READ_ADDR) &SD_SPI_READ_MASK) ? 1 : 0)
复制代码
这段代码到底怎么理解,是否为GPIO口模式传输数据用的,其中的SD_SPI_DATA_ADDR_S;SD_SPI_DATA_ADDR_C是什么用的?还有对应的0X801200D8在datasheet中找到的并不是gpio17而是gpio20??莫名了。请高手讲解一下,拜谢了!!! |
|