This file provides firmware functions to manage the following functionalities of the Inter-Integrated circuit (I2C): More...
Go to the source code of this file.
Macros | |
#define | CR1_CLEAR_MASK ((uint32_t)0x00CFE0FF) /*<! I2C CR1 clear register Mask */ |
#define | CR2_CLEAR_MASK ((uint32_t)0x07FF7FFF) /*<! I2C CR2 clear register Mask */ |
#define | ERROR_IT_MASK ((uint32_t)0x00003F00) /*<! I2C Error interrupt register Mask */ |
#define | TC_IT_MASK ((uint32_t)0x000000C0) /*<! I2C TC interrupt register Mask */ |
#define | TIMING_CLEAR_MASK ((uint32_t)0xF0FFFFFF) /*<! I2C TIMING clear register Mask */ |
Functions | |
void | I2C_10BitAddressHeaderCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the I2C 10-bit header only mode with read direction. More... | |
void | I2C_10BitAddressingModeCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the I2C 10-bit addressing mode for the master. More... | |
void | I2C_AcknowledgeConfig (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Generates I2C communication Acknowledge. More... | |
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_CalculatePEC (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the PEC value calculation of the transferred bytes. More... | |
void | I2C_ClearFlag (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG) |
Clears the I2Cx's pending flags. More... | |
void | I2C_ClearITPendingBit (I2C_TypeDef *I2Cx, uint32_t I2C_IT) |
Clears the I2Cx's interrupt pending bits. More... | |
void | I2C_ClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables I2C Clock Timeout (SCL Timeout detection). More... | |
void | I2C_Cmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C peripheral. More... | |
void | I2C_DeInit (I2C_TypeDef *I2Cx) |
Deinitialize the I2Cx peripheral registers to their default reset values. More... | |
void | I2C_DMACmd (I2C_TypeDef *I2Cx, uint32_t I2C_DMAReq, FunctionalState NewState) |
Enables or disables the I2C DMA interface. More... | |
void | I2C_DualAddressCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C dual addressing mode. More... | |
void | I2C_ExtendedClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables I2C Extended Clock Timeout (SCL cumulative Timeout detection). More... | |
void | I2C_GeneralCallCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C general call feature. 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... | |
uint8_t | I2C_GetAddressMatched (I2C_TypeDef *I2Cx) |
Returns the I2C slave matched address . More... | |
FlagStatus | I2C_GetFlagStatus (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG) |
Checks whether the specified I2C flag is set or not. More... | |
ITStatus | I2C_GetITStatus (I2C_TypeDef *I2Cx, uint32_t I2C_IT) |
Checks whether the specified I2C interrupt has occurred or not. More... | |
uint8_t | I2C_GetPEC (I2C_TypeDef *I2Cx) |
Returns the PEC value for the specified I2C. More... | |
uint16_t | I2C_GetTransferDirection (I2C_TypeDef *I2Cx) |
Returns the I2C slave received request. More... | |
void | I2C_IdleClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables I2C Idle Clock Timeout (Bus idle SCL and SDA high detection). More... | |
void | I2C_Init (I2C_TypeDef *I2Cx, I2C_InitTypeDef *I2C_InitStruct) |
Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct. More... | |
void | I2C_ITConfig (I2C_TypeDef *I2Cx, uint32_t I2C_IT, FunctionalState NewState) |
Enables or disables the specified I2C interrupts. More... | |
void | I2C_MasterRequestConfig (I2C_TypeDef *I2Cx, uint16_t I2C_Direction) |
Configures the type of transfer request for the master. More... | |
void | I2C_NumberOfBytesConfig (I2C_TypeDef *I2Cx, uint8_t Number_Bytes) |
Configures the number of bytes to be transmitted/received. More... | |
void | I2C_OwnAddress2Config (I2C_TypeDef *I2Cx, uint16_t Address, uint8_t Mask) |
Configures the I2C slave own address 2 and mask. More... | |
void | I2C_PECRequestCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables I2C PEC transmission/reception request. More... | |
uint32_t | I2C_ReadRegister (I2C_TypeDef *I2Cx, uint8_t I2C_Register) |
Reads the specified I2C register and returns its value. More... | |
uint8_t | I2C_ReceiveData (I2C_TypeDef *I2Cx) |
Returns the most recent received data by the I2Cx peripheral. More... | |
void | I2C_ReloadCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the I2C nbytes reload mode. More... | |
void | I2C_SendData (I2C_TypeDef *I2Cx, uint8_t Data) |
Sends a data byte through the I2Cx peripheral. More... | |
void | I2C_SlaveAddressConfig (I2C_TypeDef *I2Cx, uint16_t Address) |
Configures the slave address to be transmitted after start generation. More... | |
void | I2C_SlaveByteControlCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the I2C slave byte control. More... | |
void | I2C_SMBusAlertCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables I2C SMBus alert. More... | |
void | I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx) |
Enables or disables the specified I2C software reset. More... | |
void | I2C_StopModeCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables I2C wakeup from stop mode. More... | |
void | I2C_StretchClockCmd (I2C_TypeDef *I2Cx, FunctionalState NewState) |
Enables or disables the specified I2C Clock stretching. More... | |
void | I2C_StructInit (I2C_InitTypeDef *I2C_InitStruct) |
Fills each I2C_InitStruct member with its default value. More... | |
void | I2C_TimeoutAConfig (I2C_TypeDef *I2Cx, uint16_t Timeout) |
Configures the I2C Bus Timeout A (SCL Timeout when TIDLE = 0 or Bus idle SCL and SDA high when TIDLE = 1). More... | |
void | I2C_TimeoutBConfig (I2C_TypeDef *I2Cx, uint16_t Timeout) |
Configures the I2C Bus Timeout B (SCL cumulative Timeout). 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... | |
This file provides firmware functions to manage the following functionalities of the Inter-Integrated circuit (I2C):
============================================================================ ##### How to use this driver ##### ============================================================================ [..] (#) Enable peripheral clock using RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2Cx, ENABLE) function for I2C1 or I2C2. (#) Enable SDA, SCL and SMBA (when used) GPIO clocks using RCC_AHBPeriphClockCmd() function. (#) Peripherals alternate function: (++) Connect the pin to the desired peripherals' Alternate Function (AF) using GPIO_PinAFConfig() function. (++) Configure the desired pin in alternate function by: GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF (++) Select the type, OpenDrain and speed via GPIO_PuPd, GPIO_OType and GPIO_Speed members (++) Call GPIO_Init() function. (#) Program the Mode, Timing , Own address, Ack and Acknowledged Address using the I2C_Init() function. (#) Optionally you can enable/configure the following parameters without re-initialization (i.e there is no need to call again I2C_Init() function): (++) Enable the acknowledge feature using I2C_AcknowledgeConfig() function. (++) Enable the dual addressing mode using I2C_DualAddressCmd() function. (++) Enable the general call using the I2C_GeneralCallCmd() function. (++) Enable the clock stretching using I2C_StretchClockCmd() function. (++) Enable the PEC Calculation using I2C_CalculatePEC() function. (++) For SMBus Mode: (+++) Enable the SMBusAlert pin using I2C_SMBusAlertCmd() function. (#) Enable the NVIC and the corresponding interrupt using the function I2C_ITConfig() if you need to use interrupt mode. (#) When using the DMA mode (++) Configure the DMA using DMA_Init() function. (++) Active the needed channel Request using I2C_DMACmd() function. (#) Enable the I2C using the I2C_Cmd() function. (#) Enable the DMA using the DMA_Cmd() function when using DMA mode in the transfers. [..] (@) When using I2C in Fast Mode Plus, SCL and SDA pin 20mA current drive capability must be enabled by setting the driving capability control bit in SYSCFG.
Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:
http://www.st.com/software_license_agreement_liberty_v2
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file stm32f30x_i2c.c.