94 #define CR1_CLEAR_MASK ((uint32_t)0x00CFE0FF) 95 #define CR2_CLEAR_MASK ((uint32_t)0x07FF7FFF) 96 #define TIMING_CLEAR_MASK ((uint32_t)0xF0FFFFFF) 97 #define ERROR_IT_MASK ((uint32_t)0x00003F00) 98 #define TC_IT_MASK ((uint32_t)0x000000C0) 216 I2Cx->
OAR1 = (uint32_t)tmpreg;
218 I2Cx->
OAR2 = (uint32_t)tmpreg;
227 I2Cx->
OAR1 |= I2C_OAR1_OA1EN;
243 tmpreg |= I2C_InitStruct->
I2C_Ack;
349 I2Cx->
CR1 &= (uint32_t)~((uint32_t)I2C_IT);
394 I2Cx->
CR1 |= I2C_CR1_WUPEN;
399 I2Cx->
CR1 &= (uint32_t)~((uint32_t)I2C_CR1_WUPEN);
419 I2Cx->
OAR2 |= I2C_OAR2_OA2EN;
424 I2Cx->
OAR2 &= (uint32_t)~((uint32_t)I2C_OAR2_OA2EN);
457 tmpreg &= (uint32_t)~((uint32_t)(I2C_OAR2_OA2 | I2C_OAR2_OA2MSK));
460 tmpreg |= (uint32_t)(((uint32_t)Address & I2C_OAR2_OA2) | \
461 (((uint32_t)Mask << 8) & I2C_OAR2_OA2MSK)) ;
483 I2Cx->
CR1 |= I2C_CR1_GCEN;
488 I2Cx->
CR1 &= (uint32_t)~((uint32_t)I2C_CR1_GCEN);
508 I2Cx->
CR1 |= I2C_CR1_SBC;
513 I2Cx->
CR1 &= (uint32_t)~((uint32_t)I2C_CR1_SBC);
536 tmpreg &= (uint32_t)~((uint32_t)I2C_CR2_SADD);
539 tmpreg |= (uint32_t)((uint32_t)Address & I2C_CR2_SADD);
562 I2Cx->
CR2 |= I2C_CR2_ADD10;
567 I2Cx->
CR2 &= (uint32_t)~((uint32_t)I2C_CR2_ADD10);
627 I2Cx->
CR2 |= I2C_CR2_AUTOEND;
632 I2Cx->
CR2 &= (uint32_t)~((uint32_t)I2C_CR2_AUTOEND);
652 I2Cx->
CR2 |= I2C_CR2_RELOAD;
657 I2Cx->
CR2 &= (uint32_t)~((uint32_t)I2C_CR2_RELOAD);
678 tmpreg &= (uint32_t)~((uint32_t)I2C_CR2_NBYTES);
681 tmpreg |= (uint32_t)(((uint32_t)Number_Bytes << 16 ) & I2C_CR2_NBYTES);
706 I2Cx->
CR2 &= (uint32_t)~((uint32_t)I2C_CR2_RD_WRN);
711 I2Cx->
CR2 |= I2C_CR2_RD_WRN;
731 I2Cx->
CR2 |= I2C_CR2_START;
736 I2Cx->
CR2 &= (uint32_t)~((uint32_t)I2C_CR2_START);
756 I2Cx->
CR2 |= I2C_CR2_STOP;
761 I2Cx->
CR2 &= (uint32_t)~((uint32_t)I2C_CR2_STOP);
783 I2Cx->
CR2 |= I2C_CR2_HEAD10R;
788 I2Cx->
CR2 &= (uint32_t)~((uint32_t)I2C_CR2_HEAD10R);
808 I2Cx->
CR2 &= (uint32_t)~((uint32_t)I2C_CR2_NACK);
813 I2Cx->
CR2 |= I2C_CR2_NACK;
828 return (uint8_t)(((uint32_t)I2Cx->ISR & I2C_ISR_ADDCODE) >> 16) ;
839 uint16_t direction = 0;
845 tmpreg = (uint32_t)(I2Cx->ISR & I2C_ISR_DIR);
894 tmpreg &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_AUTOEND | I2C_CR2_RD_WRN | I2C_CR2_START | I2C_CR2_STOP));
897 tmpreg |= (uint32_t)(((uint32_t)Address & I2C_CR2_SADD) | (((uint32_t)Number_Bytes << 16 ) & I2C_CR2_NBYTES) | \
898 (uint32_t)ReloadEndMode | (uint32_t)StartStopMode);
960 I2Cx->
CR1 |= I2C_CR1_ALERTEN;
965 I2Cx->
CR1 &= (uint32_t)~((uint32_t)I2C_CR1_ALERTEN);
985 I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TIMOUTEN;
990 I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMOUTEN);
1010 I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TEXTEN;
1015 I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TEXTEN);
1036 I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TIDLE;
1041 I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIDLE);
1054 uint32_t tmpreg = 0;
1061 tmpreg = I2Cx->TIMEOUTR;
1064 tmpreg &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMEOUTA);
1067 tmpreg |= (uint32_t)((uint32_t)Timeout & I2C_TIMEOUTR_TIMEOUTA) ;
1070 I2Cx->TIMEOUTR = tmpreg;
1081 uint32_t tmpreg = 0;
1088 tmpreg = I2Cx->TIMEOUTR;
1091 tmpreg &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMEOUTB);
1094 tmpreg |= (uint32_t)(((uint32_t)Timeout << 16) & I2C_TIMEOUTR_TIMEOUTB) ;
1097 I2Cx->TIMEOUTR = tmpreg;
1116 I2Cx->
CR1 |= I2C_CR1_PECEN;
1121 I2Cx->
CR1 &= (uint32_t)~((uint32_t)I2C_CR1_PECEN);
1141 I2Cx->
CR1 |= I2C_CR2_PECBYTE;
1146 I2Cx->
CR1 &= (uint32_t)~((uint32_t)I2C_CR2_PECBYTE);
1161 return (uint8_t)((uint32_t)I2Cx->PECR & I2C_PECR_PEC);
1203 __IO uint32_t tmp = 0;
1209 tmp = (uint32_t)I2Cx;
1210 tmp += I2C_Register;
1213 return (*(
__IO uint32_t *) tmp);
1250 I2Cx->TXDR = (uint8_t)Data;
1264 return (uint8_t)I2Cx->RXDR;
1311 I2Cx->
CR1 |= I2C_DMAReq;
1316 I2Cx->
CR1 &= (uint32_t)~I2C_DMAReq;
1423 uint32_t tmpreg = 0;
1472 I2Cx->ICR = I2C_FLAG;
1497 uint32_t tmpreg = 0;
1499 uint32_t enablestatus = 0;
1509 enablestatus = (uint32_t)((I2C_CR1_ERRIE) & (I2Cx->
CR1));
1514 enablestatus = (uint32_t)((I2C_CR1_TCIE) & (I2Cx->
CR1));
1518 enablestatus = (uint32_t)((I2C_IT) & (I2Cx->
CR1));
1528 if((tmpreg !=
RESET) && enablestatus)
#define IS_I2C_SLAVE_ADDRESS(ADDRESS)
#define IS_I2C_CLEAR_FLAG(FLAG)
void I2C_ClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables I2C Clock Timeout (SCL Timeout detection).
void I2C_ExtendedClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables I2C Extended Clock Timeout (SCL cumulative Timeout detection).
#define IS_I2C_CONFIG_IT(IT)
#define IS_I2C_ANALOG_FILTER(FILTER)
#define RCC_APB1Periph_I2C1
void I2C_MasterRequestConfig(I2C_TypeDef *I2Cx, uint16_t I2C_Direction)
Configures the type of transfer request for the master.
uint16_t I2C_AcknowledgedAddress
#define IS_I2C_REGISTER(REGISTER)
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)...
uint16_t I2C_GetTransferDirection(I2C_TypeDef *I2Cx)
Returns the I2C slave received request.
#define IS_I2C_TIMEOUT(TIMEOUT)
void I2C_ITConfig(I2C_TypeDef *I2Cx, uint32_t I2C_IT, FunctionalState NewState)
Enables or disables the specified I2C interrupts.
#define IS_I2C_DMA_REQ(REQ)
void I2C_DMACmd(I2C_TypeDef *I2Cx, uint32_t I2C_DMAReq, FunctionalState NewState)
Enables or disables the I2C DMA interface.
#define IS_I2C_OWN_ADDRESS2(ADDRESS2)
void I2C_AcknowledgeConfig(I2C_TypeDef *I2Cx, FunctionalState NewState)
Generates I2C communication Acknowledge.
void I2C_NumberOfBytesConfig(I2C_TypeDef *I2Cx, uint8_t Number_Bytes)
Configures the number of bytes to be transmitted/received.
void I2C_AutoEndCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data...
void I2C_GenerateSTART(I2C_TypeDef *I2Cx, FunctionalState NewState)
Generates I2Cx communication START condition.
void assert_param(int val)
void I2C_GeneralCallCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables the I2C general call mode.
static I2C_TypeDef * I2Cx
uint32_t I2C_DigitalFilter
FlagStatus I2C_GetFlagStatus(I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
Checks whether the specified I2C flag is set or not.
#define IS_FUNCTIONAL_STATE(STATE)
#define IS_RELOAD_END_MODE(MODE)
#define I2C_Direction_Transmitter
#define I2C_CR1_NOSTRETCH
#define I2C_AcknowledgedAddress_7bit
#define I2C_AnalogFilter_Enable
void I2C_DeInit(I2C_TypeDef *I2Cx)
Deinitializes the I2Cx peripheral registers to their default reset values.
void I2C_OwnAddress2Config(I2C_TypeDef *I2Cx, uint16_t Address, uint8_t Mask)
Configures the I2C slave own address 2 and mask.
void I2C_StopModeCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables I2C wakeup from stop mode.
#define IS_I2C_DIGITAL_FILTER(FILTER)
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
void I2C_ClearITPendingBit(I2C_TypeDef *I2Cx, uint32_t I2C_IT)
Clears the I2Cx's interrupt pending bits.
This file contains all the functions prototypes for the RCC firmware library.
void I2C_StructInit(I2C_InitTypeDef *I2C_InitStruct)
Fills each I2C_InitStruct member with its default value.
void I2C_IdleClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables I2C Idle Clock Timeout (Bus idle SCL and SDA high detection). ...
ITStatus I2C_GetITStatus(I2C_TypeDef *I2Cx, uint32_t I2C_IT)
Checks whether the specified I2C interrupt has occurred or not.
#define IS_I2C_OWN_ADDRESS1(ADDRESS1)
#define TIMING_CLEAR_MASK
void I2C_Cmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables the specified I2C peripheral.
void I2C_CalculatePEC(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables I2C PEC calculation.
#define IS_I2C_MODE(MODE)
void I2C_ReloadCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables the I2C nbytes reload mode.
#define IS_I2C_DIRECTION(DIRECTION)
uint8_t I2C_GetPEC(I2C_TypeDef *I2Cx)
Returns the I2C PEC.
void I2C_SlaveAddressConfig(I2C_TypeDef *I2Cx, uint16_t Address)
Configures the slave address to be transmitted after start generation.
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_10BitAddressHeaderCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables the I2C 10-bit header only mode with read direction.
uint8_t I2C_GetAddressMatched(I2C_TypeDef *I2Cx)
Returns the I2C slave matched address .
#define IS_I2C_OWN_ADDRESS2_MASK(MASK)
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 ...
This file contains all the functions prototypes for the I2C firmware library.
void I2C_DualAddressCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables the I2C own address 2.
I2C Init structure definition.
void I2C_StretchClockCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables the I2C Clock stretching.
void I2C_SlaveByteControlCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables the I2C slave byte control.
#define IS_I2C_GET_IT(IT)
void I2C_TimeoutBConfig(I2C_TypeDef *I2Cx, uint16_t Timeout)
Configures the I2C Bus Timeout B (SCL cumulative Timeout).
#define IS_I2C_CLEAR_IT(IT)
void I2C_GenerateSTOP(I2C_TypeDef *I2Cx, FunctionalState NewState)
Generates I2Cx communication STOP condition.
void I2C_ClearFlag(I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
Clears the I2Cx's pending flags.
void I2C_SendData(I2C_TypeDef *I2Cx, uint8_t Data)
Sends a data byte through the I2Cx peripheral.
#define IS_I2C_ACKNOWLEDGE_ADDRESS(ADDRESS)
#define IS_START_STOP_MODE(MODE)
#define IS_I2C_GET_FLAG(FLAG)
Inter-integrated Circuit Interface.
uint32_t I2C_ReadRegister(I2C_TypeDef *I2Cx, uint8_t I2C_Register)
Reads the specified I2C register and returns its value.
#define I2C_Direction_Receiver
uint8_t I2C_ReceiveData(I2C_TypeDef *I2Cx)
Returns the most recent received data by the I2Cx peripheral.
uint32_t I2C_AnalogFilter
void I2C_10BitAddressingModeCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables the I2C 10-bit addressing mode for the master.
#define RCC_APB1Periph_I2C2
void I2C_SMBusAlertCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables I2C SMBus alert.
void I2C_SoftwareResetCmd(I2C_TypeDef *I2Cx)
Enables or disables the specified I2C software reset.
void I2C_PECRequestCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
Enables or disables I2C PEC transmission/reception request.
#define IS_I2C_ALL_PERIPH(PERIPH)