Skip to content

Commit 624b8ec

Browse files
committed
Add FreeRTOS example.
1 parent ae4bd01 commit 624b8ec

File tree

6 files changed

+65
-1
lines changed

6 files changed

+65
-1
lines changed

cores/nRF5/rtos.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
#define NABLERTOS_H
2121

2222
#include <stdint.h>
23+
#include "freertos/FreeRTOS.h"
24+
#include "freertos/task.h"
25+
#include "freertos/timers.h"
26+
#include "freertos/queue.h"
27+
#include "freertos/semphr.h"
2328

2429
class nableRtos {
2530
public:

cores/nRF5/wiring_digital.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ extern void digitalWrite( uint32_t dwPin, uint32_t dwVal ) ;
6464
*/
6565
extern int digitalRead( uint32_t ulPin ) ;
6666

67-
void ledOff(uint32_t pin);
67+
extern void ledOff(uint32_t pin);
68+
69+
extern void digitalToggle( uint32_t ulPin );
6870

6971
#ifdef __cplusplus
7072
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* FreeRTOS task demo
3+
* Shows how to blink an LED in it's own task.
4+
*
5+
* Note the use of the build_opt.h file to reduce the stack size of the main task.
6+
* Since the loop is empty the main task stack does not need as much stack space.
7+
*/
8+
9+
#ifndef LED_BUILTIN
10+
#define LED_BUILTIN 9
11+
#endif
12+
13+
void BlinkTask( void *pvParameters );
14+
15+
void setup() {
16+
Serial.begin(115200);
17+
18+
xTaskCreate(
19+
BlinkTask, // The task function to run
20+
"blnk", // name of the task
21+
128, // Size of the task stack in words (32 bit)
22+
NULL, // Pointer to data to pass to the task function or NULL.
23+
2, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
24+
NULL); // Pointer to a TaskHandle_t variable to store the task handle, or NULL.
25+
26+
// The task is started immediately by the call to xTaskCreate.
27+
}
28+
29+
void loop() {
30+
// Empty, we are using our own task.
31+
}
32+
33+
// This is our blink task.
34+
void BlinkTask(void *pvParameters) {
35+
(void) pvParameters;
36+
37+
// initialize digital LED_BUILTIN as an output.
38+
pinMode(LED_BUILTIN, OUTPUT);
39+
40+
for (;;) { // A Task shall never return or exit.
41+
digitalToggle(LED_BUILTIN);
42+
Serial.printf("Free heap: %u\n", RTOS.getFreeHeap());
43+
delay(500);
44+
}
45+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
'-DCONFIG_MAIN_TASK_STACK_SIZE=256'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=n-able
2+
version=1.0.0
3+
author=h2zero
4+
maintainer=h2zero <[email protected]>
5+
sentence=n-able examples
6+
paragraph=
7+
category=Other
8+
url=
9+
architectures=arm-ble

libraries/n-able/src/dummy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file is here only to silence warnings from Arduino IDE
2+
// Currently IDE doesn't support no-code libraries, like this collection of example sketches.

0 commit comments

Comments
 (0)