forked from wolfSSL/wolfBoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcc26x2.c
113 lines (91 loc) · 2.7 KB
/
cc26x2.c
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* cc26x2.c
*
* Copyright (C) 2021 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 <stdint.h>
#include "oscillators.h"
#include "ti-lib.h"
#include "target.h" /* For WOLFBOOT_SECTOR_SIZE */
#include "image.h"
extern void clock_init(void);
char uart_read(void)
{
return (char)UARTCharGet(UART0_BASE);
}
int uart_read_nonblock(char *c)
{
int ret = UARTCharGetNonBlocking(UART0_BASE);
if (ret == -1)
return 0;
*c = (char)ret;
return 1;
}
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
FlashProgram(data, address, len);
while(FlashCheckFsmForReady() != FAPI_STATUS_FSM_READY)
;
return 0;
}
void RAMFUNCTION hal_flash_unlock(void)
{
}
void RAMFUNCTION hal_flash_lock(void)
{
}
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
int i = 0;
while (len > 0) {
FlashSectorErase(address + (WOLFBOOT_SECTOR_SIZE * i++));
while(FlashCheckFsmForReady() != FAPI_STATUS_FSM_READY)
;
if (len <= WOLFBOOT_SECTOR_SIZE)
break;
len -= WOLFBOOT_SECTOR_SIZE;
}
return 0;
}
void hal_init(void)
{
/* Enable flash cache and prefetch. */
ti_lib_vims_mode_set(VIMS_BASE, VIMS_MODE_ENABLED);
ti_lib_vims_configure(VIMS_BASE, true, true);
ti_lib_int_master_disable();
ti_lib_prcm_power_domain_on(PRCM_DOMAIN_PERIPH);
while((ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH)
!= PRCM_DOMAIN_POWER_ON))
;
ti_lib_prcm_power_domain_on(PRCM_DOMAIN_SERIAL);
while ((ti_lib_prcm_power_domain_status(PRCM_DOMAIN_SERIAL)) != PRCM_DOMAIN_POWER_ON)
;
ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_GPIO);
ti_lib_prcm_load_set();
while(!ti_lib_prcm_load_get())
;
ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_UART0);
ti_lib_prcm_load_set();
while(!ti_lib_prcm_load_get())
;
ti_lib_int_master_enable();
clock_init();
}
void hal_prepare_boot(void)
{
}