STM8L15x Standard Peripherals Drivers: stm8l15x_i2c.h File Reference

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_i2c.h File Reference

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

#include "stm8l15x.h"

Go to the source code of this file.

Defines

#define I2C_MAX_FAST_FREQ   ((uint32_t)400000)
#define I2C_MAX_STANDARD_FREQ   ((uint32_t)100000)
#define IS_I2C_ACK_POSITION(POSITION)
 Macro used by the assert function to check the different acknowledgement position.
#define IS_I2C_ACK_STATE(STATE)
 Macro used by the assert function to check the different acknowledgement configuration.
#define IS_I2C_ACKNOWLEDGE_ADDRESS(ADDMODE)
 Macro used by the assert function to check the different I2C addressing modes.
#define IS_I2C_ADDRESS(ADD)   (((ADD) & (uint8_t)0x01) == (uint8_t)0x00)
 Macro used by the assert function to check the different I2C address The address must be even.
#define IS_I2C_CLEAR_FLAG(FLAG)   ((((uint16_t)(FLAG) & (uint16_t)0xFD00) == 0x00) && ((uint16_t)(FLAG) != 0x00))
 Macro used by the assert function to check the I2C flags to clear.
#define IS_I2C_CLEAR_IT(IT)   ((((uint16_t)(IT) & (uint16_t)0xDC00) == 0x00) && ((uint16_t)(IT) != 0x00))
 Macro used by the assert function to check the different I2C possible pending bits to clear by writing 0.
#define IS_I2C_CONFIG_IT(IT)   ((((uint16_t)(IT) & (uint16_t)0xFFF8) == 0x00) && ((uint16_t)(IT) != 0x00))
 Macro used by the assert_param function in order to check the different sensitivity values for the Interrupts.
#define IS_I2C_DIRECTION(DIR)
 Macro used by the assert function to check the different I2C communication direction.
#define IS_I2C_DUTY_CYCLE(CYCLE)
 Macro used by the assert function to check the different I2C duty cycles.
#define IS_I2C_EVENT(EVENT)
 Macro used by the assert function to check the different I2C possible events.
#define IS_I2C_GET_FLAG(FLAG)
 Macro used by the assert function to check the different I2C flags.
#define IS_I2C_GET_IT(IT)
 Macro used by the assert function to check the different I2C possible pending bits.
#define IS_I2C_MODE(MODE)
 Macro used by the assert function to check the different functions parameters.
#define IS_I2C_OUTPUT_CLOCK_FREQ(FREQ)   (((FREQ) >= (uint8_t)1) && ((FREQ) <= I2C_MAX_FAST_FREQ))
 Macro used by the assert function to check that I2C Output clock frequency must be between 1Hz and 400kHz.
#define IS_I2C_OWN_ADDRESS(ADDRESS)   ((ADDRESS) <= (uint16_t)0x03FF)
 Macro used by the assert function to check the different I2C possible own address.
#define IS_I2C_PEC_POSITION(POSITION)
 Macro used by the assert function to check the different I2C PEC positions.
#define IS_I2C_REGISTER(REGISTER)
 Macro used by the assert function to check the different I2C registers.
#define IS_I2C_SMBUS_ALERT(ALERT)
 Macro used by the assert function to check the different I2C SMBus Alert pin configuration.

Enumerations

enum  I2C_Ack_TypeDef { I2C_Ack_Disable = (uint8_t)0x00, I2C_Ack_Enable = (uint8_t)0x04 }
enum  I2C_AcknowledgedAddress_TypeDef { I2C_AcknowledgedAddress_7bit = (uint8_t)0x00, I2C_AcknowledgedAddress_10bit = (uint8_t)0x80 }
enum  I2C_AckPosition_TypeDef { I2C_AckPosition_Current = (uint8_t)0x00, I2C_AckPosition_Next = (uint8_t)0x08 }
enum  I2C_Direction_TypeDef { I2C_Direction_Transmitter = (uint8_t)0x00, I2C_Direction_Receiver = (uint8_t)0x01 }
 

Warning: the values correspond to the ADD0 bit position in the OARL register.

More...
enum  I2C_DutyCycle_TypeDef { I2C_DutyCycle_2 = (uint8_t)0x00, I2C_DutyCycle_16_9 = (uint8_t)0x40 }
enum  I2C_Event_TypeDef {
  I2C_EVENT_MASTER_MODE_SELECT = (uint16_t)0x0301, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED = (uint16_t)0x0782, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED = (uint16_t)0x0302, I2C_EVENT_MASTER_MODE_ADDRESS10 = (uint16_t)0x0308,
  I2C_EVENT_MASTER_BYTE_RECEIVED = (uint16_t)0x0340, I2C_EVENT_MASTER_BYTE_TRANSMITTING = (uint16_t)0x0780, I2C_EVENT_MASTER_BYTE_TRANSMITTED = (uint16_t)0x0784, I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED = (uint16_t)0x0202,
  I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED = (uint16_t)0x0682, I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED = (uint16_t)0x8200, I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED = (uint16_t)0x8680, I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED = (uint16_t)0x1200,
  I2C_EVENT_SLAVE_BYTE_RECEIVED = (uint16_t)0x0240, I2C_EVENT_SLAVE_STOP_DETECTED = (uint16_t)0x0010, I2C_EVENT_SLAVE_BYTE_TRANSMITTED = (uint16_t)0x0684, I2C_EVENT_SLAVE_BYTE_TRANSMITTING = (uint16_t)0x0680,
  I2C_EVENT_SLAVE_ACK_FAILURE = (uint16_t)0x0004
}
 

