8051-ELL库  beta 1.1.6
8051-ELL library API Document Center
STC8x_I2C.h 文件参考
#include "ELL_CORE.h"
#include "STC8Ax_REG.h"
STC8x_I2C.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

宏定义

#define PER_LIB_MCU_MUODEL   STC8Ax
 如果没有定义这个宏,默认为STC8Ax。 If the mirco is undefined,select to STC8Ax 更多...
 
#define PER_LIB_I2C_CTRL   1
 如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1" 更多...
 
#define PER_LIB_I2C_INIT_CTRL   1
 如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1" 更多...
 
#define PER_LIB_I2C_NVIC_CTRL   1
 如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1" 更多...
 
#define PER_LIB_I2C_WORK_CTRL   1
 如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1" 更多...
 
#define NVIC_I2C_HOST_CTRL(run)
 I2C主机中断开关控制宏函数。 更多...
 
#define NVIC_I2C_SLAVE_CTRL(run)
 I2C从机中断开关控制宏函数。 更多...
 
#define NVIC_I2C_PRI(pri)
 I2C选择中断优先级宏函数。 更多...
 
#define I2C_GET_HOST_FLAG()   (I2CMSST & 0x40)
 I2C获取主机中断请求标志位宏函数。 更多...
 
#define I2C_GET_HOST_BUSY_STATE()   (I2CMSST & 0x80)
 I2C获取主机忙/空闲状态宏函数。 更多...
 
#define I2C_CLEAR_HOST_MASTER_FLAG()   {I2CMSST &= 0xBF;}
 I2C清除主机中断请求标志位宏函数。 更多...
 
#define I2C_GET_SLAVE_BUSY_STATE()   (I2CMSST & 0x80)
 I2C获取从机状态(忙/空闲)宏函数。 更多...
 
#define I2C_GET_SLAVE_REVSTART_FLAG()   (I2CSLST & 0x40)
 I2C获取,从机接收开始信号中断请求标志位,宏函数。 更多...
 
#define I2C_GET_SLAVE_REVDATA_FLAG()   (I2CSLST & 0x20)
 I2C获取,从机接收一字节数据中断请求标志位,宏函数。 更多...
 
#define I2C_GET_SLAVE_SENDATA_FLAG()   (I2CSLST & 0x10)
 I2C获取,从机发送一字节数据中断请求标志位,宏函数。 更多...
 
#define I2C_GET_SLAVE_REVSTOP_FLAG()   (I2CSLST & 0x08)
 I2C获取,从机接收停止信号中断请求标志位,宏函数。 更多...
 
#define I2C_CLEAR_SLAVE_REVSTART_FLAG()   {I2CSLST &= 0xBF;}
 I2C清除,从机接收开始信号中断请求标志位,宏函数。 更多...
 
#define I2C_CLEAR_SLAVE_REVDATA_FLAG()   {I2CSLST &= 0xDF;}
 I2C清除,从机接收一字节数据中断请求标志位,宏函数。 更多...
 
#define I2C_CLEAR_SLAVE_SENDATA_FLAG()   {I2CSLST &= 0xEF;}
 I2C清除,从机发送一字节数据中断请求标志位,宏函数。 更多...
 
#define I2C_CLEAR_SLAVE_REVSTOP_FLAG()   {I2CSLST &= 0xF7;}
 I2C清除,从机接收停止信号中断请求标志位,宏函数。 更多...
 

枚举

enum  I2CType_Type { I2C_Type_Host = 0x01 , I2C_Type_Slave = 0x00 }
 I2C工作类型枚举体。 更多...
 
enum  I2CSTri_Type { I2C_STri_RevStart_Done = 0x40 , I2C_STri_RevData_Done = 0x20 , I2C_STri_SendData_Done = 0x10 , I2C_STri_RevStop_Done = 0x80 }
 I2C从机中断触发方式枚举体。 更多...
 

函数

