user_twim_simulate.h 1.1 KB

123456789101112131415161718192021222324252627
  1. #ifndef __USER_TWIM_SIMULATE_H__
  2. #define __USER_TWIM_SIMULATE_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "sdk_config.h"
  6. #include "define.h"
  7. //IO操作函数
  8. #define TWIM_CLK_HIGH nrf_gpio_pin_write(TWI_SCL_M0, 1);
  9. #define TWIM_CLK_LOW nrf_gpio_pin_write(TWI_SCL_M0, 0);
  10. #define TWIM_SDA_HIGH nrf_gpio_pin_write(TWI_SDA_M0, 1);
  11. #define TWIM_SDA_LOW nrf_gpio_pin_write(TWI_SDA_M0, 0);
  12. #define READ_SDA nrf_gpio_pin_read(TWI_SDA_M0) //输入SDA
  13. //IIC所有操作函数
  14. void IIC_Init(void); //初始化IIC的IO口
  15. void IIC_Start(void); //发送IIC开始信号
  16. void IIC_Stop(void); //发送IIC停止信号
  17. void IIC_Send_Byte(uint8_t txd); //IIC发送一个字节
  18. uint8_t IIC_Read_Byte(unsigned char ack);//IIC读取一个字节
  19. uint8_t IIC_Wait_Ack(void); //IIC等待ACK信号
  20. void IIC_Ack(void); //IIC发送ACK信号
  21. void IIC_NAck(void); //IIC不发送ACK信号
  22. void IIC_Write_One_Byte(uint8_t daddr,uint8_t addr,uint8_t data);
  23. uint8_t IIC_Read_One_Byte(uint8_t daddr,uint8_t addr);
  24. #endif //__USER_TWIM_SIMULATE_H__