STM8L15x Standard Peripherals Drivers: Initialization and Configuration functions

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

Initialization and Configuration functions

Initialization and Configuration functions. More...

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_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_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.
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_OwnAddress2Config (I2C_TypeDef *I2Cx, uint8_t Address)
 Configures the specified I2C own address2.
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_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.

Detailed Description

Initialization and Configuration functions.

 ===============================================================================
                   Initialization and Configuration functions
 ===============================================================================


Function Documentation

void I2C_AcknowledgeConfig ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enable or Disable the I2C acknowledge feature.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
NewState,:Specifies the new state of the I2C acknowledge. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 465 of file stm8l15x_i2c.c.

References I2C_struct::CR2, DISABLE, I2C_CR2_ACK, and IS_FUNCTIONAL_STATE.

void I2C_AckPositionConfig ( I2C_TypeDef I2Cx,
I2C_AckPosition_TypeDef  I2C_AckPosition 
)

Selects the specified I2C Ack position.

Note:
This function must be called before data reception starts.
Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
I2C_AckPosition,:specifies the Ack position. This parameter can be one of the following values:
  • I2C_AckPosition_Current: Acknowledge on the current byte
  • I2C_AckPosition_Next: Acknowledge on the next byte
Return values:
None

Definition at line 539 of file stm8l15x_i2c.c.

References I2C_struct::CR2, I2C_CR2_POS, and IS_I2C_ACK_POSITION.

void I2C_ARPCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C ARP.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
NewState,:Specifies the new state of the I2C ARP This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 440 of file stm8l15x_i2c.c.

References I2C_struct::CR1, DISABLE, I2C_CR1_ARP, and IS_FUNCTIONAL_STATE.

void I2C_Cmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C peripheral.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
NewState,:Indicate the new I2C peripheral state. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 289 of file stm8l15x_i2c.c.

References I2C_struct::CR1, DISABLE, I2C_CR1_PE, and IS_FUNCTIONAL_STATE.

void I2C_DeInit ( I2C_TypeDef I2Cx)

Deinitializes the I2C peripheral registers to their default reset values.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
Return values:
None

Definition at line 135 of file stm8l15x_i2c.c.

References I2C_struct::CCRH, I2C_struct::CCRL, I2C_struct::CR1, I2C_struct::CR2, I2C_struct::FREQR, I2C_CCRH_RESET_VALUE, I2C_CCRL_RESET_VALUE, I2C_CR1_RESET_VALUE, I2C_CR2_RESET_VALUE, I2C_FREQR_RESET_VALUE, I2C_ITR_RESET_VALUE, I2C_OAR2_RESET_VALUE, I2C_OARH_RESET_VALUE, I2C_OARL_RESET_VALUE, I2C_TRISER_RESET_VALUE, I2C_struct::ITR, I2C_struct::OAR2, I2C_struct::OARH, I2C_struct::OARL, and I2C_struct::TRISER.

void I2C_DualAddressCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C dual addressing mode.

Parameters:
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C dual addressing mode. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 512 of file stm8l15x_i2c.c.

References DISABLE, I2C_OAR2_ENDUAL, IS_FUNCTIONAL_STATE, and I2C_struct::OAR2.

void I2C_FastModeDutyCycleConfig ( I2C_TypeDef I2Cx,
I2C_DutyCycle_TypeDef  I2C_DutyCycle 
)

Selects I2C fast mode duty cycle.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
I2C_DutyCycle,:specifies the fast mode duty cycle. This parameter can be one of the following values:
  • I2C_DutyCycle_2: I2C fast mode Tlow/Thigh = 2
  • I2C_DutyCycle_16_9: I2C fast mode Tlow/Thigh = 16/9
Return values:
None

Definition at line 586 of file stm8l15x_i2c.c.

References I2C_struct::CCRH, I2C_CCRH_DUTY, I2C_DutyCycle_16_9, and IS_I2C_DUTY_CYCLE.

void I2C_GeneralCallCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C General Call feature.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
NewState,:State of the General Call feature. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 314 of file stm8l15x_i2c.c.

References I2C_struct::CR1, DISABLE, I2C_CR1_ENGC, and IS_FUNCTIONAL_STATE.

void I2C_GenerateSTART ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Generates I2C communication START condition.

Note:
CCR must be programmed, i.e. I2C_Init function must have been called with a valid I2C_ClockSpeed
Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
NewState,:Enable or disable the start condition. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 341 of file stm8l15x_i2c.c.

References I2C_struct::CR2, DISABLE, I2C_CR2_START, and IS_FUNCTIONAL_STATE.

void I2C_GenerateSTOP ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Generates I2C communication STOP condition.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
NewState,:Enable or disable the stop condition. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 366 of file stm8l15x_i2c.c.

