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...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!