STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f0xx_i2c.h File Reference

This file contains all the functions prototypes for the I2C firmware library. More...

#include "stm32f0xx.h"

Go to the source code of this file.

Data Structures

struct  I2C_InitTypeDef
 I2C Init structure definition. More...
 

Macros

#define IS_I2C_ALL_PERIPH(PERIPH)
 
#define IS_I2C_1_PERIPH(PERIPH)   ((PERIPH) == I2C1)
 
#define I2C_AnalogFilter_Enable   ((uint32_t)0x00000000)
 
#define I2C_AnalogFilter_Disable   I2C_CR1_ANFOFF
 
#define IS_I2C_ANALOG_FILTER(FILTER)
 
#define IS_I2C_DIGITAL_FILTER(FILTER)   ((FILTER) <= 0x0000000F)
 
#define I2C_Mode_I2C   ((uint32_t)0x00000000)
 
#define I2C_Mode_SMBusDevice   I2C_CR1_SMBDEN
 
#define I2C_Mode_SMBusHost   I2C_CR1_SMBHEN
 
#define IS_I2C_MODE(MODE)
 
#define I2C_Ack_Enable   ((uint32_t)0x00000000)
 
#define I2C_Ack_Disable   I2C_CR2_NACK
 
#define IS_I2C_ACK(ACK)
 
#define I2C_AcknowledgedAddress_7bit   ((uint32_t)0x00000000)
 
#define I2C_AcknowledgedAddress_10bit   I2C_OAR1_OA1MODE
 
#define IS_I2C_ACKNOWLEDGE_ADDRESS(ADDRESS)
 
#define IS_I2C_OWN_ADDRESS1(ADDRESS1)   ((ADDRESS1) <= (uint32_t)0x000003FF)
 
#define I2C_Direction_Transmitter   ((uint16_t)0x0000)
 
#define I2C_Direction_Receiver   ((uint16_t)0x0400)
 
#define IS_I2C_DIRECTION(DIRECTION)
 
#define I2C_DMAReq_Tx   I2C_CR1_TXDMAEN
 
#define I2C_DMAReq_Rx   I2C_CR1_RXDMAEN
 
#define IS_I2C_DMA_REQ(REQ)   ((((REQ) & (uint32_t)0xFFFF3FFF) == 0x00) && ((REQ) != 0x00))
 
#define IS_I2C_SLAVE_ADDRESS(ADDRESS)   ((ADDRESS) <= (uint16_t)0x03FF)
 
#define IS_I2C_OWN_ADDRESS2(ADDRESS2)   ((ADDRESS2) <= (uint16_t)0x00FF)
 
#define I2C_OA2_NoMask   ((uint8_t)0x00)
 
#define I2C_OA2_Mask01   ((uint8_t)0x01)
 
#define I2C_OA2_Mask02   ((uint8_t)0x02)
 
#define I2C_OA2_Mask03   ((uint8_t)0x03)
 
#define I2C_OA2_Mask04   ((uint8_t)0x04)
 
#define I2C_OA2_Mask05   ((uint8_t)0x05)
 
#define I2C_OA2_Mask06   ((uint8_t)0x06)
 
#define I2C_OA2_Mask07   ((uint8_t)0x07)
 
#define IS_I2C_OWN_ADDRESS2_MASK(MASK)
 
#define IS_I2C_TIMEOUT(TIMEOUT)   ((TIMEOUT) <= (uint16_t)0x0FFF)
 
#define I2C_Register_CR1   ((uint8_t)0x00)
 
#define I2C_Register_CR2   ((uint8_t)0x04)
 
#define I2C_Register_OAR1   ((uint8_t)0x08)
 
#define I2C_Register_OAR2   ((uint8_t)0x0C)
 
#define I2C_Register_TIMINGR   ((uint8_t)0x10)
 
#define I2C_Register_TIMEOUTR   ((uint8_t)0x14)
 
#define I2C_Register_ISR   ((uint8_t)0x18)
 
#define I2C_Register_ICR   ((uint8_t)0x1C)
 
#define I2C_Register_PECR   ((uint8_t)0x20)
 
#define I2C_Register_RXDR   ((uint8_t)0x24)
 
#define I2C_Register_TXDR   ((uint8_t)0x28)
 
#define IS_I2C_REGISTER(REGISTER)
 
#define I2C_IT_ERRI   I2C_CR1_ERRIE
 
#define I2C_IT_TCI   I2C_CR1_TCIE
 
#define I2C_IT_STOPI   I2C_CR1_STOPIE
 
#define I2C_IT_NACKI   I2C_CR1_NACKIE
 
#define I2C_IT_ADDRI   I2C_CR1_ADDRIE
 
#define I2C_IT_RXI   I2C_CR1_RXIE
 
#define I2C_IT_TXI   I2C_CR1_TXIE
 
#define IS_I2C_CONFIG_IT(IT)   ((((IT) & (uint32_t)0xFFFFFF01) == 0x00) && ((IT) != 0x00))
 
#define I2C_FLAG_TXE   I2C_ISR_TXE
 
#define I2C_FLAG_TXIS   I2C_ISR_TXIS
 
#define I2C_FLAG_RXNE   I2C_ISR_RXNE
 
#define I2C_FLAG_ADDR   I2C_ISR_ADDR
 
#define I2C_FLAG_NACKF   I2C_ISR_NACKF
 
#define I2C_FLAG_STOPF   I2C_ISR_STOPF
 
#define I2C_FLAG_TC   I2C_ISR_TC
 
#define I2C_FLAG_TCR   I2C_ISR_TCR
 
#define I2C_FLAG_BERR   I2C_ISR_BERR
 
