Skip to content

Commit

Permalink
Moar
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern authored and caveman99 committed Apr 15, 2023
1 parent a7f9e5d commit 516fc5c
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/apollo3/apollo3.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[apollo3_base]
platform_packages = platform_packages=framework-arduinoapollo3@https://github.com/sparkfun/Arduino_Apollo3#v2.2.0
board = RAK11722
platform = apollo3blue
platform_packages=framework-arduinoapollo3@https://github.com/sparkfun/Arduino_Apollo3#v2.2.0
framework = arduino
build_type = debug
build_flags =
Expand Down
45 changes: 45 additions & 0 deletions boards/wiscore_rak11720.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"build": {
"cpu": "cortex-m4",
"f_cpu": "48000000L",
"mcu": "AMA3B1KK",
"part": "apollo3",
"fabi": "hard",
"specs": "nosys.specs",
"framework": {
"arduino": {
"v1": {
"variant": "artemis",
"extra_flags": "-DSFE_ARTEMIS"
},
"v2": {
"variant": "WisCore_RAK11720_Board",
"extra_flags": "-DARDUINO_RAK_11720_MODULE"
}
},
"ambiqsdk-sfe": {
"variant": ["boards_sfe", "artemis_module"],
"extra_flags": "",
"variant_lib_src_filter": ""
}
}
},
"debug": {
"jlink_device": "AMA3B1KK-KBR",
"svd_path": "apollo3.svd",
"swo_freq": 12000000,
"init": {
"break": "tbreak setup"
}
},
"frameworks": ["arduino", "ambiqsdk-sfe"],
"name": "WisCore RAK11720 Board",
"upload": {
"maximum_ram_size": 393216,
"maximum_size": 983040,
"protocol": "svl",
"protocols": ["svl", "asb", "jlink"]
},
"url": "https://www.rakwireless.com",
"vendor": "RAKwireless"
}
7 changes: 7 additions & 0 deletions variants/rak11720/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef _PINS_ARDUINO_H_
#define _PINS_ARDUINO_H_

// API Competibility
#include "variant.h"

#endif /*_PINS_ARDUINO_H_*/
5 changes: 5 additions & 0 deletions variants/rak11720/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[env:rak11720]
extends = apollo3_base
board = wiscore_rak11720
board_level = extra
build_flags = ${apollo3_base.build_flags} -Ivariants/rak11720
190 changes: 190 additions & 0 deletions variants/rak11720/variant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
#ifndef _VARIANT_RAK11720_
#define _VARIANT_RAK11720_

/*----------------------------------------------------------------------------
* Definitions
*----------------------------------------------------------------------------*/

// TODO

/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

extern const uint32_t g_ADigitalPinMap[];
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))

#define portOutputRegister(port) (&AM_REGVAL(port + offsetof(GPIO_Type, WTA)))
#define portInputRegister(port) ((volatile uint32_t *)&AM_REGVAL(port + offsetof(GPIO_Type, RDA)))
#define portModeRegister(port) ()
#define digitalPinHasPWM(P) (g_ADigitalPinMap[P] > 1) // FIXME
#define digitalPinToBitMask(P) ((uint32_t)0x1 << (P % 32))
#define digitalPinToPinName(P) g_ADigitalPinMap[P]

#define digitalPinToPort(P) (GPIO_BASE + ((P & 0x20) >> 3))

// Interrupts
#define digitalPinToInterrupt(P) (P) // FIXME

/*----------------------------------------------------------------------------
* Pins
*----------------------------------------------------------------------------*/

#define PINS_COUNT (50u)
#define NUM_DIGITAL_PINS (0u)
#define NUM_ANALOG_INPUTS (0u)
#define NUM_ANALOG_OUTPUTS (0u)

#define P44 44 // LED1
#define P45 45 // LED2

#define P39 39 // UART0_TX
#define P40 40 // UART0_RX
#define P42 42 // UART1_TX
#define P43 43 // UART1_RX

#define P25 25 // I2C2_SDA
#define P27 27 // I2C2_SCL

#define P1 1 // SPI0_NSS
#define P5 5 // SPI0_SCK
#define P6 6 // SPI0_MISO
#define P7 7 // SPI0_MOSI

#define P20 20 // SWDIO
#define P21 21 // SWCLK
#define P41 41 // BOOT0 - SWO

