Skip to content

Commit

Permalink
Add support for Adafruit QT Py board
Browse files Browse the repository at this point in the history
  • Loading branch information
lnlp committed May 23, 2021
1 parent df885db commit 4089d47
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 29 deletions.
54 changes: 29 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,24 @@ Not yet a requirement but this document assumes that you will be using The Thing

The following tables list the boards currently supported by LMIC-node.

Explanation of columns: MCU: microcontroller. Wiring required: yes means manual wiring of DIO1 is required. USB: has onboard USB. LED: yes: has onboard LED *and* is usable. Display: yes means has onboard display. Board-id: board identifier as used by LMIC-node.
Explanation of columns: MCU: microcontroller. Wiring required: yes means manual wiring of DIO1 is required. USB: has onboard USB. LED: yes: has onboard LED *and* is usable (no hardware conflicts). Display: yes means has onboard display. Board-id: board identifier as used by LMIC-node.

### 2.1 LoRa development boards

The following LoRa development boards have onboard LoRa support. Most have onboard USB that supports automatic firmware upload and serial over USB for serial monitoring. Some boards require manual wiring of the LoRa DIO1 port. For boards without onboard display an external display can be optionally connected. For details and wiring instructions see the board's BSF.

| Board name | MCU | Wiring required | USB | LED | Display | Board-id |
| ---------- | --- | --- | --- | --- | --- | --- |
| Adafruit Feather M0 RFMx LoRa | SAMD21 | yes _\*1_ | yes | yes | no | adafruit_feather_m0_lora |
| Adafruit Feather M0 RFMx LoRa | SAMD21G18 | yes _\*1_ | yes | yes | no | adafruit_feather_m0_lora |
| ST B-L072Z-LRWAN1 Discovery kit | STM32L072CZ | no | yes | yes | no | discovery_l072z_lrwan1 |
| Heltec WiFi LoRa 32 V2 | ESP32 | no | yes | yes | yes | heltec_wifilora32_v2 |
| Heltec WiFi LoRa 32 (1.x) | ESP32 | no | yes | yes | yes | heltec_wifilora32 |
| Heltec Wireless Stick | ESP32 | no | yes | yes | yes _\*6_ | heltec_wireless_stick |
| Heltec Wireless Stick | ESP32 | no | yes | yes | yes _\*7_ | heltec_wireless_stick |
| Heltec Wireless Stick Lite | ESP32 | no | yes | yes | no | heltec_wireless_stick_lite |
| Pycom LoPy4 | ESP32 | no | no _\*4_ | no | no | lopy4 |
| Pycom LoPy4 | ESP32 | no | no _\*4_ | no _\*5_ | no | lopy4 |
| BSFrance LoRa32u4 II<br>*versions v1.0, v1.1, v1.2 and v1.3* | ATmega32u4 | yes _\*2_ | yes | yes | no | lora32u4II |
| TTGO LoRa32 V1.3 | ESP32 | no | yes | no | yes | ttgo_lora32_v1 |
| TTGO LoRa32 V2.0 | ESP32 | yes _\*3_ | yes | no _\*5_ | yes | ttgo_lora32_v2 |
| TTGO LoRa32 V2.0 | ESP32 | yes _\*3_ | yes | no _\*6_ | yes | ttgo_lora32_v2 |
| TTGO LoRa32 V2.1.6 | ESP32 | no | yes | no | yes | ttgo_lora32_v21 |
| TTGO T-Beam<br>*versions v0.5, v0.6 and v0.7* | ESP32 | no | yes | yes | no | ttgo_tbeam |
| TTGO T-Beam<br>*versions v1.0 and v1.1* | ESP32 | no | yes | no | no | ttgo_tbeam_v1 |
Expand All @@ -160,32 +160,35 @@ _\*1_: DIO1 must be manually wired to GPIO6.
_\*2_: For versions 1.0, 1.1 and 1.2 DIO1 must be manually wired to GPIO5 (version 1.3 is already wired on the PCB).
_\*3_: DIO1 must be manually wired to GPIO33.
_\*4_: Requires USB to Serial adapter or Pycom Expansion Board which is explained further below.
_\*5_: Either display (I2C) or LED can be used but not both at the same time. LED is default disabled.
_\*6_: Display (64x32) not supported by LMIC-node because resolution is too small.
_\*5_: Has onboard Neopixel RGB LED but is currently not supported by LMIC-node.
_\*6_: Either display (I2C) or LED can be used but not both at the same time. LED is default disabled.
_\*7_: Display (64x32) not supported by LMIC-node because resolution is too small.

### 2.2 Development boards with external SPI LoRa module

