I would like to fully understand pins_arduino.h for the Nano 33 BLE. I have several issues:
- The numbers and letters and brackets, u (unsigned) and ul (unsigned long)
example:
#define PIN_SERIAL_RX (1ul)
#define PIN_INT_APDS (26u)
#define PIN_PDM_PWR (27)
In the above example defines, I assume everything is needed, but why do some have u, some ul and some just a number in brackets?
-
The nrf52840 SOC has pins (~83 of them) labelled in multiple ways but some are like: P0.06 and P1.06. Also pins are labelled GPIO12, GPIO15 etc. Is there anyway to convert these numbers to #define numbers or do I need more reference information?
-
Can't find #define pins for +3V3, +5V RESET, GND, VIN, AREF
-
Several #define's don't seem to have physical pins. (Fine with that but do they have have physical pins somewhere?)
(22u) LEDR
(23u) LEDG
(24u) LEDB
(25u) LED_PWR
(26u) PIN_INT_APDS
(27) PIN_PDM_PWR
(28) PIN_PDM_CLK
(29) PIN_PDM_DIN
(30u) PIN_WIRE_SDA1
(31u) PIN_WIRE_SCL1
(32u) PIN_ENABLE_SENSORS_3V3
(33u) PIN_ENABLE_I2C_PULLUP
Here is an image of the Nano 33 BLE pinout with additions for the pins_arduino.h
The link is:
Hopefully this image shows up.
Here is a copy of the pins_arduino.h file
#pragma once
#include "mbed_config.h"
#include <stdint.h>
#include <macros.h>
#ifndef __PINS_ARDUINO__
#define __PINS_ARDUINO__
// Frequency of the board main oscillator
#define VARIANT_MAINOSC (32768ul)
// Master clock frequency
#define VARIANT_MCK (64000000ul)
// Pins
// ----
// Number of pins defined in PinDescription array
#ifdef __cplusplus
extern "C" unsigned int PINCOUNT_fn();
#endif
#define PINS_COUNT (PINCOUNT_fn())
#define NUM_DIGITAL_PINS (21u)
#define NUM_ANALOG_INPUTS (7u)
#define NUM_ANALOG_OUTPUTS (0u)
// LEDs
// ----
#define PIN_LED (13u)
#define LED_BUILTIN PIN_LED
#define LEDR (22u)
#define LEDG (23u)
#define LEDB (24u)
#define LED_PWR (25u)
// Analog pins
// -----------
#define PIN_A0 (14u)
#define PIN_A1 (15u)
#define PIN_A2 (16u)
#define PIN_A3 (17u)
#define PIN_A4 (18u)
#define PIN_A5 (19u)
#define PIN_A6 (20u)
#define PIN_A7 (21u)
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 12
/*
* Serial interfaces
*/
// Serial (EDBG)
#define PIN_SERIAL_RX (1ul)
#define PIN_SERIAL_TX (0ul)
// SPI
#define PIN_SPI_MISO (12u)
#define PIN_SPI_MOSI (11u)
#define PIN_SPI_SCK (13u)
#define PIN_SPI_SS (10u)
static const uint8_t SS = PIN_SPI_SS; // SPI Slave SS not used. Set here only for reference.
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
#define PIN_WIRE_SDA (18u)
#define PIN_WIRE_SCL (19u)
#define PIN_WIRE_SDA1 (30u)
#define PIN_WIRE_SCL1 (31u)
#define PIN_ENABLE_SENSORS_3V3 (32u)
#define PIN_ENABLE_I2C_PULLUP (33u)
#define PIN_INT_APDS (26u)
// PDM Interfaces
// ---------------
#define PIN_PDM_PWR (27)
#define PIN_PDM_CLK (28)
#define PIN_PDM_DIN (29)
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#define SERIAL_PORT_USBVIRTUAL SerialUSB
#define SERIAL_PORT_MONITOR SerialUSB
#define SERIAL_PORT_HARDWARE Serial1
#define SERIAL_PORT_HARDWARE_OPEN Serial1
// Mbed specific defines
#define SERIAL_HOWMANY 1
#define SERIAL1_TX (digitalPinToPinName(PIN_SERIAL_TX))
#define SERIAL1_RX (digitalPinToPinName(PIN_SERIAL_RX))
#define SERIAL_CDC 1
#define HAS_UNIQUE_ISERIAL_DESCRIPTOR
#define BOARD_VENDORID 0x2341
#define BOARD_PRODUCTID 0x805a
#define BOARD_NAME "Nano 33 BLE"
#define DFU_MAGIC_SERIAL_ONLY_RESET 0xb0
#define I2C_SDA (digitalPinToPinName(PIN_WIRE_SDA))
#define I2C_SCL (digitalPinToPinName(PIN_WIRE_SCL))
#define I2C_SDA1 (digitalPinToPinName(PIN_WIRE_SDA1))
#define I2C_SCL1 (digitalPinToPinName(PIN_WIRE_SCL1))
#define SPI_MISO (digitalPinToPinName(PIN_SPI_MISO))
#define SPI_MOSI (digitalPinToPinName(PIN_SPI_MOSI))
#define SPI_SCK (digitalPinToPinName(PIN_SPI_SCK))
#define digitalPinToPort(P) (digitalPinToPinName(P)/32)
uint8_t getUniqueSerialNumber(uint8_t* name);
void _ontouch1200bps_();
#endif //__PINS_ARDUINO__