MCCI Trusted Bootloader
Simple trusted bootloader and tools for small embedded systems
mccibootloaderboard_catenaabz_systeminit.c
Go to the documentation of this file.
1/*
2
3Module: mccibootloaderboard_catenaabz_systeminit.c
4
5Function:
6 McciBootloaderBoard_CatenaABZ_SystemInit() and system init logic for
7 MCCI Catenas based on Murata type-ABZ modules.
8
9Copyright and License:
10 This file copyright (C) 2021 by
11
12 MCCI Corporation
13 3520 Krums Corners Road
14 Ithaca, NY 14850
15
16 See accompanying LICENSE file for copyright and license information.
17
18Author:
19 Terry Moore, MCCI Corporation March 2021
20
21*/
22
24
26#include "mcci_bootloader.h"
28#include "mcci_stm32l0xx.h"
29#include "mcci_arm_cm0plus.h"
30
31/****************************************************************************\
32|
33| Manifest constants & typedefs.
34|
35\****************************************************************************/
36
38static void
41
42static void
43delayTick(void);
44
45/****************************************************************************\
46|
47| Read-only data.
48|
49\****************************************************************************/
50
51/****************************************************************************\
52|
53| Variables.
54|
55\****************************************************************************/
56
57
58/*
59
60Name: McciBootloaderBoard_CatenaAbz_systemInit()
61
62Function:
63 Initialize MCCI Catena based on Murata ABZ module for bootloader.
64
65Definition:
66 McciBootloaderPlatform_SystemInitFn_t
67 McciBootloaderBoard_CatenaAbz_systemInit;
68
69 void McciBootloaderBoard_CatenaAbz_systemInit(
70 void
71 );
72
73Description:
74 We set up the CPU for 32 MHz operation (using stm32l0 initialization).
75
76 We then then enable GPIOs for the LED (pin PB2).
77
78Returns:
79 No explicit result.
80
81Notes:
82
83
84*/
85
86void
88 void
89 )
90 {
92
93 // enable GPIO port B
97 );
98
99 // set up GPIO port B2 as an output
106 )
107 );
108
109 // clear B2
112 UINT32_C(1) << 2
113 );
114
115 // set B2 and clear it, so we can see things on a scope
118 UINT32_C(1) << 2
119 );
122 UINT32_C(1) << 2
123 );
124 }
125
126void
134
135void
143
144void
146 {
147 for (++ms; ms > 0; --ms)
148 {
150 ;
151 }
152 }
153
154static void
160
161void
163 McciBootloaderError_t errorCode
164 )
165 {
168 else
169 {
170 unsigned timeToReboot;
171
172 McciArm_disableInterrupts();
173 timeToReboot = 60 * 1000;
174
176
177 for (; timeToReboot > 0; --timeToReboot)
178 {
179 delayTick();
181 }
182
183 McciArm_DataSynchBarrier();
184
191 );
192
193 McciArm_DataSynchBarrier();
194 while (true)
195 /* spin till reset */;
196 }
197 }
198
199static void fastBlinkForever(void)
200 {
202
203 while (true)
204 {
205 // blink the led
206 rOdr ^= UINT32_C(1) << 2;
209 }
210 }
211
212/**** end of mccibootloaderboard_catenaabz_systeminit.c ****/
static uint32_t McciArm_putRegOr(uint32_t reg, uint32_t orVal)
or 32-bit values to a cm0plus register
static uint32_t McciArm_getReg(uint32_t reg)
read a 32-bit value from a cm0plus register
static uint32_t McciArm_putReg(uint32_t reg, uint32_t val)
write a 32-bit value to a cm0plus register
#define MCCI_CM0PLUS_SCB_AIRCR_SYSRESETREQ
#define MCCI_CM0PLUS_SYSTICK_CSR
#define MCCI_CM0PLUS_SCB_AIRCR
#define MCCI_CM0PLUS_SCB_AIRCR_VECTKEY_VALUE
Value to write to unlock regster.
static uint32_t McciArm_putRegMasked(uint32_t reg, uint32_t maskVal, uint32_t modVal)
store to cm0plus register under mask
#define MCCI_CM0PLUS_SYSTICK_CSR_COUNTFLAG
timer has counted to zero
#define MCCI_CM0PLUS_SCB_AIRCR_VECTKEY
Vector key.
@ McciBootloaderError_BootloaderNotValid
bootloader image isn't valid
#define MCCI_BOOTLOADER_FIELD_SET_VALUE(fmask, val)
McciBootloaderPlatform_DelayMsFn_t McciBootloaderBoard_CatenaAbz_delayMs
McciBootloaderPlatform_AnnunciatorIndicateStateFn_t McciBootloaderBoard_CatenaAbz_annunciatorIndicateState
void McciBootloaderBoard_CatenaAbz_handleSysTick(void)
McciBootloaderPlatform_SystemInitFn_t McciBootloaderBoard_CatenaAbz_systemInit
MCCI_BOOTLOADER_BEGIN_DECLS void McciBootloader_Stm32L0_systemInit(void)
#define MCCI_BOOTLOADER_NORETURN_SFX
uint32_t McciBootloaderError_t
error codes for the bootloader
#define MCCI_BOOTLOADER_NORETURN_PFX
#define MCCI_STM32L0_GPIO_BSRR
#define MCCI_STM32L0_REG_RCC_IOPENR_IOPBEN
#define MCCI_STM32L0_REG_GPIOB
Section 9.4.12: GPIO register map (1K)
#define MCCI_STM32L0_GPIO_ODR
#define MCCI_STM32L0_GPIO_MODER
#define MCCI_STM32L0_REG_RCC_IOPENR
GPIO clock enable.
#define MCCI_STM32L0_GPIO_BRR
#define MCCI_STM32L0_GPIO_MODE_OUT
#define MCCI_STM32L0_GPIO_MODE_P(p)
compute the mask for the mode bits for port bits 0..15
static MCCI_BOOTLOADER_NORETURN_PFX void fastBlinkForever(void)
void McciBootloaderBoard_CatenaAbz_fail(McciBootloaderError_t errorCode)
void McciBootloaderBoard_CatenaAbz_clearLed(void)
static void delayTick(void)
void McciBootloaderBoard_CatenaAbz_setLed(void)