45 lines
1.1 KiB
C
45 lines
1.1 KiB
C
/*
|
|
* @Author : stark1898y 1658608470@qq.com
|
|
* @Date : 2024-12-15 15:42:00
|
|
* @LastEditors : stark1898y 1658608470@qq.com
|
|
* @LastEditTime : 2025-06-04 11:58:48
|
|
* @FilePath : \BLE_TYQ_CH584M\BSP\inc\bsp_soft_i2c.h
|
|
* @Description :
|
|
*
|
|
* Copyright (c) 2024 by yzy, All Rights Reserved.
|
|
*/
|
|
#ifndef __BSP_I2C_H__
|
|
#define __BSP_I2C_H__
|
|
|
|
#include "CONFIG.h"
|
|
|
|
|
|
#define IIC_SCL_BPIN bSCL // PB13-SCL
|
|
#define IIC_SDA_BPIN bSDA // PB12-SDA
|
|
|
|
// IO方向设置
|
|
#define IIC_SDA_IN() GPIOB_ModeCfg(IIC_SDA_BPIN, GPIO_ModeIN_PU)
|
|
#define IIC_SDA_OUT() GPIOB_ModeCfg(IIC_SDA_BPIN, GPIO_ModeOut_PP_5mA)
|
|
|
|
#define IIC_SCL_H() GPIOB_SetBits(IIC_SCL_BPIN)
|
|
#define IIC_SCL_L() GPIOB_ResetBits(IIC_SCL_BPIN)
|
|
|
|
#define IIC_SDA_H() GPIOB_SetBits(IIC_SDA_BPIN)
|
|
#define IIC_SDA_L() GPIOB_ResetBits(IIC_SDA_BPIN)
|
|
|
|
#define IIC_READ_SDA() ((GPIOB_ReadPortPin(IIC_SDA_BPIN) ? 1 : 0))
|
|
|
|
|
|
void IIC_Init(void);
|
|
void IIC_Deinit(void);
|
|
void IIC_Start(void);
|
|
void IIC_Stop(void);
|
|
uint8_t IIC_Wait_Ack(void);
|
|
void IIC_Ack(void);
|
|
void IIC_NAck(void);
|
|
void IIC_Send_Byte(uint8_t txd);
|
|
uint8_t IIC_Read_Byte(unsigned char ack);
|
|
|
|
#endif // !__BSP_I2C_H__
|
|
|