FSCSTATE I2C_Init (I2CType_Type type, uint8_t wTime, BOOL state)
 I2C初始化函数。 更多...
 
FSCSTATE NVCI_I2C_Master_Init (NVICPri_Type pri, BOOL run)
 I2C主机中断初始化函数。 更多...
 
FSCSTATE NVCI_I2C_Slave_Init (NVICPri_Type pri, I2CSTri_Type triMode)
 I2C从机中断初始化函数。 更多...
 
FSCSTATE I2C_Send_Start (void)
 I2C发送开始信号函数。 更多...
 
FSCSTATE I2C_Send_Stop (void)
 I2C发送停止信号函数。 更多...
 
FSCSTATE I2C_Send_ACK (void)
 I2C发送ACK信号函数。 更多...
 
FSCSTATE I2C_Send_NACK (void)
 I2C发送NACK信号函数。 更多...
 
FSCSTATE I2C_Read_ACK (void)
 I2C读取ACK信号函数。 更多...
 
FSCSTATE I2C_Send_Btye (uint8_t dat)
 I2C发送一个字节函数。 更多...
 
uint8_t I2C_Read_Byte (void)
 I2C读取一个字节函数。 更多...
 
FSCSTATE GPIO_I2C_SWPort (GPIOSWPort_Type port)
 I2C切换复用IO函数。 更多...
 

宏定义说明

◆ I2C_CLEAR_HOST_MASTER_FLAG

#define I2C_CLEAR_HOST_MASTER_FLAG ( )    {I2CMSST &= 0xBF;}

I2C清除主机中断请求标志位宏函数。

I2C clears host interrupt request flag bit macro function.

◆ I2C_CLEAR_SLAVE_REVDATA_FLAG

#define I2C_CLEAR_SLAVE_REVDATA_FLAG ( )    {I2CSLST &= 0xDF;}

I2C清除,从机接收一字节数据中断请求标志位,宏函数。

I2C clears the slave receives one byte data, interrupt request flag bit, macro function.

返回
[bit] (中断)标志位。(interrupt) flag bit.

◆ I2C_CLEAR_SLAVE_REVSTART_FLAG

#define I2C_CLEAR_SLAVE_REVSTART_FLAG ( )    {I2CSLST &= 0xBF;}

I2C清除,从机接收开始信号中断请求标志位,宏函数。

I2C clears the slave receives start signal, interrupt request flag bit, macro function.

返回
[bit] (中断)标志位。(interrupt) flag bit.

◆ I2C_CLEAR_SLAVE_REVSTOP_FLAG

#define I2C_CLEAR_SLAVE_REVSTOP_FLAG ( )    {I2CSLST &= 0xF7;}

I2C清除,从机接收停止信号中断请求标志位,宏函数。

I2C clears the slave receives stop signal, interrupt request flag bit, macro function.

返回
[bit] (中断)标志位。(interrupt) flag bit.

◆ I2C_CLEAR_SLAVE_SENDATA_FLAG

#define I2C_CLEAR_SLAVE_SENDATA_FLAG ( )    {I2CSLST &= 0xEF;}

I2C清除,从机发送一字节数据中断请求标志位,宏函数。

I2C clears the slave sends one byte data, interrupt request flag bit, macro function.

返回
[bit] (中断)标志位。(interrupt) flag bit.

◆ I2C_GET_HOST_BUSY_STATE

#define I2C_GET_HOST_BUSY_STATE ( )    (I2CMSST & 0x80)

I2C获取主机忙/空闲状态宏函数。

I2C get the host working state (busy / idle) macro function.

返回
[bit] 0代表控制器处于空闲状态,1代表处于忙碌状态。 0 means the controller is idle and 1 means it is busy.

◆ I2C_GET_HOST_FLAG

#define I2C_GET_HOST_FLAG ( )    (I2CMSST & 0x40)

I2C获取主机中断请求标志位宏函数。

I2C gets host interrupt request flag bit macro function.

返回
[bit] (中断)标志位。(interrupt) flag bit.

