Compare commits

...
32 Commits
Author SHA1 Message Date
hathach 6338794c61 Merge pull request #44 from adafruit/develop
merge from Develop
2019-01-31 23:45:31 +07:00
hathach 641d9fe811 added changelog 2019-01-31 22:51:12 +07:00
hathach 981a6976e2 change HCI_RX_BUF_QUEUE_SIZE back to 4 2019-01-31 22:50:42 +07:00
hathach 7ec0ff51f0 Merge pull request #40 from se7ensong/OTA_fix
Fix OTA using nRF toolbox on iPhone (tested on SE and XS)
2019-01-31 22:35:12 +07:00
hathach 3737d4bc12 update segger project, cleanup 2019-01-31 21:39:02 +07:00
hathach 7279bd9b32 added metro nrf52840 revA
clean up makefile
2019-01-31 18:01:41 +07:00
hathach 2f1eec7118 fix #41 use RXD,TXD in board header 2019-01-14 12:50:20 +07:00
hathach 3611a0579e minor clean up for pca10059 2019-01-11 11:36:42 +07:00
Song Luan 04f05dac64 Fix OTA using nRF toolbox on iPhone (tested on SE and XS) 2019-01-10 13:09:24 +00:00
hathach 95cbe3b129 fix PWM psel[1] is not reset to 0xffffffff when teardown
also move neopixel to pwm1
2019-01-10 15:55:03 +07:00
hathach 9ece5f64a9 clean up makefile 2019-01-04 07:00:45 +07:00
Dan Halbert 61b4ca3354 Merge pull request #38 from adafruit/devlocal
fix current.uf2 related issue
2018-12-21 10:31:33 -05:00
hathach a316c8bd67 reduce delay to 50us 2018-12-21 15:04:48 +07:00
hathach 25f6d395bc fix neopixel didn't turn off after dfu cdc 2018-12-21 14:48:04 +07:00
hathach e66ee2af6d readme ref link 2018-12-21 12:48:24 +07:00
hathach 89be1cf9f8 Merge branch 'master' into devlocal 2018-12-21 12:17:48 +07:00
hathach d79fcb2ea5 fix #37
- dfu cdc write exact bytes of firmware which is not a muliplier of 256.
This cause incorrect section index with uf2 drive. Solution is round up
current flash size to 256
- also fix incorrect block number causing it is impossible to use old
current.uf2 to update
2018-12-21 12:17:14 +07:00
hathach 5c38bc8957 fix issue nrf52840 not reset properly when upgrading bootloader+sd combo
- root cause tusb_task()/cdc task is called when usb is not inited (in
case of sd upgrade)
2018-12-20 00:50:14 +07:00
hathach fc13287837 clean up 2018-12-19 23:27:29 +07:00
hathach 19c3721151 clean up 2018-12-19 23:20:35 +07:00
hathach 47f0bed840 clean up 2018-12-19 19:12:45 +07:00
hathach fc3d6e07ec Update README.md 2018-12-19 18:50:20 +07:00
hathach fd924b4c13 Merge pull request #36 from adafruit/devlocal
fixed the incosnsitent led pattern by using systick to call led_tick()
2018-12-19 18:43:40 +07:00
hathach c69ae13423 finished testing led pattern 2018-12-19 18:29:24 +07:00
hathach 5c6bbaca47 clean up 2018-12-19 17:23:06 +07:00
hathach 87a0124cd9 add product link to feather nrf52840 2018-12-19 17:21:10 +07:00
hathach 64f2f671f6 fixed the incosnsitent led pattern by using systick to call led_tick() 2018-12-19 17:08:23 +07:00
hathach 90cf2e53cb clean up 2018-12-19 16:54:24 +07:00
Scott Shawcroft f4d6f5c508 remove draft since it un-publishes releases 2018-12-06 12:13:06 -08:00
Scott Shawcroft 77d08f3a1e Use file glob to find release files 2018-12-06 12:01:46 -08:00
Scott Shawcroft 88b78b01fa Use an ENV variable to store auth token 2018-12-06 11:51:06 -08:00
Scott Shawcroft f4933840b5 Try new access token for adabot. 2018-12-06 11:37:08 -08:00
21 changed files with 354 additions and 226 deletions

No files matched your search

