1234567891011121314151617181920212223242526272829303132333435 |
- #ifndef __DRV_IIC_BACK2_H__
- #define __DRV_IIC_BACK2_H__
- #include <stdbool.h>
- #include <stdint.h>
- #include <string.h>
- #include "sdk_common.h"
- #include "SEGGER_RTT.h"
- #include "usr_config.h"
- #include "nrf_gpio.h"
- #include "nrf_delay.h"
- //IO口操作宏定义
- #define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
- #define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
- #define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
- #define SCL_H nrf_gpio_pin_write(PIN_BACK_SCL,1)
- #define SCL_L nrf_gpio_pin_write(PIN_BACK_SCL,0)
- #define SDA_H nrf_gpio_pin_write(PIN_BACK_SDA,1)
- #define SDA_L nrf_gpio_pin_write(PIN_BACK_SDA,0)
- #define SCL_read nrf_gpio_pin_read(PIN_BACK_SCL)
- #define SDA_read nrf_gpio_pin_read(PIN_BACK_SDA)
- void IIC_BACK2_Init(void); //初始化IIC的IO口
- extern uint8_t IIC_ReadOneByte(uint8_t SlaveAddress,uint16_t REG_Address,uint8_t* data);
- extern unsigned char IICwriteByte(unsigned char dev, uint16_t reg, unsigned char data);
- extern uint8_t IICwriteBytes(uint8_t dev, uint16_t reg, uint16_t length, uint8_t* data);
- extern uint8_t IICwriteBit(uint8_t dev,uint16_t reg,uint8_t bitNum,uint8_t data);
- extern uint8_t IICreadBytes(uint8_t SlaveAddress,uint16_t REG_Address,uint8_t len,uint8_t *data);
- #endif
- //------------------End of File----------------------------
|