
Contents UM1566
2/66 Doc ID 023577 Rev 1
Contents
1 CPAL overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 CPAL architecture description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 CPAL application hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Communication layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.1 CPAL main structures (stm32xxxx_i2c_cpal.h) . . . . . . . . . . . . . . . . . . . . 9
2.2.2 CPAL communication functions (stm32xxxx_i2c_cpal.c) . . . . . . . . . . . . 16
2.3 User application interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.1 Configuration interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.2 User callback interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.4 Low layer interface (hardware abstraction layer HAL) . . . . . . . . . . . . . . . 24
3 CPAL functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1.1 CPAL_I2C_Init() functional description . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1.2 CPAL_I2C_DeInit() functional description . . . . . . . . . . . . . . . . . . . . . . . 29
3.1.3 CPAL_I2C_StructInit() functional description . . . . . . . . . . . . . . . . . . . . . 31
3.2 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.2.1 CPAL_I2C_Read() functional description . . . . . . . . . . . . . . . . . . . . . . . 32
3.2.2 CPAL_I2C_Write() functional description . . . . . . . . . . . . . . . . . . . . . . . . 34
3.2.3 CPAL_I2C_Listen () functional description: . . . . . . . . . . . . . . . . . . . . . . 35
3.2.4 CPAL_I2C_IsDeviceReady() functional description . . . . . . . . . . . . . . . . 35
3.2.5 CPAL interrupts and DMA management . . . . . . . . . . . . . . . . . . . . . . . . 36
3.3 Event and error management (user callbacks) . . . . . . . . . . . . . . . . . . . . 38
3.3.1 Timeout management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4 How to use and customize the CPAL library (step by step) . . . . . . . . 42
4.1 Basic configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.1.1 Select peripherals to be used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.1.2 Configure transfer options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.1.3 Select and configure user and error callbacks . . . . . . . . . . . . . . . . . . . . 43
4.1.4 Configure timeout management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.1.5 Set Events, Errors and DMA interrupt priorities . . . . . . . . . . . . . . . . . . . 44
4.1.6 Configure the Log Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44