I2C possible events Values convention: 0xXXYY XX = Event SR3 corresponding value YY = Event SR1 corresponding value.

More...
enum  I2C_FLAG_TypeDef {
  I2C_FLAG_TXE = (uint16_t)0x0180, I2C_FLAG_RXNE = (uint16_t)0x0140, I2C_FLAG_STOPF = (uint16_t)0x0110, I2C_FLAG_ADD10 = (uint16_t)0x0108,
  I2C_FLAG_BTF = (uint16_t)0x0104, I2C_FLAG_ADDR = (uint16_t)0x0102, I2C_FLAG_SB = (uint16_t)0x0101, I2C_FLAG_SMBALERT = (uint16_t)0x0280,
  I2C_FLAG_TIMEOUT = (uint16_t)0x0240, I2C_FLAG_WUFH = (uint16_t)0x0220, I2C_FLAG_PECERR = (uint16_t)0x0210, I2C_FLAG_OVR = (uint16_t)0x0208,
  I2C_FLAG_AF = (uint16_t)0x0204, I2C_FLAG_ARLO = (uint16_t)0x0202, I2C_FLAG_BERR = (uint16_t)0x0201, I2C_FLAG_DUALF = (uint16_t)0x0380,
  I2C_FLAG_SMBHOST = (uint16_t)0x0340, I2C_FLAG_SMBDEFAULT = (uint16_t)0x0320, I2C_FLAG_GENCALL = (uint16_t)0x0310, I2C_FLAG_TRA = (uint16_t)0x0304,
  I2C_FLAG_BUSY = (uint16_t)0x0302, I2C_FLAG_MSL = (uint16_t)0x0301
}
 

Elements values convention: 0xXXYY X = SRx registers index X = 1 : SR1 X = 2 : SR2 X = 3 : SR3 Y = Flag mask in the register.

More...
enum  I2C_IT_TypeDef {
  I2C_IT_ERR = (uint16_t)0x0001, I2C_IT_EVT = (uint16_t)0x0002, I2C_IT_BUF = (uint16_t)0x0004, I2C_IT_TXE = (uint16_t)0x1680,
  I2C_IT_RXNE = (uint16_t)0x1640, I2C_IT_STOPF = (uint16_t)0x1210, I2C_IT_ADD10 = (uint16_t)0x1208, I2C_IT_BTF = (uint16_t)0x1204,
  I2C_IT_ADDR = (uint16_t)0x1202, I2C_IT_SB = (uint16_t)0x1201, I2C_IT_SMBALERT = (uint16_t)0x2180, I2C_IT_TIMEOUT = (uint16_t)0x2140,
  I2C_IT_WUFH = (uint16_t)0x2220, I2C_IT_PECERR = (uint16_t)0x2110, I2C_IT_OVR = (uint16_t)0x2108, I2C_IT_AF = (uint16_t)0x2104,
  I2C_IT_ARLO = (uint16_t)0x2102, I2C_IT_BERR = (uint16_t)0x2101
}
 

I2C Pending bits Elements values convention: 0xXYZZ X = SRx registers index X = 0 : ITR X = 1 : SR1 X = 2 : SR2 Y = Position of the corresponding Interrupt ZZ = flag mask in the dedicated register(X register)

More...
enum  I2C_Mode_TypeDef { I2C_Mode_I2C = (uint8_t)0x00, I2C_Mode_SMBusDevice = (uint8_t)0x02, I2C_Mode_SMBusHost = (uint8_t)0x0A }
enum  I2C_PECPosition_TypeDef { I2C_PECPosition_Current = (uint8_t)0x00, I2C_PECPosition_Next = (uint8_t)0x08 }
enum  I2C_Register_TypeDef {
  I2C_Register_CR1 = (uint8_t)0x00, I2C_Register_CR2 = (uint8_t)0x01, I2C_Register_FREQR = (uint8_t)0x02, I2C_Register_OARL = (uint8_t)0x03,
  I2C_Register_OARH = (uint8_t)0x04, I2C_Register_DR = (uint8_t)0x06, I2C_Register_SR1 = (uint8_t)0x07, I2C_Register_SR2 = (uint8_t)0x08,
  I2C_Register_SR3 = (uint8_t)0x09, I2C_Register_ITR = (uint8_t)0x0A, I2C_Register_CCRL = (uint8_t)0x0B, I2C_Register_CCRH = (uint8_t)0x0C,
  I2C_Register_TRISER = (uint8_t)0x0D, I2C_Register_PECR = (uint8_t)0x0E
}
enum  I2C_SMBusAlert_TypeDef { I2C_SMBusAlert_High = (uint8_t)0x00, I2C_SMBusAlert_Low = (uint8_t)0x01 }

