STM32F10x Standard Peripherals Library  3.5.0
/opt/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c File Reference

This file provides all the I2C firmware functions. More...

#include "stm32f10x_i2c.h"
#include "stm32f10x_rcc.h"

Go to the source code of this file.

Defines

#define CR1_PE_Set   ((uint16_t)0x0001)
#define CR1_PE_Reset   ((uint16_t)0xFFFE)
#define CR1_START_Set   ((uint16_t)0x0100)
#define CR1_START_Reset   ((uint16_t)0xFEFF)
#define CR1_STOP_Set   ((uint16_t)0x0200)
#define CR1_STOP_Reset   ((uint16_t)0xFDFF)
#define CR1_ACK_Set   ((uint16_t)0x0400)
#define CR1_ACK_Reset   ((uint16_t)0xFBFF)
#define CR1_ENGC_Set   ((uint16_t)0x0040)
#define CR1_ENGC_Reset   ((uint16_t)0xFFBF)
#define CR1_SWRST_Set   ((uint16_t)0x8000)
#define CR1_SWRST_Reset   ((uint16_t)0x7FFF)
#define CR1_PEC_Set   ((uint16_t)0x1000)
#define CR1_PEC_Reset   ((uint16_t)0xEFFF)
#define CR1_ENPEC_Set   ((uint16_t)0x0020)
#define CR1_ENPEC_Reset   ((uint16_t)0xFFDF)
#define CR1_ENARP_Set   ((uint16_t)0x0010)
#define CR1_ENARP_Reset   ((uint16_t)0xFFEF)
#define CR1_NOSTRETCH_Set   ((uint16_t)0x0080)
#define CR1_NOSTRETCH_Reset   ((uint16_t)0xFF7F)
#define CR1_CLEAR_Mask   ((uint16_t)0xFBF5)
#define CR2_DMAEN_Set   ((uint16_t)0x0800)
#define CR2_DMAEN_Reset   ((uint16_t)0xF7FF)
#define CR2_LAST_Set   ((uint16_t)0x1000)
#define CR2_LAST_Reset   ((uint16_t)0xEFFF)
#define CR2_FREQ_Reset   ((uint16_t)0xFFC0)
#define OAR1_ADD0_Set   ((uint16_t)0x0001)
#define OAR1_ADD0_Reset   ((uint16_t)0xFFFE)
#define OAR2_ENDUAL_Set   ((uint16_t)0x0001)
#define OAR2_ENDUAL_Reset   ((uint16_t)0xFFFE)
#define OAR2_ADD2_Reset   ((uint16_t)0xFF01)
#define CCR_FS_Set   ((uint16_t)0x8000)
#define CCR_CCR_Set   ((uint16_t)0x0FFF)
#define FLAG_Mask   ((uint32_t)0x00FFFFFF)
#define ITEN_Mask   ((uint32_t)0x07000000)

Functions

void I2C_DeInit (I2C_TypeDef *I2Cx)
 Deinitializes 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_DMACmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C DMA requests.
void I2C_DMALastTransferCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Specifies if the next DMA transfer will be the last one.
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_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_ITConfig (I2C_TypeDef *I2Cx, uint16_t I2C_IT, FunctionalState NewState)
 Enables or disables the specified I2C interrupts.
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_Send7bitAddress (I2C_TypeDef *I2Cx, uint8_t Address, uint8_t I2C_Direction)
 Transmits the address byte to select the slave device.
uint16_t I2C_ReadRegister (I2C_TypeDef *I2Cx, uint8_t I2C_Register)
 Reads the specified I2C register and returns its value.
void I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C software reset.
void I2C_NACKPositionConfig (I2C_TypeDef *I2Cx, uint16_t I2C_NACKPosition)
 Selects the specified I2C NACK position in master receiver mode. This function is useful in I2C Master Receiver mode when the number of data to be received is equal to 2. In this case, this function should be called (with parameter I2C_NACKPosition_Next) before data reception starts,as described in the 2-byte reception procedure recommended in Reference Manual in Section: Master receiver.
void I2C_SMBusAlertConfig (I2C_TypeDef *I2Cx, uint16_t I2C_SMBusAlert)
 Drives the SMBusAlert pin high or low for the specified I2C.
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_ARPCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C ARP.
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.
ErrorStatus I2C_CheckEvent (I2C_TypeDef *I2Cx, uint32_t I2C_EVENT)
 I2C State Monitoring Functions.
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.

Detailed Description

This file provides all the I2C firmware functions.

Author:
MCD Application Team
Version:
V3.5.0
Date:
11-March-2011
Attention:

THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

© COPYRIGHT 2011 STMicroelectronics

Definition in file stm32f10x_i2c.c.