TaskManagerIO
Loading...
Searching...
No Matches
TaskPlatformDeps.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry)..
3 * This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4 */
5
6
7#ifndef TASKMANAGERIO_PLATFORMDETERMINATION_H
8#define TASKMANAGERIO_PLATFORMDETERMINATION_H
9
14
15class TimerTask;
16
17// always defined, called from task manager very early on before any other code.
18// and also from any circular buffers. It is always safe to re-call this method.
19void tmInitAtomics();
20
21// You can add your own local definitions header file here, this enables you to adjust build flags in environments
22// where there is no easy way to do so with compiler options. Just create an include file "io_local_definitions.h"
23// at the top level of your project source tree. This file will be honoured by all our libraries.
24#if defined __has_include
25# if __has_include ("zio_local_definitions.h")
26# include "zio_local_definitions.h"
27# endif
28#endif // has include "io_local_definitions"
29
30// when not on mbed, we need to load Arduino.h to get the right defines for some boards.
31#if defined(BUILD_FOR_PICO_CMAKE)
32#include <pico/stdlib.h>
33#include <valarray>
34#elif !defined(__MBED__) && !defined(BUILD_FOR_STM32CUBE_CMAKE) && !defined(BUILD_FOR_NATIVE_PLATFORM)
35#include <Arduino.h>
36#endif
37
38#if (defined(__MBED__) || defined(ARDUINO_ARCH_MBED) || defined(TMIOA_FORCE_ARDUINO_MBED)) && !defined(ARDUINO_PICO_REVISION)
39#include "platform/mbedCas.h"
40#elif defined(ESP8266)
41#undef BOARD_SUPPORTS_PROPER_CAS
42#define IOA_USE_ARDUINO
43typedef uint8_t pintype_t;
44#include "platform/wrapAtomic.h"
45#elif defined(ESP32)
46typedef uint8_t pintype_t;
47#define IOA_USE_ARDUINO
48#define BOARD_SUPPORTS_PROPER_CAS
49#include "platform/wrapAtomic.h"
50#elif defined(BUILD_FOR_PICO_CMAKE) || defined(ARDUINO_PICO_REVISION)
51#include "platform/picosdkSupport.h"
52#elif defined(BUILD_FOR_STM32CUBE_CMAKE)
53#include "platform/stmCubeCas.h"
54#elif defined(ARDUINO_ARCH_STM32)
55typedef uint8_t pintype_t;
56#define IOA_USE_ARDUINO
57#define BOARD_SUPPORTS_PROPER_CAS
58#include "platform/wrapAtomic.h"
59#elif defined(BUILD_FOR_NATIVE_PLATFORM)
60#include "platform/nativePlatform.h"
61#else
62#include "platform/arduinoFallback.h"
63#endif // All platform checks
64
65// for all mbed and ESP boards we already enable lambda captures, SAMD is a known extra case that works.
66// we can only enable on larger boards with enough memory to take the extra size of the structures.
67#if defined(TM_ENABLE_CAPTURED_LAMBDAS) && defined(ARDUINO_ARCH_SAMD)
68# define TM_ALLOW_CAPTURED_LAMBDA
69#endif
70
71//
72// Scheduling size. On all boards by default task manager uses 32 bit schedule data to make it more general purpose.
73// Note that even on 8 bit boards, all the math still needs to be 32 bit to deal with times, so there is very little
74// to no performance gain by doing this.
75//
76// If you need the few extra bytes back, and can live with 16 bit schedule values then define TM_FORCE_16BIT_SCHEDULER
77//
78#if defined(TM_FORCE_16BIT_SCHEDULER)
79typedef uint16_t sched_t;
80#else
81typedef uint32_t sched_t;
82#endif // TM_FORCE_16BIT_SCHEDULER
83
84//
85// DEFAULT_TASK_SIZE definition:
86// TaskManagerIO will re-allocate the task array if needed. So there's little need to adjust this for most use cases.
87// For AVR boards: MEGA 2560 has a default size of 10, others have a default size of 6.
88// For all other boards the default size is 16. You can change it by defining DEFAULT_TASK_SIZE yourself.
89//
90#ifndef DEFAULT_TASK_SIZE
91#ifdef __AVR_ATmega2560__
92# define DEFAULT_TASK_SIZE 12
93# define DEFAULT_TASK_BLOCKS 8
94#elif defined(__AVR__)
95# define DEFAULT_TASK_SIZE 6
96# define DEFAULT_TASK_BLOCKS 4
97#else
98# define DEFAULT_TASK_SIZE 16
99# define DEFAULT_TASK_BLOCKS 16
100#endif
101#else
102#ifndef DEFAULT_TASK_BLOCKS
103#define DEFAULT_TASK_BLOCKS 8
104#endif // DEFAULT_TASK_BLOCKS not defined when task size is
105#endif // DEFAULT_TASK_SIZE defined already
106
107//
108// Here we define an attribute needed for interrupt support on ESP8266 and ESP32 boards, any interrupt code that is
109// going to run on these boards should be marked with this attribute.
110//
111#undef ISR_ATTR
112#if defined(ESP8266) || defined(ESP32)
113# define ISR_ATTR IRAM_ATTR
114#else
115# define ISR_ATTR
116#endif
117
118//
119// Here we have one last go at determining if we should enable capture lambdas by checking if the functional include
120// is available, we only do so if we are on GCC > 5
121//
122# if !defined(TM_ALLOW_CAPTURED_LAMBDA) && defined(TM_ENABLE_CAPTURED_LAMBDAS) && __GNUC__ >= 5
123#if __has_include(<functional>)
124# define TM_ALLOW_CAPTURED_LAMBDA
125#endif // _has_include
126#endif // GCC>=5 and !TM_ALLOW_CAPTURED_LAMBDA
127
128#ifndef internal_min
129#define internal_min(a, b) ((a) > (b) ? (b) : (a))
130#endif // internal_min
131
132#ifndef internal_max
133#define internal_max(a, b) ((a) < (b) ? (b) : (a))
134#endif // internal_max
135
136#endif //TASKMANGERIO_PLATFORMDETERMINATION_H
Definition TaskTypes.h:163