Merge branch 'master' into Serial2

This commit is contained in:
Ha Thach authored and GitHub committed 2020-01-31 17:47:49 +07:00
commit c84538a4f6
293 files changed
+66758 -23994

No files matched your search

@@ -0,0 +1,82 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"
const uint32_t g_ADigitalPinMap[] =
{
// D0 .. D13
30, // D0 is P0.30 (GPIO D0 / A6 / UART RX)
14, // D1 is P0.14 (GPIO D1 / UART TX)
5, // D2 is P0.05 (GPIO D2 / A5 / SDA)
4, // D3 is P0.04 (GPIO D3 / A4 / SCL)
34, // D4 is P1.02 (GPIO D4 / Left Button)
47, // D5 is P1.15 (GPIO D5 / Right button)
2, // D6 is P0.02 (GPIO D6 / A1)
38, // D7 is P1.06 (GPIO D7 / Slide Switch)
13, // D8 is P0.13 (GPIO D8 / NeoPixels)
29, // D9 is P0.29 (GPIO D9 / A2)
3, // D10 is P0.03 (GPIO D10 / A3)
36, // D11 is P1.04 (GPIO D11 / Speaker Shutdown)
26, // D12 is P0.26 (GPIO D12 / Audio Out)
46, // D13 is P1.14 (GPIO D13 / Red LED)
// D14 .. D23
26, // NOT REALLY ANALOG, A PLACEHODER SINCE D12 is not analog
2, // D6 is P0.02 (GPIO D6 / A1)
29, // D9 is P0.29 (GPIO D9 / A2)
3, // D10 is P0.03 (GPIO D10 / A3)
4, // D3 is P0.04 (GPIO D3 / A4 / SCL)
5, // D2 is P0.05 (GPIO D2 / A5 / SDA)
30, // D0 is P0.30 (GPIO D0 / A6 / UART RX)
14, // NOT REALLY ANALOG, A PLACEHODER SINCE D1 is not analog
28, // A8 - Light sensor
31, // A9 - Thermistor sensor
// D24 & D25 PDM pins
16, // D24 is P0.16 (PDM DAT)
17, // D25 is P0.17 (PDM CLK)
44, // D26 is P1.12 (LIS SCL)
45, // D27 is P1.13 (LIS IRQ)
42, // D28 is P1.10 (LIS SDA)
// QSPI pins (not exposed via any header / test point)
19, // D29 is P0.19 (QSPI CLK)
15, // D30 is P0.15 (QSPI CS)
21, // D31 is P0.21 (QSPI Data 0)
23, // D32 is P0.23 (QSPI Data 1)
32, // D33 is P1.00 (QSPI Data 2)
22, // D34 is P0.22 (QSPI Data 3)
// D35 power switch
6, // D36 is P0.06 (NeoPixel / Sensor switch)
};
void initVariant()
{
// LED1
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
}
@@ -0,0 +1,154 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#ifndef _VARIANT_CIRCUITPLAY52840_
#define _VARIANT_CIRCUITPLAY52840_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
//#define USE_LFXO // Board uses 32khz crystal for LF
#define USE_LFRC // Board uses RC for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
// Number of pins defined in PinDescription array
#define PINS_COUNT (36)
#define NUM_DIGITAL_PINS (36)
#define NUM_ANALOG_INPUTS (8)
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (13)
#define PIN_NEOPIXEL (8)
#define LED_BUILTIN PIN_LED1
#define LED_RED PIN_LED1
#define LED_BLUE PIN_LED1
#define LED_STATE_ON 1 // State when LED is litted
// Buttons
#define PIN_BUTTON1 (4)
#define PIN_BUTTON2 (5)
// Microphone
#define PIN_PDM_DIN 24
#define PIN_PDM_CLK 25
#define PIN_PDM_PWR -1 // not used
/*
* Analog pins
*/
#define PIN_A0 (14) // not really analog!
#define PIN_A1 (15)
#define PIN_A2 (16)
#define PIN_A3 (17)
#define PIN_A4 (18)
#define PIN_A5 (19)
#define PIN_A6 (20)
#define PIN_A7 (21) // not really analog!
#define PIN_A8 (22)
#define PIN_A9 (23)
static const uint8_t A0 = PIN_A0 ;
static const uint8_t A1 = PIN_A1 ;
static const uint8_t A2 = PIN_A2 ;
static const uint8_t A3 = PIN_A3 ;
static const uint8_t A4 = PIN_A4 ;
static const uint8_t A5 = PIN_A5 ;
static const uint8_t A6 = PIN_A6 ;
static const uint8_t A7 = PIN_A7 ;
static const uint8_t A8 = PIN_A8 ;
static const uint8_t A9 = PIN_A9 ;
#define ADC_RESOLUTION 14
/*
* Serial interfaces
*/
// Serial
#define PIN_SERIAL_RX (0)
#define PIN_SERIAL_TX (1)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (10)
#define PIN_SPI_MOSI (2)
#define PIN_SPI_SCK (3)
static const uint8_t SS = (0);
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK = PIN_SPI_SCK ;
/*
* Wire Interfaces
*/
#define WIRE_INTERFACES_COUNT 2
#define PIN_WIRE_SDA (2)
#define PIN_WIRE_SCL (3)
#define PIN_WIRE1_SDA (28)
#define PIN_WIRE1_SCL (26)
/*
* QSPI Interfaces
*/
#define PIN_QSPI_SCK 29
#define PIN_QSPI_CS 30
#define PIN_QSPI_IO0 31
#define PIN_QSPI_IO1 32
#define PIN_QSPI_IO2 33
#define PIN_QSPI_IO3 34
// On-board QSPI Flash
#define EXTERNAL_FLASH_DEVICES GD25Q16C
#define USB_MSC_BLOCK_SIZE 512
#define USB_MSC_BLOCK_COUNT ((2*1024*1024) / USB_MSC_BLOCK_SIZE)
/*
* PDM Interfaces
*/
#define PIN_PDM_DIN 24
#define PIN_PDM_CLK 25
#define PIN_PDM_PWR -1 // not used
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#endif
+93
View File
@@ -0,0 +1,93 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"
const uint32_t g_ADigitalPinMap[] =
{
// D0 .. D20
4, // D0 is P0.04 (GPIO D0 / AIN2 / UART RX)
5, // D1 is P0.05 (GPIO D1 / AIN3 / UART TX)
3, // D2 is P0.03 (GPIO D2 / AIN4)
28, // D3 is P0.28 (GPIO D3 / AIN5)
2, // D4 is P0.02 (GPIO D4 / AIN6)
34, // D5 is P1.02 (GPIO D5 / Left button)
41, // D6 is P1.09 (GPIO D6)
7, // D7 is P0.07 (GPIO D7)
39, // D8 is P1.07 (GPIO D8)
27, // D9 is P0.27 (GPIO D9)
30, // D10 is P0.30 (GPIO D10 / AIN7)
42, // D11 is P1.10 (GPIO D11 / Right Button)
31, // D12 is P0.31 (GPIO D12 / AIN0)
8, // D13 is P0.08 (GPIO D13 / SCK)
6, // D14 is P0.06 (GPIO D14 / MISO)
26, // D15 is P0.26 (GPIO D15 / MOSI)
29, // D16 is P0.29 (GPIO D16 / AIN1)
33, // D17 is P1.01 (Red LED)
16, // D18 is P0.16 (NeoPixel)
25, // D19 is P0.25 (GPIO D19 / SCL)
24, // D20 is P0.24 (GPIO D20 / SDA)
// D21..D28 (A0 to A7)
31, // D12 is P0.31 (GPIO D12 / AIN0)
29, // D16 is P0.29 (GPIO D16 / AIN1)
4, // D0 is P0.04 (GPIO D0 / AIN2 / UART RX)
5, // D1 is P0.05 (GPIO D1 / AIN3 / UART TX)
3, // D2 is P0.03 (GPIO D2 / AIN4)
28, // D3 is P0.28 (GPIO D3 / AIN5)
2, // D4 is P0.02 (GPIO D4 / AIN6)
30, // D10 is P0.30 (GPIO D10 / AIN7)
// D29 .. D34 - TFT control
14, // P0.14 (TFT SCK)
15, // P0.15 (TFT MOSI)
12, // P0.12 (TFT CS)
13, // P0.13 (TFT DC)
35, // P1.03 (TFT RESET)
37, // P1.05 (TFT LITE)
// 35 & 36 - PDM mic
0, // D35 is P0.00 (PDM DAT)
1, // D36 is P0.01 (PDM CLK)
// QSPI pins (not exposed via any header / test point)
19, // D37 is P0.19 (QSPI CLK)
20, // D38 is P0.20 (QSPI CS)
17, // D39 is P0.17 (QSPI Data 0)
22, // D40 is P0.22 (QSPI Data 1)
23, // D41 is P0.23 (QSPI Data 2)
21, // D42 is P0.21 (QSPI Data 3)
10, // D43 is P0.10 white LED control
9, // D44 is P0.09 APDS IRQ
38, // D45 is P1.06 LSM6DS33 IRQ
32, // D46 is P1.00 Speaker/buzzer
};
void initVariant()
{
// LED1
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
}
+147
View File
@@ -0,0 +1,147 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#ifndef _VARIANT_CLUE52840_
#define _VARIANT_CLUE52840_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFRC // Board uses RC for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
// Number of pins defined in PinDescription array
#define PINS_COUNT (47)
#define NUM_DIGITAL_PINS (47)
#define NUM_ANALOG_INPUTS (8)
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (17)
#define PIN_NEOPIXEL (18)
#define LED_BUILTIN PIN_LED1
#define LED_RED PIN_LED1
#define LED_BLUE PIN_LED1
#define LED_STATE_ON 1 // State when LED is litted
// Buttons
#define PIN_BUTTON1 (5)
#define PIN_BUTTON2 (11)
// Microphone
#define PIN_PDM_DIN 35
#define PIN_PDM_CLK 36
#define PIN_PDM_PWR -1 // not used
/*
* Analog pins
*/
#define PIN_A0 (21)
#define PIN_A1 (22)
#define PIN_A2 (23)
#define PIN_A3 (24)
#define PIN_A4 (25)
#define PIN_A5 (26)
#define PIN_A6 (27)
#define PIN_A7 (28)
static const uint8_t A0 = PIN_A0 ;
static const uint8_t A1 = PIN_A1 ;
static const uint8_t A2 = PIN_A2 ;
static const uint8_t A3 = PIN_A3 ;
static const uint8_t A4 = PIN_A4 ;
static const uint8_t A5 = PIN_A5 ;
static const uint8_t A6 = PIN_A6 ;
static const uint8_t A7 = PIN_A7 ;
#define ADC_RESOLUTION 14
/*
* Serial interfaces
*/
// Serial
#define PIN_SERIAL_RX (0)
#define PIN_SERIAL_TX (1)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 2
#define PIN_SPI_MISO (14)
#define PIN_SPI_MOSI (15)
#define PIN_SPI_SCK (13)
static const uint8_t SS = (16);
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK = PIN_SPI_SCK ;
#define PIN_SPI1_MISO (35)
#define PIN_SPI1_MOSI (30)
#define PIN_SPI1_SCK (29)
static const uint8_t SS1 = (31);
static const uint8_t MOSI1 = PIN_SPI1_MOSI ;
static const uint8_t MISO1 = PIN_SPI1_MISO ;
static const uint8_t SCK1 = PIN_SPI1_SCK ;
/*
* Wire Interfaces
*/
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA (20)
#define PIN_WIRE_SCL (19)
// QSPI Pins
#define PIN_QSPI_SCK 37
#define PIN_QSPI_CS 38
#define PIN_QSPI_IO0 39
#define PIN_QSPI_IO1 40
#define PIN_QSPI_IO2 41
#define PIN_QSPI_IO3 42
// On-board QSPI Flash
#define EXTERNAL_FLASH_DEVICES GD25Q16C
#define USB_MSC_BLOCK_SIZE 512
#define USB_MSC_BLOCK_COUNT ((2*1024*1024) / USB_MSC_BLOCK_SIZE)
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#endif
-1
View File
@@ -67,7 +67,6 @@ const uint32_t g_ADigitalPinMap[] = {
29, // A5
30, // A6
31, // A7
};
void initVariant()
+1 -1
View File
@@ -100,7 +100,7 @@ static const uint8_t AREF = PIN_AREF;
#define PIN_SPI_MOSI (13)
#define PIN_SPI_SCK (12)
static const uint8_t SS = 18 ;
static const uint8_t SS = 27 ;
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK = PIN_SPI_SCK ;
+3 -6
View File
@@ -55,13 +55,10 @@ extern "C"
#define LED_STATE_ON 1 // State when LED is litted
// Buttons
/*
#define PIN_BUTTON1 (2)
#define PIN_BUTTON2 (3)
#define PIN_BUTTON3 (4)
#define PIN_BUTTON4 (5)
*/
* Buttons
*/
#define PIN_BUTTON1 (7)
/*
* Analog pins
@@ -0,0 +1,104 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"
const uint32_t g_ADigitalPinMap[] =
{
// D0 .. D13
25, // D0 is P0.25 (UART RX)
24, // D1 is P0.24 (UART TX)
34, // D2 is P1.02
6, // D3 is P0.06 LED
29, // D4 is P0.29 Button
27, // D5 is P0.27
41, // D6 is P1.09 (DotStar Clock)
40, // D7 is P1.08
8, // D8 is P0.08 (DotStar Data)
7, // D9 is P0.07
5, // D10 is P0.05
26, // D11 is P0.26
11, // D12 is P0.11
12, // D13 is P0.12
// D14 .. D20 (aka A0 .. A7)
4, // D14 is P0.04 (A0)
30, // D15 is P0.30 (A1)
28, // D16 is P0.28 (A2)
31, // D17 is P0.31 (A3)
2, // D18 is P0.02 (A4)
3, // D19 is P0.03 (A5)
// Extra Analog pin #20
5, // D20 is P0.05 (A6/D10)
// D21 .. D22 (aka I2C pins)
16, // D21 is P0.16 (SDA)
14, // D22 is P0.14 (SCL)
// D23 .. D25 (aka SPI pins)
20, // D23 is P0.20 (SPI MISO)
15, // D24 is P0.15 (SPI MOSI)
13, // D25 is P0.13 (SPI SCK )
// QSPI pins (not exposed via any header / test point)
19, // D26 is P0.19 (QSPI CLK)
23, // D27 is P0.23 (QSPI CS)
21, // D28 is P0.21 (QSPI Data 0)
22, // D29 is P0.22 (QSPI Data 1)
32, // D30 is P1.00 (QSPI Data 2)
17, // D31 is P0.17 (QSPI Data 3)
// Thus, there are 32 defined pins
// The remaining pins are not usable:
//
//
// The following pins were never listed as they were considered unusable
// 0, // P0.00 is XL1 (attached to 32.768kHz crystal)
// 1, // P0.01 is XL2 (attached to 32.768kHz crystal)
// 18, // P0.18 is RESET (attached to switch)
//
// The remaining pins are not connected (per schematic)
// 9, // P0.09 is not connected per schematic
// 10, // P0.10 is not connected per schematic
// 33, // P1.01 is not connected per schematic
// 35, // P1.03 is not connected per schematic
// 36, // P1.04 is not connected per schematic
// 37, // P1.05 is not connected per schematic
// 38, // P1.06 is not connected per schematic
// 39, // P1.07 is not connected per schematic
// 43, // P1.11 is not connected per schematic
// 44, // P1.12 is not connected per schematic
// 45, // P1.13 is not connected per schematic
// 46, // P1.14 is not connected per schematic
// 47, // P1.15 is not connected per schematic
};
void initVariant()
{
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
}
@@ -0,0 +1,140 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#ifndef _VARIANT_ITSY52840_
#define _VARIANT_ITSY52840_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
// define USE_LFRC // Board uses RC for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
// Number of pins defined in PinDescription array
#define PINS_COUNT (32)
#define NUM_DIGITAL_PINS (32)
#define NUM_ANALOG_INPUTS (7)
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (3)
#define PIN_DOTSTAR_DATA (8)
#define PIN_DOTSTAR_CLOCK (6)
#define LED_BUILTIN PIN_LED1
#define LED_CONN PIN_LED1
#define LED_RED PIN_LED1
#define LED_BLUE PIN_LED1
#define LED_STATE_ON 1 // State when LED is litted
// Buttons
#define PIN_BUTTON1 (4)
/*
#define PIN_BUTTON2 (3)
#define PIN_BUTTON3 (4)
#define PIN_BUTTON4 (5)
*/
/*
* Analog pins
*/
#define PIN_A0 (14)
#define PIN_A1 (15)
#define PIN_A2 (16)
#define PIN_A3 (17)
#define PIN_A4 (18)
#define PIN_A5 (19)
#define PIN_A6 (20)
#define PIN_A7 (0xff) // to compile with Firmata library
static const uint8_t A0 = PIN_A0 ;
static const uint8_t A1 = PIN_A1 ;
static const uint8_t A2 = PIN_A2 ;
static const uint8_t A3 = PIN_A3 ;
static const uint8_t A4 = PIN_A4 ;
static const uint8_t A5 = PIN_A5 ;
static const uint8_t A6 = PIN_A6 ;
#define ADC_RESOLUTION 14
//static const uint8_t AREF = PIN_AREF;
/*
* Serial interfaces
*/
// Serial
#define PIN_SERIAL_RX (0)
#define PIN_SERIAL_TX (1)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (23)
#define PIN_SPI_MOSI (24)
#define PIN_SPI_SCK (25)
static const uint8_t SS = (5);
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK = PIN_SPI_SCK ;
/*
* Wire Interfaces
*/
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA (21)
#define PIN_WIRE_SCL (22)
// QSPI Pins
#define PIN_QSPI_SCK 26
#define PIN_QSPI_CS 27
#define PIN_QSPI_IO0 28
#define PIN_QSPI_IO1 29
#define PIN_QSPI_IO2 30
#define PIN_QSPI_IO3 31
// On-board QSPI Flash
#define EXTERNAL_FLASH_DEVICES GD25Q16C
#define USB_MSC_BLOCK_SIZE 512
#define USB_MSC_BLOCK_COUNT ((2*1024*1024) / USB_MSC_BLOCK_SIZE)
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#endif
+4 -6
View File
@@ -55,13 +55,11 @@ extern "C"
#define LED_STATE_ON 1 // State when LED is litted
// Buttons
/*
#define PIN_BUTTON1 (2)
#define PIN_BUTTON2 (3)
#define PIN_BUTTON3 (4)
#define PIN_BUTTON4 (5)
*/
* Buttons
*/
#define PIN_BUTTON1 (37)
#define PIN_BUTTON2 (36)
/*
* Analog pins
+125
View File
@@ -0,0 +1,125 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"
#include "nrf_pwm.h"
const uint32_t g_ADigitalPinMap[] =
{
// D0 .. D8
26, // P0.26 (SDA)
27, // P0.27 (SCL)
33, // P1.01 (SDA1) (UART1_RTS) (SPI1_SCK) (PWM3)
34, // P1.02 (SCL1) (UART1_CTS) (SPI1_MOSI) (PWM3)
40, // P1.08 (UART2_TX) (SPI1_MISO) (PWM1)
42, // P1.10 (UART2_RX) (PWM1)
43, // P1.11 (UART2_CTS) (PWM1)
44, // P1.12 (PWM0)
35, // P1.03 (UART2_RTS)
// D9 .. D20
6, // P0.06 (UART1_TX)
8, // P0.27 (UART1_RX)
46, // P1.14 (SPI_MISO)
45, // P1.13 (SPI_MOSI)
47, // P1.15 (SPI_SCK)
31, // P0.31 (PWM3) (SPI_SS) (ADC5)
30, // P0.30 (PWM3) (ADC4)
29, // P0.29 (PWM2) (ADC3)
28, // P0.28 (PWM2) (ADC2)
4, // P0.04 (PWM2) (ADC1)
3, // P0.03 (PWM2) (ADC0)
11, // P0.11 (MODE)
18, // P0.18 (RESET)
};
void initVariant()
{
switch_antenna(false);
}
void switch_antenna(bool useExternal) {
if (useExternal) {
digitalWrite(ANTENNA_SWITCH_1, LOW);
digitalWrite(ANTENNA_SWITCH_2, HIGH);
}
else {
digitalWrite(ANTENNA_SWITCH_1, HIGH);
digitalWrite(ANTENNA_SWITCH_2, LOW);
}
}
void led_pwm_init(uint32_t led_index, uint32_t led_pin) {
NRF_PWM_Type* pwm = NRF_PWM0;
pwm->ENABLE = 0;
nrf_gpio_cfg_output(led_pin);
nrf_gpio_pin_write(led_pin, 1 - LED_STATE_ON);
pwm->PSEL.OUT[led_index] = led_pin;
pwm->MODE = PWM_MODE_UPDOWN_Up;
pwm->COUNTERTOP = 0xff;
pwm->PRESCALER = PWM_PRESCALER_PRESCALER_DIV_16;
pwm->DECODER = PWM_DECODER_LOAD_Individual;
pwm->LOOP = 0;
pwm->SEQ[0].PTR = (uint32_t) (led_duty_cycles);
pwm->SEQ[0].CNT = 4; // default mode is Individual --> count must be 4
pwm->SEQ[0].REFRESH = 0;
pwm->SEQ[0].ENDDELAY = 0;
pwm->ENABLE = 1;
pwm->EVENTS_SEQEND[0] = 0;
// pwm->TASKS_SEQSTART[0] = 1;
}
void led_pwm_teardown(void) {
pwm_teardown(NRF_PWM0);
}
void led_pwm_duty_cycle(uint32_t led_index, uint16_t duty_cycle) {
led_duty_cycles[led_index] = duty_cycle;
nrf_pwm_event_clear(NRF_PWM0, NRF_PWM_EVENT_SEQEND0);
nrf_pwm_task_trigger(NRF_PWM0, NRF_PWM_TASK_SEQSTART0);
}
void pwm_teardown(NRF_PWM_Type* pwm) {
pwm->TASKS_SEQSTART[0] = 0;
pwm->ENABLE = 0;
pwm->PSEL.OUT[0] = 0xFFFFFFFF;
pwm->PSEL.OUT[1] = 0xFFFFFFFF;
pwm->PSEL.OUT[2] = 0xFFFFFFFF;
pwm->PSEL.OUT[3] = 0xFFFFFFFF;
pwm->MODE = 0;
pwm->COUNTERTOP = 0x3FF;
pwm->PRESCALER = 0;
pwm->DECODER = 0;
pwm->LOOP = 0;
pwm->SEQ[0].PTR = 0;
pwm->SEQ[0].CNT = 0;
}
+210
View File
@@ -0,0 +1,210 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#ifndef _VARIANT_PARTICLE_XENON_
#define _VARIANT_PARTICLE_XENON_
#define _PINNUM(port, pin) ((port)*32 + (pin))
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
// define USE_LFRC // Board uses RC for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
// Number of pins defined in PinDescription array
#define PINS_COUNT (34)
#define NUM_DIGITAL_PINS (20)
#define NUM_ANALOG_INPUTS (6) // A6 is used for battery, A7 is analog reference
#define NUM_ANALOG_OUTPUTS (6)
/*
* Digital pins
*/
#define PIN_D0 _PINNUM(0, 26)
#define PIN_D1 _PINNUM(0, 27)
#define PIN_D2 _PINNUM(1, 1)
#define PIN_D3 _PINNUM(1, 2)
#define PIN_D4 _PINNUM(1, 8)
#define PIN_D5 _PINNUM(1, 10)
#define PIN_D6 _PINNUM(1, 11)
#define PIN_D7 _PINNUM(1, 12)
#define PIN_D8 _PINNUM(1, 3)
#define PIN_D9 _PINNUM(0, 6)
#define PIN_D10 _PINNUM(0, 8)
#define PIN_D11 _PINNUM(1, 14)
#define PIN_D12 _PINNUM(1, 13)
#define PIN_D13 _PINNUM(1, 15)
#define PIN_D14 _PINNUM(0, 31)
#define PIN_D15 _PINNUM(0, 30)
#define PIN_D16 _PINNUM(0, 29)
#define PIN_D17 _PINNUM(0, 28)
#define PIN_D18 _PINNUM(0, 24)
#define PIN_D19 _PINNUM(0, 3)
#define PIN_D20 _PINNUM(0, 11)
static const uint8_t D0 = PIN_D0;
static const uint8_t D1 = PIN_D1;
static const uint8_t D2 = PIN_D2;
static const uint8_t D3 = PIN_D4;
static const uint8_t D5 = PIN_D5;
static const uint8_t D6 = PIN_D0;
static const uint8_t D7 = PIN_D1;
static const uint8_t D8 = PIN_D2;
static const uint8_t D9 = PIN_D4;
static const uint8_t D10 = PIN_D5;
static const uint8_t D11 = PIN_D0;
static const uint8_t D12 = PIN_D1;
static const uint8_t D13 = PIN_D2;
static const uint8_t D14 = PIN_D4;
static const uint8_t D15 = PIN_D5;
static const uint8_t D16 = PIN_D0;
static const uint8_t D17 = PIN_D1;
static const uint8_t D18 = PIN_D2;
static const uint8_t D19 = PIN_D4;
static const uint8_t D20 = PIN_D5;
// LEDs
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 12)
#define LED_STATE_ON 1
#define LED_PRIMARY_IDX 0
#define LED_RGB_RED_IDX 1
#define LED_RGB_GREEN_IDX 2
#define LED_RGB_BLUE_IDX 3
#define LED_RGB_RED_PIN _PINNUM(0, 13)
#define LED_RGB_GREEN_PIN _PINNUM(0, 14)
#define LED_RGB_BLUE_PIN _PINNUM(0, 15)
#define BOARD_RGB_BRIGHTNESS 0x202020
static const uint8_t LED_BUILTIN = LED_PRIMARY_PIN;
static const uint8_t LED_RGB_RED = LED_RGB_RED_PIN;
static const uint8_t LED_RGB_GREEN = LED_RGB_GREEN_PIN;
static const uint8_t LED_RGB_BLUE = LED_RGB_BLUE_PIN;
// Buttons
#define BUTTONS_NUMBER 2
#define BUTTON_DFU _PINNUM(0, 11)
#define BUTTON_FRESET _PINNUM(0, 03) // A0
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
static const uint8_t BUTTON_MODE = PIN_D20;
// Antenna
#define ANTENNA_SWITCH_1 _PINNUM(0, 24)
#define ANTENNA_SWITCH_2 _PINNUM(0, 25)
// NFC
#define NFC1 _PINNUM(0, 9)
#define NFC2 _PINNUM(0, 10)
/*
* Analog pins
*/
#define PIN_A0 _PINNUM(0, 3)
#define PIN_A1 _PINNUM(0, 4)
#define PIN_A2 _PINNUM(0, 28)
#define PIN_A3 _PINNUM(0, 29)
#define PIN_A4 _PINNUM(0, 30)
#define PIN_A5 _PINNUM(0, 31)
static const uint8_t A0 = PIN_A0 ;
static const uint8_t A1 = PIN_A1 ;
static const uint8_t A2 = PIN_A2 ;
static const uint8_t A3 = PIN_A3 ;
static const uint8_t A4 = PIN_A4 ;
static const uint8_t A5 = PIN_A5 ;
#define ADC_RESOLUTION 14
/*
* Serial interfaces
*/
// Serial
#define PIN_SERIAL_RX PIN_D9
#define PIN_SERIAL_TX PIN_D10
#define PIN_SERIAL2_RX PIN_D5
#define PIN_SERIAL2_TX PIN_D6
//#define HAVE_HWSERIAL2 true // TODO: implement UARTE in Uart.cpp
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 2
#define PIN_SPI_SS PIN_A0
#define PIN_SPI_MISO _PINNUM(1, 14)
#define PIN_SPI_MOSI _PINNUM(1, 13)
#define PIN_SPI_SCK _PINNUM(1, 15)
#define PIN_SPI1_MISO _PINNUM(1, 8)
#define PIN_SPI1_MOSI _PINNUM(1, 2)
#define PIN_SPI1_SCK _PINNUM(1, 1)
static const uint8_t SS = PIN_SPI_SS;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
static const uint8_t MOSI1 = PIN_SPI1_MOSI;
static const uint8_t MISO1 = PIN_SPI1_MISO;
static const uint8_t SCK1 = PIN_SPI1_SCK;
/*
* Wire Interfaces
*/
#define WIRE_INTERFACES_COUNT 2
#define PIN_WIRE_SDA _PINNUM(0, 26)
#define PIN_WIRE_SCL _PINNUM(0, 27)
#define PIN_WIRE1_SDA _PINNUM(1, 1)
#define PIN_WIRE1_SCL _PINNUM(1, 2)
// On-board QSPI Flash
#define EXTERNAL_FLASH_DEVICES GD25Q16C
#define USB_MSC_BLOCK_SIZE 512
#define USB_MSC_BLOCK_COUNT ((2*1024*1024) / USB_MSC_BLOCK_SIZE)
void switch_antenna(bool useExternal);
// led pwm
void led_pwm_init(uint32_t led_index, uint32_t led_pin);
void led_pwm_teardown(void);
void led_pwm_duty_cycle(uint32_t led_index, uint16_t duty_cycle);
void pwm_teardown(NRF_PWM_Type* pwm);
static uint16_t led_duty_cycles[PWM0_CH_NUM] = { 0 };
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#endif
+8
View File
@@ -54,6 +54,14 @@ extern "C"
#define LED_STATE_ON 0 // State when LED is litted
/*
* Buttons
*/
#define PIN_BUTTON1 11
#define PIN_BUTTON2 12
#define PIN_BUTTON3 24
#define PIN_BUTTON4 25
/*
* Analog pins
*/
+44
View File
@@ -0,0 +1,44 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"
const uint32_t g_ADigitalPinMap[] =
{
// D0 .. D13
45, // D0 is P1.13 (LED1)
43, // D1 is P1.11 (LED2)
15, // D2 is P0.15 (Button)
};
void initVariant()
{
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
}
+89
View File
@@ -0,0 +1,89 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
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
*/
#ifndef _VARIANT_MDBT50Q_RX_
#define _VARIANT_MDBT50Q_RX_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
// define USE_LFRC // Board uses RC for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
// Number of pins defined in PinDescription array
#define PINS_COUNT (3)
#define NUM_DIGITAL_PINS (3)
#define NUM_ANALOG_INPUTS (0) // A6 is used for battery, A7 is analog reference
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (0)
#define PIN_LED2 (1)
#define LED_BUILTIN PIN_LED1
#define LED_CONN PIN_LED2
#define LED_RED PIN_LED1
#define LED_BLUE PIN_LED2
#define LED_STATE_ON 0 // State when LED is litted
/*
* Buttons
*/
#define PIN_BUTTON1 2
#define PIN_DFU 2
// Buttons
/*
#define PIN_BUTTON1 (2)
#define PIN_BUTTON2 (3)
#define PIN_BUTTON3 (4)
#define PIN_BUTTON4 (5)
*/
#define ADC_RESOLUTION 14
// Bad things happen if the serial pins aren't defined. Instead
// define them with an invalid pin number
// Serial
#define PIN_SERIAL_RX (3)
#define PIN_SERIAL_TX (3)
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#endif