forked from wolfSSL/wolfBoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_mcxw.c
More file actions
95 lines (84 loc) · 2.59 KB
/
app_mcxw.c
File metadata and controls
95 lines (84 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* app_mcxa.c
*
* Test bare-metal boot-led-on application
*
* Copyright (C) 2024 wolfSSL Inc.
*
* This file is part of wolfBoot.
*
* wolfBoot is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "fsl_common.h"
#include "fsl_port.h"
#include "fsl_gpio.h"
#include "fsl_clock.h"
#include "wolfboot/wolfboot.h"
#include "target.h"
extern void hal_init(void);
/* init gpio for port 3 */
void gpio_portA_init(int pin)
{
const port_pin_config_t GPIO_OUT_LED = {
(uint16_t)kPORT_PullDisable,
(uint16_t)kPORT_LowPullResistor,
(uint16_t)kPORT_FastSlewRate,
(uint16_t)kPORT_PassiveFilterDisable,
(uint16_t)kPORT_OpenDrainDisable,
(uint16_t)kPORT_LowDriveStrength,
(uint16_t)kPORT_NormalDriveStrength,
(uint16_t)kPORT_MuxAsGpio,
(uint16_t)kPORT_UnlockRegister
};
const gpio_pin_config_t GPIO_OUT_LED_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U
};
/* Initialize GPIO functionality on pin */
GPIO_PinInit(GPIOA, pin, &GPIO_OUT_LED_config);
PORT_SetPinConfig(PORTA, pin, &GPIO_OUT_LED);
GPIO_PinWrite(GPIOA, pin, 1);
}
void main(void)
{
int i = 0;
uint8_t* bootPart = (uint8_t*)WOLFBOOT_PARTITION_BOOT_ADDRESS;
uint32_t bootVer = wolfBoot_get_blob_version(bootPart);
/* Enable GPIO port clocks */
CLOCK_EnableClock(kCLOCK_GpioA);
CLOCK_EnableClock(kCLOCK_PortA);
CLOCK_EnableClock(kCLOCK_PortC);
gpio_portA_init(18);
gpio_portA_init(19);
gpio_portA_init(20);
hal_init();
if (bootVer == 1) {
/* Blue LED ON, GPIOA port A pin 20 */
GPIO_PinWrite(GPIOA, 20, 0);
wolfBoot_update_trigger();
}
else {
/* Green LED ON, GPIOA port A pin 19 */
GPIO_PinWrite(GPIOA, 19, 0);
/* mark boot successful */
wolfBoot_success();
}
/* busy wait */
while (1) {
__WFI();
}
}