MCCI Trusted Bootloader
Simple trusted bootloader and tools for small embedded systems
mccibootloaderboard_catena5230_systeminit.c
Go to the documentation of this file.
1/*
2
3Module: mccibootloaderboard_catena5230_systeminit.c
4
5Function:
6 McciBootloaderBoard_Catena5230_systemInit().
7
8Copyright and License:
9 This file copyright (C) 2026 by
10
11 MCCI Corporation
12 3520 Krums Corners Road
13 Ithaca, NY 14850
14
15 See accompanying LICENSE file for copyright and license information.
16
17Author:
18 Terry Moore, MCCI Corporation June 2026
19
20*/
21
23
24#include "mcci_bootloader.h"
27#include "mcci_bootloader_device_npm1300.h"
28#include "mcci_npm1300.h"
29#include "mcci_stm32l0xx.h"
30␌
31/****************************************************************************\
32|
33| Manifest constants & typedefs.
34|
35\****************************************************************************/
36
37
38
39/****************************************************************************\
40|
41| Read-only data.
42|
43\****************************************************************************/
44
45
46
47/****************************************************************************\
48|
49| Variables.
50|
51\****************************************************************************/
52
53McciBootloaderDeviceI2cBusStm32l0_t
55
56McciBootloaderDeviceI2cDeviceStm32l0_t
58
59McciBootloaderDeviceNpm1300_t *
61␌
62/*
63
64Name: McciBootloaderBoard_Catena5230_systemInit()
65
66Function:
67 System init platform method for Catena 5230 boards.
68
69Definition:
70 void McciBootloaderBoard_Catena5230_systemInit(
71 void
72 );
73
74Description:
75 This routine initializes the platform. First it does
76 the common initialization, then sets up the I2C bus and
77 finally the PMIC.
78
79Returns:
80 No explicit result.
81
82Notes:
83 Asserts if any failures occur.
84
85*/
86
87#define FUNCTION "McciBootloaderBoard_Catena5230_systemInit"
88
89void
91 void
92 )
93 {
94 // initialize things that are common for all Catena boards
95 // based on the 1sj module.
97
98 // set up the i2c bus for talking to the PMIC
99 McciBootloaderDeviceI2cBusStm32l0_t * const pI2cBus =
101
102 // initI2cBus will call the platform abort method for errors.
104 pI2cBus, sizeof(*pI2cBus),
106 MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_100K, // timingr for 100k I2C
109 );
110
111 // set up the pins of the I2C bus (PB10, PB11)
118 );
119
120 // set up pins as AF6
122
129 );
130
131 // set up i2c pins as pull-up
138 );
139
140 // set up i2c pins as open drain
147 );
148
149 // set up i2c pins as medium speed, so we can run with 400k if
150 // we want.
157 );
158
159 // set up PMIC
161 McciBootloaderDevice_NPM1300_createAndAttach(
162 &pI2cBus->I2cBusCast,
165 );
166
167 // above can fail if there's a hardware problem.
169 {
171 }
172
173 // the device driver is created and initialized, now
174 // we set the registers for our platform.
175 const static McciBootloaderDevice_NPM1300_Init_t pmicInitTable[] =
176 {
177 { MCCI_PMIC_NPM1300_REG_BCHGVTERM, 0x08 },
178 { MCCI_PMIC_NPM1300_REG_BCHGVTERMR, 0x08 },
179 { MCCI_PMIC_NPM1300_REG_BCHGDISABLESET, 0x02 },
180 { MCCI_PMIC_NPM1300_REG_BCHGDISABLECLR, 0x01 },
181 { MCCI_PMIC_NPM1300_REG_BCHGISETMSB, 0xC8 },
182 { MCCI_PMIC_NPM1300_REG_BCHGISETLSB, 0x00 },
183 { MCCI_PMIC_NPM1300_REG_BCHGDISABLESET, 0x02 },
184 { MCCI_PMIC_NPM1300_REG_BCHGENABLESET, 0x01 },
185 { MCCI_PMIC_NPM1300_REG_BUCKENASET_1, 0x01 },
186 { MCCI_PMIC_NPM1300_REG_BUCKNORMVOUT_1, 0x17 },
187 { MCCI_PMIC_NPM1300_REG_BUCKSWCTRLSEL, 0x01 },
188 { MCCI_PMIC_NPM1300_REG_BUCKENASET_2, 0x01 },
189 { MCCI_PMIC_NPM1300_REG_LDSWLDOSEL_1, 0x01 },
190 { MCCI_PMIC_NPM1300_REG_LDSWVOUTSEL_1, 0x17 },
191 { MCCI_PMIC_NPM1300_REG_LDSWLDOSEL_2, 0x00 },
192 { MCCI_PMIC_NPM1300_REG_TASKLDSWSET_1, 0x01 },
193 { MCCI_PMIC_NPM1300_REG_TASKLDSWCLR_2, 0x01 },
194 { MCCI_PMIC_NPM1300_REG_VBUSINILIMSTARTUP, 0x0F },
195 { MCCI_PMIC_NPM1300_REG_LEDDRVMODESEL_0, 0x01 },
196 { MCCI_PMIC_NPM1300_REG_LEDDRVMODESEL_1, 0x00 },
197 };
198
199 const McciBootloaderDeviceI2cResult_t result =
200 McciBootloaderDevice_NPM1300_initializeRegisters(
202 pmicInitTable,
203 MCCIADK_LENOF(pmicInitTable)
204 );
205
206 if (result != McciBootloaderDeviceI2cResult_OK)
207 {
209 }
210
211 // the PMIC is now set up correctly.
212 }
213
214#undef FUNCTION
215
216/**** end of mccibootloaderboard_catena5230_systeminit.c ****/
static uint32_t McciArm_putRegMasked(uint32_t reg, uint32_t maskVal, uint32_t modVal)
store to cm0plus register under mask
@ McciBootloaderError_PmicProbeFailed
failed to probe PMIC.
@ McciBootloaderError_PmicInitFailed
failed to initialize PMIC.
#define MCCI_BOOTLOADER_FIELD_SET_VALUE(fmask, val)
McciBootloaderPlatform_SystemInitFn_t McciBootloaderBoard_Catena1sj_systemInit
#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_100K
value for 100k ("standard mode")
const McciBootloaderDeviceI2cBusStm32l0_Config_t gk_McciBootloaderDeviceI2cBusStm32l0_Config_I2c2
global config for I2C2. Linker discards this if not used.
#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_1M
value for 1M ("fast mode plus")
#define MCCI_BOOTLOADER_STM32L0_I2C_TIMINGR_400K
value for 400k ("fast mode")
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.
void MCCI_BOOTLOADER_NORETURN_PFX McciBootloaderPlatform_fail(McciBootloaderError_t errorCode) MCCI_BOOTLOADER_NORETURN_SFX
MCCIADK_C_ASSERT(sizeof(McciBootloaderPlatform_ARMv6M_SvcError_t)==sizeof(uint32_t))
#define MCCI_STM32L0_GPIO_PUPD_P(p)
compute the mask for the mode bits for port bits 0..15
#define MCCI_STM32L0_REG_GPIOB
Section 9.4.12: GPIO register map (1K)
#define MCCI_STM32L0_GPIO_MODER
#define MCCI_STM32L0_GPIO_AFRx_P(p)
#define MCCI_STM32L0_GPIO_PUPD_PULLUP
#define MCCI_STM32L0_GPIO_OSPEEDR
#define MCCI_STM32L0_GPIO_OSPEED_P(p)
compute the mask for the mode bits for port bits 0..15
#define MCCI_STM32L0_GPIO_MODE_AF
#define MCCI_STM32L0_GPIO_OTYPE_OD
#define MCCI_STM32L0_GPIO_OTYPE_P(p)
compute the mask for the mode bits for port bits 0..15
#define MCCI_STM32L0_GPIO_OSPEED_MEDIUM
#define MCCI_STM32L0_GPIO_PUPDR
#define MCCI_STM32L0_GPIO_OTYPER
#define MCCI_STM32L0_GPIO_MODE_P(p)
compute the mask for the mode bits for port bits 0..15
#define MCCI_STM32L0_GPIO_AFSEL_P(p)
get AFRx mask for port bit p.
void McciBootloaderBoard_Catena5230_systemInit(void)
McciBootloaderDeviceNpm1300_t * g_McciBootloaderBoard_Catena5230_pNPM1300
McciBootloaderDeviceI2cBusStm32l0_t g_McciBootloaderBoard_Catena5230_i2cBus2
McciBootloaderDeviceI2cDeviceStm32l0_t g_McciBootloaderBoard_Catena5230_i2cDevice_NPM1300