#define I2C_FLAG_ARLO   I2C_ISR_ARLO
 
#define I2C_FLAG_OVR   I2C_ISR_OVR
 
#define I2C_FLAG_PECERR   I2C_ISR_PECERR
 
#define I2C_FLAG_TIMEOUT   I2C_ISR_TIMEOUT
 
#define I2C_FLAG_ALERT   I2C_ISR_ALERT
 
#define I2C_FLAG_BUSY   I2C_ISR_BUSY
 
#define IS_I2C_CLEAR_FLAG(FLAG)   ((((FLAG) & (uint32_t)0xFFFF4000) == 0x00) && ((FLAG) != 0x00))
 
#define IS_I2C_GET_FLAG(FLAG)
 
#define I2C_IT_TXIS   I2C_ISR_TXIS
 
#define I2C_IT_RXNE   I2C_ISR_RXNE
 
#define I2C_IT_ADDR   I2C_ISR_ADDR
 
#define I2C_IT_NACKF   I2C_ISR_NACKF
 
#define I2C_IT_STOPF   I2C_ISR_STOPF
 
#define I2C_IT_TC   I2C_ISR_TC
 
#define I2C_IT_TCR   I2C_ISR_TCR
 
#define I2C_IT_BERR   I2C_ISR_BERR
 
#define I2C_IT_ARLO   I2C_ISR_ARLO
 
#define I2C_IT_OVR   I2C_ISR_OVR
 
#define I2C_IT_PECERR   I2C_ISR_PECERR
 
#define I2C_IT_TIMEOUT   I2C_ISR_TIMEOUT
 
#define I2C_IT_ALERT   I2C_ISR_ALERT
 
#define IS_I2C_CLEAR_IT(IT)   ((((IT) & (uint32_t)0xFFFFC001) == 0x00) && ((IT) != 0x00))
 
#define IS_I2C_GET_IT(IT)
 
#define I2C_Reload_Mode   I2C_CR2_RELOAD
 
#define I2C_AutoEnd_Mode   I2C_CR2_AUTOEND
 
#define I2C_SoftEnd_Mode   ((uint32_t)0x00000000)
 
#define IS_RELOAD_END_MODE(MODE)
 
#define I2C_No_StartStop   ((uint32_t)0x00000000)
 
#define I2C_Generate_Stop   I2C_CR2_STOP
 
#define I2C_Generate_Start_Read   (uint32_t)(I2C_CR2_START | I2C_CR2_RD_WRN)
 
#define I2C_Generate_Start_Write   I2C_CR2_START
 
#define IS_START_STOP_MODE(MODE)
 

Functions

void I2C_DeInit (I2C_TypeDef *I2Cx)
 Deinitializes the I2Cx peripheral registers to their default reset values. 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_StructInit (I2C_InitTypeDef *I2C_InitStruct)
 Fills each I2C_InitStruct member with its default value. More...
 
void I2C_Cmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C peripheral. More...
 
void I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C software reset. More...
 
void I2C_ITConfig (I2C_TypeDef *I2Cx, uint32_t I2C_IT, FunctionalState NewState)
 Enables or disables the specified I2C interrupts. More...
 
void I2C_StretchClockCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C Clock stretching. More...
 
void I2C_StopModeCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C wakeup from stop mode. More...
 
void I2C_DualAddressCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C own address 2. 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_GeneralCallCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C general call mode. More...
 
void I2C_SlaveByteControlCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C slave byte control. More...
 
void I2C_SlaveAddressConfig (I2C_TypeDef *I2Cx, uint16_t Address)
 Configures the slave address to be transmitted after start generation. More...
 
void I2C_10BitAddressingModeCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C 10-bit addressing mode for the master. 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_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...
 
void I2C_SMBusAlertCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C SMBus alert. More...
 
void I2C_ClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C Clock Timeout (SCL Timeout detection). More...
 
void I2C_ExtendedClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C Extended Clock Timeout (SCL cumulative Timeout detection). 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_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_CalculatePEC (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C PEC calculation. More...
 
void I2C_PECRequestCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C PEC transmission/reception request. More...
 
uint8_t I2C_GetPEC (I2C_TypeDef *I2Cx)
 Returns the I2C PEC. More...
 
uint32_t I2C_ReadRegister (I2C_TypeDef *I2Cx, uint8_t I2C_Register)
 Reads the specified I2C register and returns its value. More...
 
void I2C_SendData (I2C_TypeDef *I2Cx, uint8_t Data)
 Sends a data byte through the I2Cx peripheral. More...
 
uint8_t I2C_ReceiveData (I2C_TypeDef *I2Cx)
 Returns the most recent received data by the I2Cx peripheral. More...
 
void I2C_DMACmd (I2C_TypeDef *I2Cx, uint32_t I2C_DMAReq, FunctionalState NewState)
 Enables or disables the I2C DMA interface. More...
 
FlagStatus I2C_GetFlagStatus (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
 Checks whether the specified I2C flag is set or not. More...
 
void I2C_ClearFlag (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
 Clears the I2Cx's pending flags. More...
 
ITStatus I2C_GetITStatus (I2C_TypeDef *I2Cx, uint32_t I2C_IT)
 Checks whether the specified I2C interrupt has occurred or not. More...
 
void I2C_ClearITPendingBit (I2C_TypeDef *I2Cx, uint32_t I2C_IT)
 Clears the I2Cx's interrupt pending bits. More...
 

Detailed Description

This file contains all the functions prototypes for the I2C firmware library.

Author
MCD Application Team
Version
V1.0.1
Date
20-April-2012
Attention

© COPYRIGHT 2012 STMicroelectronics

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.