STM32F37 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F37 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
Communications handling functions

Communications handling functions. More...

Functions

void I2C_AutoEndCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data are transferred). More...
 
void I2C_ReloadCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C nbytes reload mode. More...
 
void I2C_NumberOfBytesConfig (I2C_TypeDef *I2Cx, uint8_t Number_Bytes)
 Configures the number of bytes to be transmitted/received. More...
 
void I2C_MasterRequestConfig (I2C_TypeDef *I2Cx, uint16_t I2C_Direction)
 Configures the type of transfer request for the master. More...
 
void I2C_GenerateSTART (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2Cx communication START condition. More...
 
void I2C_GenerateSTOP (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2Cx communication STOP condition. More...
 
void I2C_10BitAddressHeaderCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C 10-bit header only mode with read direction. More...
 
void I2C_AcknowledgeConfig (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2C communication Acknowledge. More...
 
uint8_t I2C_GetAddressMatched (I2C_TypeDef *I2Cx)
 Returns the I2C slave matched address . More...
 
uint16_t I2C_GetTransferDirection (I2C_TypeDef *I2Cx)
 Returns the I2C slave received request. More...
 
void I2C_TransferHandling (I2C_TypeDef *I2Cx, uint16_t Address, uint8_t Number_Bytes, uint32_t ReloadEndMode, uint32_t StartStopMode)
 Handles I2Cx communication when starting transfer or during transfer (TC or TCR flag are set). More...
 

Detailed Description

Communications handling functions.

 ===============================================================================
                  ##### Communications handling functions #####
 ===============================================================================  
    [..] This section provides a set of functions that handles I2C communication.

    [..] Automatic End mode is enabled using I2C_AutoEndCmd() function. When Reload
         mode is enabled via I2C_ReloadCmd() AutoEnd bit has no effect.

    [..] I2C_NumberOfBytesConfig() function set the number of bytes to be transferred,
         this configuration should be done before generating start condition in master 
         mode.

    [..] When switching from master write operation to read operation in 10Bit addressing
         mode, master can only sends the 1st 7 bits of the 10 bit address, followed by 
         Read direction by enabling HEADR bit using I2C_10BitAddressHeader() function.

    [..] In master mode, when transferring more than 255 bytes Reload mode should be used
         to handle communication. In the first phase of transfer, Nbytes should be set to 
         255. After transferring these bytes TCR flag is set and I2C_TransferHandling()
         function should be called to handle remaining communication.

    [..] In master mode, when software end mode is selected when all data is transferred
         TC flag is set I2C_TransferHandling() function should be called to generate STOP
         or generate ReStart.

Function Documentation

void I2C_10BitAddressHeaderCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C 10-bit header only mode with read direction.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C 10-bit header only mode. This parameter can be: ENABLE or DISABLE.
Note
This mode can be used only when switching from master transmitter mode to master receiver mode.
Return values
None
void I2C_AcknowledgeConfig ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Generates I2C communication Acknowledge.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the Acknowledge. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_AutoEndCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data are transferred).

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C automatic end mode. This parameter can be: ENABLE or DISABLE.
Note
This function has effect if Reload mode is disabled.
Return values
None
void I2C_GenerateSTART ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Generates I2Cx communication START condition.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C START condition generation. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_GenerateSTOP ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Generates I2Cx communication STOP condition.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C STOP condition generation. This parameter can be: ENABLE or DISABLE.
Return values
None
uint8_t I2C_GetAddressMatched ( I2C_TypeDef *  I2Cx)

Returns the I2C slave matched address .

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Return values
Thevalue of the slave matched address .
uint16_t I2C_GetTransferDirection ( I2C_TypeDef *  I2Cx)

Returns the I2C slave received request.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Return values
Thevalue of the received request.
void I2C_MasterRequestConfig ( I2C_TypeDef *  I2Cx,
uint16_t  I2C_Direction 
)

Configures the type of transfer request for the master.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
I2C_Direction,:specifies the transfer request direction to be programmed. This parameter can be one of the following values:
  • I2C_Direction_Transmitter: Master request a write transfer
  • I2C_Direction_Receiver: Master request a read transfer
Return values
None
void I2C_NumberOfBytesConfig ( I2C_TypeDef *  I2Cx,
uint8_t  Number_Bytes 
)

Configures the number of bytes to be transmitted/received.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Number_Bytes,:specifies the number of bytes to be programmed.
Return values
None
void I2C_ReloadCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C nbytes reload mode.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the nbytes reload mode. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_TransferHandling ( I2C_TypeDef *  I2Cx,
uint16_t  Address,
uint8_t  Number_Bytes,
uint32_t  ReloadEndMode,
uint32_t  StartStopMode 
)

Handles I2Cx communication when starting transfer or during transfer (TC or TCR flag are set).

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Address,:specifies the slave address to be programmed.
Number_Bytes,:specifies the number of bytes to be programmed. This parameter must be a value between 0 and 255.
ReloadEndMode,:new state of the I2C START condition generation. This parameter can be one of the following values:
  • I2C_Reload_Mode: Enable Reload mode .
  • I2C_AutoEnd_Mode: Enable Automatic end mode.
  • I2C_SoftEnd_Mode: Enable Software end mode.
StartStopMode,:new state of the I2C START condition generation. This parameter can be one of the following values:
  • I2C_No_StartStop: Don't Generate stop and start condition.
  • I2C_Generate_Stop: Generate stop condition (Number_Bytes should be set to 0).
  • I2C_Generate_Start_Read: Generate Restart for read request.
  • I2C_Generate_Start_Write: Generate Restart for write request.
Return values
None