first commit
This commit is contained in:
40
Drivers/BSP/IIC/iic.h
Normal file
40
Drivers/BSP/IIC/iic.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef __IIC_H
|
||||
#define __IIC_H
|
||||
|
||||
|
||||
#include "./SYSTEM/sys/sys.h"
|
||||
#include "./SYSTEM/delay/delay.h"
|
||||
|
||||
|
||||
#define IIC_SCL_GPIO_PORT GPIOA
|
||||
#define IIC_SCL_GPIO_PIN GPIO_PIN_5
|
||||
#define IIC_SCL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
|
||||
#define IIC_SDA_GPIO_PORT GPIOA
|
||||
#define IIC_SDA_GPIO_PIN GPIO_PIN_6
|
||||
#define IIC_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
|
||||
#define IIC_SCL(x) do{ x ? \
|
||||
HAL_GPIO_WritePin(IIC_SCL_GPIO_PORT, IIC_SCL_GPIO_PIN, GPIO_PIN_SET) : \
|
||||
HAL_GPIO_WritePin(IIC_SCL_GPIO_PORT, IIC_SCL_GPIO_PIN, GPIO_PIN_RESET); \
|
||||
}while(0) /* SCL */
|
||||
#define IIC_SDA(x) do{x? \
|
||||
HAL_GPIO_WritePin(IIC_SDA_GPIO_PORT,IIC_SDA_GPIO_PIN,GPIO_PIN_SET): \
|
||||
HAL_GPIO_WritePin(IIC_SDA_GPIO_PORT,IIC_SDA_GPIO_PIN,GPIO_PIN_RESET); \
|
||||
}while(0);
|
||||
#define IIC_READ_SDA HAL_GPIO_ReadPin(IIC_SDA_GPIO_PORT,IIC_SDA_GPIO_PIN)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void iic_init(void);
|
||||
void iic_start(void);
|
||||
uint8_t iic_read_byte(uint8_t ack);
|
||||
void iic_send_byte(uint8_t data);
|
||||
void iic_stop(void);
|
||||
uint8_t iic_wait_ack(void);
|
||||
void iic_ack(void);
|
||||
void iic_nack(void);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user