drv_iic_back2.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef __DRV_IIC_BACK2_H__
  2. #define __DRV_IIC_BACK2_H__
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <string.h>
  6. #include "sdk_common.h"
  7. #include "SEGGER_RTT.h"
  8. #include "usr_config.h"
  9. #include "nrf_gpio.h"
  10. #include "nrf_delay.h"
  11. //IO口操作宏定义
  12. #define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
  13. #define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
  14. #define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
  15. #define SCL_H nrf_gpio_pin_write(PIN_BACK_SCL,1)
  16. #define SCL_L nrf_gpio_pin_write(PIN_BACK_SCL,0)
  17. #define SDA_H nrf_gpio_pin_write(PIN_BACK_SDA,1)
  18. #define SDA_L nrf_gpio_pin_write(PIN_BACK_SDA,0)
  19. #define SCL_read nrf_gpio_pin_read(PIN_BACK_SCL)
  20. #define SDA_read nrf_gpio_pin_read(PIN_BACK_SDA)
  21. void IIC_BACK2_Init(void); //初始化IIC的IO口
  22. extern uint8_t IIC_ReadOneByte(uint8_t SlaveAddress,uint16_t REG_Address,uint8_t* data);
  23. extern unsigned char IICwriteByte(unsigned char dev, uint16_t reg, unsigned char data);
  24. extern uint8_t IICwriteBytes(uint8_t dev, uint16_t reg, uint16_t length, uint8_t* data);
  25. extern uint8_t IICwriteBit(uint8_t dev,uint16_t reg,uint8_t bitNum,uint8_t data);
  26. extern uint8_t IICreadBytes(uint8_t SlaveAddress,uint16_t REG_Address,uint8_t len,uint8_t *data);
  27. #endif
  28. //------------------End of File----------------------------