References I2C_struct::CR2, DISABLE, I2C_CR2_STOP, and IS_FUNCTIONAL_STATE.

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.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
OutputClockFrequency,:Specifies the output clock frequency in Hz.
OwnAddress,:Specifies the own address.
I2C_Mode,:Specifies the addressing mode to apply. This parameter can be one of the following values:
  • I2C_Mode_I2C: I2C mode
  • I2C_Mode_SMBusDevice: SMBus Device mode
  • I2C_Mode_SMBusHost: SMBus Host mode
I2C_DutyCycle,:Specifies the duty cycle to apply in fast mode. This parameter can be one of the following values:
  • I2C_DutyCycle_2: I2C fast mode Tlow/Thigh = 2
  • I2C_DutyCycle_16_9: I2C fast mode Tlow/Thigh = 16/9
Note:
The I2C_DutyCycle parameter doesn't have impact when the OutputClockFrequency is lower than 100KHz.
Parameters:
I2C_Ack,:Specifies the acknowledge mode to apply. This parameter can be one of the following values:
  • I2C_Ack_Disable: No acknowledge
  • I2C_Ack_Enable: Acknowledge Enabled
I2C_AcknowledgedAddress,:Specifies the acknowledge address to apply. This parameter can be one of the following values:
  • I2C_AcknowledgedAddress_7bit: 7-bit slave address
  • I2C_AcknowledgedAddress_10bit: 10-bit slave address
Note:
To use the I2C at 400 KHz (in fast mode), the PCLK frequency (I2C peripheral input clock) must be a multiple of 10 MHz.
Return values:
None

Definition at line 178 of file stm8l15x_i2c.c.

References I2C_struct::CCRH, I2C_struct::CCRL, CLK_GetClockFreq(), I2C_struct::CR1, I2C_struct::CR2, I2C_struct::FREQR, I2C_CCRH_CCR, I2C_CCRH_DUTY, I2C_CCRH_FS, I2C_CCRL_CCR, I2C_CR1_PE, I2C_DutyCycle_2, I2C_FREQR_FREQ, I2C_MAX_STANDARD_FREQ, I2C_OARH_ADDCONF, IS_I2C_ACK_STATE, IS_I2C_ACKNOWLEDGE_ADDRESS, IS_I2C_DUTY_CYCLE, IS_I2C_MODE, IS_I2C_OUTPUT_CLOCK_FREQ, IS_I2C_OWN_ADDRESS, I2C_struct::OARH, I2C_struct::OARL, and I2C_struct::TRISER.

void I2C_OwnAddress2Config ( I2C_TypeDef I2Cx,
uint8_t  Address 
)

Configures the specified I2C own address2.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
Address,:specifies the 7bit I2C own address2.
Return values:
None.

Definition at line 488 of file stm8l15x_i2c.c.

References I2C_OAR2_ADD2, and I2C_struct::OAR2.

void I2C_Send7bitAddress ( I2C_TypeDef I2Cx,
uint8_t  Address,
I2C_Direction_TypeDef  I2C_Direction 
)

Transmits the 7-bit address (to select the) slave device.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
Address,:Specifies the slave address which will be transmitted.
I2C_Direction,:specifies whether the I2C device will be a Transmitter or a Receiver. This parameter can be one of the following values
  • I2C_Direction_Transmitter: Transmitter mode
  • I2C_Direction_Receiver: Receiver mode
Return values:
None

Definition at line 615 of file stm8l15x_i2c.c.

References I2C_struct::DR, I2C_Direction_Transmitter, IS_I2C_ADDRESS, IS_I2C_DIRECTION, OAR1_ADD0_Reset, and OAR1_ADD0_Set.

void I2C_SMBusAlertConfig ( I2C_TypeDef I2Cx,
I2C_SMBusAlert_TypeDef  I2C_SMBusAlert 
)

Drives the SMBusAlert pin high or low.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
I2C_SMBusAlert,:SMBusAlert pin state. This parameter can be one of the following values:
  • I2C_SMBusAlert_High: SMBAlert pin high
  • I2C_SMBusAlert_Low: SMBAlert pin Low
Return values:
None

Definition at line 559 of file stm8l15x_i2c.c.

References I2C_struct::CR2, I2C_CR2_ALERT, I2C_SMBusAlert_High, and IS_I2C_SMBUS_ALERT.

void I2C_SoftwareResetCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C software reset.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
NewState,:Specifies the new state of the I2C software reset. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 391 of file stm8l15x_i2c.c.

References I2C_struct::CR2, DISABLE, I2C_CR2_SWRST, and IS_FUNCTIONAL_STATE.

void I2C_StretchClockCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C clock stretching.

Parameters:
I2Cx,:where x can be 1 to select the specified I2C peripheral.
NewState,:Specifies the new state of the I2C Clock stretching. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 415 of file stm8l15x_i2c.c.

References I2C_struct::CR1, DISABLE, I2C_CR1_NOSTRETCH, and IS_FUNCTIONAL_STATE.

STM8S Firmware Library: Overview

 

 

 

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