◆ I2C_GET_SLAVE_BUSY_STATE

#define I2C_GET_SLAVE_BUSY_STATE ( )    (I2CMSST & 0x80)

I2C获取从机状态(忙/空闲)宏函数。

I2C get the slave working state (busy / idle) macro function.

返回
[bit] 0代表控制器处于空闲状态,1代表处于忙碌状态。 0 means the controller is idle and 1 means it is busy.

◆ I2C_GET_SLAVE_REVDATA_FLAG

#define I2C_GET_SLAVE_REVDATA_FLAG ( )    (I2CSLST & 0x20)

I2C获取,从机接收一字节数据中断请求标志位,宏函数。

I2C acquisition, slave receives one byte data, interrupt request flag bit, macro function.

返回
[bit] (中断)标志位。(interrupt) flag bit.

◆ I2C_GET_SLAVE_REVSTART_FLAG

#define I2C_GET_SLAVE_REVSTART_FLAG ( )    (I2CSLST & 0x40)

I2C获取,从机接收开始信号中断请求标志位,宏函数。

I2C acquisition, slave receives start signal, interrupt request flag bit, macro function.

返回
[bit] (中断)标志位。(interrupt) flag bit.

◆ I2C_GET_SLAVE_REVSTOP_FLAG

#define I2C_GET_SLAVE_REVSTOP_FLAG ( )    (I2CSLST & 0x08)

I2C获取,从机接收停止信号中断请求标志位,宏函数。

I2C acquisition, slave receives stop signal, interrupt request flag bit, macro function.

返回
[bit] (中断)标志位。(interrupt) flag bit.

◆ I2C_GET_SLAVE_SENDATA_FLAG

#define I2C_GET_SLAVE_SENDATA_FLAG ( )    (I2CSLST & 0x10)

I2C获取,从机发送一字节数据中断请求标志位,宏函数。

I2C acquisition, slave sends one byte data, interrupt request flag bit, macro function.

返回
[bit] (中断)标志位。(interrupt) flag bit.

◆ NVIC_I2C_HOST_CTRL

#define NVIC_I2C_HOST_CTRL (   run)
值:
{ \
EAXFR_ENABLE(); \
I2CMSCR = run << 7; \
EAXFR_DISABLE(); \
}

I2C主机中断开关控制宏函数。

I2C host interrupt switch control macro function.

参数
[in]run使能控制位。Enable control bit.

◆ NVIC_I2C_PRI

#define NVIC_I2C_PRI (   pri)
值:
do{ \
IP2H = (IP2H & 0xBF) | ((pri & 0x02) << 5); \
IP2 = (IP2 & 0xBF) | ((pri & 0x01) << 6); \
}while(0)
sfr IP2H
Definition: STC15x_REG.h:213
sfr IP2
Definition: STC15x_REG.h:211

I2C选择中断优先级宏函数。

I2C select interrupt priority macro function.

参数
[in]pri中断优先级。 Priority of interrupt.

◆ NVIC_I2C_SLAVE_CTRL

#define NVIC_I2C_SLAVE_CTRL (   run)
值:
{ \
EAXFR_ENABLE(); \
I2CSLCR &= (I2CSLCR & 0x01 ) | \
(run << 6) | (run << 5) | \
(run << 4) | (run << 3) ; \
EAXFR_DISABLE(); \
}
#define I2CSLCR
Definition: STC15x_REG.h:1212

I2C从机中断开关控制宏函数。

I2C slave interrupt switch control macro function.

参数
[in]run使能控制位。Enable control bit.

◆ PER_LIB_I2C_CTRL

#define PER_LIB_I2C_CTRL   1

如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1"

◆ PER_LIB_I2C_INIT_CTRL

#define PER_LIB_I2C_INIT_CTRL   1

如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1"

◆ PER_LIB_I2C_NVIC_CTRL

#define PER_LIB_I2C_NVIC_CTRL   1

如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1"

