PAN1080 Peripheral API
|
I2c Interface. More...
Modules | |
I2c rx threshold level | |
I2c receive fifo threshold level. | |
I2c tx transmit level | |
I2c transmit fifo threshold level. | |
I2c interrupts | |
I2c raw interrupts flag. | |
I2c state | |
I2c device and fifo state flag. | |
Data Structures | |
struct | I2C_InitTypeDef |
Structure with i2c init feature. More... | |
Macros | |
#define | PAN_I2C_MODE_MASTER ((uint16_t)0x0021) |
#define | PAN_I2C_MODE_SLAVE ((uint16_t)0x0000) |
#define | IS_I2C_MODE(MODE) |
#define | I2C_SPEED_STANDARD_MODE (uint16_t)(0x0002) |
#define | I2C_SPEED_FAST_MODE (uint16_t)(0x0004) |
#define | I2C_SPEED_HIGH_MODE (uint16_t)(0x0006) |
#define | I2C_DutyCycle_16_9 ((uint16_t)0x4000) |
#define | I2C_DutyCycle_2 ((uint16_t)0xBFFF) |
#define | IS_I2C_DUTY_CYCLE(CYCLE) |
#define | I2C_AcknowledgedAddress_7bit ((uint16_t)0x4000) |
#define | I2C_AcknowledgedAddress_10bit ((uint16_t)0xC000) |
#define | I2C_CMD_WR ((uint8_t)0x00) |
#define | I2C_CMD_RD ((uint8_t)0x01) |
#define | I2C_CMD_STOP ((uint8_t)0x02) |
#define | I2C_CMD_RESTART ((uint8_t)0x04) |
#define | FLAG_MASK ((uint32_t)0x007F0FFF) |
#define | ITEN_MASK ((uint16_t)0x2FFF) |
#define | IT_FLAG_MASK ((uint16_t)0x2FFF) |
Functions | |
__STATIC_INLINE void | I2C_SetMode (I2C_T *I2Cx, uint16_t Mode) |
Set I2C mode . More... | |
__STATIC_INLINE void | I2C_SetTxTirggerLevel (I2C_T *I2Cx, uint8_t ThresholdValue) |
Set I2C Tx fifo threshold value . More... | |
__STATIC_INLINE void | I2C_SetRxTirggerLevel (I2C_T *I2Cx, uint8_t ThresholdValue) |
Set I2C Rx fifo threshold value . More... | |
__STATIC_INLINE void | I2C_Cmd (I2C_T *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C peripheral. More... | |
__STATIC_INLINE void | I2C_GeneralCallCmd (I2C_T *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C general call feature. More... | |
__STATIC_INLINE void | I2C_SendDataCmd (I2C_T *I2Cx, uint8_t Data, uint8_t Cmd) |
Sends a data byte through the I2Cx peripheral. More... | |
__STATIC_INLINE void | I2C_SendCmd (I2C_T *I2Cx, uint8_t Cmd) |
Sends a data byte through the I2Cx peripheral. More... | |
__STATIC_INLINE uint8_t | I2C_ReceiveData (I2C_T *I2Cx) |
Returns the most recent received data by the I2Cx peripheral. More... | |
__STATIC_INLINE void | I2C_AbortTransfer (I2C_T *I2Cx) |
Aborting I2C Transfers. More... | |
__STATIC_INLINE void | I2C_DMACmd (I2C_T *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C DMA requests. More... | |
__STATIC_INLINE void | I2C_DMATransferDataLevel (I2C_T *I2Cx, uint8_t Level) |
DMA Transmit Data Level Register. More... | |
__STATIC_INLINE void | I2C_DMAReceiveDataLevel (I2C_T *I2Cx, uint8_t Level) |
DMA Receive Data Level Register. More... | |
__STATIC_INLINE ITStatus | I2C_GetITStatus (I2C_T *I2Cx, uint16_t I2C_IT) |
Checks whether the specified I2C interrupt has occurred or not. More... | |
__STATIC_INLINE ITStatus | I2C_GetRawITStatus (I2C_T *I2Cx, uint16_t I2C_IT) |
Checks whether the specified I2C interrupt has occurred or not. More... | |
__STATIC_INLINE void | I2C_ITConfig (I2C_T *I2Cx, uint16_t I2C_IT, FunctionalState NewState) |
Enables or disables the specified I2C interrupts. More... | |
__STATIC_INLINE void | I2C_DisableAllIT (I2C_T *I2Cx) |
Enables or disables all the specified I2C interrupts. More... | |
__STATIC_INLINE void | I2C_ClearAllITPendingBit (I2C_T *I2Cx) |
Clears all the I2Cx's interrupt pending bits. More... | |
__STATIC_INLINE bool | I2C_AbortSrcCheck (I2C_T *I2Cx, uint32_t IC_MSK) |
Get the source of tx_abort. More... | |
__STATIC_INLINE void | I2C_SetSlaveAddr (I2C_T *I2Cx, uint32_t addr) |
Set slave address. More... | |
bool | I2C_Init (I2C_T *I2Cx, I2C_InitTypeDef *I2C_InitStruct) |
Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct. More... | |
void | I2C_Set7bitAddress (I2C_T *I2Cx, uint8_t Address) |
Configure the target address for any master transaction. More... | |
void | I2C_Set10bitAddress (I2C_T *I2Cx, uint16_t Address) |
Configure the target address for any master transaction. More... | |
FlagStatus | I2C_GetFlagStatus (I2C_T *I2Cx, uint32_t I2C_FLAG) |
Checks whether the specified I2C flag is set or not. More... | |
void | I2C_ClearITPendingBit (I2C_T *I2Cx, uint16_t I2C_IT) |
Clears the I2Cx's interrupt pending bits. More... | |
void | I2C_Write (I2C_T *I2Cx, uint8_t *WriteBuf, uint32_t Size) |
read data from the I2Cx peripheral. More... | |
void | I2C_Read (I2C_T *I2Cx, uint8_t *ReadBuf, uint32_t Size) |
write data to the I2Cx peripheral. More... | |
I2c Interface.
#define FLAG_MASK ((uint32_t)0x007F0FFF) |
I2C flag mask
#define I2C_AcknowledgedAddress_10bit ((uint16_t)0xC000) |
I2C 10-bit acknowledged address enable
#define I2C_AcknowledgedAddress_7bit ((uint16_t)0x4000) |
I2C 7-bit acknowledged address enable
#define I2C_CMD_RD ((uint8_t)0x01) |
I2C read cmd
#define I2C_CMD_RESTART ((uint8_t)0x04) |
I2C restart cmd
#define I2C_CMD_STOP ((uint8_t)0x02) |
I2C stop cmd
#define I2C_CMD_WR ((uint8_t)0x00) |
I2C write cmd
#define I2C_DutyCycle_16_9 ((uint16_t)0x4000) |
I2C fast mode Tlow/Thigh = 16/9
#define I2C_DutyCycle_2 ((uint16_t)0xBFFF) |
I2C fast mode Tlow/Thigh = 2
#define I2C_SPEED_FAST_MODE (uint16_t)(0x0004) |
I2C fast speed mode,speed less than 1MHz
#define I2C_SPEED_HIGH_MODE (uint16_t)(0x0006) |
I2C high speed mode,speed larger than 1MHz
#define I2C_SPEED_STANDARD_MODE (uint16_t)(0x0002) |
I2C standard speed mode, speed less than 100KHz
#define IS_I2C_DUTY_CYCLE | ( | CYCLE | ) |
I2C fast mode duty cycle check
#define IS_I2C_MODE | ( | MODE | ) |
I2C mode check
#define IT_FLAG_MASK ((uint16_t)0x2FFF) |
I2C interrupt flag mask
#define ITEN_MASK ((uint16_t)0x2FFF) |
I2C interrupt enable mask
#define PAN_I2C_MODE_MASTER ((uint16_t)0x0021) |
I2C master mode
#define PAN_I2C_MODE_SLAVE ((uint16_t)0x0000) |
I2C slave mode
__STATIC_INLINE bool I2C_AbortSrcCheck | ( | I2C_T * | I2Cx, |
uint32_t | IC_MSK | ||
) |
Get the source of tx_abort.
I2Cx | where I2Cx is a i2c peripheral base address. |
__STATIC_INLINE void I2C_AbortTransfer | ( | I2C_T * | I2Cx | ) |
Aborting I2C Transfers.
I2Cx | where I2Cx is a i2c peripheral base address. |
__STATIC_INLINE void I2C_ClearAllITPendingBit | ( | I2C_T * | I2Cx | ) |
Clears all the I2Cx's interrupt pending bits.
I2Cx | where I2Cx is a i2c peripheral base address. |
void I2C_ClearITPendingBit | ( | I2C_T * | I2Cx, |
uint16_t | I2C_IT | ||
) |
Clears the I2Cx's interrupt pending bits.
I2Cx | where I2Cx is a i2c peripheral base address. |
I2C_IT | specifies the interrupt pending bit to clear.
|
__STATIC_INLINE void I2C_Cmd | ( | I2C_T * | I2Cx, |
FunctionalState | NewState | ||
) |
Enables or disables the specified I2C peripheral.
I2Cx | where I2Cx is a i2c peripheral base address. |
NewState | new state of the I2Cx peripheral. This parameter can be: ENABLE or DISABLE. |
__STATIC_INLINE void I2C_DisableAllIT | ( | I2C_T * | I2Cx | ) |
Enables or disables all the specified I2C interrupts.
I2Cx | where I2Cx is a i2c peripheral base address. |
__STATIC_INLINE void I2C_DMACmd | ( | I2C_T * | I2Cx, |
FunctionalState | NewState | ||
) |
Enables or disables the specified I2C DMA requests.
I2Cx | where I2Cx is a i2c peripheral base address. |
NewState | new state of the I2C DMA transfer. This parameter can be: ENABLE or DISABLE. |
__STATIC_INLINE void I2C_DMAReceiveDataLevel | ( | I2C_T * | I2Cx, |
uint8_t | Level | ||
) |
DMA Receive Data Level Register.
I2Cx | where I2Cx is a i2c peripheral base address. |
Level | This parameter controls the level at which a DMA request is made by the receive logic. |
__STATIC_INLINE void I2C_DMATransferDataLevel | ( | I2C_T * | I2Cx, |
uint8_t | Level | ||
) |
DMA Transmit Data Level Register.
I2Cx | where I2Cx is a i2c peripheral base address. |
Level | This parameter controls the level at which a DMA request is made by the transmit logic |
__STATIC_INLINE void I2C_GeneralCallCmd | ( | I2C_T * | I2Cx, |
FunctionalState | NewState | ||
) |
Enables or disables the specified I2C general call feature.
I2Cx | where I2Cx is a i2c peripheral base address. |
NewState | new state of the I2C General call. This parameter can be: ENABLE or DISABLE. |
FlagStatus I2C_GetFlagStatus | ( | I2C_T * | I2Cx, |
uint32_t | I2C_FLAG | ||
) |
Checks whether the specified I2C flag is set or not.
I2Cx | where I2Cx is a i2c peripheral base address. |
I2C_FLAG | specifies the flag to check. This parameter can be one of the following values:
|
__STATIC_INLINE ITStatus I2C_GetITStatus | ( | I2C_T * | I2Cx, |
uint16_t | I2C_IT | ||
) |
Checks whether the specified I2C interrupt has occurred or not.
I2Cx | where I2Cx is a i2c peripheral base address. |
I2C_IT | specifies the interrupt source to check. This parameter can be one of the following values:
|
__STATIC_INLINE ITStatus I2C_GetRawITStatus | ( | I2C_T * | I2Cx, |
uint16_t | I2C_IT | ||
) |
Checks whether the specified I2C interrupt has occurred or not.
I2Cx | where I2Cx is a i2c peripheral base address. |
I2C_IT | specifies the interrupt source to check. This parameter can be one of the following values:
|
bool I2C_Init | ( | I2C_T * | I2Cx, |
I2C_InitTypeDef * | I2C_InitStruct | ||
) |
Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct.
I2Cx | where I2Cx is a i2c peripheral base address. |
I2C_InitStruct | pointer to a I2C_InitTypeDef structure that contains the configuration information for the specified I2C peripheral. |
false | init fail |
true | init succeed |
__STATIC_INLINE void I2C_ITConfig | ( | I2C_T * | I2Cx, |
uint16_t | I2C_IT, | ||
FunctionalState | NewState | ||
) |
Enables or disables the specified I2C interrupts.
I2Cx | where I2Cx is a i2c peripheral base address. |
I2C_IT | specifies the I2C interrupts sources to be enabled or disabled. This parameter can be any combination of the following values:
|
NewState | new state of the specified I2C interrupts. This parameter can be: ENABLE or DISABLE. |
void I2C_Read | ( | I2C_T * | I2Cx, |
uint8_t * | ReadBuf, | ||
uint32_t | Size | ||
) |
write data to the I2Cx peripheral.
I2Cx | where I2Cx is a i2c peripheral base address. |
ReadBuf | cache of stored writings. |
Size | number of data read from I2C peripheral. |
__STATIC_INLINE uint8_t I2C_ReceiveData | ( | I2C_T * | I2Cx | ) |
Returns the most recent received data by the I2Cx peripheral.
I2Cx | where I2Cx is a i2c peripheral base address. |
__STATIC_INLINE void I2C_SendCmd | ( | I2C_T * | I2Cx, |
uint8_t | Cmd | ||
) |
Sends a data byte through the I2Cx peripheral.
I2Cx | where I2Cx is a i2c peripheral base address. |
Cmd | : I2c operate command I2C_CMD_RD,I2C_CMD_WR,I2C_CMD_RESTART,I2C_CMD_STOP |
__STATIC_INLINE void I2C_SendDataCmd | ( | I2C_T * | I2Cx, |
uint8_t | Data, | ||
uint8_t | Cmd | ||
) |
Sends a data byte through the I2Cx peripheral.
I2Cx | where I2Cx is a i2c peripheral base address. |
Data | Byte to be transmitted.. |
Cmd | : I2c operate command I2C_CMD_RD,I2C_CMD_WR,I2C_CMD_RESTART,I2C_CMD_STOP |
void I2C_Set10bitAddress | ( | I2C_T * | I2Cx, |
uint16_t | Address | ||
) |
Configure the target address for any master transaction.
I2Cx | where I2Cx is a i2c peripheral base address. |
Address | specifies the slave 10-bit address which will be transmitted |
void I2C_Set7bitAddress | ( | I2C_T * | I2Cx, |
uint8_t | Address | ||
) |
Configure the target address for any master transaction.
I2Cx | where I2Cx is a i2c peripheral base address. |
Address | specifies the slave 7-bit address which will be transmitted |
__STATIC_INLINE void I2C_SetMode | ( | I2C_T * | I2Cx, |
uint16_t | Mode | ||
) |
Set I2C mode .
I2Cx | where I2Cx is a i2c peripheral base address. |
Mode | role of the I2Cx peripheral. This parameter can be: PAN_I2C_MODE_MASTER or PAN_I2C_MODE_SLAVE. |
__STATIC_INLINE void I2C_SetRxTirggerLevel | ( | I2C_T * | I2Cx, |
uint8_t | ThresholdValue | ||
) |
Set I2C Rx fifo threshold value .
I2Cx | where I2Cx is a i2c peripheral base address. |
ThresholdValue | Receive FIFO Threshold Level This parameter can be I2c rx threshold level. |
__STATIC_INLINE void I2C_SetSlaveAddr | ( | I2C_T * | I2Cx, |
uint32_t | addr | ||
) |
Set slave address.
I2Cx | where I2Cx is a i2c peripheral base address. |
addr | slave address. |
__STATIC_INLINE void I2C_SetTxTirggerLevel | ( | I2C_T * | I2Cx, |
uint8_t | ThresholdValue | ||
) |
Set I2C Tx fifo threshold value .
I2Cx | where I2Cx is a i2c peripheral base address. |
ThresholdValue | Transmit FIFO Threshold Level This parameter can be I2c tx transmit level. |
void I2C_Write | ( | I2C_T * | I2Cx, |
uint8_t * | WriteBuf, | ||
uint32_t | Size | ||
) |
read data from the I2Cx peripheral.
I2Cx | where I2Cx is a i2c peripheral base address. |
WriteBuf | cache of stored readings. |
Size | number of data read from I2C peripheral. |