drv_iic_04.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef __drv_iic_04_h__
  2. #define __drv_iic_04_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. #if SHAREPIN_CONFIG == 1
  11. #define IIC_04_SCL_SET nrf_gpio_pin_write(PIN_SDA_1,1)
  12. #define IIC_04_SCL_CLR nrf_gpio_pin_write(PIN_SDA_1,0)
  13. #define IIC_04_SDA_SET nrf_gpio_pin_write(PIN_SCL_1,1)
  14. #define IIC_04_SDA_CLR nrf_gpio_pin_write(PIN_SCL_1,0)
  15. #define IIC_04_SDA_READ nrf_gpio_pin_read(PIN_SCL_1)
  16. #elif SHAREPIN_CONFIG == 2
  17. #define IIC_04_SCL_SET nrf_gpio_pin_write(PIN_QMC6310_SCL_01,1)
  18. #define IIC_04_SCL_CLR nrf_gpio_pin_write(PIN_QMC6310_SCL_01,0)
  19. #define IIC_04_SDA_SET nrf_gpio_pin_write(PIN_QMC6310_SDA_01,1)
  20. #define IIC_04_SDA_CLR nrf_gpio_pin_write(PIN_QMC6310_SDA_01,0)
  21. #define IIC_04_SDA_READ nrf_gpio_pin_read(PIN_QMC6310_SDA_01)
  22. #elif SHAREPIN_CONFIG == 3
  23. #define IIC_04_SCL_SET nrf_gpio_pin_write(PIN_SCL_MAG,1)
  24. #define IIC_04_SCL_CLR nrf_gpio_pin_write(PIN_SCL_MAG,0)
  25. #define IIC_04_SDA_SET nrf_gpio_pin_write(PIN_SDA_BACK,1)
  26. #define IIC_04_SDA_CLR nrf_gpio_pin_write(PIN_SDA_BACK,0)
  27. #define IIC_04_SDA_READ nrf_gpio_pin_read(PIN_SDA_BACK)
  28. #endif
  29. void IIC_04_Init(void);
  30. bool IIC_04_WriteBytes(uint8_t add,uint8_t reg,uint8_t* p,uint8_t len);
  31. bool IIC_04_ReadBytes(uint8_t add,uint8_t reg,uint8_t* p,uint8_t len);
  32. #endif