HAL Library 16- I2C for STM32Fxxx devices

Here it is. After some email for I2C library for HAL, I’ve made it. I ported my old for F4 to HAL based libraries for F0/F4/F7 series.

I added method to read single byte, multi bytes, write single byte, write multi bytes, write/read single byte from/to register which has 16-bit address size.

Library

Read more about new HAL libraries

Features

  • Supports up to 4 I2C peripherals
  • Supports different pinouts selectable on initialization
    • Supports custom pin combinations
  • Supports multiple read/write modes
  • Based on HAL drivers for maximal portability between series

Dependencies

  • HAL
  • TM
    • STM32F4xxx HAL
    • defines.h
    • TM GPIO

Library pinouts

PINS PACK 1 PINS PACK 2 PINS PACK 3 PINS PACK 4
I2Cx SCL SDA SCL SDA SCL SDA SCL SDA
I2C1 PB6 PB7 PB8 PB9 PB6 PB9
I2C2 PB10 PB11 PF1 PF0 PH4 PH5
I2C3 PA8 PC9 PH7 PH8
I2C4 PD12 PD13 PF1 PF0 PF14 PF15 PH11 PH12

Functions and enumerations

Example 1

Example 2

Example 3

Project are available on Github, download all libraries below.

tilz0R

Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...