MakerLabs ACM
delay.h
Go to the documentation of this file.
1 /*
2  * Copyright Paul Reimer, 2018
3  *
4  * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 Unported License.
5  * To view a copy of this license, visit
6  * https://creativecommons.org/licenses/by-nc-sa/4.0/
7  * or send a letter to
8  * Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
9  */
10 
11 #pragma once
12 
13 #include <chrono>
14 
15 #include "freertos/FreeRTOS.h"
16 #include "freertos/task.h"
17 
18 auto timeout = [](
19  const auto duration,
20  const TickType_t time_base = portTICK_RATE_MS
21 ) -> TickType_t
22 {
23  return (
24  std::chrono::milliseconds(duration).count()
25  / time_base
26  );
27 };
28 
29 auto delay = [](const auto duration)
30 {
31  vTaskDelay(timeout(duration));
32 };
auto delay
Definition: delay.h:29
auto timeout
Definition: delay.h:18