forked from wolfSSL/wolfBoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpic32ck.c
More file actions
79 lines (71 loc) · 1.81 KB
/
pic32ck.c
File metadata and controls
79 lines (71 loc) · 1.81 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
/* pic32ck.c
*
* Copyright (C) 2025 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 <hal/pic32c.h>
#include <stdint.h>
int hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
return pic32_flash_write(address, data, len);
}
void hal_flash_lock(void)
{
pic32_fcw_grab();
}
void hal_flash_unlock(void)
{
pic32_fcw_release();
}
int hal_flash_erase(uint32_t addr, int len)
{
return pic32_flash_erase(addr, len);
}
#ifdef DUALBANK_SWAP
void hal_flash_dualbank_swap(void)
{
pic32_flash_dualbank_swap();
}
#endif /* DUALBANK_SWAP */
void hal_init(void)
{
#if defined(TEST_CLOCK)
/* toggle led at 1hz for 10sec */
pic32_clock_test(48000000U);
#endif
pic32_clock_fracdiv0_set(0, 0);
pic32_clock_pll0_init(12, 240, 1, 8);
pic32_clock_gclk_gen0(1, 1);
#if defined(TEST_FLASH)
pic32_flash_test();
while (1) {}
#endif
#if defined(TEST_CLOCK)
/* toggle led at 1hz */
pic32_clock_test(120000000U);
pic32_clock_reset();
pic32_clock_test(48000000U);
while (1) {};
#endif
}
void hal_prepare_boot(void)
{
#ifndef TZEN
pic32_clock_reset();
#endif
}