◆ PER_LIB_I2C_WORK_CTRL

#define PER_LIB_I2C_WORK_CTRL   1

如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1"

◆ PER_LIB_MCU_MUODEL

#define PER_LIB_MCU_MUODEL   STC8Ax

如果没有定义这个宏,默认为STC8Ax。 If the mirco is undefined,select to STC8Ax

枚举类型说明

◆ I2CSTri_Type

I2C从机中断触发方式枚举体。

I2C slave interrupt trigger mode enumeration body.

枚举值
I2C_STri_RevStart_Done 

I2C从机接收START完成中断。I2C slave receives START completion interrupt.

I2C_STri_RevData_Done 

I2C从机接收数据完成中断。The I2C slave receives data and is interrupted.

I2C_STri_SendData_Done 

I2C从机发送数据完成中断。The I2C slave is interrupted when sending data.

I2C_STri_RevStop_Done 

I2C从机接收STOP完成中断。The I2C slave receives the STOP completion interrupt.

◆ I2CType_Type

I2C工作类型枚举体。

I2C type control enumenumeration.

枚举值
I2C_Type_Host 

I2C工作在主机类型。I2C works in the host type.

I2C_Type_Slave 

I2C工作在从机类型。I2C works in the slave type.

函数说明

◆ GPIO_I2C_SWPort()

FSCSTATE GPIO_I2C_SWPort ( GPIOSWPort_Type  port)

I2C切换复用IO函数。

I2C switch out port control function.

参数
[in]port复用IO枚举体。IO switch enumerator.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ I2C_Init()

FSCSTATE I2C_Init ( I2CType_Type  type,
uint8_t  wTime,
BOOL  state 
)

I2C初始化函数。

I2C initialization function.

参数
[in]typeI2C工作模式(主从机)。I2C working mode (master-slave).
[in]wTimeI2C等待时间。value of wait time.
[in]run运行控制位。Operation control bit.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ I2C_Read_ACK()

FSCSTATE I2C_Read_ACK ( void  )

I2C读取ACK信号函数。

I2C reads signal of ACK function.

参数
None.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ I2C_Read_Byte()

uint8_t I2C_Read_Byte ( void  )

I2C读取一个字节函数。

I2C reads a byte data function.

参数
None.
返回
[uint8_t] data of recive.

◆ I2C_Send_ACK()

FSCSTATE I2C_Send_ACK ( void  )

I2C发送ACK信号函数。

I2C sends signal of ACK function.

参数
None.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ I2C_Send_Btye()

FSCSTATE I2C_Send_Btye ( uint8_t  dat)

I2C发送一个字节函数。

I2C sends a byte data function.

参数
[in]dat字节数据。byte data.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ I2C_Send_NACK()

FSCSTATE I2C_Send_NACK ( void  )

I2C发送NACK信号函数。

I2C sends signal of NACK function.

参数
None.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ I2C_Send_Start()

FSCSTATE I2C_Send_Start ( void  )

I2C发送开始信号函数。

I2C sends signal of start function.

参数
None.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ I2C_Send_Stop()

FSCSTATE I2C_Send_Stop ( void  )

I2C发送停止信号函数。

I2C sends signal of stop function.

参数
None.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ NVCI_I2C_Master_Init()

FSCSTATE NVCI_I2C_Master_Init ( NVICPri_Type  pri,
BOOL  run 
)

I2C主机中断初始化函数。

I2C Master init NVIC function.

参数
[in]pri中断优先级。interrupt priority.
[in]run使能控制位。enable control.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ NVCI_I2C_Slave_Init()

FSCSTATE NVCI_I2C_Slave_Init ( NVICPri_Type  pri,
I2CSTri_Type  triMode 
)

I2C从机中断初始化函数。

I2C Slave init NVIC function.

参数
[in]pri中断优先级。interrupt priority.
[in]triMode触发模式,可以选择多个,并用或运算符连接。 Trigger mode, multiple can be selected and connected with or operator.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.