RTduino Source Code Reference Manual
RTduino.h
Go to the documentation of this file.
1 
31 #ifndef __RTDUINO_CORE__
32 #define __RTDUINO_CORE__
33 
34 #include "Arduino.h"
35 
36 #ifndef RTDUINO_THREAD_SIZE
37 #define RTDUINO_THREAD_SIZE 2048
38 #endif /* RTDUINO_THREAD_SIZE */
39 
40 #ifndef RTDUINO_THREAD_PRIO
41 #define RTDUINO_THREAD_PRIO (RT_THREAD_PRIORITY_MAX - 2)
42 #endif /* RTDUINO_THREAD_PRIO */
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
57 typedef struct
58 {
59  const char* name;
60  void (*setup)(void);
61  void (*loop)(void);
62  rt_thread_t thread;
64 
73 
86  void (*setup)(void), void (*loop)(void), rt_uint32_t stack_size, rt_uint8_t priority);
87 
98  void (*setup)(void), void (*loop)(void))
99 {
100  return rtduino_sketch_loader_create_stacksize_prio(name, setup, loop, RTDUINO_THREAD_SIZE, RTDUINO_THREAD_PRIO);
101 }
102 
114  void (*setup)(void), void (*loop)(void), rt_uint8_t priority)
115 {
116  return rtduino_sketch_loader_create_stacksize_prio(name, setup, loop, RTDUINO_THREAD_SIZE, priority);
117 }
118 
130  void (*setup)(void), void (*loop)(void), rt_uint32_t stack_size)
131 {
132  return rtduino_sketch_loader_create_stacksize_prio(name, setup, loop, stack_size, RTDUINO_THREAD_PRIO);
133 }
134 
146 #define RTDUINO_SKETCH_LOADER_STACKSIZE_PRIO_INITLEVEL(name, setup, loop, stack_size, priority, init_level) \
147  static int _sketch_loader(void) \
148  { \
149  rtduino_sketch_loader_create_stacksize_prio(name, setup, loop, stack_size, priority);\
150  return 0; \
151  } \
152  init_level(_sketch_loader)
153 
164 #define RTDUINO_SKETCH_LOADER_STACKSIZE_PRIO(name, setup, loop, stack_size, priority) \
165  RTDUINO_SKETCH_LOADER_STACKSIZE_PRIO_INITLEVEL(name, setup, loop, stack_size, priority, INIT_APP_EXPORT)
166 
175 #define RTDUINO_SKETCH_LOADER(name, setup, loop) \
176  RTDUINO_SKETCH_LOADER_STACKSIZE_PRIO(name, setup, loop, RTDUINO_THREAD_SIZE, RTDUINO_THREAD_PRIO)
177 
187 #define RTDUINO_SKETCH_LOADER_PRIO(name, setup, loop, priority) \
188  RTDUINO_SKETCH_LOADER_STACKSIZE_PRIO(name, setup, loop, RTDUINO_THREAD_SIZE, priority)
189 
199 #define RTDUINO_SKETCH_LOADER_STACKSIZE(name, setup, loop, stack_size) \
200  RTDUINO_SKETCH_LOADER_STACKSIZE_PRIO(name, setup, loop, stack_size, RTDUINO_THREAD_PRIO)
201 
202 #ifdef __cplusplus
203 } /* extern "C" { */
204 #endif
205 
206 #endif /* __RTDUINO_CORE__ */
Arduino Core Header File.
rt_inline rtduino_loader_t rtduino_sketch_loader_create_prio(const char *name, void(*setup)(void), void(*loop)(void), rt_uint8_t priority)
Creates an RTduino loader with specified priority.
Definition: RTduino.h:113
rtduino_loader_t rtduino_sketch_loader_create_stacksize_prio(const char *name, void(*setup)(void), void(*loop)(void), rt_uint32_t stack_size, rt_uint8_t priority)
Creates an RTduino loader with specified stack size and priority.
Definition: RTduino.cpp:42
rt_err_t rtduino_sketch_loader_delete(rtduino_loader_t loader)
Deletes an RTduino loader.
Definition: RTduino.cpp:79
rt_inline rtduino_loader_t rtduino_sketch_loader_create_stacksize(const char *name, void(*setup)(void), void(*loop)(void), rt_uint32_t stack_size)
Creates an RTduino loader with specified stack size.
Definition: RTduino.h:129
rt_inline rtduino_loader_t rtduino_sketch_loader_create(const char *name, void(*setup)(void), void(*loop)(void))
Creates an RTduino loader with default stack size and priority.
Definition: RTduino.h:97
void loop(void)
Main loop function for the Arduino program.
void setup(void)
Initialization function for the Arduino environment.
RTduino loader.
Definition: RTduino.h:58
rt_thread_t thread
Definition: RTduino.h:62
const char * name
Definition: RTduino.h:59