summaryrefslogtreecommitdiff
path: root/ESP32_BLE_Arduino/src/FreeRTOS.h
blob: 320f4cc61407384beea08bc82b7a5e043491ec98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * FreeRTOS.h
 *
 *  Created on: Feb 24, 2017
 *      Author: kolban
 */
 
#ifndef MAIN_FREERTOS_H_
#define MAIN_FREERTOS_H_
#include <stdint.h>
#include <string>
 
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/semphr.h>
 
 
/**
 * @brief Interface to %FreeRTOS functions.
 */
class FreeRTOS {
public:
static void sleep(uint32_t ms);
static void startTask(void task(void *), std::string taskName, void *param=nullptr, int stackSize = 2048);
static void deleteTask(TaskHandle_t pTask = nullptr);
 
static uint32_t getTimeSinceStart();
 
class Semaphore {
public:
Semaphore(std::string owner = "<Unknown>");
~Semaphore();
void give();
void giveFromISR();
void give(uint32_t value);
void setName(std::string name);
void take(std::string owner="<Unknown>");
void take(uint32_t timeoutMs, std::string owner="<Unknown>");
uint32_t wait(std::string owner="<Unknown>");
std::string toString();
private:
SemaphoreHandle_t m_semaphore;
std::string m_name;
std::string m_owner;
uint32_t    m_value;
};
};
 
#endif /* MAIN_FREERTOS_H_ */