Skip to content

Commit f413c49

Browse files
Add Meshtiny device (#7676)
* Add Meshtiny device - nRF52 OLED upDown encoder * Update platformio.ini * Update platformio.ini * Add GPS Exclude to Meshtiny. --------- Co-authored-by: Ben Meadors <[email protected]>
1 parent c19f573 commit f413c49

File tree

4 files changed

+324
-0
lines changed

4 files changed

+324
-0
lines changed

boards/meshtiny.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "nrf52840_s140_v6.ld"
5+
},
6+
"core": "nRF5",
7+
"cpu": "cortex-m4",
8+
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
9+
"f_cpu": "64000000L",
10+
"hwids": [
11+
["0x239A", "0x8029"],
12+
["0x239A", "0x0029"],
13+
["0x239A", "0x002A"],
14+
["0x239A", "0x802A"]
15+
],
16+
"usb_product": "MeshTiny",
17+
"mcu": "nrf52840",
18+
"variant": "meshtiny",
19+
"bsp": {
20+
"name": "adafruit"
21+
},
22+
"softdevice": {
23+
"sd_flags": "-DS140",
24+
"sd_name": "s140",
25+
"sd_version": "6.1.1",
26+
"sd_fwid": "0x00B6"
27+
},
28+
"bootloader": {
29+
"settings_addr": "0xFF000"
30+
}
31+
},
32+
"connectivity": ["bluetooth"],
33+
"debug": {
34+
"jlink_device": "nRF52840_xxAA",
35+
"svd_path": "nrf52840.svd",
36+
"openocd_target": "nrf52840-mdk-rs"
37+
},
38+
"frameworks": ["arduino", "freertos"],
39+
"name": "MeshTiny",
40+
"upload": {
41+
"maximum_ram_size": 248832,
42+
"maximum_size": 815104,
43+
"speed": 115200,
44+
"protocol": "nrfutil",
45+
"protocols": ["jlink", "nrfjprog", "nrfutil", "stlink"],
46+
"use_1200bps_touch": true,
47+
"require_upload_port": true,
48+
"wait_for_upload_port": true
49+
},
50+
"url": "https://github.com/meshtastic/firmware",
51+
"vendor": "MTools Tec"
52+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; MeshTiny - Custom device based on GAT562 with encoder and buzzer support
2+
[env:meshtiny]
3+
extends = nrf52840_base
4+
board = meshtiny
5+
board_level = extra
6+
build_flags = ${nrf52840_base.build_flags} -Ivariants/nrf52840/meshtiny -D MESHTINY
7+
-DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
8+
-DRADIOLIB_EXCLUDE_SX128X=1
9+
-DRADIOLIB_EXCLUDE_SX127X=1
10+
-DRADIOLIB_EXCLUDE_LR11X0=1
11+
-D INPUTDRIVER_ENCODER_TYPE=2
12+
-D INPUTDRIVER_ENCODER_UP=4
13+
-D INPUTDRIVER_ENCODER_DOWN=26
14+
-D INPUTDRIVER_ENCODER_BTN=28
15+
-D USE_PIN_BUZZER=PIN_BUZZER
16+
-D MESHTASTIC_EXCLUDE_GPS=1
17+
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/meshtiny>
18+
lib_deps =
19+
${nrf52840_base.lib_deps}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
Copyright (c) 2016 Sandeep Mistry All right reserved.
4+
Copyright (c) 2018, Adafruit Industries (adafruit.com)
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
See the GNU Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#include "variant.h"
22+
#include "nrf.h"
23+
#include "wiring_constants.h"
24+
#include "wiring_digital.h"
25+
26+
const uint32_t g_ADigitalPinMap[] = {
27+
// P0
28+
0, 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,
29+
30+
// P1
31+
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};
32+
33+
void initVariant()
34+
{
35+
// LED1 & LED2
36+
pinMode(PIN_LED1, OUTPUT);
37+
ledOff(PIN_LED1);
38+
39+
pinMode(PIN_LED2, OUTPUT);
40+
ledOff(PIN_LED2);
41+
42+
// 3V3 Power Rail
43+
pinMode(PIN_3V3_EN, OUTPUT);
44+
digitalWrite(PIN_3V3_EN, HIGH);
45+
46+
// Initialize Encoder pins
47+
pinMode(INPUTDRIVER_ENCODER_UP, INPUT_PULLUP);
48+
pinMode(INPUTDRIVER_ENCODER_DOWN, INPUT_PULLUP);
49+
pinMode(INPUTDRIVER_ENCODER_BTN, INPUT_PULLUP);
50+
51+
// Initialize Buzzer pin
52+
pinMode(PIN_BUZZER, OUTPUT);
53+
digitalWrite(PIN_BUZZER, LOW);
54+
}
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
Copyright (c) 2016 Sandeep Mistry All right reserved.
4+
Copyright (c) 2018, Adafruit Industries (adafruit.com)
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
See the GNU Lesser General Public License for more details.
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#ifndef _VARIANT_MESHTINY_
20+
#define _VARIANT_MESHTINY_
21+
22+
#define MESHTINY
23+
24+
// #define RAK4630
25+
26+
/** Master clock frequency */
27+
#define VARIANT_MCK (64000000ul)
28+
29+
#define USE_LFXO // Board uses 32khz crystal for LF
30+
// define USE_LFRC // Board uses RC for LF
31+
32+
/*----------------------------------------------------------------------------
33+
* Headers
34+
*----------------------------------------------------------------------------*/
35+
36+
#include "WVariant.h"
37+
38+
#ifdef __cplusplus
39+
extern "C" {
40+
#endif // __cplusplus
41+
42+
// Number of pins defined in PinDescription array
43+
#define PINS_COUNT (48)
44+
#define NUM_DIGITAL_PINS (48)
45+
#define NUM_ANALOG_INPUTS (6)
46+
#define NUM_ANALOG_OUTPUTS (0)
47+
48+
// LEDs
49+
#define PIN_LED1 (35)
50+
#define PIN_LED2 (36)
51+
52+
#define LED_BUILTIN PIN_LED1
53+
#define LED_CONN PIN_LED2
54+
55+
#define LED_GREEN PIN_LED1
56+
#define LED_BLUE PIN_LED2
57+
58+
#define LED_STATE_ON 1 // State when LED is litted
59+
60+
/*
61+
* Encoder
62+
*/
63+
#define INPUTDRIVER_ENCODER_TYPE 2
64+
#define INPUTDRIVER_ENCODER_UP 26
65+
#define INPUTDRIVER_ENCODER_DOWN 4
66+
#define INPUTDRIVER_ENCODER_BTN 28
67+
68+
#define CANNED_MESSAGE_MODULE_ENABLE 1
69+
70+
/*
71+
* Buzzer - PWM
72+
*/
73+
#define PIN_BUZZER 30
74+
75+
/*
76+
* Buttons
77+
*/
78+
79+
#define PIN_BUTTON1 9
80+
#define BUTTON_NEED_PULLUP
81+
#define PIN_BUTTON2 12
82+
#define PIN_BUTTON3 24
83+
#define PIN_BUTTON4 25
84+
85+
/*
86+
* Analog pins
87+
*/
88+
#define PIN_A0 (5)
89+
#define PIN_A1 (31)
90+
#define PIN_A2 (28)
91+
#define PIN_A3 (29)
92+
#define PIN_A4 (30)
93+
#define PIN_A5 (31)
94+
#define PIN_A6 (0xff)
95+
#define PIN_A7 (0xff)
96+
97+
static const uint8_t A0 = PIN_A0;
98+
static const uint8_t A1 = PIN_A1;
99+
static const uint8_t A2 = PIN_A2;
100+
static const uint8_t A3 = PIN_A3;
101+
static const uint8_t A4 = PIN_A4;
102+
static const uint8_t A5 = PIN_A5;
103+
static const uint8_t A6 = PIN_A6;
104+
static const uint8_t A7 = PIN_A7;
105+
#define ADC_RESOLUTION 14
106+
107+
// Other pins
108+
#define PIN_AREF (2)
109+
#define PIN_NFC1 (9)
110+
#define PIN_NFC2 (10)
111+
112+
static const uint8_t AREF = PIN_AREF;
113+
114+
/*
115+
* Serial interfaces
116+
*/
117+
#define PIN_SERIAL1_RX (15)
118+
#define PIN_SERIAL1_TX (16)
119+
120+
// Connected to Jlink CDC
121+
#define PIN_SERIAL2_RX (8)
122+
#define PIN_SERIAL2_TX (6)
123+
124+
/*
125+
* SPI Interfaces
126+
*/
127+
#define SPI_INTERFACES_COUNT 2
128+
129+
#define PIN_SPI_MISO (45)
130+
#define PIN_SPI_MOSI (44)
131+
#define PIN_SPI_SCK (43)
132+
133+
#define PIN_SPI1_MISO (29) // (0 + 29)
134+
#define PIN_SPI1_MOSI (30) // (0 + 30)
135+
#define PIN_SPI1_SCK (3) // (0 + 3)
136+
137+
static const uint8_t SS = 42;
138+
static const uint8_t MOSI = PIN_SPI_MOSI;
139+
static const uint8_t MISO = PIN_SPI_MISO;
140+
static const uint8_t SCK = PIN_SPI_SCK;
141+
142+
#define HAS_SCREEN 1
143+
#define USE_SSD1306
144+
145+
/*
146+
* Wire Interfaces
147+
*/
148+
#define WIRE_INTERFACES_COUNT 1
149+
150+
#define PIN_WIRE_SDA (13)
151+
#define PIN_WIRE_SCL (14)
152+
153+
// QSPI Pins
154+
#define PIN_QSPI_SCK 3
155+
#define PIN_QSPI_CS 22 // Changed from 26 to avoid conflict with encoder
156+
#define PIN_QSPI_IO0 27 // Changed from 30 to avoid conflict with buzzer
157+
#define PIN_QSPI_IO1 29
158+
#define PIN_QSPI_IO2 21 // Changed from 28 to avoid conflict with encoder button
159+
#define PIN_QSPI_IO3 2
160+
161+
// On-board QSPI Flash
162+
#define EXTERNAL_FLASH_DEVICES IS25LP080D
163+
#define EXTERNAL_FLASH_USE_QSPI
164+
165+
#define USE_SX1262
166+
#define SX126X_CS (42)
167+
#define SX126X_DIO1 (47)
168+
#define SX126X_BUSY (46)
169+
#define SX126X_RESET (38)
170+
#define SX126X_POWER_EN (37)
171+
// DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
172+
#define SX126X_DIO2_AS_RF_SWITCH
173+
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
174+
175+
// Testing USB detection
176+
#define NRF_APM
177+
178+
#define PIN_3V3_EN (34)
179+
180+
// Battery
181+
// The battery sense is hooked to pin A0 (5)
182+
#define BATTERY_PIN PIN_A0
183+
// and has 12 bit resolution
184+
#define BATTERY_SENSE_RESOLUTION_BITS 12
185+
#define BATTERY_SENSE_RESOLUTION 4096.0
186+
#undef AREF_VOLTAGE
187+
#define AREF_VOLTAGE 3.0
188+
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
189+
#define ADC_MULTIPLIER 1.73
190+
191+
#ifdef __cplusplus
192+
}
193+
#endif
194+
195+
/*----------------------------------------------------------------------------
196+
* Arduino objects - C++ only
197+
*----------------------------------------------------------------------------*/
198+
199+
#endif

0 commit comments

Comments
 (0)