MCCI Trusted Bootloader
Simple trusted bootloader and tools for small embedded systems
mcci_bootloader_device_i2c_bus_stm32l0.h File Reference
#include "mcci_bootloader_device_i2c_bus_stm32l0_types.h"
#include "mcci_bootloader_device_i2c_device_stm32l0_types.h"
#include "mcci_bootloader_device_i2c_bus.h"

Go to the source code of this file.

Data Structures

struct  McciBootloaderDeviceI2cBusStm32l0_Config_t
 
struct  McciBootloaderDeviceI2cBusStm32l0_Contents_t
 
union  McciBootloaderDeviceI2cBusStm32l0_t
 

Macros

#define _mcci_bootloader_device_i2c_bus_stm32l0_h_   /* prevent multiple includes */
 
#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_100K   UINT32_C(0x30922727)
 value for 100k ("standard mode")
 
#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_1M   UINT32_C(0x0050090F)
 value for 1M ("fast mode plus")
 
#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_400K   UINT32_C(0x10640e14)
 value for 400k ("fast mode")
 
#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_NOT_SUPPORTED   UINT32_C(0xFFFFFFFF)
 value to use for timing parameters when a speed is not supported.
 

Functions

McciBootloaderDeviceI2cBus_t * McciBootloader_Stm32L0Interface_initI2cBus (void *pRamForBus, size_t sizeForBus, const McciBootloaderDeviceI2cBusStm32l0_Config_t *pConfig, uint32_t timingr100k, uint32_t timingr400k, uint32_t timingr1M)
 Initialize an I2C bus controller driver on an STM32L0.
 
static McciBootloaderDeviceI2cBusStm32l0_t * McciBootloaderDevice_getI2cBusStm32l0 (McciBootloaderDevice_t *pDevice)
 upcast from device to enclosing McciBootloaderDeviceI2cBusStm32l0_t
 
static McciBootloaderDeviceI2cBusStm32l0_t * McciBootloaderDeviceI2cBus_getI2cBusStm32l0 (McciBootloaderDeviceI2cBus_t *pDevice)
 upcast from i2c controller device to enclosing McciBootloaderDeviceI2cBusStm32l0_t
 

Variables

const McciBootloaderDeviceI2cBusStm32l0_Config_t gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c1
 global config for I2C1. Linker discards this if not used.
 
const McciBootloaderDeviceI2cBusStm32l0_Config_t gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c2
 global config for I2C2. Linker discards this if not used.
 
const McciBootloaderDeviceI2cBusStm32l0_Config_t gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c3
 global config for I2C3. Linker discards this if not used.
 

Macro Definition Documentation

◆ _mcci_bootloader_device_i2c_bus_stm32l0_h_

#define _mcci_bootloader_device_i2c_bus_stm32l0_h_   /* prevent multiple includes */

Definition at line 23 of file mcci_bootloader_device_i2c_bus_stm32l0.h.

◆ MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_100K

#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_100K   UINT32_C(0x30922727)

value for 100k ("standard mode")

|-------—|--------—|----------------------------—|-------—|

Field Value Time Comments
PRESC 3 t_PRESC = 4 × 31.25 = 125 ns free choice, keeps counts in 8 bits
SCLL 39 (0x27) 40 x 125 = 5000 ns >= t_LOW min, 4.7 us
SCLH 39 (0x27) 40 x 125 = 5000 ns >= t_HIGH min, 4.0 us
SDADEL 2 2 x 125 = 250 ns >= ~156 ns (fall time - filter - 3*t_I2CCLK); <= 3.45 us max
SCLDEL 9 10 x 125 = 1250 ns >= t_r + t_SU DAT = 1000+ 250

Actual is about 95 kHz

Definition at line 124 of file mcci_bootloader_device_i2c_bus_stm32l0.h.

◆ MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_1M

#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_1M   UINT32_C(0x0050090F)

value for 1M ("fast mode plus")

|-------—|--------—|----------------------------—|-------—|

Field Value Time Comments
PRESC 0 t_PRESC = 1 × 31.25 = 31.25 ns free choice
SCLL 15 (0x0F) 16 x 31.25 = 500 ns >= t_LOW min, 0.5 us
SCLH 9 10 x 31.25 = 312.5 ns >= t_HIGH min, 0.26 us
SDADEL 0 0 ns fast edges + analog filter cover hold time
SCLDEL 5 6 x 31.25 = 187.5 ns >= t_r + t_SU DAT = 170 ns

Actual is approximately 965 kHz

Definition at line 160 of file mcci_bootloader_device_i2c_bus_stm32l0.h.

◆ MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_400K

#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_400K   UINT32_C(0x10640e14)

value for 400k ("fast mode")

|-------—|--------—|----------------------------—|-------—|

