![]() |
MCCI Trusted Bootloader
Simple trusted bootloader and tools for small embedded systems
|
#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. | |
| #define _mcci_bootloader_device_i2c_bus_stm32l0_h_ /* prevent multiple includes */ |
Definition at line 23 of file mcci_bootloader_device_i2c_bus_stm32l0.h.
| #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.
| #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.
| #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.
| #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.
| 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.
| pRamForBus | Pointer to a block of RAM to be used for the driver instance data |
| sizeForBus | Size of the block of RAM. The driver checks this against the required size (must be >= sizeof(McciBootloaderDeviceI2cBusStm32l0_t)) |
| pConfig | Configuration of the I2C block; selects the controller, etc. |
| timingr100k | Value to use in timing register for 100kHz I2C operations |
| timingr400k | Value to use in timing register for 400kHz I2C operations, or MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_NOT_SUPPORTED |
| timingr1M | Value to use in timing register for 1MHz I2C operations, or MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_NOT_SUPPORTED |
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().
|
inlinestatic |
upcast from device to enclosing McciBootloaderDeviceI2cBusStm32l0_t
| pDevice | Pointer to device |
Definition at line 177 of file mcci_bootloader_device_i2c_bus_stm32l0.h.
Referenced by i2cBusBegin(), and i2cBusEnd().
|
inlinestatic |
upcast from i2c controller device to enclosing McciBootloaderDeviceI2cBusStm32l0_t
| pDevice | Pointer to i2c controller device |
Definition at line 195 of file mcci_bootloader_device_i2c_bus_stm32l0.h.
Referenced by i2cBusAddDevice(), i2cBusRead(), and i2cBusWrite().
|
extern |
global config for I2C1. Linker discards this if not used.
Definition at line 91 of file mccibootloader_stm32l0_i2c_bus.c.
|
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().
|
extern |
global config for I2C3. Linker discards this if not used.
Definition at line 117 of file mccibootloader_stm32l0_i2c_bus.c.