diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index c0da5fb9..b156f207 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -10,23 +10,20 @@ assignees: '' **Describe the bug** A clear and concise description of what the bug is. -**Set up (please complete the following information)** - - Your Board and BSP version - - Your OS (mac/windows/linux) and its version - - Serial debug log (enable IDE's Debug Mode Level to 1 or 2) +**Set up (mandatory)** + - **PC & IDE** : Arduino 1.8.13 on Ubuntu 18.04 / Windows 10/ macOS 10.15 + - **BSP** : 0.20.0 + - **Board** : Feather nRF52840 Express + - **Sketch**: Bluefruit52Lib/examples/Peripheral/bleuart. If it is a custom sketch, please provide a minimal sketch within codeblock **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. +3. See error **Screenshots** If applicable, add screenshots to help explain your problem. -**Additional context** -Add any other context about the problem here. +**Serial Log** +Serial output when IDE's Debug Mode Level to 1 or 2 diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index c4c86a22..c8fdb224 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -47,15 +47,24 @@ jobs: arduino-cli core update-index arduino-cli core update-index --additional-urls $BSP_URL arduino-cli core install adafruit:nrf52 --additional-urls $BSP_URL + # Repalce release BSP with our code BSP_VERSION=`eval ls $HOME/$BSP_PATH` rm -r $HOME/$BSP_PATH/* ln -s $GITHUB_WORKSPACE $HOME/$BSP_PATH/$BSP_VERSION + # Install library dependency - arduino-cli lib install "Adafruit AHRS" "Adafruit APDS9960 Library" "Adafruit BMP280 Library" "Adafruit Circuit Playground" "Adafruit EPD" "Adafruit GFX Library" "Adafruit HX8357 Library" "Adafruit ILI9341" "Adafruit LIS3MDL" "Adafruit LSM6DS" "Adafruit NeoPixel" "Adafruit NeoMatrix" "Adafruit nRFCrypto" "Adafruit Sensor Calibration" "Adafruit SHT31 Library" "Adafruit SSD1306" "Adafruit ST7735 and ST7789 Library" "Firmata" "SdFat - Adafruit Fork" + arduino-cli lib install "Adafruit AHRS" "Adafruit APDS9960 Library" "Adafruit BMP280 Library" "Adafruit Circuit Playground" "Adafruit EPD" "Adafruit GFX Library" "Adafruit HX8357 Library" "Adafruit ILI9341" "Adafruit LIS3MDL" "Adafruit LSM6DS" "Adafruit NeoPixel" "Adafruit NeoMatrix" "Adafruit nRFCrypto" "Adafruit Sensor Calibration" "Adafruit SHT31 Library" "Adafruit SSD1306" "Adafruit ST7735 and ST7789 Library" "SdFat - Adafruit Fork" # TODO update to support MIDI version 5 later on arduino-cli lib install "MIDI Library"@4.3.1 + # TODO use firmata master to prevent build error with gcc v9 (should be remove after 2.5.9 is released) + # https://github.com/firmata/arduino/pull/438 + git clone --depth 1 https://github.com/firmata/arduino.git $HOME/Arduino/libraries/firmata + + # Library summary + arduino-cli lib list + - name: Build examples run: python3 tools/build_all.py ${{ matrix.arduino-platform }} diff --git a/cores/nRF5/TinyUSB/Adafruit_TinyUSB_ArduinoCore b/cores/nRF5/TinyUSB/Adafruit_TinyUSB_ArduinoCore index 07490772..238a5c0b 160000 --- a/cores/nRF5/TinyUSB/Adafruit_TinyUSB_ArduinoCore +++ b/cores/nRF5/TinyUSB/Adafruit_TinyUSB_ArduinoCore @@ -1 +1 @@ -Subproject commit 07490772a559b2b0cac8aa187566aff4bec7376a +Subproject commit 238a5c0b95fcd402d24524c7bebbdd822168a51e diff --git a/cores/nRF5/TinyUSB/Adafruit_TinyUSB_nRF.cpp b/cores/nRF5/TinyUSB/Adafruit_TinyUSB_nRF.cpp index 919e89a8..e4f50237 100644 --- a/cores/nRF5/TinyUSB/Adafruit_TinyUSB_nRF.cpp +++ b/cores/nRF5/TinyUSB/Adafruit_TinyUSB_nRF.cpp @@ -30,6 +30,16 @@ #include "Arduino.h" #include "Adafruit_TinyUSB_Core.h" +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM DECLARATION +//--------------------------------------------------------------------+ + +#define USBD_STACK_SZ (200) + +// tinyusb function that handles power event (detected, ready, removed) +// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. +extern "C" void tusb_hal_nrf_power_event(uint32_t event); + //--------------------------------------------------------------------+ // Forward USB interrupt events to TinyUSB IRQ Handler //--------------------------------------------------------------------+ @@ -42,34 +52,10 @@ extern "C" void USBD_IRQHandler(void) tud_int_handler(0); #if CFG_SYSVIEW - SEGGER_SYSVIEW_RecordExitISR(); + SEGGER_SYSVIEW_RecordExitISR(); #endif } -//--------------------------------------------------------------------+ -// MACRO TYPEDEF CONSTANT ENUM DECLARATION -//--------------------------------------------------------------------+ - -#define USBD_STACK_SZ (200) - -// tinyusb function that handles power event (detected, ready, removed) -// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. -extern "C" void tusb_hal_nrf_power_event(uint32_t event); - -// USB Device Driver task -// This top level thread process all usb events and invoke callbacks -static void usb_device_task(void* param) -{ - (void) param; - - // RTOS forever loop - while (1) - { - // tinyusb device task - tud_task(); - } -} - //--------------------------------------------------------------------+ // Core Init & Touch1200 //--------------------------------------------------------------------+ @@ -99,8 +85,12 @@ static void usb_hardware_init(void) if ( usb_reg & POWER_USBREGSTATUS_OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY); } -void Adafruit_TinyUSB_Core_init(void) +// USB Device Driver task +// This top level thread process all usb events and invoke callbacks +static void usb_device_task(void* param) { + (void) param; + USBDevice.addInterface( (Adafruit_USBD_Interface&) Serial); USBDevice.setID(USB_VID, USB_PID); USBDevice.begin(); @@ -110,6 +100,16 @@ void Adafruit_TinyUSB_Core_init(void) // Init tinyusb stack tusb_init(); + // RTOS forever loop + while (1) + { + // tinyusb device task + tud_task(); + } +} + +void Adafruit_TinyUSB_Core_init(void) +{ // Create a task for tinyusb device stack xTaskCreate( usb_device_task, "usbd", USBD_STACK_SZ, NULL, TASK_PRIO_HIGH, NULL); } diff --git a/cores/nRF5/avr/pgmspace.h b/cores/nRF5/avr/pgmspace.h index 68ff4971..c1fd7910 100644 --- a/cores/nRF5/avr/pgmspace.h +++ b/cores/nRF5/avr/pgmspace.h @@ -102,7 +102,7 @@ typedef const void* uint_farptr_t; #define pgm_read_word(addr) (*(const unsigned short *)(addr)) #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) #define pgm_read_float(addr) (*(const float *)(addr)) -#define pgm_read_ptr(addr) (*(const void *)(addr)) +#define pgm_read_ptr(addr) (*(const void* *)(addr)) #define pgm_read_byte_near(addr) pgm_read_byte(addr) #define pgm_read_word_near(addr) pgm_read_word(addr) diff --git a/cores/nRF5/main.cpp b/cores/nRF5/main.cpp index 1998345e..98e3a291 100644 --- a/cores/nRF5/main.cpp +++ b/cores/nRF5/main.cpp @@ -72,14 +72,14 @@ int main( void ) init(); initVariant(); -#ifdef USE_TINYUSB - Adafruit_TinyUSB_Core_init(); -#endif - #if CFG_SYSVIEW SEGGER_SYSVIEW_Conf(); #endif +#ifdef USE_TINYUSB + Adafruit_TinyUSB_Core_init(); +#endif + // Create a task for loop() xTaskCreate( loop_task, "loop", LOOP_STACK_SZ, NULL, TASK_PRIO_LOW, &_loopHandle); diff --git a/libraries/BLEAdafruitService/src/services/BLEAdafruitSensor.cpp b/libraries/BLEAdafruitService/src/services/BLEAdafruitSensor.cpp index be3b7a86..d4e06df3 100644 --- a/libraries/BLEAdafruitService/src/services/BLEAdafruitSensor.cpp +++ b/libraries/BLEAdafruitService/src/services/BLEAdafruitSensor.cpp @@ -36,7 +36,7 @@ BLEAdafruitSensor::BLEAdafruitSensor(BLEUuid service_uuid, BLEUuid data_uuid) _notify_cb = NULL; } -err_t BLEAdafruitSensor::_begin(int32_t ms) +err_t BLEAdafruitSensor::_begin(int ms) { // Invoke base class begin() VERIFY_STATUS( BLEService::begin() ); @@ -59,19 +59,19 @@ err_t BLEAdafruitSensor::_begin(int32_t ms) return ERROR_NONE; } -err_t BLEAdafruitSensor::begin(measure_callback_t fp, int32_t ms) +err_t BLEAdafruitSensor::begin(measure_callback_t fp, int ms) { _measure_cb = fp; return _begin(ms); } -err_t BLEAdafruitSensor::begin(Adafruit_Sensor* sensor, int32_t ms) +err_t BLEAdafruitSensor::begin(Adafruit_Sensor* sensor, int ms) { _sensor = sensor; return _begin(ms); } -void BLEAdafruitSensor::setPeriod(int32_t period_ms) +void BLEAdafruitSensor::setPeriod(int period_ms) { _period.write32(period_ms); _update_timer(period_ms); diff --git a/libraries/BLEAdafruitService/src/services/BLEAdafruitSensor.h b/libraries/BLEAdafruitService/src/services/BLEAdafruitSensor.h index e7003286..a934508b 100644 --- a/libraries/BLEAdafruitService/src/services/BLEAdafruitSensor.h +++ b/libraries/BLEAdafruitService/src/services/BLEAdafruitSensor.h @@ -30,17 +30,17 @@ class BLEAdafruitSensor : public BLEService { public: - static const int32_t DEFAULT_PERIOD = 1000; + static const int DEFAULT_PERIOD = 1000; typedef void (*notify_callback_t)(uint16_t conn_hdl, bool enabled); typedef uint16_t (*measure_callback_t )(uint8_t* buf, uint16_t bufsize); BLEAdafruitSensor(BLEUuid service_uuid, BLEUuid data_uuid); - virtual err_t begin(measure_callback_t fp, int32_t ms = DEFAULT_PERIOD); - virtual err_t begin(Adafruit_Sensor* sensor, int32_t ms = DEFAULT_PERIOD); + virtual err_t begin(measure_callback_t fp, int ms = DEFAULT_PERIOD); + virtual err_t begin(Adafruit_Sensor* sensor, int ms = DEFAULT_PERIOD); - void setPeriod(int32_t period_ms); + void setPeriod(int period_ms); void setNotifyCallback(notify_callback_t fp); protected: @@ -54,7 +54,7 @@ class BLEAdafruitSensor : public BLEService SoftwareTimer _timer; - err_t _begin(int32_t ms); + err_t _begin(int ms); virtual void _update_timer(int32_t ms); virtual void _measure_handler(void); diff --git a/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp b/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp index a7c0a267..9d902ef0 100644 --- a/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp +++ b/libraries/Bluefruit52Lib/src/BLECharacteristic.cpp @@ -588,11 +588,6 @@ uint16_t BLECharacteristic::write32(int num) return write32( (uint32_t) num ); } -uint16_t BLECharacteristic::write32(int32_t num) -{ - return write32( (uint32_t) num ); -} - /*------------------------------------------------------------------*/ /* READ *------------------------------------------------------------------*/ diff --git a/libraries/Bluefruit52Lib/src/BLECharacteristic.h b/libraries/Bluefruit52Lib/src/BLECharacteristic.h index f17395f9..acd17531 100644 --- a/libraries/Bluefruit52Lib/src/BLECharacteristic.h +++ b/libraries/Bluefruit52Lib/src/BLECharacteristic.h @@ -112,7 +112,6 @@ class BLECharacteristic uint16_t write16 (uint16_t num); uint16_t write32 (uint32_t num); uint16_t write32 (int num); - uint16_t write32 (int32_t num); /*------------- Read -------------*/ uint16_t read (void* buffer, uint16_t bufsize, uint16_t offset = 0); diff --git a/libraries/Bluefruit52Lib/src/BLEClientCharacteristic.cpp b/libraries/Bluefruit52Lib/src/BLEClientCharacteristic.cpp index 68830b85..f0eb7c44 100644 --- a/libraries/Bluefruit52Lib/src/BLEClientCharacteristic.cpp +++ b/libraries/Bluefruit52Lib/src/BLEClientCharacteristic.cpp @@ -153,7 +153,7 @@ bool BLEClientCharacteristic::_discoverDescriptor(uint16_t conn_handle, ble_gatt if ( disc_rsp.descs[i].uuid.type == BLE_UUID_TYPE_BLE && disc_rsp.descs[i].uuid.uuid == BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG ) { - LOG_LV2("DISC", "Found CCDD: handle = %d", disc_rsp.descs[i].handle); + LOG_LV2("DISC", "Found CCCD: handle = %d", disc_rsp.descs[i].handle); _cccd_handle = disc_rsp.descs[i].handle; break; diff --git a/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp b/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp index 84276889..880d7097 100644 --- a/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp +++ b/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp @@ -107,9 +107,10 @@ bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLEClientService& svc, uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic* chr[], uint8_t count) { // We could found more characteristic than we looking for. Buffer must be large enough - enum { MAX_DISC_CHARS = 4 }; + enum { MAX_DISC_CHARS = 8 }; - uint16_t bufsize = sizeof(ble_gattc_evt_char_disc_rsp_t) + (MAX_DISC_CHARS-1)*sizeof(ble_gattc_char_t); + // -1 because the first ble_gattc_char_t is built in to ble_gattc_evt_char_disc_rsp_t + uint16_t bufsize = sizeof(ble_gattc_evt_char_disc_rsp_t) + (MAX_DISC_CHARS-1)*sizeof(ble_gattc_char_t); ble_gattc_evt_char_disc_rsp_t* disc_chr = (ble_gattc_evt_char_disc_rsp_t*) rtos_malloc( bufsize ); uint8_t found = 0; @@ -129,6 +130,9 @@ uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLEClientChar // timeout or has no data (due to GATT Error) if ( bytecount <= 0 ) break; + // if we truncated the response, adjust the count to match + if ( disc_chr->count > MAX_DISC_CHARS ) disc_chr->count = MAX_DISC_CHARS; + // Look for matched uuid in the discovered list for(uint8_t d=0 ; dcount; d++) { diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index 63e38d19..97651ad1 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -164,6 +164,9 @@ AdafruitBluefruit::AdafruitBluefruit(void) _ble_event_sem = NULL; _soc_event_sem = NULL; +#ifdef ANT_LICENSE_KEY + _mprot_event_sem = NULL; //additiona semaphore for multiprotocol +#endif _led_blink_th = NULL; _led_conn = true; @@ -298,7 +301,15 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count) #error Clock Source is not configured, define USE_LFXO or USE_LFRC according to your board in variant.h #endif + /*------------------------------------------------------------------ + ** BLE only Softdevices have 2-args sd_softdevice_enable() + ** BLE & ANT+ Softdevices have 3-args sd_softdevice_enable() + */ + #ifdef ANT_LICENSE_KEY + VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, nrf_error_cb, ANT_LICENSE_KEY), false ); +#else //#ifdef ANT_LICENSE_KEY VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, nrf_error_cb), false ); +#endif //#ifdef ANT_LICENSE_KEY #ifdef USE_TINYUSB usb_softdevice_post_enable(); @@ -642,6 +653,10 @@ extern "C" void SD_EVT_IRQHandler(void) // Notify both BLE & SOC Task xSemaphoreGiveFromISR(Bluefruit._soc_event_sem, NULL); xSemaphoreGiveFromISR(Bluefruit._ble_event_sem, NULL); +#ifdef ANT_LICENSE_KEY + // Notify parallel multiprotocol Task, if any + if (Bluefruit._mprot_event_sem) xSemaphoreGiveFromISR(Bluefruit._mprot_event_sem, NULL); +#endif } /** diff --git a/libraries/Bluefruit52Lib/src/bluefruit.h b/libraries/Bluefruit52Lib/src/bluefruit.h index 147b04fd..6224408c 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.h +++ b/libraries/Bluefruit52Lib/src/bluefruit.h @@ -172,6 +172,17 @@ class AdafruitBluefruit BLEConnection* Connection(uint16_t conn_hdl); +#ifdef ANT_LICENSE_KEY + /*------------------------------------------------------------------* + * Optional semaphore for additional event handlers for SD event. + * It can be used for handling non-BLE SD events + *------------------------------------------------------------------*/ + void setMultiprotocolSemaphore(SemaphoreHandle_t* p_mprot_event_semaphore) + { + _mprot_event_sem= p_mprot_event_semaphore; + } +#endif + /*------------------------------------------------------------------*/ /* Callbacks *------------------------------------------------------------------*/ @@ -214,6 +225,12 @@ class AdafruitBluefruit SemaphoreHandle_t _ble_event_sem; SemaphoreHandle_t _soc_event_sem; +#ifdef ANT_LICENSE_KEY + /* Optional semaphore for additional event handlers for SD event. + * It can be used for handling non-BLE SD events + */ + SemaphoreHandle_t* _mprot_event_sem; +#endif // Auto LED Blinky TimerHandle_t _led_blink_th; diff --git a/platform.txt b/platform.txt index 4c3e70af..fddd0314 100644 --- a/platform.txt +++ b/platform.txt @@ -66,7 +66,7 @@ nordic.path={build.core.path}/nordic # build.logger_flags and build.sysview_flags are intentionally empty, # to allow modification via a user's own boards.local.txt or platform.local.txt files. -build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 -Ofast {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" # usb flags build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' diff --git a/tools/build_all.py b/tools/build_all.py index 37327ba3..0df2166e 100644 --- a/tools/build_all.py +++ b/tools/build_all.py @@ -39,7 +39,7 @@ def build_examples(variant): print(build_separator) print('| {:^79} |'.format('Board ' + variant)) print(build_separator) - print((build_format).format('Library', 'Example', 'Result', 'Time')) + print(build_format.format('Library', 'Example', 'Result', 'Time')) print(build_separator) fqbn = "adafruit:nrf52:{}:softdevice={},debug=l0".format(variant, 's140v6' if variant != 'feather52832' else 's132v6') @@ -85,8 +85,7 @@ def build_examples(variant): success_count += 1 build_duration = time.monotonic() - start_time - - print((build_format).format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, "{:.2f}".format(build_duration))) + print(build_format.format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, '{:5.2f}s'.format(build_duration))) if success != "\033[33mskipped\033[0m ": if build_result.returncode != 0: diff --git a/tools/build_all_travis.py b/tools/build_all_travis.py deleted file mode 100644 index 0b01f55f..00000000 --- a/tools/build_all_travis.py +++ /dev/null @@ -1,149 +0,0 @@ -import os -import glob -import sys -import subprocess -import time - -travis = False -if "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true": - travis = True - -all_warnings = False -if "ALL_WARNINGS" in os.environ and os.environ["ALL_WARNINGS"] == "true": - all_warnings = True - -ENV_VARIABLE_NAME = 'VARIANT' - - -exit_status = 0 -success_count = 0 -fail_count = 0 - -build_format = '| {:20} | {:30} | {:9} ' -build_separator = '-' * 78 - -variants_dict = { - 'feather52840': 'Feather nRF52840 Express', - 'cplaynrf52840': 'Circuit Playground Bluefruit Express', - 'itsybitsy52840': 'ItsyBitsy nRF52840 Express', - 'cluenrf52840': 'Clue nRF52840', - 'feather52832': 'Feather nRF52832' -} - -# STDERR receives output that starts with the following text, none of which should be considered a warning or error... -output_to_ignore = ( - 'Picked up JAVA_TOOL_OPTIONS:', - 'Loading configuration...', - 'Initializing packages...', - 'Preparing boards...', - 'Verifying...', -) - -def errorOutputFilter(line): - if len(line) == 0: - return False - if line.isspace(): # Note: empty string does not match here! - return False - if line.startswith(output_to_ignore): # alternatively, can trim() each line, but that would create lots of short-lived strings... - return False - # TODO: additional items to remove? - return True - - -def build_examples(variant): - global exit_status, success_count, fail_count, build_format, build_separator - - print('\n') - print(build_separator) - print('| {:^74} |'.format(variants_dict[variant])) - print(build_separator) - print((build_format + '| {:6} |').format('Library', 'Example', 'Result', 'Time')) - print(build_separator) - subprocess.run("arduino --board adafruit:nrf52:{}:softdevice={},debug=l0 --save-prefs".format(variant, 's140v6' if variant != 'feather52832' else 's132v6'), shell=True, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - - if all_warnings: - subprocess.run("arduino --pref 'compiler.warning_level=all' --save-prefs", shell=True, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - - for sketch in glob.iglob('libraries/**/*.ino', recursive=True): - start_time = time.monotonic() - - # skip if example contains: ".skip" or ".skip.variant" - # however ".build.variant" file can overwrite ".skip", used to build a specific variant only - sketchdir = os.path.dirname(sketch) - if ( (os.path.exists(sketchdir + '/.skip') or os.path.exists(sketchdir + '/.skip.' + variant)) and - not os.path.exists(sketchdir + '/.build.' + variant)): - success = "skipped" - else: - # TODO - preferably, would have STDERR show up in **both** STDOUT and STDERR. - # preferably, would use Python logging handler to get both distinct outputs and one merged output - # for now, split STDERR when building with all warnings enabled, so can detect warning/error output. - if all_warnings: - build_result = subprocess.run("arduino --verify {}".format(sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - else: - build_result = subprocess.run("arduino --verify {}".format(sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - - # get stderr into a form where len(warningLines) indicates a true warning was output to stderr - warningLines = []; - if all_warnings and build_result.stderr: - tmpWarningLines = build_result.stderr.decode("utf-8").splitlines() - warningLines = list(filter(errorOutputFilter, (tmpWarningLines))) - - if build_result.returncode != 0: - exit_status = build_result.returncode - success = "\033[31mfailed\033[0m " - fail_count += 1 - elif len(warningLines) != 0: - exit_status = -1 - success = "\033[31mwarnings\033[0m " - fail_count += 1 - else: - success = "\033[32msucceeded\033[0m" - success_count += 1 - - build_duration = time.monotonic() - start_time - - if travis: - print('travis_fold:start:build-{}\\r'.format(sketch)) - - print((build_format + '| {:5.2f}s |').format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, build_duration)) - - if success != "skipped": - if build_result.returncode != 0: - print(build_result.stdout.decode("utf-8")) - if (build_result.stderr): - print(build_result.stderr.decode("utf-8")) - if len(warningLines) != 0: - for line in warningLines: - print(line) - - if travis: - print('travis_fold:end:build-{}\\r'.format(sketch)) - - -build_time = time.monotonic() - - -# build only one variant if the environment variable is specified -if (ENV_VARIABLE_NAME in os.environ): - variant = os.environ.get(ENV_VARIABLE_NAME) - # only use the environment variable if the variant exists in the dictionary - if (variant in variants_dict): - build_examples(variant) - else: - print('\033[31INTERNAL ERR\033[0m - invalid variant name "{}"'.format(variant)) - fail_count += 1 - exit_status = -1 - -else: # no environment variable specified, so build all variants - for var in variants_dict: - build_examples(var) - - -print(build_separator) -build_time = time.monotonic() - build_time -print("Build Summary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m and took {:.2f}s".format(success_count, fail_count, build_time)) -print(build_separator) - -sys.exit(exit_status) diff --git a/variants/pca10056/variant.cpp b/variants/pca10056/variant.cpp index bd85e971..1ea45f32 100644 --- a/variants/pca10056/variant.cpp +++ b/variants/pca10056/variant.cpp @@ -39,11 +39,17 @@ const uint32_t g_ADigitalPinMap[] = void initVariant() { - // LED1 & LED2 + // init all 4 onboard LEDs pinMode(PIN_LED1, OUTPUT); ledOff(PIN_LED1); pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2);; + ledOff(PIN_LED2); + + pinMode(PIN_LED3, OUTPUT); + ledOff(PIN_LED3); + + pinMode(PIN_LED4, OUTPUT); + ledOff(PIN_LED4); } diff --git a/variants/pca10056/variant.h b/variants/pca10056/variant.h index e9aa38db..ed0b2c13 100644 --- a/variants/pca10056/variant.h +++ b/variants/pca10056/variant.h @@ -45,6 +45,8 @@ extern "C" // LEDs #define PIN_LED1 (13) #define PIN_LED2 (14) +#define PIN_LED3 (15) +#define PIN_LED4 (16) #define LED_BUILTIN PIN_LED1 #define LED_CONN PIN_LED2