Skip to content

Commit ff5cd76

Browse files
committed
WIP SD testing.
1 parent f7df79e commit ff5cd76

File tree

4 files changed

+69
-45
lines changed

4 files changed

+69
-45
lines changed

libraries/BlockDevices/BlockDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20-
#ifdef ARDUINO_PORTENTA_C33
20+
#if defined(ARDUINO_PORTENTA_C33) || defined(ARDUINO_THINGPLUS_RA6M5)
2121

2222
#include <QSPIFlashBlockDevice.h>
2323

variants/THINGPLUS_RA6M5/pinmux.inc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,29 @@ const uint16_t P014[] = {
404404
PIN_ANALOG|CHANNEL_12|ADC_0|LAST_ITEM_GUARD
405405
};
406406

407+
// pins not yet handled by the script
408+
const uint16_t P208[] = { LAST_ITEM_GUARD };
409+
410+
const uint16_t P209[] = { LAST_ITEM_GUARD };
411+
412+
const uint16_t P210[] = {
413+
PIN_PWM_AGT|CHANNEL_5|PWM_CHANNEL_B|LAST_ITEM_GUARD,
414+
};
415+
416+
const uint16_t P211[] = { LAST_ITEM_GUARD };
417+
418+
const uint16_t P214[] = { LAST_ITEM_GUARD };
419+
420+
421+
const uint16_t P015_b[] = {
422+
PIN_DAC|CHANNEL_1,
423+
PIN_ANALOG|CHANNEL_13|ADC_0,
424+
PIN_INTERRUPT|CHANNEL_13|LAST_ITEM_GUARD
425+
};
426+
#define P015 P015_b
427+
428+
const uint16_t P014_b[] = {
429+
PIN_DAC|CHANNEL_0,
430+
PIN_ANALOG|CHANNEL_12|ADC_0|LAST_ITEM_GUARD
431+
};
432+
#define P014 P014_b

variants/THINGPLUS_RA6M5/pins_arduino.h

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,27 @@ static const uint8_t PICO = PIN_SPI_MOSI;
126126
/****** SDCARD CORE DEFINES *******/
127127
#define SDCARD_HOWMANY 1
128128

129-
130-
#define EXT_INTERRUPTS_HOWMANY 14
131-
132129
#define USE_4BIT_SDCARD 1
133130

131+
/****** USB CORE DEFINES ******/
134132
#define USB_VID (0x1b4f)
135133
#define USB_PID (0x0036)
136134
#define USB_NAME "SparkFun Thing Plus RA6M5"
137135

136+
/****** FLASH DEFINES ******/
138137
#define ARDUINO_FLASH_TYPE HP_FLASH
139138
#define FLASH_BASE_ADDRESS 0x08000000
140139
#define FLASH_TOTAL_SIZE 0x2000
141140
#define FLASH_BLOCK_SIZE 0x40
142141

143-
#define PIN_QSPI_CLK (40u)
144-
#define PIN_QSPI_SS (41u)
145-
#define PIN_QSPI_D0 (42u)
146-
#define PIN_QSPI_D1 (43u)
147-
#define PIN_QSPI_D2 (44u)
148-
#define PIN_QSPI_D3 (45u)
142+
/****** QSPI CORE DEFINES ******/
143+
144+
#define PIN_QSPI_CLK (40)
145+
#define PIN_QSPI_SS (41)
146+
#define PIN_QSPI_D0 (42)
147+
#define PIN_QSPI_D1 (43)
148+
#define PIN_QSPI_D2 (44)
149+
#define PIN_QSPI_D3 (45)
149150

150151
#define HAS_QSPI
151152

@@ -154,15 +155,23 @@ static const uint8_t PICO = PIN_SPI_MOSI;
154155
#define QSPI_ERASE_BLOCK_SIZE (0x1000)
155156
#define QSPI_WRITE_BLOCK_SIZE (0x1)
156157

