Skip to content

Commit f9490ba

Browse files
committed
Initial Nano ESP32 support
* inst/+arduinoio/+config/config_nano_esp32.m: new file * inst/+arduinoio/boardTypeString.m: add nano esp id * inst/+arduinoio/lib/OctaveCoreLibrary.cpp, inst/+arduinoio/lib/OctaveServoLibrary.cpp: add mods for nano esp
1 parent c7979d2 commit f9490ba

File tree

4 files changed

+71
-2
lines changed

4 files changed

+71
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## Copyright (C) 2023 John Donoghue <john.donoghue@ieee.org>
2+
##
3+
## This program is free software: you can redistribute it and/or modify it
4+
## under the terms of the GNU General Public License as published by
5+
## the Free Software Foundation, either version 3 of the License, or
6+
## (at your option) any later version.
7+
##
8+
## This program is distributed in the hope that it will be useful, but
9+
## WITHOUT ANY WARRANTY; without even the implied warranty of
10+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
## GNU General Public License for more details.
12+
##
13+
## You should have received a copy of the GNU General Public License
14+
## along with this program. If not, see
15+
## <https://www.gnu.org/licenses/>.
16+
17+
## -*- texinfo -*-
18+
## @deftypefn {} {@var{retval} =} config_nano_esp32 (@var{initdata})
19+
## Private function for setting allowed modes of nano esp32 board pins
20+
## @end deftypefn
21+
22+
function retval = config_nano_esp32 (initdata)
23+
retval = [];
24+
# default board info - must be provided
25+
# will be filled in on connection
26+
retval.board = "nano_esp32";
27+
retval.mcu = '';
28+
retval.voltref = 33;
29+
retval.libs = {};
30+
retval.port = "";
31+
32+
# info expected to be provided by config.
33+
retval.description = 'Arduino Nano ESP32 Board';
34+
35+
# pin config
36+
retval.pins = {};
37+
retval.pins{end+1} = arduinoio.config.pin_info("D0", 0, { 'digital' , 'uart_rx'});
38+
retval.pins{end+1} = arduinoio.config.pin_info("D1", 1, { 'digital' , 'uart_tx'});
39+
retval.pins{end+1} = arduinoio.config.pin_info("D2", 2, { 'digital', 'interrupt' });
40+
retval.pins{end+1} = arduinoio.config.pin_info("D3", 3, { 'digital', 'pwm', 'interrupt' });
41+
retval.pins{end+1} = arduinoio.config.pin_info("D4", 4, { 'digital', 'interrupt' });
42+
retval.pins{end+1} = arduinoio.config.pin_info("D5", 5, { 'digital', 'pwm', 'interrupt' });
43+
retval.pins{end+1} = arduinoio.config.pin_info("D6", 6, { 'digital', 'pwm', 'interrupt' });
44+
retval.pins{end+1} = arduinoio.config.pin_info("D7", 7, { 'digital', 'interrupt' });
45+
retval.pins{end+1} = arduinoio.config.pin_info("D8", 8, { 'digital', 'interrupt' });
46+
retval.pins{end+1} = arduinoio.config.pin_info("D9", 9, { 'digital', 'pwm', 'interrupt' });
47+
retval.pins{end+1} = arduinoio.config.pin_info("D10", 10, { 'digital', 'pwm', 'spi0_ss', 'interrupt' });
48+
retval.pins{end+1} = arduinoio.config.pin_info("D11", 11, { 'digital', 'pwm', 'spi0_mosi', 'interrupt' });
49+
retval.pins{end+1} = arduinoio.config.pin_info("D12", 12, { 'digital', 'pwm', 'spi0_miso', 'interrupt' });
50+
retval.pins{end+1} = arduinoio.config.pin_info("D13", 13, { 'digital', 'pwm', 'spi0_sck', 'led', 'interrupt' });
51+
52+
retval.pins{end+1} = arduinoio.config.pin_info("D14", 14, { 'digital', 'pwm', 'led_r', 'interrupt' });
53+
retval.pins{end+1} = arduinoio.config.pin_info("D15", 15, { 'digital', 'pwm', 'led_g', 'interrupt' });
54+
retval.pins{end+1} = arduinoio.config.pin_info("D16", 16, { 'digital', 'pwm', 'led_b', 'interrupt' });
55+
56+
retval.pins{end+1} = arduinoio.config.pin_info("A0", 17, { 'analog' });
57+
retval.pins{end+1} = arduinoio.config.pin_info("A1", 18, { 'analog' });
58+
retval.pins{end+1} = arduinoio.config.pin_info("A2", 19, { 'analog' });
59+
retval.pins{end+1} = arduinoio.config.pin_info("A3", 20, { 'analog' });
60+
retval.pins{end+1} = arduinoio.config.pin_info("A4", 21, { 'digital', 'analog', 'i2c_sda' });
61+
retval.pins{end+1} = arduinoio.config.pin_info("A5", 22, { 'digital', 'analog', 'i2c_scl' });
62+
retval.pins{end+1} = arduinoio.config.pin_info("A6", 23, { 'analog' });
63+
retval.pins{end+1} = arduinoio.config.pin_info("A7", 24, { 'analog' });
64+
endfunction

inst/+arduinoio/boardTypeString.m

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
retval = "raspi_pico";
6666
case 101
6767
retval = "nano_rp2040_connect";
68+
case 102
69+
retval = "nano_esp32";
6870
case 111
6971
retval = "esp32_dev";
7072
case 112

inst/+arduinoio/lib/OctaveCoreLibrary.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "settings.h"
2020
#include "OctaveCoreLibrary.h"
2121

22-
#ifdef ARDUINO_ARCH_ESP32
22+
#if defined(ARDUINO_ARCH_ESP32) && ! defined(ARDUINO_NANO_ESP32)
2323
// contains analogWrite
2424
#include <ESP32Servo.h>
2525
#endif
@@ -97,6 +97,9 @@
9797
#ifndef ARDUINO_ARCH_MBED
9898
#error "Expected mbed architechture"
9999
#endif
100+
#elif defined(ARDUINO_NANO_ESP32)
101+
#define BOARD_ID 102
102+
#define BOARD_VOLTAGE 33
100103
#elif defined(ARDUINO_ESP32_DEV)
101104
#define BOARD_ID 111
102105
#define BOARD_VOLTAGE 33

inst/+arduinoio/lib/OctaveServoLibrary.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// NOTE: if cant fint servo.h, you probally dont have the Servo library installed
2626
// go to Sketch -> Include Library -> Manage Libraries, and select 'Servo'
2727
// For ESP boards, it bwill need to be ESP32Servo
28-
# ifdef ARDUINO_ARCH_ESP32
28+
# if defined(ARDUINO_ARCH_ESP32) && ! defined(ARDUINO_NANO_ESP32)
2929
#include <ESP32Servo.h>
3030
# else
3131
#include <Servo.h>

0 commit comments

Comments
 (0)