This pull request adds the configuration.c and configuration.h files that provide the setup for the I2C1 peripheral on the STM32 microcontroller. The I2C peripheral is configured to operate in standard mode at 100 kHz using GPIO pins for I2C communication.
Changes:
configuration.c: Contains the implementation of the config_i2c() function, which:
Enables the necessary clocks for GPIOB and I2C1.
Configures GPIOB pins for I2C1_SCL and I2C1_SDA in open-drain alternate function mode.
Disables the I2C peripheral before configuration to ensure a clean setup.
Sets the I2C clock frequency, rise time, and CCR value for 100 kHz communication speed.
Enables the I2C peripheral for communication.
configuration.h: Defines constants for the I2C1 configuration, including:
I2C1_TRISE_100KHZ: The rise time for 100 kHz I2C standard mode.
I2C1_CCR_100KHZ: The CCR value for 100 kHz speed.
I2C_CR2_FREQ_36MHZ: The system clock frequency setting for I2C operation at 36 MHz.
This configuration assumes a system clock of 36 MHz, and adjustments may be necessary for different clock frequencies.
Purpose:
The addition of these files enables the STM32 to communicate over I2C at a standard 100 kHz speed, which can be used for various peripherals, such as external sensors or displays.
This pull request adds the
configuration.c
andconfiguration.h
files that provide the setup for the I2C1 peripheral on the STM32 microcontroller. The I2C peripheral is configured to operate in standard mode at 100 kHz using GPIO pins for I2C communication.Changes:
configuration.c
: Contains the implementation of theconfig_i2c()
function, which:configuration.h
: Defines constants for the I2C1 configuration, including:I2C1_TRISE_100KHZ
: The rise time for 100 kHz I2C standard mode.I2C1_CCR_100KHZ
: The CCR value for 100 kHz speed.I2C_CR2_FREQ_36MHZ
: The system clock frequency setting for I2C operation at 36 MHz.This configuration assumes a system clock of 36 MHz, and adjustments may be necessary for different clock frequencies.
Purpose:
The addition of these files enables the STM32 to communicate over I2C at a standard 100 kHz speed, which can be used for various peripherals, such as external sensors or displays.