158+
/****** MISC GPIO CORE DEFINES ******/
159+
#define EXT_INTERRUPTS_HOWMANY 14
160+
161+
#define SD_NEN (35)
162+
#define BLE_NRST (36)
163+
#define VREF_EN (37)
164+
#define PWR_STAT (38)
165+
157166
#define HAS_SDHI
158167

159-
#define PIN_SDHI_CLK (22u)
160-
#define PIN_SDHI_CMD (23u)
161-
#define PIN_SDHI_D0 (24u)
162-
#define PIN_SDHI_D1 (25u)
163-
#define PIN_SDHI_D2 (26u)
164-
#define PIN_SDHI_D3 (27u)
165-
#define PIN_SDHI_CD (28u)
166-
#define PIN_SDHI_WP (29u)
168+
#define PIN_SDHI_CLK (22)
169+
#define PIN_SDHI_CMD (23)
170+
#define PIN_SDHI_D0 (24)
171+
#define PIN_SDHI_D1 (25)
172+
#define PIN_SDHI_D2 (26)
173+
#define PIN_SDHI_D3 (27)
174+
#define PIN_SDHI_CD (28)
175+
#define PIN_SDHI_WP (29)
167176

168177
#define RTC_CLOCK_SOURCE RTC_CLOCK_SOURCE_SUBCLK

variants/THINGPLUS_RA6M5/variant.cpp

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,6 @@
11
#include "Arduino.h"
22
#include "pinmux.inc"
33

4-
// pins not yet handled by the script
5-
const uint16_t P208[] = { LAST_ITEM_GUARD };
6-
7-
const uint16_t P209[] = { LAST_ITEM_GUARD };
8-
9-
const uint16_t P210[] = {
10-
PIN_PWM_AGT|CHANNEL_5|PWM_CHANNEL_B|LAST_ITEM_GUARD,
11-
};
12-
13-
const uint16_t P211[] = { LAST_ITEM_GUARD };
14-
15-
const uint16_t P214[] = { LAST_ITEM_GUARD };
16-
17-
18-
const uint16_t P015_b[] = {
19-
PIN_DAC|CHANNEL_1,
20-
PIN_ANALOG|CHANNEL_13|ADC_0,
21-
PIN_INTERRUPT|CHANNEL_13|LAST_ITEM_GUARD
22-
};
23-
#define P015 P015_b
24-
25-
const uint16_t P014_b[] = {
26-
PIN_DAC|CHANNEL_0,
27-
PIN_ANALOG|CHANNEL_12|ADC_0|LAST_ITEM_GUARD
28-
};
29-
#define P014 P014_b
30-
314
extern "C" const PinMuxCfg_t g_pin_cfg[] = {
325

336
// Thing Plus Form Factor
@@ -126,6 +99,22 @@ void initVariant() {
12699
// bootloader configures LED_BUILTIN as PWM output, deconfigure it to avoid spurious signals
127100
pinMode(LED_BUILTIN, INPUT);
128101

102+
// Set internal gpio pins.
103+
// Disable SD Card Power
104+
pinMode(SD_NEN, OUTPUT_OPENDRAIN);
105+
digitalWrite(SD_NEN, HIGH);
106+
107+
// Turn on VREF.
108+
pinMode(VREF_EN, OUTPUT_OPENDRAIN);
109+
digitalWrite(VREF_EN, HIGH);
110+
111+
// Configure Battery Power Mode Status Pin
112+
pinMode(PWR_STAT, INPUT_PULLUP);
113+
114+
// Take BLE out of reset.
115+
pinMode(BLE_NRST, OUTPUT_OPENDRAIN);
116+
digitalWrite(BLE_NRST, HIGH);
117+
129118
// We're using an extenal reference voltage, so set that here. NOTE: AREF = 3.3V
130119
analogReference(AR_EXTERNAL);
131120
}

0 commit comments

Comments
 (0)