mirror of
https://github.com/Fishwaldo/LMIC-node.git
synced 2025-03-15 19:31:44 +00:00
Add support for Teensy LC
This commit is contained in:
parent
afd6a87261
commit
1ecc2b2f4b
3 changed files with 164 additions and 6 deletions
|
@ -174,6 +174,7 @@ An external display can be optionally connected. For details and wiring instruct
|
|||
| NodeMCU-32S | ESP32 | yes | yes | yes | no | nodemcu_32 |
|
||||
| NodeMCU V2 (aka v1.0) | ESP8266 | yes | yes | yes | no | nodemcuv2 |
|
||||
| Arduino Pro Mini (ATmega328 8mHz) | ATmega328 | yes | yes | no | no | pro8mhzatmega328 |
|
||||
| Teensy LC | MKL26Z64VFT4 | yes | yes | yes | no | teensylc |
|
||||
| Arduino Zero (USB) | SAMD21 | yes | yes | yes | no | zerousb |
|
||||
|
||||
_\*7_: These boards have onboard USB but by default do not support firmware upload over USB or serial over USB. For upload use a STLink programmer or USB to serial adapter.
|
||||
|
|
|
@ -41,12 +41,12 @@ default_envs =
|
|||
; heltec_wireless_stick_lite ; Heltec Wireless Stick Lite
|
||||
; heltec_wireless_stick ; Heltec Wireless Stick
|
||||
; lopy4 ; Pycom Lopy4
|
||||
; lora32u4II ; BSFrance LoRa32u4 II
|
||||
; ttgo_lora32_v1 ; TTGO LoRa32 V1.3
|
||||
; ttgo_lora32_v2 ; TTGO LoRa32 V2.0
|
||||
; ttgo_lora32_v21 ; TTGO LoRa32 V2.1.6
|
||||
; ttgo_tbeam ; TTGO T-Beam V0.7
|
||||
; ttgo_tbeam_v1 ; TTGO T-Beam V1.0
|
||||
; lora32u4II ; BSFrance LoRa32u4 II v1.0, v1.1, v1.2, v1.3
|
||||
; ttgo_lora32_v1 ; TTGO LoRa32 v1.3
|
||||
; ttgo_lora32_v2 ; TTGO LoRa32 v2.0
|
||||
; ttgo_lora32_v21 ; TTGO LoRa32 v2.1.6
|
||||
; ttgo_tbeam ; TTGO T-Beam v0.5, v0.6, v0.7
|
||||
; ttgo_tbeam_v1 ; TTGO T-Beam v1.0, v1.1
|
||||
|
||||
; Development boards that require an external SPI LoRa module:
|
||||
|
||||
|
@ -62,6 +62,7 @@ default_envs =
|
|||
; nodemcu_32s ; NodeMCU-32S
|
||||
; nodemcuv2 ; NodeMCU V2
|
||||
; pro8mhzatmega328 ; Arduino Pro Mini 3.3V 8Mhz
|
||||
; teensylc ; Teensy LC
|
||||
; zerousb ; Arduino Zero (USB)
|
||||
|
||||
|
||||
|
@ -704,6 +705,26 @@ build_flags =
|
|||
; -D USE_DISPLAY ; Requires external I2C OLED display
|
||||
|
||||
|
||||
[env:teensylc]
|
||||
; Teensy LC (NXP MKL26Z64VFT4)
|
||||
; No display
|
||||
platform = teensy
|
||||
board = teensylc
|
||||
framework = arduino
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
lib_deps =
|
||||
${common.lib_deps}
|
||||
${mcci_lmic.lib_deps}
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
${mcci_lmic.build_flags}
|
||||
-D BSFILE=\"boards/teensylc.h\"
|
||||
-D MONITOR_SPEED=${common.monitor_speed}
|
||||
-D USE_SERIAL
|
||||
-D USE_LED
|
||||
; -D USE_DISPLAY ; Requires external I2C OLED display
|
||||
|
||||
|
||||
[env:zerousb]
|
||||
; Arduino Zero USB (SAMD21)
|
||||
; The SPI pins are available on the ICSP connector pins on top of the PCB
|
||||
|
|
136
src/boards/teensylc.h
Normal file
136
src/boards/teensylc.h
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
* File: teensylc.h
|
||||
*
|
||||
* Function: Board Support File for Teensy LC with external SPI LoRa module.
|
||||
*
|
||||
* Copyright: Copyright (c) 2021 Leonel Lopes Parente
|
||||
*
|
||||
* License: MIT License. See accompanying LICENSE file.
|
||||
*
|
||||
* Author: Leonel Lopes Parente
|
||||
*
|
||||
* Description: This board has onboard USB (provided by the MCU).
|
||||
* It supports automatic firmware upload and serial over USB.
|
||||
* No onboard display. Optionally an external display con be connected.
|
||||
*
|
||||
* Onboard LED and SPI SCK use the same GPIO (13) which causes a hardware conflict.
|
||||
* Fortunately SCK can be remapped to a different GPIO (14).
|
||||
*
|
||||
* Connect an optional display according to below connection details.
|
||||
*
|
||||
* CONNECTIONS AND PIN DEFINITIONS:
|
||||
*
|
||||
* Indentifiers between parentheses are defined in the board's
|
||||
* Board Support Package (BSP) which is part of the Arduino core.
|
||||
*
|
||||
* Leds GPIO
|
||||
* ---- ----
|
||||
* LED <――――――――――> 13 (LED_BUILTIN) (SCK) Hardware conflict.
|
||||
* Cannot use LED_BUILTIN and SCK together.
|
||||
*
|
||||
* I2C [display] GPIO
|
||||
* --- ----
|
||||
* SDA <――――――――――> 18 (SDA)
|
||||
* SCL <――――――――――> 19 (SCL)
|
||||
*
|
||||
* SPI/LoRa module GPIO
|
||||
* --- ----
|
||||
* MOSI <――――――――――> 11 (MOSI)
|
||||
* MISO <――――――――――> 12 (MISO)
|
||||
* SCK <――――――――――> 14 NOT SCK!
|
||||
* SPI SCK is remapped to GPIO14 because
|
||||
* SCK definition conflicts with onboard LED.
|
||||
* NSS <――――――――――> 10
|
||||
* RST <――――――――――> 9
|
||||
* DIO0 <――――――――――> 8
|
||||
* DIO1 <――――――――――> 7
|
||||
* DIO2 - Not needed for LoRa.
|
||||
*
|
||||
* Docs: https://docs.platformio.org/en/latest/boards/teensy/teensylc.html
|
||||
*
|
||||
* Identifiers: LMIC-node
|
||||
* board: teensylc
|
||||
* PlatformIO
|
||||
* board: teensylc
|
||||
* platform: teensy
|
||||
* Arduino
|
||||
* board: ARDUINO_TEENSYLC
|
||||
* architecture: <not defined>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef TEENSYLC_H_
|
||||
#define TEENSYLC_H_
|
||||
|
||||
#include "LMIC-node.h"
|
||||
#include <SPI.h>
|
||||
|
||||
#define DEVICEID_DEFAULT "teensylc" // Default deviceid value
|
||||
|
||||
// Wait for Serial
|
||||
// Can be useful for boards with MCU with integrated USB support.
|
||||
#define WAITFOR_SERIAL_SECONDS_DEFAULT 10 // -1 waits indefinitely
|
||||
|
||||
// LMIC Clock Error
|
||||
// This is only needed for slower 8-bit MCUs (e.g. 8MHz ATmega328 and ATmega32u4).
|
||||
// Value is defined in parts per million (of MAX_CLOCK_ERROR).
|
||||
// #define LMIC_CLOCK_ERROR_PPM 0
|
||||
|
||||
// Pin mappings for LoRa tranceiver
|
||||
const lmic_pinmap lmic_pins = {
|
||||
.nss = 10,
|
||||
.rxtx = LMIC_UNUSED_PIN,
|
||||
.rst = 9,
|
||||
.dio = { /*dio0*/ 8, /*dio1*/ 7, /*dio2*/ LMIC_UNUSED_PIN }
|
||||
#ifdef MCCI_LMIC
|
||||
,
|
||||
.rxtx_rx_active = 0,
|
||||
.rssi_cal = 10,
|
||||
.spi_freq = 8000000 /* 8 MHz */
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef USE_SERIAL
|
||||
usb_serial_class& serial = Serial;
|
||||
#endif
|
||||
|
||||
#ifdef USE_LED
|
||||
EasyLed led(LED_BUILTIN, EasyLed::ActiveLevel::High);
|
||||
#endif
|
||||
|
||||
#ifdef USE_DISPLAY
|
||||
// Create U8x8 instance for SSD1306 OLED display (no reset) using hardware I2C.
|
||||
U8X8_SSD1306_128X64_NONAME_HW_I2C display(/*rst*/ U8X8_PIN_NONE, /*scl*/ SCL, /*sda*/ SDA);
|
||||
#endif
|
||||
|
||||
|
||||
bool boardInit(InitType initType)
|
||||
{
|
||||
// This function is used to perform board specific initializations.
|
||||
// Required as part of standard template.
|
||||
|
||||
// InitType::Hardware Must be called at start of setup() before anything else.
|
||||
// InitType::PostInitSerial Must be called after initSerial() before other initializations.
|
||||
|
||||
bool success = true;
|
||||
switch (initType)
|
||||
{
|
||||
case InitType::Hardware:
|
||||
// Note: Serial port and display are not yet initialized and cannot be used use here.
|
||||
// SPI SCK needs to remapped to GPIO14 because it conflicts with LED_BUILTIN.
|
||||
SPI.setSCK(14);
|
||||
break;
|
||||
|
||||
case InitType::PostInitSerial:
|
||||
// Note: If enabled Serial port and display are already initialized here.
|
||||
// No actions required for this board.
|
||||
break;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
#endif // TEENSYLC_H_
|
Loading…
Add table
Reference in a new issue