The following development boards require an external SX127x or RFM9x SPI LoRa module.
Most boards have onboard USB that supports automatic firmware upload and serial over USB for serial monitoring.
An external display can be optionally connected. For details and wiring instructions see the board's BSF.

| Board name | MCU | Wiring required | USB | LED | Display | Board-id |
| ---------- | --- | --- | --- | --- | --- | -------- |
| Black Pill STM32F103C8 128k | STM32F103C8T6 | yes | yes _\*7_ | yes | no | blackpill_f103c8_128k |
| Black Pill STM32F103C8 64k | STM32F103C8T6 | yes | yes _\*7_ | yes | no | blackill_f103c8 |
| Blue Pill STM32F103C8 128k | STM32F103C8T6 | yes | yes _\*7_ | yes | no | bluepill_f103c8_128k |
| Blue Pill STM32F103C8 64k | STM32F103C8T6 | yes | yes _\*7_ | yes | no | bluepill_f103c8 |
| Lolin D32 Pro | ESP32 | yes | yes | yes | no | lolin_d32_pro |
| Lolin D32 | ESP32 | yes | yes | yes | no | lolin_d32 |
| Lolin32 | ESP32 | yes | yes | yes | no | lolin32 |
| NodeMCU-32S | ESP32 | yes | yes | yes | no | nodemcu_32 |
| NodeMCU V2 (aka v1.0) | ESP8266 | yes | yes | yes | no | nodemcuv2 |
| Raspberry Pi Pico | RP2040 | yes | yes | yes | no | pico |
| Arduino Pro Mini (ATmega328 8mHz) | ATmega328 | yes | yes | no | no | pro8mhzatmega328 |
| SAMD21 M0-Mini | SAMD21 | yes | yes | no | no | samd21_m0_mini |
| Teensy LC | MKL26Z64VFT4 | yes | yes | yes | no | teensylc |

_\*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.
| Board name | MCU | Wiring required | USB | LED | Display | Board-id |
| ---------- | --- | --- | --- | --- | --- | -------- |
| Adafruit QT PY | SAMD21E18 | yes | yes | no _\*5_ | no | adafruit_qt_py_m0 |
| Black Pill STM32F103C8 128k | STM32F103C8T6 | yes | yes _\*8_ | yes | no | blackpill_f103c8_128k |
| Black Pill STM32F103C8 64k | STM32F103C8T6 | yes | yes _\*8_ | yes | no | blackill_f103c8 |
| Blue Pill STM32F103C8 128k | STM32F103C8T6 | yes | yes _\*8_ | yes | no | bluepill_f103c8_128k |
| Blue Pill STM32F103C8 64k | STM32F103C8T6 | yes | yes _\*8_ | yes | no | bluepill_f103c8 |
| Lolin D32 Pro | ESP32 | yes | yes | yes | no | lolin_d32_pro |
| Lolin D32 | ESP32 | yes | yes | yes | no | lolin_d32 |
| Lolin32 | ESP32 | yes | yes | yes | no | lolin32 |
| NodeMCU-32S | ESP32 | yes | yes | yes | no | nodemcu_32 |
| NodeMCU V2 (aka v1.0) | ESP8266 | yes | yes | yes | no | nodemcuv2 |
| Raspberry Pi Pico | RP2040 | yes | yes | yes | no | pico |
| Arduino Pro Mini (ATmega328 8mHz) | ATmega328 | yes | yes | no | no | pro8mhzatmega328 |
| SAMD21 M0-Mini | SAMD21G18 | yes | yes | no | no | samd21_m0_mini |
| Teensy LC | MKL26Z64VFT4 | yes | yes | yes | no | teensylc |

_\*5_: Has onboard Neopixel RGB LED but is currently not supported by LMIC-node.
_\*8_: 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.

## 3 Details

Expand Down Expand Up @@ -567,7 +570,8 @@ default_envs =
; Development boards that require an external SPI LoRa module:

; Board-id Board name
;--------- ----------
;--------- ----------
; adafruit_qt_py_m0 ; Adafruit QT Py
; blackpill_f103c8_128k ; Black Pill 128k
; blackpill_f103c8 ; Black Pill 64k
; bluepill_f103c8_128k ; Blue Pill 128k
Expand Down
33 changes: 29 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ default_envs =
; Development boards that require an external SPI LoRa module:

; Board-id Board name
;--------- ----------
;--------- ----------
; adafruit_qt_py_m0 ; Adafruit QT Py
; blackpill_f103c8_128k ; Black Pill 128k
; blackpill_f103c8 ; Black Pill 64k
; bluepill_f103c8_128k ; Blue Pill 128k
Expand Down Expand Up @@ -337,7 +338,7 @@ build_flags =

