Nut/OS  5.0.5
API Reference
I2C_Exported_Functions
Collaboration diagram for I2C_Exported_Functions:

Functions

void I2C_DeInit (I2C_TypeDef *I2Cx)
void I2C_Init (I2C_TypeDef *I2Cx, I2C_InitTypeDef *I2C_InitStruct)
void I2C_StructInit (I2C_InitTypeDef *I2C_InitStruct)
void I2C_Cmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_DMACmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_DMALastTransferCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_GenerateSTART (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_GenerateSTOP (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_AcknowledgeConfig (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_OwnAddress2Config (I2C_TypeDef *I2Cx, uint8_t Address)
void I2C_DualAddressCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_GeneralCallCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_ITConfig (I2C_TypeDef *I2Cx, uint16_t I2C_IT, FunctionalState NewState)
void I2C_SendData (I2C_TypeDef *I2Cx, uint8_t Data)
uint8_t I2C_ReceiveData (I2C_TypeDef *I2Cx)
void I2C_Send7bitAddress (I2C_TypeDef *I2Cx, uint8_t Address, uint8_t I2C_Direction)
uint16_t I2C_ReadRegister (I2C_TypeDef *I2Cx, uint8_t I2C_Register)
void I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_SMBusAlertConfig (I2C_TypeDef *I2Cx, uint16_t I2C_SMBusAlert)
void I2C_TransmitPEC (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_PECPositionConfig (I2C_TypeDef *I2Cx, uint16_t I2C_PECPosition)
void I2C_CalculatePEC (I2C_TypeDef *I2Cx, FunctionalState NewState)
uint8_t I2C_GetPEC (I2C_TypeDef *I2Cx)
void I2C_ARPCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_StretchClockCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
void I2C_FastModeDutyCycleConfig (I2C_TypeDef *I2Cx, uint16_t I2C_DutyCycle)
ErrorStatus I2C_CheckEvent (I2C_TypeDef *I2Cx, uint32_t I2C_EVENT)
 I2C State Monitoring Functions.
uint32_t I2C_GetLastEvent (I2C_TypeDef *I2Cx)
FlagStatus I2C_GetFlagStatus (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
void I2C_ClearFlag (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
ITStatus I2C_GetITStatus (I2C_TypeDef *I2Cx, uint32_t I2C_IT)
void I2C_ClearITPendingBit (I2C_TypeDef *I2Cx, uint32_t I2C_IT)

Function Documentation

void I2C_DeInit ( I2C_TypeDef I2Cx)
void I2C_Init ( I2C_TypeDef I2Cx,
I2C_InitTypeDef I2C_InitStruct 
)
void I2C_StructInit ( I2C_InitTypeDef I2C_InitStruct)
void I2C_Cmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_DMACmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_DMALastTransferCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_GenerateSTART ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_GenerateSTOP ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_AcknowledgeConfig ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_OwnAddress2Config ( I2C_TypeDef I2Cx,
uint8_t  Address 
)
void I2C_DualAddressCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_GeneralCallCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_ITConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_IT,
FunctionalState  NewState 
)
void I2C_SendData ( I2C_TypeDef I2Cx,
uint8_t  Data 
)
uint8_t I2C_ReceiveData ( I2C_TypeDef I2Cx)
void I2C_Send7bitAddress ( I2C_TypeDef I2Cx,
uint8_t  Address,
uint8_t  I2C_Direction 
)
uint16_t I2C_ReadRegister ( I2C_TypeDef I2Cx,
uint8_t  I2C_Register 
)
void I2C_SoftwareResetCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_SMBusAlertConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_SMBusAlert 
)
void I2C_TransmitPEC ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_PECPositionConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_PECPosition 
)
void I2C_CalculatePEC ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
uint8_t I2C_GetPEC ( I2C_TypeDef I2Cx)
void I2C_ARPCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_StretchClockCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)
void I2C_FastModeDutyCycleConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_DutyCycle 
)
ErrorStatus I2C_CheckEvent ( I2C_TypeDef I2Cx,
uint32_t  I2C_EVENT 
)

I2C State Monitoring Functions.

This I2C driver provides three different ways for I2C state monitoring depending on the application requirements and constraints:

1) Basic state monitoring: Using I2C_CheckEvent() function: It compares the status registers (SR1 and SR2) content to a given event (can be the combination of one or more flags). It returns SUCCESS if the current status includes the given flags and returns ERROR if one or more flags are missing in the current status.

  • When to use:
    • This function is suitable for most applications as well as for startup activity since the events are fully described in the product reference manual (RM0008).
    • It is also suitable for users who need to define their own events.
  • Limitations:
    • If an error occurs (ie. error flags are set besides to the monitored flags), the I2C_CheckEvent() function may return SUCCESS despite the communication hold or corrupted real state. In this case, it is advised to use error interrupts to monitor the error events and handle them in the interrupt IRQ handler.
Note:
For error management, it is advised to use the following functions:

2) Advanced state monitoring: Using the function I2C_GetLastEvent() which returns the image of both status registers in a single word (uint32_t) (Status Register 2 value is shifted left by 16 bits and concatenated to Status Register 1).

  • When to use:
    • This function is suitable for the same applications above but it allows to overcome the limitations of I2C_GetFlagStatus() function (see below). The returned value could be compared to events already defined in the library (stm32f10x_i2c.h) or to custom values defined by user.
    • This function is suitable when multiple flags are monitored at the same time.
    • At the opposite of I2C_CheckEvent() function, this function allows user to choose when an event is accepted (when all events flags are set and no other flags are set or just when the needed flags are set like I2C_CheckEvent() function).
  • Limitations:
    • User may need to define his own events.
    • Same remark concerning the error management is applicable for this function if user decides to check only regular communication flags (and ignores error flags).

3) Flag-based state monitoring: Using the function I2C_GetFlagStatus() which simply returns the status of one single flag (ie. I2C_FLAG_RXNE ...).

  • When to use:
    • This function could be used for specific applications or in debug phase.
    • It is suitable when only one flag checking is needed (most I2C events are monitored through multiple flags).
  • Limitations:
    • When calling this function, the Status register is accessed. Some flags are cleared when the status register is accessed. So checking the status of one Flag, may clear other ones.
    • Function may need to be called twice or more in order to monitor one single event.

1) Basic state monitoring

uint32_t I2C_GetLastEvent ( I2C_TypeDef I2Cx)

2) Advanced state monitoring

FlagStatus I2C_GetFlagStatus ( I2C_TypeDef I2Cx,
uint32_t  I2C_FLAG 
)

3) Flag-based state monitoring

void I2C_ClearFlag ( I2C_TypeDef I2Cx,
uint32_t  I2C_FLAG 
)
ITStatus I2C_GetITStatus ( I2C_TypeDef I2Cx,
uint32_t  I2C_IT 
)
void I2C_ClearITPendingBit ( I2C_TypeDef I2Cx,
uint32_t  I2C_IT 
)