Skip to content

Commit 503609f

Browse files
committed
Added Challenger 840 BLE board
1 parent 150a8a5 commit 503609f

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

src/boards/boards.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ bool button_pressed(uint32_t pin)
6262
return nrf_gpio_pin_read(pin) == active_state;
6363
}
6464

65+
// This is declared so that a board specific init can be called from here.
66+
void __attribute__((weak)) extern_board_init(void) { }
6567
void board_init(void)
6668
{
6769
// stop LF clock just in case we jump from application without reset
@@ -93,6 +95,8 @@ void board_init(void)
9395
#if ENABLE_DCDC_1 == 1
9496
NRF_POWER->DCDCEN = 1;
9597
#endif
98+
// Make sure any custom inits are performed
99+
extern_board_init();
96100

97101
// When board is supplied on VDDH (and not VDD), this specifies what voltage the GPIO should run at
98102
// and what voltage is output at VDD. The default (0xffffffff) is 1.8V; typically you'll want

src/boards/challenger_840_ble/board.h

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2018 Ha Thach for Adafruit Industries, 2022 Invector Labs
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#ifndef _CHALLENGER_840_BLE_H
26+
#define _CHALLENGER_840_BLE_H
27+
28+
#define _PINNUM(port, pin) ((port)*32 + (pin))
29+
30+
/*------------------------------------------------------------------*/
31+
/* LED
32+
*------------------------------------------------------------------*/
33+
#define LEDS_NUMBER 1
34+
#define LED_PRIMARY_PIN _PINNUM(0, 12)
35+
#define LED_STATE_ON 1
36+
37+
#define LED_NEOPIXEL _PINNUM(1, 8)
38+
#define NEOPIXELS_NUMBER 1
39+
#define BOARD_RGB_BRIGHTNESS 0x040404
40+
41+
/*------------------------------------------------------------------*/
42+
/* BUTTON
43+
*------------------------------------------------------------------*/
44+
#define BUTTONS_NUMBER 2
45+
#define BUTTON_1 _PINNUM(0, 19)
46+
#define BUTTON_2 _PINNUM(0, 8) // Pulls flash cs high
47+
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
48+
49+
/*------------------------------------------------------------------*/
50+
/* On board LDO control
51+
*------------------------------------------------------------------*/
52+
#define LDO_CONTROL_PIN _PINNUM(1, 9) // Enables external pwr
53+
54+
//--------------------------------------------------------------------+
55+
// BLE OTA
56+
//--------------------------------------------------------------------+
57+
#define BLEDIS_MANUFACTURER "Invector Labs"
58+
#define BLEDIS_MODEL "Challenger 840 BLE"
59+
60+
//--------------------------------------------------------------------+
61+
// USB
62+
//--------------------------------------------------------------------+
63+
#define USB_DESC_VID 0x1209
64+
#define USB_DESC_UF2_PID 0x7380
65+
#define USB_DESC_CDC_ONLY_PID 0x7381
66+
67+
//------------- UF2 -------------//
68+
#define UF2_PRODUCT_NAME "ILabs Challenger 840"
69+
#define UF2_VOLUME_LABEL "CH840BOOT"
70+
#define UF2_BOARD_ID "nRF52840-Challenger-840"
71+
#define UF2_INDEX_URL "https://www.ilabs.se"
72+
73+
#endif // _CHALLENGER_840_BLE_H
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MCU_SUB_VARIANT = nrf52840
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "boards.h"
2+
#include "board.h"
3+
#include "uf2/configkeys.h"
4+
5+
__attribute__((used, section(".bootloaderConfig")))
6+
const uint32_t bootloaderConfig[] =
7+
{
8+
/* CF2 START */
9+
CFG_MAGIC0, CFG_MAGIC1, // magic
10+
5, 100, // used entries, total entries
11+
12+
204, 0x100000, // FLASH_BYTES = 0x100000
13+
205, 0x40000, // RAM_BYTES = 0x40000
14+
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
15+
209, 0xada52840, // UF2_FAMILY = 0xada52840
16+
210, 0x20, // PINS_PORT_SIZE = PA_32
17+
18+
0, 0, 0, 0, 0, 0, 0, 0
19+
/* CF2 END */
20+
};
21+
22+
void extern_board_init(void)
23+
{
24+
// Turn LDO on
25+
nrf_gpio_cfg_output(LDO_CONTROL_PIN);
26+
nrf_gpio_pin_write(LDO_CONTROL_PIN, 1);
27+
}

0 commit comments

Comments
 (0)