From 0b90ffad87695aa1ef54b8844cd934b1da0cc218 Mon Sep 17 00:00:00 2001 From: Pete Lewis <601236+lewispg228@users.noreply.github.com> Date: Sun, 9 Jun 2024 22:06:29 -0600 Subject: [PATCH] adds board support for SparkFun Thing Plus NORAW306 (#233) * board support for SparkFun Thing Plus NORAW306 * added SPI function to pin descriptions * board name correction * SPI and Wire updates * WS2812B board support compile error * SPI.begin bug fix -Moved SPI.begin() out of show() and into begin(). -whne you call show multiple times to change the LED, then SPI.begin() was being called and causing it to fail. * Update WS2812B.cpp fix for compatibility issue BOARD_AMB23, BOARD_AITHINKER_BW16 --- Arduino_package/hardware/boards.txt | 45 +++++++ .../hardware/libraries/SPI/src/SPI.cpp | 2 +- .../hardware/libraries/SPI/src/SPI.h | 2 +- .../libraries/WS2812B/src/WS2812B.cpp | 68 ++++------ .../hardware/libraries/WS2812B/src/WS2812B.h | 2 +- .../hardware/libraries/Wire/src/Wire.cpp | 2 +- .../hardware/libraries/Wire/src/Wire.h | 2 +- .../pins_arduino.h | 20 +++ .../sparkfun_thingplus-nora-w306/variant.cpp | 89 +++++++++++++ .../sparkfun_thingplus-nora-w306/variant.h | 123 ++++++++++++++++++ 10 files changed, 304 insertions(+), 51 deletions(-) create mode 100644 Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/pins_arduino.h create mode 100644 Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/variant.cpp create mode 100644 Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/variant.h diff --git a/Arduino_package/hardware/boards.txt b/Arduino_package/hardware/boards.txt index dd4627b9..2fa97ca3 100644 --- a/Arduino_package/hardware/boards.txt +++ b/Arduino_package/hardware/boards.txt @@ -322,3 +322,48 @@ u-blox_NORA-W30.menu.UploadBaudrate.921600.upload.speed=921600 u-blox_NORA-W30.menu.UploadBaudrate.1500000=1500000 u-blox_NORA-W30.menu.UploadBaudrate.1500000.upload.speed=1500000 ############################################################## + +Sparkfun_ThingPlus-NORA-W306.name=SparkFun Thing Plus NORA-W306 (RTL8720DF) + +Sparkfun_ThingPlus-NORA-W306.build.tarch=cortex-m33 +Sparkfun_ThingPlus-NORA-W306.build.mcu=RTL8720DF +Sparkfun_ThingPlus-NORA-W306.build.f_cpu=200000000L +Sparkfun_ThingPlus-NORA-W306.build.usb_product="Sparkfun_ThingPlus-NORA-W306" +Sparkfun_ThingPlus-NORA-W306.build.board=SPARKFUN_THINGPLUS_NORAW306 +Sparkfun_ThingPlus-NORA-W306.build.core=ambd +Sparkfun_ThingPlus-NORA-W306.build.extra_flags=-mthumb -DRTL8722DM -DBOARD_SPARKFUN_NORAW306 {build.usb_flags} -DArduino_STD_PRINTF +Sparkfun_ThingPlus-NORA-W306.build.ldscript=linker_scripts/gcc/amebad_img2_is_arduino.ld +Sparkfun_ThingPlus-NORA-W306.build.variant=sparkfun_thingplus-nora-w306 + +Sparkfun_ThingPlus-NORA-W306.upload.tool=ameba_d_tools +Sparkfun_ThingPlus-NORA-W306.upload.protocol=usb_serial +Sparkfun_ThingPlus-NORA-W306.upload.maximum_size=2097152 +Sparkfun_ThingPlus-NORA-W306.upload.use_1200bps_touch=false +Sparkfun_ThingPlus-NORA-W306.upload.wait_for_upload_port=false +Sparkfun_ThingPlus-NORA-W306.upload.native_usb=false +Sparkfun_ThingPlus-NORA-W306.upload.auto_mode=Disable +Sparkfun_ThingPlus-NORA-W306.upload.erase_flash=Disable +Sparkfun_ThingPlus-NORA-W306.upload.speed=921600 + +Sparkfun_ThingPlus-NORA-W306.menu.EraseFlash.Disable=Disable +Sparkfun_ThingPlus-NORA-W306.menu.EraseFlash.Disable.upload.erase_flash=Disable +Sparkfun_ThingPlus-NORA-W306.menu.EraseFlash.Enable=Erase only +Sparkfun_ThingPlus-NORA-W306.menu.EraseFlash.Enable.upload.erase_flash=Enable + +Sparkfun_ThingPlus-NORA-W306.menu.AutoUploadMode.Enable=Enable +Sparkfun_ThingPlus-NORA-W306.menu.AutoUploadMode.Enable.upload.auto_mode=Enable +Sparkfun_ThingPlus-NORA-W306.menu.AutoUploadMode.Disable=Disable +Sparkfun_ThingPlus-NORA-W306.menu.AutoUploadMode.Disable.upload.auto_mode=Disable + +Sparkfun_ThingPlus-NORA-W306.menu.StdLibInit.Enable=Arduino_STD_PRINTF +Sparkfun_ThingPlus-NORA-W306.menu.StdLibInit.Enable.build.extra_flags=-mthumb -DRTL8722DM -DBOARD_SPARKFUN_NORAW306 {build.usb_flags} -DArduino_STD_PRINTF +Sparkfun_ThingPlus-NORA-W306.menu.StdLibInit.Disable=Disable +Sparkfun_ThingPlus-NORA-W306.menu.StdLibInit.Disable.build.extra_flags=-mthumb -DRTL8722DM -DBOARD_SPARKFUN_NORAW306 {build.usb_flags} +Sparkfun_ThingPlus-NORA-W306.menu.StdLibInit.Enable=Arduino_STD_PRINTF +Sparkfun_ThingPlus-NORA-W306.menu.StdLibInit.Enable.build.extra_flags=-mthumb -DRTL8722DM -DBOARD_SPARKFUN_NORAW306 {build.usb_flags} -DArduino_STD_PRINTF + +Sparkfun_ThingPlus-NORA-W306.menu.UploadBaudrate.921600=921600 +Sparkfun_ThingPlus-NORA-W306.menu.UploadBaudrate.921600.upload.speed=921600 +Sparkfun_ThingPlus-NORA-W306.menu.UploadBaudrate.1500000=1500000 +Sparkfun_ThingPlus-NORA-W306.menu.UploadBaudrate.1500000.upload.speed=1500000 +############################################################## diff --git a/Arduino_package/hardware/libraries/SPI/src/SPI.cpp b/Arduino_package/hardware/libraries/SPI/src/SPI.cpp index f3408097..9c6f1df4 100644 --- a/Arduino_package/hardware/libraries/SPI/src/SPI.cpp +++ b/Arduino_package/hardware/libraries/SPI/src/SPI.cpp @@ -396,7 +396,7 @@ SPIClass SPI((void *)(&spi_obj0), SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_SS); SPIClass SPI((void *)(&spi_obj0), SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_SS); // 1, 2, 0, 8 SPIClass SPI1((void *)(&spi_obj1), SPI1_MOSI, SPI1_MISO, SPI1_SCLK, SPI1_SS); // 14, 15, 16, 17 or 4, 3, 29, 28 -#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) +#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) || defined(BOARD_SPARKFUN_NORAW306) SPIClass SPI((void *)(&spi_obj0), SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_SS); // 17, 16, 19, 18 SPIClass SPI1((void *)(&spi_obj1), SPI1_MOSI, SPI1_MISO, SPI1_SCLK, SPI1_SS); // 3, 2, 1, 0 diff --git a/Arduino_package/hardware/libraries/SPI/src/SPI.h b/Arduino_package/hardware/libraries/SPI/src/SPI.h index 0bf18b33..5280d7e0 100644 --- a/Arduino_package/hardware/libraries/SPI/src/SPI.h +++ b/Arduino_package/hardware/libraries/SPI/src/SPI.h @@ -131,7 +131,7 @@ extern SPIClass SPI; #elif defined(BOARD_SPARKFUN_AWCU488) extern SPIClass SPI; extern SPIClass SPI1; -#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) +#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) || defined(BOARD_SPARKFUN_NORAW306) extern SPIClass SPI; extern SPIClass SPI1; #else diff --git a/Arduino_package/hardware/libraries/WS2812B/src/WS2812B.cpp b/Arduino_package/hardware/libraries/WS2812B/src/WS2812B.cpp index c11604aa..e6473458 100644 --- a/Arduino_package/hardware/libraries/WS2812B/src/WS2812B.cpp +++ b/Arduino_package/hardware/libraries/WS2812B/src/WS2812B.cpp @@ -29,6 +29,28 @@ void WS2812B::begin(void) { printf("spi_init: error. wrong spi_idx \r\n"); return; } + if (_input_pin == SPI_MOSI) { + SPI.begin(); + //Revert the unnecessary SPI pins to GPIO functions + Pinmux_Config((PinName)g_APinDescription[SPI_MISO].pinname, PINMUX_FUNCTION_GPIO); + Pinmux_Config((PinName)g_APinDescription[SPI_SCLK].pinname, PINMUX_FUNCTION_GPIO); + Pinmux_Config((PinName)g_APinDescription[SPI_SS].pinname, PINMUX_FUNCTION_GPIO); + SPI.setDefaultFrequency(2500000); + SPI.setDataMode(12, 0); +#if !defined(BOARD_AMB23) && !defined(BOARD_AITHINKER_BW16) + } else if (_input_pin == SPI1_MOSI) { + SPI1.begin(); + //Revert the unnecessary SPI pins to GPIO functions + Pinmux_Config((PinName)g_APinDescription[SPI1_MISO].pinname, PINMUX_FUNCTION_GPIO); + Pinmux_Config((PinName)g_APinDescription[SPI1_SCLK].pinname, PINMUX_FUNCTION_GPIO); + Pinmux_Config((PinName)g_APinDescription[SPI1_SS].pinname, PINMUX_FUNCTION_GPIO); + SPI1.setDefaultFrequency(2500000); + SPI1.setDataMode(12, 0); +#endif + } else { + printf("spi_init: error. wrong spi_idx \r\n"); + return; + } } void WS2812B::sendPixel(uint8_t red ,uint8_t green ,uint8_t blue) { @@ -55,52 +77,6 @@ void WS2812B::sendPixel(uint8_t red ,uint8_t green ,uint8_t blue) { } void WS2812B::show(void) { -#if 0 - if (_input_pin == SPI_MOSI) { - //Initialise SPI - spi_init((spi_t *)pSpiMaster, (PinName)g_APinDescription[_input_pin].pinname, (PinName)g_APinDescription[SPI_MISO].pinname, (PinName)g_APinDescription[SPI_SCLK].pinname, (PinName)g_APinDescription[SPI_SS].pinname); - //Revert the unnecessary SPI pins to GPIO functions - Pinmux_Config((PinName)g_APinDescription[SPI_SCLK].pinname, PINMUX_FUNCTION_GPIO); - Pinmux_Config((PinName)g_APinDescription[SPI_SCLK].pinname, PINMUX_FUNCTION_GPIO); - Pinmux_Config((PinName)g_APinDescription[SPI_SS].pinname, PINMUX_FUNCTION_GPIO); - } else if (_input_pin == SPI1_MOSI) { - spi_init((spi_t *)pSpiMaster, (PinName)g_APinDescription[_input_pin].pinname, (PinName)g_APinDescription[SPI1_MISO].pinname, (PinName)g_APinDescription[SPI1_SCLK].pinname, (PinName)g_APinDescription[SPI1_SS].pinname); - //Revert the unnecessary SPI pins to GPIO functions - Pinmux_Config((PinName)g_APinDescription[SPI1_SCLK].pinname, PINMUX_FUNCTION_GPIO); - Pinmux_Config((PinName)g_APinDescription[SPI1_SCLK].pinname, PINMUX_FUNCTION_GPIO); - Pinmux_Config((PinName)g_APinDescription[SPI1_SS].pinname, PINMUX_FUNCTION_GPIO); - } else { - printf("spi_init: error. wrong spi_idx \r\n"); - return; - } - spi_format((spi_t *)pSpiMaster, 12, 0, 0); - spi_frequency((spi_t *)pSpiMaster, 2500000); -#else - if (_input_pin == SPI_MOSI) { - //Initialise SPI - SPI.begin(); - //Revert the unnecessary SPI pins to GPIO functions - Pinmux_Config((PinName)g_APinDescription[SPI_MISO].pinname, PINMUX_FUNCTION_GPIO); - Pinmux_Config((PinName)g_APinDescription[SPI_SCLK].pinname, PINMUX_FUNCTION_GPIO); - Pinmux_Config((PinName)g_APinDescription[SPI_SS].pinname, PINMUX_FUNCTION_GPIO); - SPI.setDefaultFrequency(2500000); - SPI.setDataMode(12, 0); -#if !defined(BOARD_AMB23) && !defined(BOARD_AITHINKER_BW16) - } else if (_input_pin == SPI1_MOSI) { - //Initialise SPI - SPI1.begin(); - //Revert the unnecessary SPI pins to GPIO functions - Pinmux_Config((PinName)g_APinDescription[SPI1_MISO].pinname, PINMUX_FUNCTION_GPIO); - Pinmux_Config((PinName)g_APinDescription[SPI1_SCLK].pinname, PINMUX_FUNCTION_GPIO); - Pinmux_Config((PinName)g_APinDescription[SPI1_SS].pinname, PINMUX_FUNCTION_GPIO); - SPI1.setDefaultFrequency(2500000); - SPI1.setDataMode(12, 0); -#endif - } else { - printf("spi_init: error. wrong spi_idx \r\n"); - return; - } -#endif //Send Reset pulse of at least 50us duration for (uint8_t i = 0; i < reset_count; i++) { spi_slave_write((spi_t *)pSpiMaster, 0); diff --git a/Arduino_package/hardware/libraries/WS2812B/src/WS2812B.h b/Arduino_package/hardware/libraries/WS2812B/src/WS2812B.h index d914ce7a..e3655733 100644 --- a/Arduino_package/hardware/libraries/WS2812B/src/WS2812B.h +++ b/Arduino_package/hardware/libraries/WS2812B/src/WS2812B.h @@ -51,7 +51,7 @@ extern SPIClass SPI; #elif defined(BOARD_SPARKFUN_AWCU488) extern SPIClass SPI; extern SPIClass SPI1; -#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) +#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) || defined(BOARD_SPARKFUN_NORAW306) extern SPIClass SPI; extern SPIClass SPI1; #else diff --git a/Arduino_package/hardware/libraries/Wire/src/Wire.cpp b/Arduino_package/hardware/libraries/Wire/src/Wire.cpp index e6c94f16..f9591c80 100644 --- a/Arduino_package/hardware/libraries/Wire/src/Wire.cpp +++ b/Arduino_package/hardware/libraries/Wire/src/Wire.cpp @@ -317,7 +317,7 @@ TwoWire Wire = TwoWire(I2C_SDA, I2C_SCL); // PA_26, PA_25 // HW: I2C0 TwoWire Wire = TwoWire(I2C_SDA, I2C_SCL); // PA_26, PA_25 / PB_6, PB_5 -#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) +#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) || defined(BOARD_SPARKFUN_NORAW306) // SDA SCL // HW: I2C0 TwoWire Wire = TwoWire(I2C_SDA, I2C_SCL); // PA_26, PA_25 diff --git a/Arduino_package/hardware/libraries/Wire/src/Wire.h b/Arduino_package/hardware/libraries/Wire/src/Wire.h index e9540bde..b7cbba7e 100644 --- a/Arduino_package/hardware/libraries/Wire/src/Wire.h +++ b/Arduino_package/hardware/libraries/Wire/src/Wire.h @@ -108,7 +108,7 @@ extern TwoWire Wire1; extern TwoWire Wire; #elif defined(BOARD_SPARKFUN_AWCU488) extern TwoWire Wire; -#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) +#elif defined(BOARD_AMB25) || defined(BOARD_AMB26) || defined(BOARD_UBLOX_NORAW30) || defined(BOARD_SPARKFUN_NORAW306) extern TwoWire Wire; #endif diff --git a/Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/pins_arduino.h b/Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/pins_arduino.h new file mode 100644 index 00000000..1ca5600e --- /dev/null +++ b/Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/pins_arduino.h @@ -0,0 +1,20 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" diff --git a/Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/variant.cpp b/Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/variant.cpp new file mode 100644 index 00000000..022241ab --- /dev/null +++ b/Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/variant.cpp @@ -0,0 +1,89 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* SparkFun Thing Plus NORA-W306 (RTL8720DF) */ + +#include "variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +//#include "PinNames.h" +void __libc_init_array(void); + +/* + * Pins descriptions + */ + +PinDescription g_APinDescription[TOTAL_GPIO_PIN_NUM]= +{ + {PA_8, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ , MODE_NOT_INITIAL}, // AMB_D0 + {PA_7, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ , MODE_NOT_INITIAL}, // AMB_D1 + {PA_30, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM , MODE_NOT_INITIAL}, // AMB_D2 + {PA_28, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM , MODE_NOT_INITIAL}, // AMB_D3 + {PB_21, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM | PIO_SPI, MODE_NOT_INITIAL}, // AMB_D4 + {PB_20, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM | PIO_SPI, MODE_NOT_INITIAL}, // AMB_D5 + {PB_18, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM | PIO_SPI, MODE_NOT_INITIAL}, // AMB_D6 + {PB_19, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM | PIO_SPI, MODE_NOT_INITIAL}, // AMB_D7 + {PB_2, TYPE_DIGITAL | TYPE_ANALOG, PIO_GPIO | PIO_GPIO_IRQ | PIO_ADC , MODE_NOT_INITIAL}, // AMB_D8 + {PB_1, TYPE_DIGITAL | TYPE_ANALOG, PIO_GPIO | PIO_GPIO_IRQ | PIO_ADC , MODE_NOT_INITIAL}, // AMB_D9 + {PA_27, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ , MODE_NOT_INITIAL}, // AMB_D10 + {PA_26, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM | PIO_I2C , MODE_NOT_INITIAL}, // AMB_D11 + {PA_25, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM | PIO_I2C , MODE_NOT_INITIAL}, // AMB_D12 + {PA_13, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM | PIO_SPI, MODE_NOT_INITIAL}, // AMB_D13 + {PA_12, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM | PIO_SPI, MODE_NOT_INITIAL}, // AMB_D14 + {PA_15, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_SPI, MODE_NOT_INITIAL}, // AMB_D15 + {PA_14, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_SPI, MODE_NOT_INITIAL}, // AMB_D16 + {PB_23, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM , MODE_NOT_INITIAL}, // AMB_D17 + {PB_22, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM , MODE_NOT_INITIAL}, // AMB_D18 + {PB_3, TYPE_DIGITAL | TYPE_ANALOG, PIO_GPIO | PIO_GPIO_IRQ | PIO_ADC , MODE_NOT_INITIAL}, // AMB_D19 + {PB_24, TYPE_DIGITAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM , MODE_NOT_INITIAL}, // AMB_D20 +}; + +void *gpio_pin_struct[TOTAL_GPIO_PIN_NUM] = {NULL}; +void *gpio_irq_handler_list[TOTAL_GPIO_PIN_NUM] = {NULL}; + +#ifdef __cplusplus +} // extern C +#endif + +void serialEvent() __attribute__((weak)); +bool Serial_available() __attribute__((weak)); + +// ---------------------------------------------------------------------------- + +void serialEventRun(void) +{ + if (Serial_available && serialEvent && Serial_available()) serialEvent(); +} + +void init(void) +{ + // Initialize C library + __libc_init_array(); +} + +// ---------------------------------------------------------------------------- + +void wait_for_debug(void) { + while (((CoreDebug->DHCSR) & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) { + asm("nop"); + } + delay(1000); +} diff --git a/Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/variant.h b/Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/variant.h new file mode 100644 index 00000000..414e10bd --- /dev/null +++ b/Arduino_package/hardware/variants/sparkfun_thingplus-nora-w306/variant.h @@ -0,0 +1,123 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* SparkFun Thing Plus NORA-W306 (RTL8720DF) */ + +#ifndef _VARIANT_ARDUINO_AMEBA_ +#define _VARIANT_ARDUINO_AMEBA_ + +#include "Arduino.h" +#include + +#ifdef __cplusplus +extern "C"{ +#include "PinNames.h" + +#define portOutputRegister(P) ((volatile uint32_t *)(0x48014000 + (P) * 0x400)) +#define portInputRegister(P) ((volatile uint32_t *)(0x48014050 + (P) * 0x400)) +#define portModeRegister(P) ((volatile uint32_t *)(0x48014004 + (P) * 0x400)) + +/* + * Wait until enter debug mode + * + * Check DHCSR(0xE000EDF0) register and hold until bit C_DEBUGEN is set. + * Use this function along with J-LINK or other debug tool + **/ +extern void wait_for_debug(void); +} +#endif + +#define MAIN_THREAD_STACK_SIZE (4096 * 4) + +#define TOTAL_GPIO_PIN_NUM (21) +#define TOTAL_PWM_PIN_NUM (12) + +/* Digital pin mapping refer to g_APinDescription */ +// index into g_APinDescription --v AMEBA NORA Function + +// Analog pin mapping +#define A0 19 // PB_1 +#define A1 8 // PB_3 +#define A2 9 // PB_2 + +// NORA-W30 module pad names +#define NORA_A5 1 // PA_7 NORA_A5 DBG_TX +#define NORA_A6 0 // PA_8 NORA_A6 DBG_RX +#define NORA_B1 11 // PA_30 NORA_B1 SPI_SCLK +#define NORA_B3 12 // PA_28 NORA_B3 SPI_CS +#define NORA_C1 7 // PA_26 NORA_C1 SPI_MISO +#define NORA_C2 6 // PA_25 NORA_C2 SPI_MOSI +#define NORA_C8 16 // PB_23 NORA_C8 SW2 +#define NORA_D8 17 // PB_1 NORA_D8 SW1 +#define NORA_E8 19 // PB_2 NORA_E8 UART_DTR +#define NORA_E9 15 // PB_22 NORA_E9 UART_DSR +#define NORA_F8 9 // PB_21 NORA_F8 I2C_SDA / UART_RTS +#define NORA_F9 10 // PB_20 NORA_F9 I2C_SCL / UART_CTS +#define NORA_G8 13 // PB_19 NORA_G8 UART_TXD +#define NORA_G9 14 // PB_18 NORA_G9 UART_RXD +#define NORA_H2 8 // PA_27 NORA_H2 +#define NORA_H8 2 // PA_15 NORA_H8 LED_GREEN +#define NORA_H9 3 // PA_14 NORA_H9 LED_BLUE +#define NORA_J2 18 // PB_3 NORA_J2 +#define NORA_J8 5 // PA_13 NORA_J8 LED_RED +#define NORA_J9 4 // PA_12 NORA_J9 + +/* LED pin mapping */ +#define LED_BUILTIN 18 // PB_22 + +/* ADC/DAC pin mapping */ +#define FEATURE_ADC +//#define FEATURE_DAC + +/* SPI pin mapping */ +#define SPI_PICO 6 // PB_18 +#define SPI_POCI 7 // PB_19 +#define SPI_SCLK 5 // PB_20 +#define SPI_SS 4 // PB_21 + +/* SPI1 pin mapping */ +#define SPI1_PICO 14 // PA_12 +#define SPI1_POCI 13 // PA_13 +#define SPI1_SCLK 16 // PA_14 +#define SPI1_SS 15 // PA_15 + +/* Naming modernization/backwards compatibility*/ +#define SPI_MOSI SPI_PICO +#define SPI_MISO SPI_POCI +#define SPI1_MOSI SPI1_PICO +#define SPI1_MISO SPI1_POCI + +/* "SS" is used in some libraries, e.g. SdFat. */ +#define SS SPI_SS + +/* TwoWire/I2C pin mapping */ +#define I2C_SDA 11 // PA_26 +#define I2C_SCL 12 // PA_25 + +/* UART pin mapping */ +#define LOG_UART_MODIFIABLE_BAUD_RATE 1 +#define SERIAL_ONE_UART_MODIFIABLE_BAUD_RATE 1 +#define SERIAL_TWO_UART_MODIFIABLE_BAUD_RATE 1 +#define LOG_TX 1 // PA_7 +#define LOG_RX 0 // PA_8 +#define SERIAL1_TX 9 // PB_1 +#define SERIAL1_RX 8 // PB_2 +#define SERIAL2_TX 4 // PA_12 +#define SERIAL2_RX 5 // PA_13 + +#endif /* _VARIANT_ARDUINO_AMEBA_ */