[env:lopy4]
; Pycom LoPy4 (ESP32).
; Onboard WS2812 RGB LED is not supported by LMIC-node.
; Onboard WS2812 RGB LED is currently not supported by LMIC-node.
; No display.
; Requires a Pycom Expansion Board or USB to Serial adapter.
; See Board Support File for details.
Expand All @@ -356,7 +357,7 @@ build_flags =
-D MONITOR_SPEED=${common.monitor_speed}
-D LMIC_PRINTF_TO=Serial
-D USE_SERIAL
; -D USE_LED ; NOT SUPPORTED
; -D USE_LED ; CURRENTLY NOT SUPPORTED
; -D USE_DISPLAY ; Requires external I2C OLED display


Expand Down Expand Up @@ -502,10 +503,34 @@ build_flags =
; ------------------------------------------------------------------------------
; | Development boards that require an external SPI LoRa module |
; | |
; | None of these boards have an onboard display. |
; | None of these boards have an onboard display. |
; | Check the Board Support Files in the boards folder for required wiring!! |
; ------------------------------------------------------------------------------


[env:adafruit_qt_py_m0]
; Adafruit QT Py (SAMD21).
; Onboard Neopixel RGB LED is currently not supported by LMIC-node.
; No display.
platform = atmelsam
board = adafruit_qt_py_m0
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/bsf_adafruit_qt_py_m0.h\"
-D MONITOR_SPEED=${common.monitor_speed}
-D _GNU_SOURCE
-D LMIC_PRINTF_TO=Serial
-D USE_SERIAL
; -D USE_LED ; CURRENTLY NOT SUPPORTED
; -D USE_DISPLAY ; Requires external I2C OLED display


[env:blackpill_f103c8_128k]
; Blackill F103C8 128k (STMF103C8T6).
; No display.
Expand Down
134 changes: 134 additions & 0 deletions src/boards/bsf_adafruit_qt_py_m0.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*******************************************************************************
*
* File: bsf_adafruit_qt_py_m0.h
*
* Function: Board Support File for Adafruit QT Py (SAMD21)
* 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 can be connected.
* Has onboard LED but this is a Neopixel RGB LED which requires
* a separate library and is currently not supported by LMIC-node.
*
* Connect the LoRa module and 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
* ---- ----
* 13 (LED_BUILTIN) defined but there is no LED
* NEOPIX <――――――――――> 11 (PIN_NEOPIXEL) Neopixel LED
* 12 Neopixel enable. Default enabled = HIGH.
*
* I2C [display] GPIO
* --- ----
* SDA <――――――――――> 20 (SDA)
* SCL <――――――――――> 21 (SCL)
*
* SPI/LoRa GPIO
* --- ----
* MOSI <――――――――――> 10 (MOSI)
* MISO <――――――――――> 9 (MISO)
* SCK <――――――――――> 8 (SCK)
* NSS <――――――――――> 1 NOT SS, SS = 0
* RST <――――――――――> - not connected
* DIO0 <――――――――――> 2
* DIO1 <----------> 3
* DIO2 - Not needed for LoRa
*
* Docs: https://docs.platformio.org/en/latest/boards/atmelsam/adafruit_qt_py_m0.html
*
* Identifiers: LMIC-node
* board-id: adafruit_qt_py_m0
* PlatformIO
* board: adafruit_qt_py_m0
* platform: atmelsam
* Arduino
* board: ADAFRUIT_QTPY_M0
* architecture: ARDUINO_ARCH_SAMD
*
******************************************************************************/

#pragma once

#ifndef BSF_ADAFRUIT_QT_PY_M0_H_
#define BSF_ADAFRUIT_QT_PY_M0_H_

#include "LMIC-node.h"

#define DEVICEID_DEFAULT "qt-py" // 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 = 1,
.rxtx = LMIC_UNUSED_PIN,
.rst = LMIC_UNUSED_PIN,
.dio = { /*dio0*/ 2, /*dio1*/ 3, /*dio2*/ LMIC_UNUSED_PIN }
#ifdef MCCI_LMIC
,
.rxtx_rx_active = 0,
.rssi_cal = 8,
.spi_freq = 8000000 /* 8 MHz */
#endif
};

#ifdef USE_SERIAL
Serial_& serial = Serial;
#endif

#ifdef USE_LED
#error "Invalid option: USE_LED. Onboard Neopixel RGB LED is currently not supported."
#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.
// No actions required for this board.
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 // BSF_ADAFRUIT_QT_PY_M0_H_

0 comments on commit 4089d47

Please sign in to comment.