forked from arduino/ArduinoCore-mbed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0033-RP2040-Start-adding-Flash-support.patch
148 lines (145 loc) · 3.45 KB
/
0033-RP2040-Start-adding-Flash-support.patch
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
From 309fe15100a5de30a9ea01b26aa9db7b97e25991 Mon Sep 17 00:00:00 2001
From: giulcioffi <g.cioffi@arduino.cc>
Date: Thu, 25 Feb 2021 18:44:50 +0100
Subject: [PATCH 033/204] RP2040: Start adding Flash support
---
.../TARGET_RP2040/flash_api.c | 107 ++++++++++++++++++
targets/targets.json | 2 +
2 files changed, 109 insertions(+)
create mode 100644 targets/TARGET_RASPBERRYPI/TARGET_RP2040/flash_api.c
diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/flash_api.c b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/flash_api.c
new file mode 100644
index 0000000000..85e8f5c81f
--- /dev/null
+++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/flash_api.c
@@ -0,0 +1,107 @@
+/******************************************************************************
+ * INCLUDE
+ ******************************************************************************/
+
+#include "mbed_assert.h"
+#include "mbed_critical.h"
+#include "hal/flash_api.h"
+#include "flash.h"
+//#include "hal/lp_ticker_api.h"
+//#include "PeripheralPins.h"
+#include "PeripheralNames.h"
+
+/******************************************************************************
+ * CONSTANT
+ ******************************************************************************/
+
+
+
+/******************************************************************************
+ * FUNCTION DEFINITION
+ ******************************************************************************/
+
+int32_t flash_init(flash_t *obj)
+{
+ (void)(obj);
+
+ return 0;
+}
+
+int32_t flash_free(flash_t *obj)
+{
+ (void)(obj);
+
+ uint32_t address = 0;
+
+ for (int i = 0; i < PICO_FLASH_SIZE_BYTES/FLASH_SECTOR_SIZE; i++ ) {
+ flash_range_erase(address, FLASH_SECTOR_SIZE);
+ address = address + FLASH_SECTOR_SIZE;
+ }
+
+ return 0;
+}
+
+int32_t flash_erase_sector(flash_t *obj, uint32_t address)
+{
+ (void)(obj);
+
+ flash_range_erase(address, FLASH_SECTOR_SIZE);
+
+ return 0;
+}
+
+int32_t flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size)
+{
+ (void)(obj);
+
+ for (int i = 0; i < size; i++) {
+ data = (const uint8_t *) (XIP_BASE + address + i);
+ data++;
+ }
+ return 0;
+}
+
+int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size)
+{
+ (void)(obj);
+
+ flash_range_program(address, data, size);
+
+ return 0;
+
+}
+
+uint32_t flash_get_size(const flash_t *obj)
+{
+ (void)(obj);
+
+ return PICO_FLASH_SIZE_BYTES;
+}
+
+uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
+{
+ (void)(obj);
+
+ return FLASH_SECTOR_SIZE;
+}
+
+uint32_t flash_get_page_size(const flash_t *obj)
+{
+ (void)(obj);
+
+ return FLASH_PAGE_SIZE;
+}
+
+uint32_t flash_get_start_address(const flash_t *obj)
+{
+ return XIP_BASE;
+
+}
+
+uint8_t flash_get_erase_value(const flash_t *obj)
+{
+ (void)obj;
+
+ return 0xFF;
+
+}
\ No newline at end of file
diff --git a/targets/targets.json b/targets/targets.json
index 0d696c3196..ba6bcb6946 100644
--- a/targets/targets.json
+++ b/targets/targets.json
@@ -9406,6 +9406,7 @@
},
"RP2040": {
"inherits": ["Target"],
+ "components_add": ["FLASHIAP"],
"core": "Cortex-M0+",
"supported_toolchains": ["GCC_ARM"],
"extra_labels": [
@@ -9420,6 +9421,7 @@
},
"device_has": [
"ANALOGIN",
+ "FLASH",
"I2C",
"INTERRUPTIN",
"PORT_IN",
--
2.39.1