diff --git a/cores/nRF5/Arduino.h b/cores/nRF5/Arduino.h index c2fef7d2..66350e72 100644 --- a/cores/nRF5/Arduino.h +++ b/cores/nRF5/Arduino.h @@ -69,11 +69,7 @@ void setLoopStacksize(uint32_t size); #include "WInterrupts.h" // RTOS -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" -#include "queue.h" -#include "semphr.h" +#include "rtos.h" enum { diff --git a/cores/nRF5/freertos/source/include/projdefs.h b/cores/nRF5/freertos/source/include/projdefs.h index e4bcf6af..ed21aa72 100644 --- a/cores/nRF5/freertos/source/include/projdefs.h +++ b/cores/nRF5/freertos/source/include/projdefs.h @@ -77,10 +77,14 @@ typedef void (*TaskFunction_t)( void * ); /* Converts a time in milliseconds to a time in ticks. */ -#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) - -#define ms2tick(ms) pdMS_TO_TICKS(ms) +#if configTICK_RATE_HZ == 1000 +#define ms2tick(ms) ms +#define tick2ms(tck) tck +#else +#define ms2tick( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) #define tick2ms(tck) ( ((tck) * 1000) / configTICK_RATE_HZ ) +#endif + #define pdFALSE ( ( BaseType_t ) 0 ) #define pdTRUE ( ( BaseType_t ) 1 ) diff --git a/cores/nRF5/rtos.h b/cores/nRF5/rtos.h new file mode 100644 index 00000000..e96fec04 --- /dev/null +++ b/cores/nRF5/rtos.h @@ -0,0 +1,54 @@ +/**************************************************************************/ +/*! + @file rtos.h + @author hathach + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2017, 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 RTOS_H_ +#define RTOS_H_ + +#include +#include +#include +#include +#include + +#include "FreeRTOS.h" +#include "task.h" +#include "timers.h" +#include "queue.h" +#include "semphr.h" + +#define rtos_delay(ms) vTaskDelay(ms2tick(ms)) + + +#endif /* RTOS_H_ */ diff --git a/libraries/Bluefruit52Lib/examples/bleuart/bleuart.ino b/libraries/Bluefruit52Lib/examples/bleuart/bleuart.ino index e5694216..2f56a823 100644 --- a/libraries/Bluefruit52Lib/examples/bleuart/bleuart.ino +++ b/libraries/Bluefruit52Lib/examples/bleuart/bleuart.ino @@ -1,39 +1,16 @@ -/**************************************************************************/ -/*! - @file bleuart.ino - @author hathach +/********************************************************************* + This is an example for our nRF52 based Bluefruit LE modules - @section LICENSE + Pick one up today in the adafruit shop! - Software License Agreement (BSD License) - - Copyright (c) 2016, 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. -*/ -/**************************************************************************/ + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + MIT license, check LICENSE for more information + All text above, and the splash screen below must be included in + any redistribution +*********************************************************************/ #include BLEDis bledis; diff --git a/libraries/Bluefruit52Lib/examples/blinky_ota/blinky_ota.ino b/libraries/Bluefruit52Lib/examples/blinky_ota/blinky_ota.ino index 1f761737..0b3c5640 100644 --- a/libraries/Bluefruit52Lib/examples/blinky_ota/blinky_ota.ino +++ b/libraries/Bluefruit52Lib/examples/blinky_ota/blinky_ota.ino @@ -1,52 +1,28 @@ -/**************************************************************************/ -/*! - @file bleuart.ino - @author hathach +/********************************************************************* + This is an example for our nRF52 based Bluefruit LE modules - @section LICENSE + Pick one up today in the adafruit shop! - Software License Agreement (BSD License) + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! - Copyright (c) 2016, 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. -*/ -/**************************************************************************/ + MIT license, check LICENSE for more information + All text above, and the splash screen below must be included in + any redistribution +*********************************************************************/ #include -uint32_t ms = 0; - void setup() { pinMode(LED_BUILTIN, OUTPUT); Serial.begin(115200); - Serial.println("Blinky Example"); + Serial.println("Bluefruit52 Blinky Example"); Bluefruit.begin(); - Bluefruit.setName("Blinky"); + Bluefruit.setName("Bluefruit52"); // Set up Advertising Packet setupAdv(); @@ -69,14 +45,9 @@ void setupAdv(void) void loop() { // Toggle both LEDs every 1 second - if ( millis() - ms >= 1000 ) - { - static int state = LOW; - digitalWrite(LED_BUILTIN, state); - digitalWrite(LED_CONN, state); + digitalToggle(LED_BUILTIN); + digitalToggle(LED_CONN); - state = 1 - state; - ms += 1000; - } + rtos_delay(1000); } diff --git a/libraries/Bluefruit52Lib/src/utility/verify.h b/libraries/Bluefruit52Lib/src/utility/verify.h index 8e9c51ca..864551a3 100644 --- a/libraries/Bluefruit52Lib/src/utility/verify.h +++ b/libraries/Bluefruit52Lib/src/utility/verify.h @@ -60,7 +60,7 @@ extern "C" #define _VERIFY_COUNTER __LINE__ #endif -#define VERIFY_STATIC(const_expr, message) enum { XSTRING_CONCAT_(static_verify_, _VERIFY_COUNTER) = 1/(!!(const_expr)) } +#define VERIFY_STATIC(const_expr) enum { XSTRING_CONCAT_(static_verify_, _VERIFY_COUNTER) = 1/(!!(const_expr)) } //--------------------------------------------------------------------+ // VERIFY Helper