// GP4 - GP36 - GP37 - GP38 - GP44(LED1) -GP45(LED2)
// ADC9(12), ADC8(13), ADC3(31), ADC4(32), ADC5(33)
#define P38 38 // IO1
#define P4 4 // IO2
#define P37 37 // IO3
#define P31 31 // IO4 - ADC3(31)
#define P12 12 // IO5 - ADC9(12)
#define P36 36 // IO6
#define P32 32 // IO7 - ADC4(32)

#define P13 13 // AN0 - ADC8(13)
#define P33 33 // AN1 - ADC5(33)

#define P18 18 // ANT_SW(LORA internal)
#define P17 17 // NRESET(LORA internal)
#define P16 16 // BUSY(LORA internal)
#define P15 15 // DIO1(LORA internal)
#define P14 14 // DIO2(LORA internal)
#define P11 11 // SPI_NSS(LORA internal)
#define P8 8 // SPI_CLK(LORA internal)
#define P10 10 // SPI_MOSI(LORA internal)
#define P9 9 // SPI_MISO(LORA internal)

/*
* WisBlock Base GPIO definitions
*/

#define WB_IO1 P38 // SLOT_A SLOT_B
#define WB_IO2 P4 // SLOT_A SLOT_B
#define WB_IO3 P37 // SLOT_C
#define WB_IO4 P31 // SLOT_C
#define WB_IO5 P12 // SLOT_D
#define WB_IO6 P36 // SLOT_D
#define WB_IO7 P32
#define WB_SW1 0xFF // IO_SLOT
#define WB_A0 P13 // IO_SLOT
#define WB_A1 P33 // IO_SLOT
#define WB_I2C1_SDA P25 // SENSOR_SLOT IO_SLOT
#define WB_I2C1_SCL P27 // SENSOR_SLOT IO_SLOT
#define WB_I2C2_SDA 0xFF // IO_SLOT
#define WB_I2C2_SCL 0xFF // IO_SLOT
#define WB_SPI_CS P1 // IO_SLOT
#define WB_SPI_CLK P5 // IO_SLOT
#define WB_SPI_MISO P6 // IO_SLOT
#define WB_SPI_MOSI P7 // IO_SLOT
#define WB_RXD0 P40 // IO_SLOT
#define WB_TXD0 P39 // IO_SLOT
#define WB_RXD1 P43 // SLOT_A IO_SLOT
#define WB_TXD1 P42 // SLOT_A IO_SLOT
#define WB_LED1 P44 // IO_SLOT
#define WB_LED2 P45 // IO_SLOT

// LEDs
#define PIN_LED1 WB_LED1 // PA0
#define PIN_LED2 WB_LED2 // PA1

#define LED_BUILTIN PIN_LED1
#define LED_CONN PIN_LED2

#define LED_GREEN PIN_LED1
#define LED_BLUE PIN_LED2

#define LED_STATE_ON 1 // State when LED is litted

/*
* Analog pins
*/
#define PIN_A0 P13
#define PIN_A1 P33

static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;

#define PIN_A3 P5 // channel1
#define PIN_A4 P31 // channel2
#define PIN_A5 P32 // channel4
#define PIN_A6 P36
#define PIN_A7 P7 // channel6

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
// Other pins
#define PIN_AREF (0)

static const uint8_t AREF = PIN_AREF;

/*
* Serial interfaces
*/
#define PIN_SERIAL0_RX WB_RXD0 // PB7
#define PIN_SERIAL0_TX WB_TXD0 // PB6

#define PIN_SERIAL1_RX WB_RXD1 // PA3
#define PIN_SERIAL1_TX WB_TXD1 // PA2

/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1

#define PIN_SPI_CS WB_SPI_CS
#define PIN_SPI_MISO WB_SPI_MISO
#define PIN_SPI_MOSI WB_SPI_MOSI
#define PIN_SPI_SCK WB_SPI_CLK

static const uint8_t SS = PIN_SPI_CS;
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 WB_I2C1_SDA
#define PIN_WIRE_SCL WB_I2C1_SCL

#ifdef __cplusplus
}
#endif

#endif /* _VARIANT_RAK11720_ */

0 comments on commit 516fc5c

Please sign in to comment.