Field Value Time Comments
PRESC 1 t_PRESC = 2 × 31.25 = 62.5 ns free choice
SCLL 20 (0x14) 21 x 62.5 = 1312.5 ns >= t_LOW min, 1.3 us
SCLH 14 (0x0E) 15 x 62.5 = 937.5 ns >= t_HIGH min, 0.6 us
SDADEL 4 4 x 62.5 = 250 ns >= ~156 ns, <= 0.9 us
SCLDEL 6 7 x 62.5 = 437.5 ns >= t_r + t_SU DAT = 400 ns

Actual is approximately 388 kHz

Definition at line 142 of file mcci_bootloader_device_i2c_bus_stm32l0.h.

◆ MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_NOT_SUPPORTED

#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_NOT_SUPPORTED   UINT32_C(0xFFFFFFFF)

value to use for timing parameters when a speed is not supported.

Definition at line 106 of file mcci_bootloader_device_i2c_bus_stm32l0.h.

Function Documentation

◆ McciBootloader_Stm32L0Interface_initI2cBus()

McciBootloaderDeviceI2cBus_t * McciBootloader_Stm32L0Interface_initI2cBus ( void *  pRamForBus,
size_t  sizeForBus,
const McciBootloaderDeviceI2cBusStm32l0_Config_t *  pConfig,
uint32_t  timingr100k,
uint32_t  timingr400k,
uint32_t  timingr1M 
)

Initialize an I2C bus controller driver on an STM32L0.

Parameters
pRamForBusPointer to a block of RAM to be used for the driver instance data
sizeForBusSize of the block of RAM. The driver checks this against the required size (must be >= sizeof(McciBootloaderDeviceI2cBusStm32l0_t))
pConfigConfiguration of the I2C block; selects the controller, etc.
timingr100kValue to use in timing register for 100kHz I2C operations
timingr400kValue to use in timing register for 400kHz I2C operations, or MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_NOT_SUPPORTED
timingr1MValue to use in timing register for 1MHz I2C operations, or MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_NOT_SUPPORTED
Returns
pointer to initialized McciBootloaderDeviceI2cBus_t object.

For simplicity, the details of the pin mapping for the I2C I/O pins is left to the caller to control. Please set up the pins prior to using the bus.

This funcion does an implicit device begin on the initialized bus.

Definition at line 196 of file mccibootloader_stm32l0_i2c_bus.c.

References i2cBus_deviceMethods, i2cBus_i2cBusMethods, MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_NOT_SUPPORTED, McciBootloaderError_I2cBegin, McciBootloaderError_InternalConsistency, and McciBootloaderPlatform_fail().

Referenced by McciBootloaderBoard_Catena5230_systemInit().

◆ McciBootloaderDevice_getI2cBusStm32l0()

static McciBootloaderDeviceI2cBusStm32l0_t * McciBootloaderDevice_getI2cBusStm32l0 ( McciBootloaderDevice_t *  pDevice)
inlinestatic

upcast from device to enclosing McciBootloaderDeviceI2cBusStm32l0_t

Parameters
pDevicePointer to device
Returns
pointer to enclosing object
Note
This is only safe to call when you know that the device is part of a STM32L0 I2C Bus Controller driver instance.

Definition at line 177 of file mcci_bootloader_device_i2c_bus_stm32l0.h.

Referenced by i2cBusBegin(), and i2cBusEnd().

◆ McciBootloaderDeviceI2cBus_getI2cBusStm32l0()

static McciBootloaderDeviceI2cBusStm32l0_t * McciBootloaderDeviceI2cBus_getI2cBusStm32l0 ( McciBootloaderDeviceI2cBus_t *  pDevice)
inlinestatic

upcast from i2c controller device to enclosing McciBootloaderDeviceI2cBusStm32l0_t

Parameters
pDevicePointer to i2c controller device
Returns
pointer to enclosing object
Note
This is only safe to call when you know that the device is part of a STM32L0 I2C Bus Controller driver instance.

Definition at line 195 of file mcci_bootloader_device_i2c_bus_stm32l0.h.

Referenced by i2cBusAddDevice(), i2cBusRead(), and i2cBusWrite().

Variable Documentation

◆ gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c1

const McciBootloaderDeviceI2cBusStm32l0_Config_t gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c1
extern

global config for I2C1. Linker discards this if not used.

Definition at line 91 of file mccibootloader_stm32l0_i2c_bus.c.

◆ gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c2

const McciBootloaderDeviceI2cBusStm32l0_Config_t gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c2
extern

global config for I2C2. Linker discards this if not used.

Definition at line 104 of file mccibootloader_stm32l0_i2c_bus.c.

Referenced by McciBootloaderBoard_Catena5230_systemInit().

◆ gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c3

const McciBootloaderDeviceI2cBusStm32l0_Config_t gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c3
extern

global config for I2C3. Linker discards this if not used.

Definition at line 117 of file mccibootloader_stm32l0_i2c_bus.c.