Functions

void I2C_AcknowledgeConfig (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enable or Disable the I2C acknowledge feature.
void I2C_AckPositionConfig (I2C_TypeDef *I2Cx, I2C_AckPosition_TypeDef I2C_AckPosition)
 Selects the specified I2C Ack position.
void I2C_ARPCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C ARP.
void I2C_CalculatePEC (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables PEC calculation.
ErrorStatus I2C_CheckEvent (I2C_TypeDef *I2Cx, I2C_Event_TypeDef I2C_Event)
 =============================================================================== 1.
void I2C_ClearFlag (I2C_TypeDef *I2Cx, I2C_FLAG_TypeDef I2C_FLAG)
 Clear flags.
void I2C_ClearITPendingBit (I2C_TypeDef *I2Cx, I2C_IT_TypeDef I2C_IT)
 Clear IT pending bit.
void I2C_Cmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C peripheral.
void I2C_DeInit (I2C_TypeDef *I2Cx)
 Deinitializes the I2C peripheral registers to their default reset values.
void I2C_DMACmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C DMA requests .
void I2C_DMALastTransferCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Specifies that the next DMA transfer is the last one .
void I2C_DualAddressCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C dual addressing mode.
void I2C_FastModeDutyCycleConfig (I2C_TypeDef *I2Cx, I2C_DutyCycle_TypeDef I2C_DutyCycle)
 Selects I2C fast mode duty cycle.
void I2C_GeneralCallCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C General Call feature.
void I2C_GenerateSTART (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2C communication START condition.
void I2C_GenerateSTOP (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2C communication STOP condition.
FlagStatus I2C_GetFlagStatus (I2C_TypeDef *I2Cx, I2C_FLAG_TypeDef I2C_FLAG)
 =============================================================================== 3.
ITStatus I2C_GetITStatus (I2C_TypeDef *I2Cx, I2C_IT_TypeDef I2C_IT)
 Checks whether the specified I2C interrupt has occurred or not.
I2C_Event_TypeDef I2C_GetLastEvent (I2C_TypeDef *I2Cx)
 =============================================================================== 2.
uint8_t I2C_GetPEC (I2C_TypeDef *I2Cx)
 Returns PEC value.
void I2C_Init (I2C_TypeDef *I2Cx, uint32_t OutputClockFrequency, uint16_t OwnAddress, I2C_Mode_TypeDef I2C_Mode, I2C_DutyCycle_TypeDef I2C_DutyCycle, I2C_Ack_TypeDef I2C_Ack, I2C_AcknowledgedAddress_TypeDef I2C_AcknowledgedAddress)
 Initializes the I2C according to the specified parameters in standard or fast mode.
void I2C_ITConfig (I2C_TypeDef *I2Cx, I2C_IT_TypeDef I2C_IT, FunctionalState NewState)
 Enables or disables the specified I2C interrupt.
void I2C_OwnAddress2Config (I2C_TypeDef *I2Cx, uint8_t Address)
 Configures the specified I2C own address2.
void I2C_PECPositionConfig (I2C_TypeDef *I2Cx, I2C_PECPosition_TypeDef I2C_PECPosition)
 Selects I2C PEC position.
uint8_t I2C_ReadRegister (I2C_TypeDef *I2Cx, I2C_Register_TypeDef I2C_Register)
 Reads the specified I2C register and returns its value.
uint8_t I2C_ReceiveData (I2C_TypeDef *I2Cx)
 Returns the most recent received data.
void I2C_Send7bitAddress (I2C_TypeDef *I2Cx, uint8_t Address, I2C_Direction_TypeDef I2C_Direction)
 Transmits the 7-bit address (to select the) slave device.
void I2C_SendData (I2C_TypeDef *I2Cx, uint8_t Data)
 Send a byte by writing in the DR register.
void I2C_SMBusAlertConfig (I2C_TypeDef *I2Cx, I2C_SMBusAlert_TypeDef I2C_SMBusAlert)
 Drives the SMBusAlert pin high or low.
void I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C software reset.
void I2C_StretchClockCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C clock stretching.
void I2C_TransmitPEC (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables PEC transfer.

Detailed Description

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

Author:
MCD Application Team
Version:
V1.5.0
Date:
13-May-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 stm8l15x_i2c.h.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com