Merge branch 'master' into develop and rename linker file

This commit is contained in:
hathach committed 2018-08-07 16:20:19 +07:00
commit 6ea7e84a0a
12 files changed
+202 -63

No files matched your search

@@ -0,0 +1,47 @@
/*********************************************************************
This is an example for our nRF52 based Bluefruit LE modules
Pick one up today in the adafruit shop!
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 <Arduino.h>
// Note: Extern "C" is required since all the IRQ hardware handler is
// declared as "C function" within the startup (assembly) file.
// Without it, our SysTick_Handler will be declared as "C++ function"
// which is not the same as the "C function" in startup even it has
// the same name.
extern "C"
{
/* This is hardware interupt service function exectuing in non-RTOS thread
* Function implementation should be quick and short if possible.
*
* WARNING: This function MUST NOT call any blocking FreeRTOS API
* such as delay(), xSemaphoreTake() etc ... for more information
* http://www.freertos.org/a00016.html
*/
void SysTick_Handler(void)
{
ledToggle(LED_RED);
}
} // extern C
void setup()
{
// Set up systick to fire 10 times per second
SysTick_Config(F_CPU/10);
}
void loop()
{
// do nothing here
}
@@ -0,0 +1,58 @@
/*********************************************************************
This is an example for our nRF52 based Bluefruit LE modules
Pick one up today in the adafruit shop!
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 <Arduino.h>
/* SoftwareTimer is a helper class that uses FreeRTOS software timer
* to invoke callback. Its periodic timing is flexible as opposed to
* hardware timer and cannot be faster than rtos's tick which is configured
* at ~1 ms interval.
*
* If you need an strict interval timing, or faster frequency, check out
* the hw_systick sketch example that use hardware systick timer.
*
* http://www.freertos.org/RTOS-software-timer.html
*/
SoftwareTimer blinkTimer;
void setup()
{
// Configure the timer with 1000 ms interval, with our callback
blinkTimer.begin(1000, blink_timer_callback);
// Start the timer
blinkTimer.start();
}
void loop()
{
// do nothing here
}
/**
* Software Timer callback is invoked via a built-in FreeRTOS thread with
* minimal stack size. Therefore it should be as simple as possible. If
* a periodically heavy task is needed, please use Scheduler.startLoop() to
* create a dedicated task for it.
*
* More information http://www.freertos.org/RTOS-software-timer.html
*/
void blink_timer_callback(TimerHandle_t xTimerID)
{
// freeRTOS timer ID, ignored if not used
(void) xTimerID;
digitalToggle(LED_RED);
}
@@ -52,6 +52,9 @@ void setup()
*/
blehid.begin();
// Set callback for set LED from central
blehid.setKeyboardLedCallback(set_keyboard_led);
/* Set connection interval (min, max) to your perferred value.
* Note: It is already set by BLEHidAdafruit::begin() to 11.25ms - 15ms
* min = 9*1.25=11.25 ms, max = 12*1.25= 15 ms
@@ -122,22 +125,21 @@ void loop()
}
/**
* RTOS Idle callback is automatically invoked by FreeRTOS
* when there are no active threads. E.g when loop() calls delay() and
* there is no bluetooth or hw event. This is the ideal place to handle
* background data.
*
* NOTE: FreeRTOS is configured as tickless idle mode. After this callback
* is executed, if there is time, freeRTOS kernel will go into low power mode.
* Therefore waitForEvent() should not be called in this callback.
* http://www.freertos.org/low-power-tickless-rtos.html
*
* WARNING: This function MUST NOT call any blocking FreeRTOS API
* such as delay(), xSemaphoreTake() etc ... for more information
* http://www.freertos.org/a00016.html
* Callback invoked when received Set LED from central.
* Must be set previously with setKeyboardLedCallback()
*
* The LED bit map is as follows: (also defined by KEYBOARD_LED_* )
* Kana (4) | Compose (3) | ScrollLock (2) | CapsLock (1) | Numlock (0)
*/
void rtos_idle_callback(void)
void set_keyboard_led(uint8_t led_bitmap)
{
// Don't call any other FreeRTOS blocking API()
// Perform background task(s) here
// light up Red Led if any bits is set
if ( led_bitmap )
{
ledOn( LED_RED );
}
else
{
ledOff( LED_RED );
}
}
@@ -73,6 +73,9 @@ void setup()
*/
blehid.begin();
// Set callback for set LED from central
blehid.setKeyboardLedCallback(set_keyboard_led);
/* Set connection interval (min, max) to your perferred value.
* Note: It is already set by BLEHidAdafruit::begin() to 11.25ms - 15ms
* min = 9*1.25=11.25 ms, max = 12*1.25= 15 ms
@@ -168,3 +171,23 @@ void loop()
// Poll interval
delay(10);
}
/**
* Callback invoked when received Set LED from central.
* Must be set previously with setKeyboardLedCallback()
*
* The LED bit map is as follows: (also defined by KEYBOARD_LED_* )
* Kana (4) | Compose (3) | ScrollLock (2) | CapsLock (1) | Numlock (0)
*/
void set_keyboard_led(uint8_t led_bitmap)
{
// light up Red Led if any bits is set
if ( led_bitmap )
{
ledOn( LED_RED );
}
else
{
ledOff( LED_RED );
}
}