+3 -5
View File
@@ -6,12 +6,10 @@ compiler:
deploy:
provider: releases
api_key:
secure: "HGfSIgVPX8O+Wfs3E1l/qI8tJZ6wwEgFg3EO6E1+6eGZolr+LW+ANpMUTqcKy18VzbnSx+AH5Ktu8bw4XuPQRPaAvEIMDEZSbj//WE/nqo+p+SccxUy+mKK6x/gb4aiWUw8gYebeLNvWkU+JVupRqMkUdFOJJRZiIvp1usX+jNU8vTt07INNi90LZ8I/KvDEkvHJ/2nOBKW519rlp5XM0a5j8Bv+9gt5wgfl/hFW42JA4Gmj/nacZtro/3pYJWAZ4ZNLOsupMDPZGFX/Ndb+TqseBAkCLl2bvBZ5gFg4NvtaSRFZW532EXDmdCthUBLUGjw7V3VWq8shgHSi6Iq/5lL9t2jawkJPfp5JdiTPTLkUIZ8BfwwrbHp2qiTOGQHbN8kkfjtcQopjVdaPvavr4oaUN+ju6JNsTNc47FIcKivMi1TV6IUT4byjIWZ7ioV0X7KEdoD5WspjIYVhi1vwOBOLT0CEDMtPwIisZ3QuQGJ5clDMJ82ZU9LBfffzvBkeQNmMCM5L412FN7LP2lVNL5eafuJvFZS9Bpbp9uUhzHsDbbpLnz8TFa5rIMzKQXf1KbLnKZ7LHsieB2NleUE6OUxltNm1PwmWWxZKEZeRYxZSMgzbAOrl/Jl2F7zCU7RWCFRnvC73vVJAXaFJ3/DYBF21ew8NyOgMrRLOeH0s5rg="
file:
- $(ls -d1 bin/*/* | tr "\n" ":")
api_key: "$GITHUB_TOKEN"
file_glob: true
file: "$TRAVIS_BUILD_DIR/bin/*/*"
skip_cleanup: true
draft: true
on:
tags: true
+53 -63
View File
@@ -7,31 +7,28 @@
# - SD_VER1, SD_VER2, SD_VER3: SoftDevice version e.g 6.0.0
# - SD_HEX : to bootloader hex binary
#******************************************************************************
SRC_PATH = src
SRC_PATH = src
SDK_PATH = lib/sdk/components
SDK11_PATH = lib/sdk11/components
SD_PATH = lib/softdevice/$(SD_FILENAME)
SDK_PATH = lib/sdk/components
SDK11_PATH = lib/sdk11/components
SD_PATH = lib/softdevice/$(SD_FILENAME)
TUSB_PATH = lib/tinyusb/src
NRFX_PATH = lib/nrfx
TUSB_PATH = lib/tinyusb/src
NRFX_PATH = lib/nrfx
SD_VER1 = 6
SD_VER2 = 1
SD_VER3 = 1
SD_VER1 = 6
SD_VER2 = 1
SD_VER3 = 1
SD_VERSION = $(SD_VER1).$(SD_VER2).$(SD_VER3)
SD_VERSION_FULL = $(SD_VERSION)
SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION)
SD_VERSION = $(SD_VER1).$(SD_VER2).$(SD_VER3)
SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION)
SD_API_PATH = $(SD_PATH)/$(SD_FILENAME)_API
SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
LD_FILE = $(SRC_PATH)/linker/$(SD_NAME)_v$(SD_VER1).ld
SD_API_PATH = $(SD_PATH)/$(SD_FILENAME)_API
SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
LD_FILE = $(SRC_PATH)/linker/$(SD_NAME)_v$(SD_VER1).ld
MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION_FULL)
RELEASE_DIR = bin/$(BOARD)/$(SD_VERSION_FULL)
MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION)
RELEASE_DIR = bin/$(BOARD)
MK_DIS_FIRMWARE = "$(SD_NAME) $(SD_VERSION)"
@@ -45,7 +42,6 @@ OUTPUT_FILENAME = $(BOARD)_bootloader-$(GIT_VERSION)
#******************************************************************************
NRFUTIL = adafruit-nrfutil
ifneq ($(JLINK),)
NRFJPROG = nrfjprog -s $(JLINK)
else
@@ -60,10 +56,11 @@ endif
MK := mkdir
RM := rm -rf
# Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
ifeq ("$(V)","2")
QUIET :=
QUIET =
else
QUIET := @
QUIET = @
endif
GNU_PREFIX = arm-none-eabi
@@ -86,8 +83,8 @@ remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-ou
#*********************************
BOARD_LIST = $(sort $(subst .h,,$(subst src/boards/,,$(wildcard src/boards/*.h))))
NRF52840_BOARDLIST = pca10056 pca10059 feather_nrf52840_express particle_argon particle_boron particle_xenon
IS_NRF52840 = $(filter $(BOARD),$(NRF52840_BOARDLIST))
NRF52832_BOARDLIST = feather_nrf52832
IS_52832 = $(filter $(BOARD),$(NRF52832_BOARDLIST))
ifeq ($(filter $(MAKECMDGOALS),all-board all-release help),)
ifeq ($(BOARD),)
@@ -104,12 +101,12 @@ endif
BUILD = _build-$(BOARD)
ifneq ($(IS_NRF52840),)
SD_NAME = s140
DFU_DEV_REV = 52840
else
ifneq ($(IS_52832),)
SD_NAME = s132
DFU_DEV_REV = 0xADAF
else
SD_NAME = s140
DFU_DEV_REV = 52840
endif
@@ -153,7 +150,19 @@ C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_slip.c
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_transport.c
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/nrf_assert.c
ifneq ($(IS_NRF52840),)
ifneq ($(IS_52832),)
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52.c
C_SOURCE_FILES += $(SDK_PATH)/libraries/uart/app_uart.c
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
IPATH += $(SDK11_PATH)/libraries/util
IPATH += $(SDK_PATH)/drivers_nrf/common
IPATH += $(SDK_PATH)/drivers_nrf/uart
else
# src
C_SOURCE_FILES += $(SRC_PATH)/usb/usb_desc.c
@@ -175,28 +184,16 @@ C_SOURCE_FILES += $(TUSB_PATH)/class/msc/msc_device.c
C_SOURCE_FILES += $(TUSB_PATH)/class/custom/custom_device.c
C_SOURCE_FILES += $(TUSB_PATH)/tusb.c
else
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52.c
C_SOURCE_FILES += $(SDK_PATH)/libraries/uart/app_uart.c
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
IPATH += $(SDK11_PATH)/libraries/util
IPATH += $(SDK_PATH)/drivers_nrf/common
IPATH += $(SDK_PATH)/drivers_nrf/uart
endif
#******************************************************************************
# Assembly Files
#******************************************************************************
ifneq ($(IS_NRF52840),)
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_nrf52840.S
else
ifneq ($(IS_52832),)
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_nrf52.S
else
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_nrf52840.S
endif
#******************************************************************************
@@ -207,6 +204,7 @@ endif
IPATH += $(SRC_PATH)
IPATH += $(SRC_PATH)/cmsis/include
IPATH += $(SRC_PATH)/usb
IPATH += $(SRC_PATH)/boards
IPATH += $(TUSB_PATH)
# nrfx
@@ -267,20 +265,16 @@ CFLAGS += -DMK_DIS_FIRMWARE='$(MK_DIS_FIRMWARE)'
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS) $(SD_NAME) $(SD_VERSION)"'
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
CFLAGS += -DBOARD_HEADER_FILE='"$(BOARD).h"'
ifneq ($(IS_NRF52840),)
CFLAGS += -DNRF52840_XXAA
CFLAGS += -DS140
else
ifneq ($(IS_52832),)
CFLAGS += -DNRF52
CFLAGS += -DNRF52832_XXAA
CFLAGS += -DS132
else
CFLAGS += -DNRF52840_XXAA
CFLAGS += -DS140
endif
@@ -314,19 +308,14 @@ ASMFLAGS += -DSWI_DISABLE0
ASMFLAGS += -DSOFTDEVICE_PRESENT
ASMFLAGS += -DFLOAT_ABI_HARD
ifneq ($(IS_NRF52840),)
ASMFLAGS += -DNRF52840_XXAA
ASMFLAGS += -DS140
else
ifneq ($(IS_52832),)
ASMFLAGS += -DNRF52
ASMFLAGS += -DS132
else
ASMFLAGS += -DNRF52840_XXAA
ASMFLAGS += -DS140
endif
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
C_OBJECTS = $(addprefix $(BUILD)/, $(C_SOURCE_FILE_NAMES:.c=.o) )
@@ -349,6 +338,8 @@ $(info CFLAGS $(CFLAGS))
$(info )
$(info LDFLAGS $(LDFLAGS))
$(info )
$(info ASMFLAGS $(ASMFLAGS))
$(info )
endif
.phony: all clean size flash sd erase
@@ -475,7 +466,6 @@ $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out
@echo CR $(OUTPUT_FILENAME)-nosd.hex
$(QUIET)$(OBJCOPY) -O ihex $< $@
# merge bootloader and sd hex together
combinehex: $(BUILD)/$(MERGED_FNAME).hex
+3 -16
View File
@@ -3,7 +3,7 @@
This is a CDC/DFU/UF2 bootloader for nRF52 boards.
- [Adafruit Feather nRF52832](https://www.adafruit.com/product/3406)
- Adafruit Feather nRF52840 Express
- [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
- Nordic nRF52840DK PCA10056
- Nordic nRF52840DK PCA10059 ("Dongle")
- Particle Argon
@@ -26,7 +26,7 @@ $ pip3 install --user adafruit-nrfutil
This repository depends on the following submodules:
- [tinyusb](https://github.com/hathach/tinyusb/tree/develop)
- [tinyusb](https://github.com/hathach/tinyusb)
- [nrfx](https://github.com/NordicSemiconductor/nrfx)
Note that `tinyusb` also includes `nrfx` as a submodule, so you need
@@ -74,20 +74,7 @@ For other boards, please check the board definition for details.
You can burn and/or upgrade the bootloader with either a J-link or DFU (serial) to a specific pre-built binary version
without the hassle of installing a toolchain and compiling the code.
This is preferred if you are not developing/customizing the bootloader.
To flash version `6.1.1r0` using J-Link:
```
make BOARD=feather_nrf52840_express VERSION=6.1.1r0 flash
```
To upgrade with dfu serial
```
make BOARD=feather_nrf52840_express VERSION=6.1.1r0 dfu-flash
```
Pre-builtin binaries are available on GitHub releases.
Pre-builtin binaries are available on GitHub [releases](https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases)
Note: The bootloader can be downgraded. Since the binary release is a merged version of
of both bootloader and the Nordic SoftDevice, you can freely upgrade/downgrade to any version you like.
+26
View File
@@ -0,0 +1,26 @@
# Adafruit nRF52 Bootloader Changelog
## 0.2.7
- Fixed PWM psel[1] is not reset
- Fixed #41 move RXD, TXD into board header
- Added Metro nRF52840 Rev A
- Fixed #40 OTA issue with BLE_GAP_EVT_PHY_UPDATE_REQUEST e.g connecting with iPhone X
## 0.2.6
- Fixed copy/restore current.uf2 issue
- Fixed neopixel won't turn off after dfu cdc
## 0.2.5
- Make led pattern more consistent
- Fixed issue nrf52840 not reset properly when upgrading bootloader+sd combo
- Make led pattern more consistent
## 0.2.3
- Fully support Feather nRF52840
- Update bootloader with new led pattern
- Fix #203: return software timer handle
@@ -128,16 +128,15 @@ static void wait_for_events(void)
app_sched_execute();
#ifdef NRF52840_XXAA
// usb is not enabled in OTA
if ( !is_ota() )
// skip if usb is not inited ( e.g OTA / finializing sd/bootloader )
extern bool usb_inited(void);
if ( usb_inited() )
{
tusb_task();
tud_cdc_write_flush();
}
#endif
led_tick();
if ((m_update_status == BOOTLOADER_COMPLETE) ||
(m_update_status == BOOTLOADER_TIMEOUT) ||
(m_update_status == BOOTLOADER_RESET) )
@@ -741,7 +741,6 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
case BLE_GAP_EVT_CONNECTED:
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
m_is_advertising = false;
led_state(STATE_BLE_CONNECTED);
break;
case BLE_GAP_EVT_DISCONNECTED:
@@ -751,8 +750,6 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
m_direct_adv_cnt = APP_DIRECTED_ADV_TIMEOUT;
led_state(STATE_BLE_DISCONNECTED);
err_code = sd_ble_gatts_sys_attr_get(m_conn_handle,
sys_attr,
&sys_attr_len,
@@ -888,6 +885,14 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
APP_ERROR_CHECK( sd_ble_gap_data_length_update(m_conn_handle, NULL, NULL) );
break;
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
{
// Tell SoftDevice to choose PHY automatically
ble_gap_phys_t phy = { BLE_GAP_PHY_AUTO, BLE_GAP_PHY_AUTO };
(void) sd_ble_gap_phy_update(m_conn_handle, &phy);
}
break;
case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
{
uint16_t att_mtu = MIN(p_ble_evt->evt.gatts_evt.params.exchange_mtu_request.client_rx_mtu, BLEGATT_ATT_MTU_MAX);
@@ -41,22 +41,14 @@
#if defined(NRF52832_XXAA)
#define BOOTLOADER_REGION_START 0x00074000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0007E000 /**< The field specifies the page location of the mbr params page address. */
#elif defined(NRF52840_XXAA)
// Increase bootloader size to application data region for easy debugging
#ifdef DEBUG_SIZE_EXPAND
#define BOOTLOADER_REGION_START (0x000F4000 - CODE_PAGE_SIZE*7)
#define DFU_APP_DATA_RESERVED 0
#else
#define BOOTLOADER_REGION_START 0x000F4000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
#endif
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000 /**< The field specifies the page location of the bootloader settings address. */
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000 /**< The field specifies the page location of the mbr params page address. */
+52 -14
View File
@@ -80,10 +80,17 @@ void board_init(void)
// Init app timer (use RTC1)
app_timer_init();
// Configure Systick for led blinky
NVIC_SetPriority(SysTick_IRQn, 7);
SysTick_Config(SystemCoreClock/1000);
}
void board_teardown(void)
{
// Disable systick, turn off LEDs
SysTick->CTRL = 0;
// Disable and reset PWM for LEDs
led_pwm_teardown();
@@ -104,18 +111,29 @@ void board_teardown(void)
NRF_CLOCK->TASKS_LFCLKSTOP = 1UL;
}
static uint32_t _systick_count = 0;
void SysTick_Handler(void)
{
_systick_count++;
led_tick();
}
uint32_t tusb_hal_millis(void)
{
return ( ( ((uint64_t)app_timer_cnt_get())*1000*(APP_TIMER_CONFIG_RTC_FREQUENCY+1)) / APP_TIMER_CLOCK_FREQ );
}
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;
@@ -126,7 +144,7 @@ void pwm_teardown(NRF_PWM_Type* pwm )
pwm->SEQ[0].CNT = 0;
}
static uint16_t led_duty_cycles[PWM0_CH_NUM];
static uint16_t led_duty_cycles[PWM0_CH_NUM] = { 0 };
#if LEDS_NUMBER > PWM0_CH_NUM
#error "Only " PWM0_CH_NUM " concurrent status LEDs are supported."
@@ -136,10 +154,13 @@ 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->ENABLE = 1;
pwm->MODE = PWM_MODE_UPDOWN_Up;
pwm->COUNTERTOP = 0xff;
pwm->PRESCALER = PWM_PRESCALER_PRESCALER_DIV_16;
@@ -150,8 +171,11 @@ void led_pwm_init(uint32_t led_index, uint32_t led_pin)
pwm->SEQ[0].CNT = 4; // default mode is Individual --> count must be 4
pwm->SEQ[0].REFRESH = 0;
pwm->SEQ[0].ENDDELAY = 0;
pwm->LOOP = 0;
pwm->TASKS_SEQSTART[0] = 1;
pwm->ENABLE = 1;
pwm->EVENTS_SEQEND[0] = 0;
// pwm->TASKS_SEQSTART[0] = 1;
}
void led_pwm_teardown(void)
@@ -171,7 +195,7 @@ static uint32_t primary_cycle_length;
static uint32_t secondary_cycle_length;
#endif
void led_tick() {
uint32_t millis = tusb_hal_millis();
uint32_t millis = _systick_count;
uint32_t cycle = millis % primary_cycle_length;
uint32_t half_cycle = primary_cycle_length / 2;
@@ -207,19 +231,25 @@ void led_state(uint32_t state)
switch (state) {
case STATE_USB_MOUNTED:
new_rgb_color = 0x00ff00;
primary_cycle_length = 4000;
primary_cycle_length = 3000;
break;
case STATE_BOOTLOADER_STARTED:
case STATE_USB_UNMOUNTED:
new_rgb_color = 0xff0000;
primary_cycle_length = 300;
break;
case STATE_WRITING_STARTED:
temp_color = 0xff0000;
primary_cycle_length = 100;
break;
case STATE_WRITING_FINISHED:
// Empty means to unset any temp colors.
primary_cycle_length = 3000;
break;
case STATE_BLE_CONNECTED:
new_rgb_color = 0x0000ff;
#ifdef LED_SECONDARY_PIN
@@ -228,6 +258,7 @@ void led_state(uint32_t state)
primary_cycle_length = 500;
#endif
break;
case STATE_BLE_DISCONNECTED:
new_rgb_color = 0xff00ff;
#ifdef LED_SECONDARY_PIN
@@ -236,6 +267,7 @@ void led_state(uint32_t state)
primary_cycle_length = 300;
#endif
break;
default:
break;
}
@@ -260,7 +292,7 @@ void led_state(uint32_t state)
#endif
}
#if LED_NEOPIXEL
#ifdef LED_NEOPIXEL
// WS2812B (rev B) timing is 0.4 and 0.8 us
#define MAGIC_T0H 6UL | (0x8000) // 0.375us
@@ -271,6 +303,7 @@ void led_state(uint32_t state)
static uint16_t pixels_pattern[NEO_NUMBYTE * 8 + 2];
// use PWM1 for neopixel
void neopixel_init(void)
{
// To support both the SoftDevice + Neopixels we use the EasyDMA
@@ -280,7 +313,7 @@ void neopixel_init(void)
// totalMem = numBytes*8*2+(2*2)
// The two additional bytes at the end are needed to reset the
// sequence.
NRF_PWM_Type* pwm = NRF_PWM2;
NRF_PWM_Type* pwm = NRF_PWM1;
// Set the wave mode to count UP
// Set the PWM to use the 16MHz clock
@@ -317,11 +350,13 @@ void neopixel_init(void)
void neopixel_teardown(void)
{
uint8_t grb[3] = { 0, 0, 0 };
NRFX_DELAY_US(50); // wait for previous write is complete
neopixel_write(grb);
NRFX_DELAY_US(50); // wait for this write
NRFX_DELAY_US(100);
pwm_teardown(NRF_PWM2);
pwm_teardown(NRF_PWM1);
}
// write 3 bytes color to a built-in neopixel
@@ -344,13 +379,16 @@ void neopixel_write (uint8_t *pixels)
pixels_pattern[pos++] = 0 | (0x8000); // Seq end
pixels_pattern[pos++] = 0 | (0x8000); // Seq end
NRF_PWM_Type* pwm = NRF_PWM2;
NRF_PWM_Type* pwm = NRF_PWM1;
nrf_pwm_seq_ptr_set(pwm, 0, pixels_pattern);
nrf_pwm_seq_cnt_set(pwm, 0, sizeof(pixels_pattern)/2);
nrf_pwm_event_clear(pwm, NRF_PWM_EVENT_SEQEND0);
nrf_pwm_task_trigger(pwm, NRF_PWM_TASK_SEQSTART0);
// blocking wait for sequence complete
while( !nrf_pwm_event_check(pwm, NRF_PWM_EVENT_SEQEND0) ) {}
nrf_pwm_event_clear(pwm, NRF_PWM_EVENT_SEQEND0);
}
#endif
+12 -28
View File
@@ -17,23 +17,7 @@
#include <string.h>
#include "nrf_gpio.h"
#if defined BOARD_FEATHER_NRF52840_EXPRESS
#include "boards/feather_nrf52840_express.h"
#elif defined BOARD_FEATHER_NRF52832
#include "boards/feather_nrf52832.h"
#elif defined BOARD_PCA10056
#include "boards/pca10056.h"
#elif defined BOARD_PCA10059
#include "boards/pca10059.h"
#elif defined BOARD_PARTICLE_ARGON
#include "boards/particle_argon.h"
#elif defined BOARD_PARTICLE_BORON
#include "boards/particle_boron.h"
#elif defined BOARD_PARTICLE_XENON
#include "boards/particle_xenon.h"
#else
#error No boards defined
#endif
#include BOARD_HEADER_FILE
#ifndef BUTTON_DFU
#define BUTTON_DFU BUTTON_1
@@ -73,15 +57,17 @@ void board_teardown(void);
#define bit(b) (1UL << (b))
#define STATE_BOOTLOADER_STARTED 0
#define STATE_USB_MOUNTED 1
#define STATE_USB_UNMOUNTED 2
#define STATE_FACTORY_RESET_STARTED 3
#define STATE_FACTORY_RESET_FINISHED 4
#define STATE_WRITING_STARTED 5
#define STATE_WRITING_FINISHED 6
#define STATE_BLE_CONNECTED 7
#define STATE_BLE_DISCONNECTED 8
enum {
STATE_BOOTLOADER_STARTED = 0,
STATE_USB_MOUNTED,
STATE_USB_UNMOUNTED,
STATE_FACTORY_RESET_STARTED,
STATE_FACTORY_RESET_FINISHED,
STATE_WRITING_STARTED,
STATE_WRITING_FINISHED,
STATE_BLE_CONNECTED,
STATE_BLE_DISCONNECTED
};
void led_pwm_init(uint32_t led_index, uint32_t led_pin);
void led_pwm_teardown(void);
@@ -108,8 +94,6 @@ static inline bool button_pressed(uint32_t pin)
return (nrf_gpio_pin_read(pin) == 0) ? true : false;
}
bool is_ota(void);
#endif
+16 -16
View File
@@ -40,32 +40,32 @@
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 17 // Red
#define LED_SECONDARY_PIN 19 // Blue
#define LED_STATE_ON 1
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 17 // Red
#define LED_SECONDARY_PIN 19 // Blue
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 20
#define BUTTON_2 22
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTONS_NUMBER 2
#define BUTTON_1 20
#define BUTTON_2 22
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 7
#define RTS_PIN_NUMBER 5
#define HWFC false
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
// Used as model string in OTA mode
#define DIS_MANUFACTURER "Adafruit Industries"
#define DIS_MODEL "Bluefruit Feather nRF52832"
#define DIS_MANUFACTURER "Adafruit Industries"
#define DIS_MODEL "Bluefruit Feather nRF52832"
#define PRODUCT_NAME "Adafruit Bluefruit Feather nRF52832"
#define PRODUCT_NAME "Adafruit Bluefruit Feather nRF52832"
#endif // _FEATHER52832_H
+19 -19
View File
@@ -42,35 +42,35 @@
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 15)
#define LED_SECONDARY_PIN _PINNUM(1, 10)
#define LED_NEOPIXEL 16
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_STATE_ON 1
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 15)
#define LED_SECONDARY_PIN _PINNUM(1, 10)
#define LED_NEOPIXEL 16
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 15)
#define BUTTON_2 _PINNUM(0, 19)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 15)
#define BUTTON_2 _PINNUM(0, 19)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 7
#define RTS_PIN_NUMBER 5
#define HWFC false
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
// Used as model string in OTA mode
#define DIS_MANUFACTURER "Adafruit Industries"
#define DIS_MODEL "Bluefruit Feather nRF52840 Express"
#define DIS_MANUFACTURER "Adafruit Industries"
#define DIS_MODEL "Bluefruit Feather nRF52840 Express"
#define PRODUCT_NAME "Adafruit Feather nRF52840 Express"
#define VOLUME_LABEL "FTHR840BOOT"
#define PRODUCT_NAME "Adafruit Feather nRF52840 Express"
#define VOLUME_LABEL "FTHR840BOOT"
#endif // _FEATHER52840_H
+77
View File
@@ -0,0 +1,77 @@
/**************************************************************************/
/*!
@file metro_nrf52840_express.h
@author hathach (tinyusb.org)
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2019, Adafruit Industries (adafruit.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**************************************************************************/
#ifndef _METRO_NRF52840_EXPRESS_H_
#define _METRO_NRF52840_EXPRESS_H_
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 13)
#define LED_SECONDARY_PIN _PINNUM(1, 15)
#define LED_NEOPIXEL _PINNUM(0, 13)
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 0)
#define BUTTON_2 _PINNUM(2, 2)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
// Used as model string in OTA mode
#define DIS_MANUFACTURER "Adafruit Industries"
#define DIS_MODEL "Bluefruit Metro nRF52840 Express"
#define PRODUCT_NAME "Adafruit Metro nRF52840 Express"
#define VOLUME_LABEL "METR840BOOT"
#endif /* _METRO_NRF52840_EXPRESS_H_ */
+9 -9
View File
@@ -42,21 +42,21 @@
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 12)
#define LED_STATE_ON 1
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 12)
#define LED_STATE_ON 1
#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
#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
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_DFU _PINNUM(0, 11)
#define BUTTON_FRESET _PINNUM(0, 03) // A0
#define BUTTON_DFU _PINNUM(0, 11)
#define BUTTON_FRESET _PINNUM(0, 03) // A0
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
+14 -14
View File
@@ -40,30 +40,30 @@
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 13
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 13
#define LED_SECONDARY_PIN 14
#define LED_STATE_ON 0
#define LED_STATE_ON 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 11
#define BUTTON_2 12
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTONS_NUMBER 2
#define BUTTON_1 11
#define BUTTON_2 12
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 7
#define RTS_PIN_NUMBER 5
#define HWFC false
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
// Used as model string in OTA mode
#define DIS_MANUFACTURER "Nordic"
#define DIS_MODEL "PCA10056"
#define DIS_MANUFACTURER "Nordic"
#define DIS_MODEL "PCA10056"
#endif // PCA10056_H
+4 -2
View File
@@ -37,6 +37,8 @@
#ifndef PCA10059_H
#define PCA10059_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
@@ -50,8 +52,8 @@
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 (1 << 5 | 6)
#define BUTTON_2 (1 << 5 | 10)
#define BUTTON_1 _PINNUM(1, 6)
#define BUTTON_2 _PINNUM(1, 10)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
+3 -4
View File
@@ -71,7 +71,7 @@ void usb_teardown(void);
#else
#define usb_init(x)
#define usb_init(x) led_state(STATE_USB_MOUNTED) // mark nrf52832 as mounted
#define usb_teardown()
#endif
@@ -167,6 +167,8 @@ int main(void)
board_init();
bootloader_init();
led_state(STATE_BOOTLOADER_STARTED);
// When updating SoftDevice, bootloader will reset before swapping SD
if (bootloader_dfu_sd_in_progress())
{
@@ -209,8 +211,6 @@ int main(void)
(*dbl_reset_mem) = 0;
led_state(STATE_BOOTLOADER_STARTED);
if ( dfu_start || !valid_app )
{
if ( _ota_dfu )
@@ -222,7 +222,6 @@ int main(void)
else
{
led_state(STATE_USB_UNMOUNTED);
// otherwise USB for Serial & UF2
usb_init(serial_only_dfu);
}
+7 -5
View File
@@ -43,17 +43,19 @@
#ifndef SDK_CONFIG_H
#define SDK_CONFIG_H
#include "boards.h"
//==========================================================
// <e> HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI
//==========================================================
#define HCI_SLIP_ENABLED 1
#define HCI_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200
#define HCI_UART_FLOW_CONTROL 0
#define HCI_UART_RX_PIN 8
#define HCI_UART_TX_PIN 6
#define HCI_UART_RTS_PIN 5
#define HCI_UART_CTS_PIN 7
#define HCI_UART_FLOW_CONTROL HWFC
#define HCI_UART_RX_PIN RX_PIN_NUMBER
#define HCI_UART_TX_PIN TX_PIN_NUMBER
#define HCI_UART_CTS_PIN CTS_PIN_NUMBER
#define HCI_UART_RTS_PIN RTS_PIN_NUMBER
#define HCI_TRANSPORT_ENABLED 1
#define HCI_MAX_PACKET_SIZE_IN_BITS 8000
+15 -8
View File
@@ -18,10 +18,12 @@
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="nRF52840_xxAA"
arm_target_interface_type="SWD"
c_preprocessor_definitions="__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;NO_VTOR_CONFIG;MK_BOOTLOADER_VERSION=0x06010000;CONFIG_GPIO_AS_PINRESET;BLE_STACK_SUPPORT_REQD;SWI_DISABLE0;SOFTDEVICE_PRESENT;FLOAT_ABI_HARD;CFG_TUSB_DEBUG=2"
c_user_include_directories="../;../usb;../cmsis/include;$(tusbDir);$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(sdDir)/include;$(sdDir)/include/nrf52;$(sdk11Dir)/drivers_nrf/pstorage;$(sdk11Dir)/ble/common/;$(sdk11Dir)/ble/ble_services/ble_dfu;$(sdk11Dir)/ble/ble_services/ble_dis;$(sdk11Dir)/libraries/bootloader_dfu;$(sdk11Dir)/libraries/bootloader_dfu/hci_transport;$(sdk11Dir)/libraries/util;$(sdkDir)/toolchain/cmsis/include;$(sdkDir)/device;$(sdkDir)/toolchain;$(sdkDir)/drivers_nrf/hal;$(sdkDir)/drivers_nrf/systick;$(sdkDir)/drivers_nrf/uart;$(sdkDir)/drivers_nrf/usbd;$(sdkDir)/drivers_nrf/common;$(sdkDir)/drivers_nrf/delay;$(sdkDir)/drivers_nrf/power;$(sdkDir)/drivers_nrf/clock;$(sdkDir)/libraries/util;$(sdkDir)/libraries/timer;$(sdkDir)/libraries/scheduler;$(sdkDir)/libraries/crc16;$(sdkDir)/libraries/util;$(sdkDir)/libraries/hci/config;$(sdkDir)/libraries/uart;$(sdkDir)/libraries/hci;$(sdkDir)/external/fprintf;$(sdkDir)/libraries/strerror;$(sdkDir)/libraries/atomic;$(sdkDir)/libraries/balloc;$(sdkDir)/libraries/experimental_log/src;$(sdkDir)/libraries/experimental_log;$(sdkDir)/libraries/experimental_section_vars;$(sdkDir)/libraries/experimental_memobj"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;NO_VTOR_CONFIG;MK_BOOTLOADER_VERSION=0x06010000;CONFIG_GPIO_AS_PINRESET;BLE_STACK_SUPPORT_REQD;SWI_DISABLE0;SOFTDEVICE_PRESENT;FLOAT_ABI_HARD;CFG_TUSB_DEBUG=2;UF2_VERSION=&quot;Segger&quot;"
c_user_include_directories="../;../usb;../boards;../cmsis/include;$(tusbDir);$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(sdDir)/include;$(sdDir)/include/nrf52;$(sdk11Dir)/drivers_nrf/pstorage;$(sdk11Dir)/ble/common/;$(sdk11Dir)/ble/ble_services/ble_dfu;$(sdk11Dir)/ble/ble_services/ble_dis;$(sdk11Dir)/libraries/bootloader_dfu;$(sdk11Dir)/libraries/bootloader_dfu/hci_transport;$(sdk11Dir)/libraries/util;$(sdkDir)/toolchain/cmsis/include;$(sdkDir)/device;$(sdkDir)/toolchain;$(sdkDir)/drivers_nrf/hal;$(sdkDir)/drivers_nrf/systick;$(sdkDir)/drivers_nrf/uart;$(sdkDir)/drivers_nrf/usbd;$(sdkDir)/drivers_nrf/common;$(sdkDir)/drivers_nrf/delay;$(sdkDir)/drivers_nrf/power;$(sdkDir)/drivers_nrf/clock;$(sdkDir)/libraries/util;$(sdkDir)/libraries/timer;$(sdkDir)/libraries/scheduler;$(sdkDir)/libraries/crc16;$(sdkDir)/libraries/util;$(sdkDir)/libraries/hci/config;$(sdkDir)/libraries/uart;$(sdkDir)/libraries/hci;$(sdkDir)/external/fprintf;$(sdkDir)/libraries/strerror;$(sdkDir)/libraries/atomic;$(sdkDir)/libraries/balloc;$(sdkDir)/libraries/experimental_log/src;$(sdkDir)/libraries/experimental_log;$(sdkDir)/libraries/experimental_section_vars;$(sdkDir)/libraries/experimental_memobj"
debug_register_definition_file="$(ProjectDir)/nrf52840_Registers.xml"
debug_target_connection="J-Link"
gcc_enable_all_warnings="No"
gcc_entry_point="Reset_Handler"
linker_memory_map_file="$(ProjectDir)/nRF52840_xxAA_MemoryMap.xml"
linker_section_placement_file="$(ProjectDir)/flash_placement.xml"
@@ -327,6 +329,7 @@
<configuration
Name="Feather52840"
build_exclude_from_build="Yes" />
<configuration Name="PCA10056" build_exclude_from_build="Yes" />
</file>
<file file_name="../../lib/nrfx/mdk/ses_startup_nrf52840.s">
<configuration
@@ -349,6 +352,7 @@
<configuration
Name="Feather52840"
build_exclude_from_build="Yes" />
<configuration Name="PCA10056" build_exclude_from_build="Yes" />
</file>
<file file_name="../../lib/nrfx/mdk/system_nrf52.h" />
<file file_name="../../lib/nrfx/mdk/system_nrf52840.c">
@@ -370,16 +374,19 @@
</folder>
<configuration
Name="Feather52840"
c_preprocessor_definitions="NRF52840_XXAA;MK_DIS_FIRMWARE=&quot;s140 6.1.1 r0&quot;;S140;BOARD_PCA10056"
c_preprocessor_definitions="NRF52840_XXAA;MK_DIS_FIRMWARE=&quot;s140 6.1.1 r0&quot;;S140;BOARD_FEATHER_NRF52840_EXPRESS;BOARD_HEADER_FILE=&quot;feather_nrf52840_express.h&quot;"
linker_memory_map_file="nRF52840_xxAA_MemoryMap.xml" />
<configuration
Name="Feather52832"
c_preprocessor_definitions="NRF52832_XXAA;MK_DIS_FIRMWARE=&quot;s132 6.1.1 r0&quot;;S132;BOARD_FEATHER_NRF52832"
c_preprocessor_definitions="NRF52832_XXAA;MK_DIS_FIRMWARE=&quot;s132 6.1.1 r0&quot;;S132;BOARD_FEATHER_NRF52832;BOARD_HEADER_FILE=&quot;feather_nrf52832.h&quot;"
linker_memory_map_file="nRF52832_xxAA_MemoryMap.xml" />
<configuration
Name="PCA10056"
c_preprocessor_definitions="NRF52840_XXAA;MK_DIS_FIRMWARE=&quot;s140 6.1.1 r0&quot;;S140;BOARD_PCA10056;BOARD_HEADER_FILE=&quot;pca10056.h&quot;"
gcc_optimization_level="Debug"
linker_memory_map_file="nRF52840_xxAA_MemoryMap.xml" />
</project>
<configuration
Name="Feather52840"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="DEBUG_SIZE_EXPAND" />
<configuration Name="Feather52840" />
<configuration Name="Feather52832" />
<configuration Name="PCA10056" />
</solution>
+1 -2
View File
@@ -1,7 +1,6 @@
<!DOCTYPE Board_Memory_Definition_File>
<root name="nRF52840_xxAA">
<!--MemorySegment name="FLASH" start="0x000F4000" size="0xA000" access="ReadOnly" /-->
<MemorySegment name="FLASH" start="0x000ED000" size="0x11000" access="ReadOnly" />
<MemorySegment name="FLASH" start="0x000F4000" size="0xA000" access="ReadOnly" />
<MemorySegment name="BOOTLOADER_SETTINGS" start="0x000FF000" size="0x1000" access="ReadOnly" />
<MemorySegment name="MBR_PARAMS_PAGE" start="0x000FE000" size="0x1000" access="ReadOnly" />
<MemorySegment name="UICR_BOOTLOADER" start="0x10001014" size="0x04" access="ReadOnly" />
+14 -5
View File
@@ -83,7 +83,7 @@ static struct TextFile const info[] = {
};
#define NUM_INFO (sizeof(info) / sizeof(info[0]))
#define UF2_SIZE (get_flash_size() * 2)
#define UF2_SIZE (current_flash_size() * 2)
#define UF2_SECTORS (UF2_SIZE / 512)
#define UF2_FIRST_SECTOR (NUM_INFO + 1)
#define UF2_LAST_SECTOR (UF2_FIRST_SECTOR + UF2_SECTORS - 1)
@@ -120,7 +120,9 @@ static FAT_BootBlock const BootBlock = {
#define NRF_LOG_WARNING(...)
static WriteState _wr_state = { 0 };
static uint32_t get_flash_size(void)
// get current.uf2 flash size in bytes, round up to 256 bytes
static uint32_t current_flash_size(void)
{
static uint32_t flash_sz = 0;
@@ -136,10 +138,17 @@ static uint32_t get_flash_size(void)
bootloader_settings_t const * boot_setting;
bootloader_util_settings_get(&boot_setting);
flash_sz = boot_setting->bank_0_size;
// Copy size must be multiple of 256 bytes
// else we will got an issue copying current.uf2
if (flash_sz & 0xff)
{
flash_sz = (flash_sz & ~0xff) + 256;
}
// if bank0 size is not valid, happens when flashed with jlink
// use maximum application size
flash_sz = boot_setting->bank_0_size;
if ( (flash_sz == 0) || (flash_sz == 0xFFFFFFFFUL) )
{
flash_sz = FLASH_SIZE;
@@ -217,7 +226,7 @@ void read_block(uint32_t block_no, uint8_t *data) {
bl->magicStart1 = UF2_MAGIC_START1;
bl->magicEnd = UF2_MAGIC_END;
bl->blockNo = sectionIdx;
bl->numBlocks = FLASH_SIZE / 256;
bl->numBlocks = current_flash_size() / 256;
bl->targetAddr = addr;
bl->payloadSize = 256;
bl->flags = UF2_FLAG_FAMILYID;
+14
View File
@@ -65,8 +65,22 @@ extern void tusb_hal_nrf_power_event(uint32_t event);
//------------- IMPLEMENTATION -------------//
static bool _inited = false;
bool usb_inited(void)
{
return _inited;
}
void usb_init(bool cdc_only)
{
// skipped if already inited
if ( _inited ) return;
_inited = true;
NVIC_SetPriority(USBD_IRQn, 2);
// USB power may already be ready at this time -> no event generated
// We need to invoke the handler based on the status initially
uint32_t usb_reg;