I2C driver modules. More...
Data Structures | |
struct | I2C_InitTypeDef |
I2C Init structure definition. More... | |
Modules | |
I2C_Exported_Constants | |
I2C_Private_Functions | |
Defines | |
#define | CR1_CLEAR_MASK ((uint16_t)0xFBF5) |
#define | FLAG_MASK ((uint32_t)0x00FFFFFF) |
#define | ITEN_MASK ((uint32_t)0x07000000) |
Functions | |
void | I2C_DeInit (I2C_TypeDef *I2Cx) |
Deinitialize the I2Cx peripheral registers to their default reset values. | |
void | I2C_Init (I2C_TypeDef *I2Cx, I2C_InitTypeDef *I2C_InitStruct) |
Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct. | |
void | I2C_StructInit (I2C_InitTypeDef *I2C_InitStruct) |
Fills each I2C_InitStruct member with its default value. | |
void | I2C_Cmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C peripheral. | |
void | I2C_GenerateSTART (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Generates I2Cx communication START condition. | |
void | I2C_GenerateSTOP (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Generates I2Cx communication STOP condition. | |
void | I2C_Send7bitAddress (I2C_TypeDef *I2Cx, uint8_t Address, uint8_t I2C_Direction) |
Transmits the address byte to select the slave device. | |
void | I2C_AcknowledgeConfig (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C acknowledge feature. | |
void | I2C_OwnAddress2Config (I2C_TypeDef *I2Cx, uint8_t Address) |
Configures the specified I2C own address2. | |
void | I2C_DualAddressCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C dual addressing mode. | |
void | I2C_GeneralCallCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C general call feature. | |
void | I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C software reset. | |
void | I2C_StretchClockCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C Clock stretching. | |
void | I2C_FastModeDutyCycleConfig (I2C_TypeDef *I2Cx, uint16_t I2C_DutyCycle) |
Selects the specified I2C fast mode duty cycle. | |
void | I2C_NACKPositionConfig (I2C_TypeDef *I2Cx, uint16_t I2C_NACKPosition) |
Selects the specified I2C NACK position in master receiver mode. | |
void | I2C_SMBusAlertConfig (I2C_TypeDef *I2Cx, uint16_t I2C_SMBusAlert) |
Drives the SMBusAlert pin high or low for the specified I2C. | |
void | I2C_ARPCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C ARP. | |
void | I2C_SendData (I2C_TypeDef *I2Cx, uint8_t Data) |
Sends a data byte through the I2Cx peripheral. | |
uint8_t | I2C_ReceiveData (I2C_TypeDef *I2Cx) |
Returns the most recent received data by the I2Cx peripheral. | |
void | I2C_TransmitPEC (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C PEC transfer. | |
void | I2C_PECPositionConfig (I2C_TypeDef *I2Cx, uint16_t I2C_PECPosition) |
Selects the specified I2C PEC position. | |
void | I2C_CalculatePEC (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the PEC value calculation of the transferred bytes. | |
uint8_t | I2C_GetPEC (I2C_TypeDef *I2Cx) |
Returns the PEC value for the specified I2C. | |
void | I2C_DMACmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C DMA requests. | |
void | I2C_DMALastTransferCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Specifies that the next DMA transfer is the last one. | |
uint16_t | I2C_ReadRegister (I2C_TypeDef *I2Cx, uint8_t I2C_Register) |
Reads the specified I2C register and returns its value. | |
void | I2C_ITConfig (I2C_TypeDef *I2Cx, uint16_t I2C_IT, FunctionalState NewState) |
Enables or disables the specified I2C interrupts. | |
ErrorStatus | I2C_CheckEvent (I2C_TypeDef *I2Cx, uint32_t I2C_EVENT) |
Checks whether the last I2Cx Event is equal to the one passed as parameter. | |
uint32_t | I2C_GetLastEvent (I2C_TypeDef *I2Cx) |
Returns the last I2Cx Event. | |
FlagStatus | I2C_GetFlagStatus (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG) |
Checks whether the specified I2C flag is set or not. | |
void | I2C_ClearFlag (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG) |
Clears the I2Cx's pending flags. | |
ITStatus | I2C_GetITStatus (I2C_TypeDef *I2Cx, uint32_t I2C_IT) |
Checks whether the specified I2C interrupt has occurred or not. | |
void | I2C_ClearITPendingBit (I2C_TypeDef *I2Cx, uint32_t I2C_IT) |
Clears the I2Cx's interrupt pending bits. |
I2C driver modules.
void I2C_AcknowledgeConfig | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C acknowledge feature.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2C Acknowledgement. This parameter can be: ENABLE or DISABLE. |
None. |
void I2C_ARPCmd | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C ARP.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2Cx ARP. This parameter can be: ENABLE or DISABLE. |
None |
void I2C_CalculatePEC | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the PEC value calculation of the transferred bytes.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2Cx PEC value calculation. This parameter can be: ENABLE or DISABLE. |
None |
ErrorStatus I2C_CheckEvent | ( | I2C_TypeDef * | I2Cx, | |
uint32_t | I2C_EVENT | |||
) |
Checks whether the last I2Cx Event is equal to the one passed as parameter.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_EVENT,: | specifies the event to be checked. This parameter can be one of the following values:
|
An | ErrorStatus enumeration value:
|
void I2C_ClearFlag | ( | I2C_TypeDef * | I2Cx, | |
uint32_t | I2C_FLAG | |||
) |
Clears the I2Cx's pending flags.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_FLAG,: | specifies the flag to clear. This parameter can be any combination of the following values:
|
None |
void I2C_ClearITPendingBit | ( | I2C_TypeDef * | I2Cx, | |
uint32_t | I2C_IT | |||
) |
Clears the I2Cx's interrupt pending bits.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_IT,: | specifies the interrupt pending bit to clear. This parameter can be any combination of the following values:
|
None |
void I2C_Cmd | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C peripheral.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2Cx peripheral. This parameter can be: ENABLE or DISABLE. |
None |
void I2C_DeInit | ( | I2C_TypeDef * | I2Cx | ) |
Deinitialize the I2Cx peripheral registers to their default reset values.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. |
None |
void I2C_DMACmd | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C DMA requests.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2C DMA transfer. This parameter can be: ENABLE or DISABLE. |
None |
void I2C_DMALastTransferCmd | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Specifies that the next DMA transfer is the last one.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2C DMA last transfer. This parameter can be: ENABLE or DISABLE. |
None |
void I2C_DualAddressCmd | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C dual addressing mode.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2C dual addressing mode. This parameter can be: ENABLE or DISABLE. |
None |
void I2C_FastModeDutyCycleConfig | ( | I2C_TypeDef * | I2Cx, | |
uint16_t | I2C_DutyCycle | |||
) |
Selects the specified I2C fast mode duty cycle.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_DutyCycle,: | specifies the fast mode duty cycle. This parameter can be one of the following values:
|
None |
void I2C_GeneralCallCmd | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C general call feature.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2C General call. This parameter can be: ENABLE or DISABLE. |
None |
void I2C_GenerateSTART | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Generates I2Cx communication START condition.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2C START condition generation. This parameter can be: ENABLE or DISABLE. |
None. |
void I2C_GenerateSTOP | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Generates I2Cx communication STOP condition.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2C STOP condition generation. This parameter can be: ENABLE or DISABLE. |
None. |
FlagStatus I2C_GetFlagStatus | ( | I2C_TypeDef * | I2Cx, | |
uint32_t | I2C_FLAG | |||
) |
Checks whether the specified I2C flag is set or not.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_FLAG,: | specifies the flag to check. This parameter can be one of the following values:
|
The | new state of I2C_FLAG (SET or RESET). |
ITStatus I2C_GetITStatus | ( | I2C_TypeDef * | I2Cx, | |
uint32_t | I2C_IT | |||
) |
Checks whether the specified I2C interrupt has occurred or not.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_IT,: | specifies the interrupt source to check. This parameter can be one of the following values:
|
The | new state of I2C_IT (SET or RESET). |
uint32_t I2C_GetLastEvent | ( | I2C_TypeDef * | I2Cx | ) |
Returns the last I2Cx Event.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. |
The | last event |
uint8_t I2C_GetPEC | ( | I2C_TypeDef * | I2Cx | ) |
Returns the PEC value for the specified I2C.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. |
The | PEC value. |
void I2C_Init | ( | I2C_TypeDef * | I2Cx, | |
I2C_InitTypeDef * | I2C_InitStruct | |||
) |
Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_InitStruct,: | pointer to a I2C_InitTypeDef structure that contains the configuration information for the specified I2C peripheral. |
None |
void I2C_ITConfig | ( | I2C_TypeDef * | I2Cx, | |
uint16_t | I2C_IT, | |||
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C interrupts.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
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. |
None |
void I2C_NACKPositionConfig | ( | I2C_TypeDef * | I2Cx, | |
uint16_t | I2C_NACKPosition | |||
) |
Selects the specified I2C NACK position in master receiver mode.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_NACKPosition,: | specifies the NACK position. This parameter can be one of the following values:
|
None |
void I2C_OwnAddress2Config | ( | I2C_TypeDef * | I2Cx, | |
uint8_t | Address | |||
) |
Configures the specified I2C own address2.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
Address,: | specifies the 7bit I2C own address2. |
None. |
void I2C_PECPositionConfig | ( | I2C_TypeDef * | I2Cx, | |
uint16_t | I2C_PECPosition | |||
) |
Selects the specified I2C PEC position.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_PECPosition,: | specifies the PEC position. This parameter can be one of the following values:
|
None |
uint16_t I2C_ReadRegister | ( | I2C_TypeDef * | I2Cx, | |
uint8_t | I2C_Register | |||
) |
Reads the specified I2C register and returns its value.
I2C_Register,: | specifies the register to read. This parameter can be one of the following values:
|
The | value of the read register. |
uint8_t I2C_ReceiveData | ( | I2C_TypeDef * | I2Cx | ) |
Returns the most recent received data by the I2Cx peripheral.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. |
The | value of the received data. |
void I2C_Send7bitAddress | ( | I2C_TypeDef * | I2Cx, | |
uint8_t | Address, | |||
uint8_t | I2C_Direction | |||
) |
Transmits the address byte to select the slave device.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
Address,: | specifies the slave address which will be transmitted | |
I2C_Direction,: | specifies whether the I2C device will be a Transmitter or a Receiver. This parameter can be one of the following values
|
None. |
void I2C_SendData | ( | I2C_TypeDef * | I2Cx, | |
uint8_t | Data | |||
) |
Sends a data byte through the I2Cx peripheral.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
Data,: | Byte to be transmitted.. |
None |
void I2C_SMBusAlertConfig | ( | I2C_TypeDef * | I2Cx, | |
uint16_t | I2C_SMBusAlert | |||
) |
Drives the SMBusAlert pin high or low for the specified I2C.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
I2C_SMBusAlert,: | specifies SMBAlert pin level. This parameter can be one of the following values:
|
None |
void I2C_SoftwareResetCmd | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C software reset.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2C software reset. This parameter can be: ENABLE or DISABLE. |
None |
void I2C_StretchClockCmd | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C Clock stretching.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2Cx Clock stretching. This parameter can be: ENABLE or DISABLE. |
None |
void I2C_StructInit | ( | I2C_InitTypeDef * | I2C_InitStruct | ) |
Fills each I2C_InitStruct member with its default value.
I2C_InitStruct,: | pointer to an I2C_InitTypeDef structure which will be initialized. |
None |
void I2C_TransmitPEC | ( | I2C_TypeDef * | I2Cx, | |
FunctionalState | NewState | |||
) |
Enables or disables the specified I2C PEC transfer.
I2Cx,: | where x can be 1, 2 or 3 to select the I2C peripheral. | |
NewState,: | new state of the I2C PEC transmission. This parameter can be: ENABLE or DISABLE. |
None |