MG32L003 Standard Peripherals Firmware Library

结构体 | 宏定义 | 枚举 | 函数
mg32l003_i2c.h 文件参考

This file contains all the functions prototypes for the I2C firmware library. 更多...

`#include "mg32l003.h"`

浏览源代码.

## 结构体
struct | I2C_InitTypeDef
| I2C Initial Configuration Structure definition 更多...

## 宏定义
#define | I2C_MASTER_MODE_DISABLE ((uint32_t)0x00000000U)
#define | I2C_MASTER_MODE_ENABLE ((uint32_t)0x00000001U)
#define | IS_I2C_MASTER_MODE(MASTER_MODE)
#define | I2C_SLAVE_MODE_ENABLE ((uint32_t)0x00000000U)
#define | I2C_SLAVE_MODE_DISABLE ((uint32_t)0x00000001U)
#define | IS_I2C_SLAVE_MODE(SLAVE_MODE)
#define | I2C_BROAD_ACK_ENABLE ((uint32_t)0x00000000U)
#define | I2C_BROAD_ACK_DISABLE ((uint32_t)0x00000001U)
#define | IS_I2C_BROAD_ACK(BROAD_ACK)
#define | I2C_HIGH_RATE_ENABLE ((uint32_t)0x00000000U)
#define | I2C_HIGH_RATE_DISABLE I2C_CR_H1M
#define | I2C_Direction_Transmitter ((uint8_t)0x00)
#define | I2C_Direction_Receiver ((uint8_t)0x01)
#define | IS_I2C_DIRECTION(I2C_Direction)
#define | I2C_STA_0 ((uint8_t)(0x00))
#define | I2C_STA_1 ((uint8_t)(0x01 << 5))
#define | I2C_STO_0 ((uint8_t)(0x00))
#define | I2C_STO_1 ((uint8_t)(0x01 << 4))
#define | I2C_AA_0 ((uint8_t)(0x00))
#define | I2C_AA_1 ((uint8_t)(0x01 << 2))
#define | I2C_CR_Status_Mask ((uint8_t)(0xC3))
#define | IS_I2C_STA(I2C_STA) (((I2C_STA) == I2C_STA_0) || ((I2C_STA) == I2C_STA_1))
#define | IS_I2C_STO(I2C_STO) (((I2C_STO) == I2C_STO_0) || ((I2C_STO) == I2C_STO_1))
#define | IS_I2C_AA(I2C_AA) (((I2C_AA) == I2C_AA_0) || ((I2C_AA) == I2C_AA_1))
#define | I2C_FLAG_ERROR_UNDER ((uint32_t)0x00000000U)
#define | I2C_FLAG_USELESS ((uint32_t)0x000000F8U)
#define | I2C_FLAG_MASTER_TX_START ((uint32_t)0x00000008U)
#define | I2C_FLAG_MASTER_TX_RESTART ((uint32_t)0x00000010U)
#define | I2C_FLAG_MASTER_TX_SLAW_ACK ((uint32_t)0x00000018U)
#define | I2C_FLAG_MASTER_TX_SLAW_NOACK ((uint32_t)0x00000020U)
#define | I2C_FLAG_MASTER_TX_DATA_ACK ((uint32_t)0x00000028U)
#define | I2C_FLAG_MASTER_TX_DATA_NOACK ((uint32_t)0x00000030U)
#define | I2C_FLAG_MASTER_TX_LOST_SCL ((uint32_t)0x00000038U)
#define | I2C_FLAG_MASTER_RX_START ((uint32_t)0x00000008U)
#define | I2C_FLAG_MASTER_RX_RESTART ((uint32_t)0x00000010U)
#define | I2C_FLAG_MASTER_RX_SLAW_ACK ((uint32_t)0x00000040U)
#define | I2C_FLAG_MASTER_RX_SLAW_NOACK ((uint32_t)0x00000048U)
#define | I2C_FLAG_MASTER_RX_DATA_ACK ((uint32_t)0x00000050U)
#define | I2C_FLAG_MASTER_RX_DATA_NOACK ((uint32_t)0x00000058U)
#define | I2C_FLAG_MASTER_RX_LOST_SCL ((uint32_t)0x00000038U)
#define | I2C_FLAG_SLAVE_TX_SLAW_ACK ((uint32_t)0x000000A8U)
#define | I2C_FLAG_SLAVE_TX_DATA_ACK ((uint32_t)0x000000B8U)
#define | I2C_FLAG_SLAVE_TX_DATA_NOACK ((uint32_t)0x000000C0U)
#define | I2C_FLAG_SLAVE_TX_DATA_LAST ((uint32_t)0x000000C8U)
#define | I2C_FLAG_SLAVE_TX_LOST_SCL ((uint32_t)0x000000B0U)
#define | I2C_FLAG_SLAVE_RX_SLAW_ACK ((uint32_t)0x00000060U)
#define | I2C_FLAG_SLAVE_RX_BROAD_ACK ((uint32_t)0x00000070U)
#define | I2C_FLAG_SLAVE_RX_SDATA_ACK ((uint32_t)0x00000080U)
#define | I2C_FLAG_SLAVE_RX_SDATA_NOACK ((uint32_t)0x00000088U)
#define | I2C_FLAG_SLAVE_RX_BDATA_ACK ((uint32_t)0x00000090U)
#define | I2C_FLAG_SLAVE_RX_BDATA_NOACK ((uint32_t)0x00000098U)
#define | I2C_FLAG_SLAVE_RX_SA_LOST_SCL ((uint32_t)0x00000068U)
#define | I2C_FLAG_SLAVE_RX_BA_LOST_SCL ((uint32_t)0x00000078U)
#define | I2C_FLAG_SLAVE_STOP_RESTART ((uint32_t)0x000000A0U)

