From 2aef4dd2f0ed511a55bd31afb62cebfbcaf57ba8 Mon Sep 17 00:00:00 2001 From: Hirotaka Kawata Date: Thu, 14 Feb 2019 20:09:12 +0900 Subject: [PATCH 01/15] Bug Fix: Incorrect cast on BLECharacteristic::read32() --- libraries/Bluefruit52Lib/src/BLECharacteristic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp b/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp index 2d020855..378101f5 100644 --- a/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp +++ b/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp @@ -484,7 +484,7 @@ uint16_t BLECharacteristic::read16(void) uint32_t BLECharacteristic::read32(void) { - uint16_t num; + uint32_t num; return read(&num, sizeof(num)) ? num : 0; } From f42cf4b60b6cdb475824eb90e2133d8bb302102e Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 20 Feb 2019 14:18:55 -0800 Subject: [PATCH 02/15] fix uf2conv.py --- tools/uf2conv/uf2conv.py | 162 ++++++++++++++++++++++----------------- 1 file changed, 92 insertions(+), 70 deletions(-) diff --git a/tools/uf2conv/uf2conv.py b/tools/uf2conv/uf2conv.py index 2418d8e4..4a1455e0 100644 --- a/tools/uf2conv/uf2conv.py +++ b/tools/uf2conv/uf2conv.py @@ -1,5 +1,4 @@ -#!/usr/bin/python - +#!/usr/bin/env python3 import sys import struct import subprocess @@ -8,6 +7,7 @@ import os import os.path import argparse + UF2_MAGIC_START0 = 0x0A324655 # "UF2\n" UF2_MAGIC_START1 = 0x9E5D5157 # Randomly selected UF2_MAGIC_END = 0x0AB16F30 # Ditto @@ -26,27 +26,31 @@ INFO_FILE = "/INFO_UF2.TXT" appstartaddr = 0x2000 familyid = 0x0 -def isUF2(buf): + +def is_uf2(buf): w = struct.unpack(" 0: padding -= 4 - outp += "\x00\x00\x00\x00" + outp += b"\x00\x00\x00\x00" outp += block[32 : 32 + datalen] curraddr = newaddr + datalen return outp -def convertToUF2(fileContent): +def convert_to_carray(file_content): + outp = "const unsigned char bindata[] __attribute__((aligned(16))) = {" + for i in range(len(file_content)): + if i % 16 == 0: + outp += "\n" + outp += "0x%02x, " % ord(file_content[i]) + outp += "\n};\n" + return outp + +def convert_to_uf2(file_content): global familyid - datapadding = "" + datapadding = b"" while len(datapadding) < 512 - 256 - 32 - 4: - datapadding += "\x00\x00\x00\x00" - numblocks = (len(fileContent) + 255) / 256 - outp = "" - for blockno in range(0, numblocks): + datapadding += b"\x00\x00\x00\x00" + numblocks = (len(file_content) + 255) // 256 + outp = b"" + for blockno in range(numblocks): ptr = 256 * blockno - chunk = fileContent[ptr:ptr + 256] + chunk = file_content[ptr:ptr + 256] flags = 0x0 if familyid: flags |= 0x2000 - hd = struct.pack("= 3 and words[1] == "2" and words[2] == "FAT": @@ -176,36 +187,41 @@ def getdrives(): rootpath = tmp for d in os.listdir(rootpath): drives.append(os.path.join(rootpath, d)) - - def hasInfo(d): + + + def has_info(d): try: return os.path.isfile(d + INFO_FILE) except: return False - - return filter(hasInfo, drives) -def boardID(path): + return list(filter(has_info, drives)) + + +def board_id(path): with open(path + INFO_FILE, mode='r') as file: - fileContent = file.read() - return re.search("Board-ID: ([^\r\n]*)", fileContent).group(1) - -def listdrives(): - for d in getdrives(): - print d, boardID(d) + file_content = file.read() + return re.search("Board-ID: ([^\r\n]*)", file_content).group(1) -def writeFile(name, buf): + +def list_drives(): + for d in get_drives(): + print(d, board_id(d)) + + +def write_file(name, buf): with open(name, "wb") as f: f.write(buf) - print "Wrote %d bytes to %s." % (len(buf), name) + print("Wrote %d bytes to %s." % (len(buf), name)) + def main(): global appstartaddr, familyid def error(msg): - print msg + print(msg) sys.exit(1) parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.') - parser.add_argument('input', metavar='INPUT', type=str, nargs='?', + parser.add_argument('input', metavar='INPUT', type=str, nargs='?', help='input file (HEX, BIN or UF2)') parser.add_argument('-b' , '--base', dest='base', type=str, default="0x2000", @@ -221,6 +237,8 @@ def main(): parser.add_argument('-f' , '--family', dest='family', type=str, default="0x0", help='specify familyID - number or name (default: 0x0)') + parser.add_argument('-C' , '--carray', action='store_true', + help='convert binary file to a C array, not UF2') args = parser.parse_args() appstartaddr = int(args.base, 0) @@ -233,38 +251,42 @@ def main(): error("Family ID needs to be a number or one of: " + ", ".join(families.keys())) if args.list: - listdrives() + list_drives() else: if not args.input: error("Need input file") - with open(args.input, mode='rb') as file: - inpbuf = file.read() - fromUF2 = isUF2(inpbuf) + with open(args.input, mode='rb') as f: + inpbuf = f.read() + from_uf2 = is_uf2(inpbuf) ext = "uf2" - if fromUF2: - outbuf = convertFromUF2(inpbuf) + if from_uf2: + outbuf = convert_from_uf2(inpbuf) ext = "bin" - elif isHEX(inpbuf): - outbuf = convertFromHexToUF2(inpbuf) + elif is_hex(inpbuf): + outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8")) + elif args.carray: + outbuf = convert_to_carray(inpbuf) + ext = "h" else: - outbuf = convertToUF2(inpbuf) - print "Converting to %s, output size: %d, start address: 0x%x" % (ext, len(outbuf), appstartaddr) - + outbuf = convert_to_uf2(inpbuf) + print("Converting to %s, output size: %d, start address: 0x%x" % + (ext, len(outbuf), appstartaddr)) if args.convert: drives = [] if args.output == None: args.output = "flash." + ext else: - drives = getdrives() - + drives = get_drives() + if args.output: - writeFile(args.output, outbuf) + write_file(args.output, outbuf) else: if len(drives) == 0: error("No drive to deploy.") for d in drives: - print "Flashing %s (%s)" % (d, boardID(d)) - writeFile(outbuf, d + "/NEW.UF2") + print("Flashing %s (%s)" % (d, board_id(d))) + write_file(d + "/NEW.UF2", outbuf) + if __name__ == "__main__": - main() + main() \ No newline at end of file From 43ba823eb7b9f60aa95dd333ed11d5e7cd75e515 Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Sun, 10 Mar 2019 20:23:37 -0400 Subject: [PATCH 03/15] Fix missing returns in BLEClientHidAdafruit.cpp --- .../src/clients/BLEClientHidAdafruit.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/Bluefruit52Lib/src/clients/BLEClientHidAdafruit.cpp b/libraries/Bluefruit52Lib/src/clients/BLEClientHidAdafruit.cpp index cd5cfe4a..96b00731 100644 --- a/libraries/Bluefruit52Lib/src/clients/BLEClientHidAdafruit.cpp +++ b/libraries/Bluefruit52Lib/src/clients/BLEClientHidAdafruit.cpp @@ -81,6 +81,8 @@ bool BLEClientHidAdafruit::begin(void) // set notify callback _kbd_boot_input.setNotifyCallback(kbd_client_notify_cb); _mse_boot_input.setNotifyCallback(mse_client_notify_cb); + + return true; } void BLEClientHidAdafruit::setKeyboardReportCallback(kbd_callback_t fp) @@ -140,12 +142,12 @@ bool BLEClientHidAdafruit::keyboardPresent(void) bool BLEClientHidAdafruit::enableKeyboard(void) { - _kbd_boot_input.enableNotify(); + return _kbd_boot_input.enableNotify(); } bool BLEClientHidAdafruit::disableKeyboard(void) { - _kbd_boot_input.disableNotify(); + return _kbd_boot_input.disableNotify(); } void BLEClientHidAdafruit::_handle_kbd_input(uint8_t* data, uint16_t len) @@ -171,12 +173,12 @@ bool BLEClientHidAdafruit::mousePresent(void) bool BLEClientHidAdafruit::enableMouse(void) { - _mse_boot_input.enableNotify(); + return _mse_boot_input.enableNotify(); } bool BLEClientHidAdafruit::disableMouse(void) { - _mse_boot_input.disableNotify(); + return _mse_boot_input.disableNotify(); } void BLEClientHidAdafruit::_handle_mse_input(uint8_t* data, uint16_t len) From f63a5a9b3703e1bdcf71a04928c0d67da5de6e9a Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Sun, 10 Mar 2019 20:28:42 -0400 Subject: [PATCH 04/15] Fix return value in EddyStone.cpp/h --- libraries/Bluefruit52Lib/src/services/EddyStone.cpp | 2 +- libraries/Bluefruit52Lib/src/services/EddyStone.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/Bluefruit52Lib/src/services/EddyStone.cpp b/libraries/Bluefruit52Lib/src/services/EddyStone.cpp index 22b45b31..d4ca4983 100644 --- a/libraries/Bluefruit52Lib/src/services/EddyStone.cpp +++ b/libraries/Bluefruit52Lib/src/services/EddyStone.cpp @@ -81,7 +81,7 @@ EddyStoneUrl::EddyStoneUrl(int8_t rssiAt0m, const char* url) _url = url; } -bool EddyStoneUrl::setUrl(const char* url) +void EddyStoneUrl::setUrl(const char* url) { _url = url; } diff --git a/libraries/Bluefruit52Lib/src/services/EddyStone.h b/libraries/Bluefruit52Lib/src/services/EddyStone.h index 4dc45853..eb752239 100644 --- a/libraries/Bluefruit52Lib/src/services/EddyStone.h +++ b/libraries/Bluefruit52Lib/src/services/EddyStone.h @@ -59,7 +59,7 @@ class EddyStoneUrl EddyStoneUrl(void); EddyStoneUrl(int8_t rssiAt0m, const char* url = NULL); - bool setUrl(const char* url); + void setUrl(const char* url); void setRssi(int8_t rssiAt0m); bool start(void); From 3d923e95b0f3551839fe12c3c7c8b5eca526b0ea Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Sun, 10 Mar 2019 20:31:37 -0400 Subject: [PATCH 05/15] Fix return in attachInterrupt --- cores/nRF5/WInterrupts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/nRF5/WInterrupts.c b/cores/nRF5/WInterrupts.c index f208176f..86331a2f 100644 --- a/cores/nRF5/WInterrupts.c +++ b/cores/nRF5/WInterrupts.c @@ -86,7 +86,7 @@ int attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode) break; default: - return; + return 0; } for (int ch = 0; ch < NUMBER_OF_GPIO_TE; ch++) { From 8238a84607348080923ca5c61b2dbe750ccbacdd Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Sun, 10 Mar 2019 20:34:50 -0400 Subject: [PATCH 06/15] Fix _write return value in main.cpp --- cores/nRF5/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cores/nRF5/main.cpp b/cores/nRF5/main.cpp index 4f0918db..459a20de 100644 --- a/cores/nRF5/main.cpp +++ b/cores/nRF5/main.cpp @@ -114,8 +114,9 @@ int _write (int fd, const void *buf, size_t count) if ( Serial ) { - Serial.write( (const uint8_t *) buf, count); + return Serial.write( (const uint8_t *) buf, count); } + return 0; } } From affe39167754245dff4f427a4aed8961d8a5dcfb Mon Sep 17 00:00:00 2001 From: Jeremy Poulter Date: Fri, 8 Mar 2019 22:49:01 +0000 Subject: [PATCH 07/15] Unmount the FS befor formating --- libraries/FileSystem/src/InternalFS.cpp | 9 ++++++++- libraries/FileSystem/src/InternalFS.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/FileSystem/src/InternalFS.cpp b/libraries/FileSystem/src/InternalFS.cpp index 0bf356c9..e580569b 100644 --- a/libraries/FileSystem/src/InternalFS.cpp +++ b/libraries/FileSystem/src/InternalFS.cpp @@ -193,6 +193,7 @@ LittleFS::LittleFS (void) _lfs_cfg.lookahead = 128; _begun = false; + _mounted = false; } LittleFS::~LittleFS () @@ -212,6 +213,8 @@ bool LittleFS::begin (void) { LOG_LV1("IFLASH", "Format internal file system"); this->format(false); + } else { + _mounted = true; } return true; @@ -226,10 +229,14 @@ bool LittleFS::format (bool eraseall) flash_nrf5x_erase(addr); } } - + if(_mounted) { + VERIFY_LFS(lfs_unmount(&_lfs), false); + } VERIFY_LFS(lfs_format(&_lfs, &_lfs_cfg), false); VERIFY_LFS(lfs_mount(&_lfs, &_lfs_cfg), false); + _mounted = true; + return true; } diff --git a/libraries/FileSystem/src/InternalFS.h b/libraries/FileSystem/src/InternalFS.h index 153bb423..248bd9e8 100644 --- a/libraries/FileSystem/src/InternalFS.h +++ b/libraries/FileSystem/src/InternalFS.h @@ -74,6 +74,7 @@ class LittleFS: public BluefruitFS::FileSystemClass struct lfs_config _lfs_cfg; lfs_t _lfs; bool _begun; + bool _mounted; BluefruitFS::File _open_file (char const *filepath, uint8_t mode); BluefruitFS::File _open_dir (char const *filepath); From 82cd7e87f056df8abb7e6414fcc1c4fe59f44196 Mon Sep 17 00:00:00 2001 From: Jeremy Poulter Date: Fri, 23 Nov 2018 22:54:17 +0000 Subject: [PATCH 08/15] Allow the task stack sizes to be configured --- cores/nRF5/utility/AdaCallback.h | 9 +++++++++ libraries/Bluefruit52Lib/src/bluefruit.cpp | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cores/nRF5/utility/AdaCallback.h b/cores/nRF5/utility/AdaCallback.h index 0e61210a..1a197ec4 100644 --- a/cores/nRF5/utility/AdaCallback.h +++ b/cores/nRF5/utility/AdaCallback.h @@ -38,9 +38,18 @@ #include "common_inc.h" +#ifndef CFG_CALLBACK_TASK_STACKSIZE #define CFG_CALLBACK_TASK_STACKSIZE (512*2) +#endif + +#ifndef CFG_CALLBACK_QUEUE_LENGTH #define CFG_CALLBACK_QUEUE_LENGTH 20 +#endif + +#ifndef CFG_CALLBACK_TIMEOUT #define CFG_CALLBACK_TIMEOUT 100 +#endif + #ifdef __cplusplus extern "C"{ diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index 7e7848e7..a13dc8c4 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -42,11 +42,23 @@ #include "usb/usb.h" #endif +#ifndef CFG_BLE_TX_POWER_LEVEL #define CFG_BLE_TX_POWER_LEVEL 0 -#define CFG_DEFAULT_NAME "Bluefruit52" +#endif +#ifndef CFG_DEFAULT_NAME +#define CFG_DEFAULT_NAME "Bluefruit52" +#endif + + +#ifndef CFG_BLE_TASK_STACKSIZE #define CFG_BLE_TASK_STACKSIZE (512*3) +#endif + +#ifndef CFG_SOC_TASK_STACKSIZE #define CFG_SOC_TASK_STACKSIZE (200) +#endif + AdafruitBluefruit Bluefruit; From 03b500d078cef31a6baf085ea0291a54dc92a8fc Mon Sep 17 00:00:00 2001 From: Jeremy Poulter Date: Wed, 13 Mar 2019 21:37:58 +0000 Subject: [PATCH 09/15] Restructured so the class can be extended to add support for external flash chips. --- libraries/FileSystem/src/InternalFS.cpp | 167 ++++++++++++++---------- libraries/FileSystem/src/InternalFS.h | 21 ++- 2 files changed, 118 insertions(+), 70 deletions(-) diff --git a/libraries/FileSystem/src/InternalFS.cpp b/libraries/FileSystem/src/InternalFS.cpp index e580569b..5064f787 100644 --- a/libraries/FileSystem/src/InternalFS.cpp +++ b/libraries/FileSystem/src/InternalFS.cpp @@ -118,79 +118,30 @@ static inline uint32_t lba2addr(uint32_t block) return ((uint32_t) LFS_FLASH_ADDR) + block * LFS_BLOCK_SIZE; } -static int _iflash_read (const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size) -{ - (void) c; - - uint32_t addr = lba2addr(block) + off; - flash_nrf5x_read(buffer, addr, size); - - return 0; -} - -// Program a region in a block. The block must have previously -// been erased. Negative error codes are propogated to the user. -// May return LFS_ERR_CORRUPT if the block should be considered bad. -static int _iflash_prog (const struct lfs_config *c, lfs_block_t block, lfs_off_t off, const void *buffer, - lfs_size_t size) -{ - (void) c; - - uint32_t addr = lba2addr(block) + off; - flash_nrf5x_write(addr, buffer, size); - - return 0; -} - -// Erase a block. A block must be erased before being programmed. -// The state of an erased block is undefined. Negative error codes -// are propogated to the user. -// May return LFS_ERR_CORRUPT if the block should be considered bad. -static int _iflash_erase (const struct lfs_config *c, lfs_block_t block) -{ - (void) c; - - uint32_t addr = lba2addr(block); - - // implement as write 0xff to whole block address - for(int i=0; i context)->_flash_read(block, off, buffer, size); +} + +// Program a region in a block. The block must have previously +// been erased. Negative error codes are propogated to the user. +// May return LFS_ERR_CORRUPT if the block should be considered bad. +int LittleFS::_iflash_prog (const struct lfs_config *c, lfs_block_t block, lfs_off_t off, const void *buffer, + lfs_size_t size) +{ + return ((LittleFS *)c->context)->_flash_prog(block, off, buffer, size); +} + +// Erase a block. A block must be erased before being programmed. +// The state of an erased block is undefined. Negative error codes +// are propogated to the user. +// May return LFS_ERR_CORRUPT if the block should be considered bad. +int LittleFS::_iflash_erase (const struct lfs_config *c, lfs_block_t block) +{ + return ((LittleFS *)c->context)->_flash_erase(block); +} + +// Sync the state of the underlying block device. Negative error codes +// are propogated to the user. +int LittleFS::_iflash_sync (const struct lfs_config *c) +{ + return ((LittleFS *)c->context)->_flash_sync(); +} diff --git a/libraries/FileSystem/src/InternalFS.h b/libraries/FileSystem/src/InternalFS.h index 248bd9e8..03086487 100644 --- a/libraries/FileSystem/src/InternalFS.h +++ b/libraries/FileSystem/src/InternalFS.h @@ -58,6 +58,12 @@ class LittleFS: public BluefruitFS::FileSystemClass bool rmdir_r (char const *filepath); bool format (bool eraseall); + protected: + bool _begun; + bool _mounted; + + LittleFS (lfs_size_t read_size, lfs_size_t prog_size, lfs_size_t block_size, lfs_size_t block_count, lfs_size_t lookahead); + // Internal API: shouldn't be used by Arduino sketch virtual size_t _f_write (void* fhdl, uint8_t const *buf, size_t size); virtual int _f_read (void* fhdl, void *buf, uint16_t nbyte); @@ -67,17 +73,26 @@ class LittleFS: public BluefruitFS::FileSystemClass virtual uint32_t _f_position (void* fhdl); virtual uint32_t _f_size (void* fhdl); + // Raw flash opperations, override to use an external flash chip + virtual int _flash_read (lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size); + virtual int _flash_prog (lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size); + virtual int _flash_erase (lfs_block_t block); + virtual void _flash_erase_all(); + virtual int _flash_sync (); + virtual BluefruitFS::File _f_openNextFile (void* fhdl, char const* cwd, uint8_t mode); virtual void _f_rewindDirectory (void* fhdl); - private: struct lfs_config _lfs_cfg; lfs_t _lfs; - bool _begun; - bool _mounted; BluefruitFS::File _open_file (char const *filepath, uint8_t mode); BluefruitFS::File _open_dir (char const *filepath); + + static int _iflash_read (const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size); + static int _iflash_prog (const struct lfs_config *c, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size); + static int _iflash_erase (const struct lfs_config *c, lfs_block_t block); + static int _iflash_sync (const struct lfs_config *c); }; extern LittleFS InternalFS; From c55250e0016405a390aec4ed76e2bbe28f93dfc1 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 18 Mar 2019 01:09:17 +0700 Subject: [PATCH 10/15] fix #242 add ARDUINO_NRF52832_FEATHER for feather nrf52832 --- boards.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards.txt b/boards.txt index 2b8b45a7..a16281ce 100644 --- a/boards.txt +++ b/boards.txt @@ -38,7 +38,7 @@ feather52832.build.f_cpu=64000000 feather52832.build.board=NRF52_FEATHER feather52832.build.core=nRF5 feather52832.build.variant=feather_nrf52832 -feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 -DARDUINO_NRF52832_FEATHER # SofDevice Menu # Ram & ROM size varies depending on SoftDevice (check linker script) From 76cbab0b010eef5abed098fd26900f2545e151dc Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 18 Mar 2019 01:11:55 +0700 Subject: [PATCH 11/15] correct #242 --- boards.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/boards.txt b/boards.txt index a16281ce..20aaafc1 100644 --- a/boards.txt +++ b/boards.txt @@ -35,10 +35,10 @@ feather52832.upload.native_usb=false # Build feather52832.build.mcu=cortex-m4 feather52832.build.f_cpu=64000000 -feather52832.build.board=NRF52_FEATHER +feather52832.build.board=NRF52832_FEATHER feather52832.build.core=nRF5 feather52832.build.variant=feather_nrf52832 -feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 -DARDUINO_NRF52832_FEATHER +feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52 -DARDUINO_NRF52_FEATHER # SofDevice Menu # Ram & ROM size varies depending on SoftDevice (check linker script) @@ -98,7 +98,7 @@ feather52840.build.f_cpu=64000000 feather52840.build.board=NRF52840_FEATHER feather52840.build.core=nRF5 feather52840.build.variant=feather_nrf52840_express -feather52840.build.extra_flags=-DNRF52840_XXAA +feather52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_FEATHER # SofDevice Menu # Ram & ROM size varies depending on SoftDevice (check linker script) From 8ef3e452b3b6651af0e9219fcf98eeae8dfb828d Mon Sep 17 00:00:00 2001 From: "Limor \"Ladyada\" Fried" Date: Fri, 22 Mar 2019 12:22:52 -0400 Subject: [PATCH 12/15] Update SoftwareSerialExample.ino --- .../examples/SoftwareSerialExample/SoftwareSerialExample.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino index bf852bf2..4ecbff3f 100644 --- a/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino +++ b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino @@ -9,6 +9,9 @@ * TX is digital pin A1 (connect to RX of other device) This example code is in the public domain. + + Software Serial will not work when Bluetooth Radio is active because the softdevice + interrupts the library. */ From 83c5de04738439f86fc34ae561bc776fc6f37b53 Mon Sep 17 00:00:00 2001 From: "Limor \"Ladyada\" Fried" Date: Fri, 22 Mar 2019 12:23:09 -0400 Subject: [PATCH 13/15] Update TwoPortReceive.ino --- .../SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino index 88c4284a..b1e2ac98 100644 --- a/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino +++ b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino @@ -18,6 +18,9 @@ This example code is in the public domain. + Software Serial will not work when Bluetooth Radio is active because the softdevice + interrupts the library. + */ #include From 3de7530962660f08f80780a3ad5d61ec124fa5ca Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 29 Mar 2019 11:01:57 +0700 Subject: [PATCH 14/15] add while(!Serial) to all examples --- .../Bluefruit52Lib/examples/Hardware/SerialEcho/SerialEcho.ino | 1 + .../digital_interrupt_deferred/digital_interrupt_deferred.ino | 1 + .../BarometricPressureSensor/BarometricPressureSensor.ino | 1 + libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino | 1 + libraries/Wire/examples/master_reader/master_reader.ino | 1 + libraries/Wire/examples/slave_receiver/slave_receiver.ino | 1 + 6 files changed, 6 insertions(+) diff --git a/libraries/Bluefruit52Lib/examples/Hardware/SerialEcho/SerialEcho.ino b/libraries/Bluefruit52Lib/examples/Hardware/SerialEcho/SerialEcho.ino index 0daf7167..df86e0bc 100644 --- a/libraries/Bluefruit52Lib/examples/Hardware/SerialEcho/SerialEcho.ino +++ b/libraries/Bluefruit52Lib/examples/Hardware/SerialEcho/SerialEcho.ino @@ -24,6 +24,7 @@ const int baudrate = 115200; void setup() { Serial.begin (baudrate); + while ( !Serial ) delay(10); // for nrf52840 with native usb Serial.println("Serial Echo demo"); Serial.print("Badurate : "); diff --git a/libraries/Bluefruit52Lib/examples/Hardware/digital_interrupt_deferred/digital_interrupt_deferred.ino b/libraries/Bluefruit52Lib/examples/Hardware/digital_interrupt_deferred/digital_interrupt_deferred.ino index 464e31b7..1e59bdbb 100644 --- a/libraries/Bluefruit52Lib/examples/Hardware/digital_interrupt_deferred/digital_interrupt_deferred.ino +++ b/libraries/Bluefruit52Lib/examples/Hardware/digital_interrupt_deferred/digital_interrupt_deferred.ino @@ -23,6 +23,7 @@ int interruptPin = A0; void setup() { Serial.begin(115200); + while ( !Serial ) delay(10); // for nrf52840 with native usb pinMode(interruptPin, INPUT_PULLUP); diff --git a/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino b/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino index 8104fcbc..31712934 100755 --- a/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino +++ b/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino @@ -39,6 +39,7 @@ const int chipSelectPin = 7; void setup() { Serial.begin(9600); + while ( !Serial ) delay(10); // for nrf52840 with native usb // start the SPI library: SPI.begin(); diff --git a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino index 9c41c18f..f41511c1 100755 --- a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino +++ b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino @@ -16,6 +16,7 @@ void setup() { Wire.begin(); // join i2c bus (address optional for master) Serial.begin(9600); // start serial communication at 9600bps + while ( !Serial ) delay(10); // for nrf52840 with native usb } int reading = 0; diff --git a/libraries/Wire/examples/master_reader/master_reader.ino b/libraries/Wire/examples/master_reader/master_reader.ino index 4124d7d6..ee59610e 100755 --- a/libraries/Wire/examples/master_reader/master_reader.ino +++ b/libraries/Wire/examples/master_reader/master_reader.ino @@ -16,6 +16,7 @@ void setup() { Wire.begin(); // join i2c bus (address optional for master) Serial.begin(9600); // start serial for output + while ( !Serial ) delay(10); // for nrf52840 with native usb } void loop() diff --git a/libraries/Wire/examples/slave_receiver/slave_receiver.ino b/libraries/Wire/examples/slave_receiver/slave_receiver.ino index 60dd4bdd..c0c26286 100755 --- a/libraries/Wire/examples/slave_receiver/slave_receiver.ino +++ b/libraries/Wire/examples/slave_receiver/slave_receiver.ino @@ -17,6 +17,7 @@ void setup() Wire.begin(4); // join i2c bus with address #4 Wire.onReceive(receiveEvent); // register event Serial.begin(9600); // start serial for output + while ( !Serial ) delay(10); // for nrf52840 with native usb } void loop() From 69f180283957f870f29701098a2450c0f7e76a09 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 29 Mar 2019 13:20:06 +0700 Subject: [PATCH 15/15] add bledis to hid_keyscan exmaple windows insist to have bledis to work with --- .../examples/Peripheral/hid_keyscan/hid_keyscan.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/hid_keyscan/hid_keyscan.ino b/libraries/Bluefruit52Lib/examples/Peripheral/hid_keyscan/hid_keyscan.ino index 719b876e..c35998f1 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/hid_keyscan/hid_keyscan.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/hid_keyscan/hid_keyscan.ino @@ -19,6 +19,7 @@ #include +BLEDis bledis; BLEHidAdafruit blehid; // Array of pins and its keycode @@ -56,6 +57,11 @@ void setup() Bluefruit.setTxPower(4); Bluefruit.setName("Bluefruit52"); + // Configure and Start Device Information Service + bledis.setManufacturer("Adafruit Industries"); + bledis.setModel("Bluefruit Feather 52"); + bledis.begin(); + // set up pin as input for (uint8_t i=0; i