## 枚举
enum | I2CStatus { I2C_ERROR = 0, I2C_OK = 1, I2C_SUCCESS = 2, I2C_WAITING = 3 }
| I2CStatus enum definition 更多...

## 函数
void | I2C_DeInit (void)
| Deinitializes the I2C peripheral registers to their default reset values. 更多...
void | I2C_Init (I2C_InitTypeDef *I2C_InitStruct)
| Initializes the I2C peripheral according to the specified parameters in the I2C_InitStruct. 更多...
void | I2C_SlaveAddressConfig (uint32_t SlaveAddress)
| Configures the I2C slave address. 更多...
void | I2C_HighSpeedModeCmd (FunctionalState NewState)
| Configures I2C high speed mode. 更多...
void | I2C_SwitchStatus (uint8_t I2C_STA, uint8_t I2C_STO, uint8_t I2C_AA)
| Writes I2C CR register for switching I2C bus status. 更多...
void | I2C_Start (FunctionalState NewState)
| Sets or clears I2C peripheral start status. 更多...
void | I2C_Stop (FunctionalState NewState)
| Sets or clears I2C peripheral stop status. 更多...
void | I2C_ACK (FunctionalState NewState)
| Sets or clears I2C peripheral ACK status. 更多...
void | I2C_Cmd (FunctionalState NewState)
| Enables or disables I2C peripheral. 更多...
void | I2C_AckGeneralCallCmd (FunctionalState NewState)
| Enables or disables the general ack. 更多...
void | I2C_ReceiveByte (uint8_t *pData)
| Reads data from data register. 更多...
void | I2C_WriteByte (uint8_t I2C_DataCmd)
| Write one byte data. 更多...
void | I2C_WriteAddress (uint8_t Address, uint8_t I2C_Direction)
| Write the slave address byte by the direction. 更多...
I2CStatus | I2C_CheckFlag (uint32_t *I2C_Flag)
| Gets the last I2C module status flag. 更多...
ITStatus | I2C_GetITStatus (void)
| Checks whether I2C interrupt has occurred or not. 更多...
void | I2C_ClearITPendingBit (void)
| Clears I2C interrupt pending bit. 更多...

## 详细描述

This file contains all the functions prototypes for the I2C firmware library.

作者
  megawin Application Team

版本
  V0.0.5

日期
  13-August-2024