Revision f3ac1c96
core/inc/aos_confcheck.h | ||
---|---|---|
29 | 29 |
|
30 | 30 |
#include <aosconf.h> |
31 | 31 |
|
32 |
/* |
|
33 |
* Kernel parameters and options |
|
34 |
*/ |
|
32 |
/******************************************************************************/ |
|
33 |
/* CONSTANTS */ |
|
34 |
/******************************************************************************/ |
|
35 |
|
|
36 |
/******************************************************************************/ |
|
37 |
/* SETTINGS */ |
|
38 |
/******************************************************************************/ |
|
39 |
|
|
40 |
/******************************************************************************/ |
|
41 |
/* CHECKS */ |
|
42 |
/******************************************************************************/ |
|
43 |
|
|
44 |
/* kernel parameters and options */ |
|
35 | 45 |
|
36 | 46 |
#ifndef AMIROOS_CFG_DBG |
37 | 47 |
#error "AMIROOS_CFG_DBG not defined in aosconf.h" |
... | ... | |
49 | 59 |
#error "AMIROOS_CFG_MAIN_LOOP_TIMEOUT not defined in aosconf.h" |
50 | 60 |
#endif |
51 | 61 |
|
52 |
/* |
|
53 |
* SSSP parameters and options |
|
54 |
*/ |
|
62 |
/* SSSP parameters and options */ |
|
55 | 63 |
|
56 | 64 |
#ifndef AMIROOS_CFG_SSSP_ENABLE |
57 | 65 |
#error "AMIROOS_CFG_SSSP_ENABLE not defined in aosconf.h" |
... | ... | |
88 | 96 |
|
89 | 97 |
#endif |
90 | 98 |
|
91 |
/* |
|
92 |
* System shell options |
|
93 |
*/ |
|
99 |
/* system shell options */ |
|
94 | 100 |
|
95 | 101 |
#ifndef AMIROOS_CFG_SHELL_ENABLE |
96 | 102 |
#error "AMIROOS_CFG_SHELL_ENABLE not defined in aosconf.h" |
... | ... | |
122 | 128 |
|
123 | 129 |
#endif /* AMIROOS_CFG_SHELL_ENABLE */ |
124 | 130 |
|
131 |
/******************************************************************************/ |
|
132 |
/* DATA STRUCTURES AND TYPES */ |
|
133 |
/******************************************************************************/ |
|
134 |
|
|
135 |
/******************************************************************************/ |
|
136 |
/* MACROS */ |
|
137 |
/******************************************************************************/ |
|
138 |
|
|
139 |
/******************************************************************************/ |
|
140 |
/* EXTERN DECLARATIONS */ |
|
141 |
/******************************************************************************/ |
|
142 |
|
|
143 |
/******************************************************************************/ |
|
144 |
/* INLINE FUNCTIONS */ |
|
145 |
/******************************************************************************/ |
|
146 |
|
|
125 | 147 |
#endif /* AMIROOS_CONFCHECK_H */ |
126 | 148 |
|
127 | 149 |
/** @} */ |
core/inc/aos_debug.h | ||
---|---|---|
30 | 30 |
#include <aosconf.h> |
31 | 31 |
#include <hal.h> |
32 | 32 |
#include <chprintf.h> |
33 |
/******************************************************************************/ |
|
34 |
/* CONSTANTS */ |
|
35 |
/******************************************************************************/ |
|
36 |
|
|
37 |
/******************************************************************************/ |
|
38 |
/* SETTINGS */ |
|
39 |
/******************************************************************************/ |
|
40 |
|
|
41 |
/******************************************************************************/ |
|
42 |
/* CHECKS */ |
|
43 |
/******************************************************************************/ |
|
44 |
|
|
45 |
/******************************************************************************/ |
|
46 |
/* DATA STRUCTURES AND TYPES */ |
|
47 |
/******************************************************************************/ |
|
48 |
|
|
49 |
/******************************************************************************/ |
|
50 |
/* MACROS */ |
|
51 |
/******************************************************************************/ |
|
33 | 52 |
|
34 | 53 |
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__) |
35 | 54 |
|
36 | 55 |
/** |
56 |
* @brief Printf function for messages only printed in debug builds. |
|
57 |
* |
|
58 |
* @param[in] fmt Formatted string to print. |
|
59 |
*/ |
|
60 |
#define aosDbgPrintf(fmt, ...) aosprintf(fmt, ##__VA_ARGS__) |
|
61 |
|
|
62 |
/** |
|
37 | 63 |
* @brief Function parameters check. |
38 | 64 |
* @details If the condition check fails, the kernel panics and halts. |
39 | 65 |
* |
... | ... | |
63 | 89 |
chDbgAssert(c, r); \ |
64 | 90 |
} |
65 | 91 |
|
66 |
/** |
|
67 |
* @brief Printf function for messages only printed in debug builds. |
|
68 |
* |
|
69 |
* @param[in] fmt Formatted string to print. |
|
70 |
*/ |
|
71 |
#define aosDbgPrintf(fmt, ...) chprintf((BaseSequentialStream*)&aos.iostream, fmt, ##__VA_ARGS__) |
|
72 |
|
|
73 | 92 |
#else /* (AMIROOS_CFG_DBG != true) */ |
74 | 93 |
|
94 |
#define aosDbgPrintf(fmt, ...) { \ |
|
95 |
(void)(fmt); \ |
|
96 |
} |
|
97 |
|
|
75 | 98 |
#define aosDbgCheck(c) { \ |
76 | 99 |
(void)(c); \ |
77 | 100 |
} |
... | ... | |
85 | 108 |
(void)(r); \ |
86 | 109 |
} |
87 | 110 |
|
88 |
#define aosDbgPrintf(fmt, ...) { \ |
|
89 |
(void)(fmt); \ |
|
90 |
} |
|
111 |
#endif /* AMIROOS_CFG_DBG */ |
|
112 |
|
|
113 |
/******************************************************************************/ |
|
114 |
/* EXTERN DECLARATIONS */ |
|
115 |
/******************************************************************************/ |
|
91 | 116 |
|
92 |
#endif |
|
117 |
/******************************************************************************/ |
|
118 |
/* INLINE FUNCTIONS */ |
|
119 |
/******************************************************************************/ |
|
93 | 120 |
|
94 | 121 |
#endif /* AMIROOS_DEBUG_H */ |
95 | 122 |
|
core/inc/aos_iostream.h | ||
---|---|---|
32 | 32 |
#include <stdarg.h> |
33 | 33 |
|
34 | 34 |
|
35 |
/******************************************************************************/ |
|
36 |
/* CONSTANTS */ |
|
37 |
/******************************************************************************/ |
|
35 | 38 |
|
36 | 39 |
/** |
37 | 40 |
* @brief Channel flag to indicate whether the channel is attached to a stream. |
38 | 41 |
*/ |
39 |
#define AOS_IOCHANNEL_ATTACHED (1 << 0)
|
|
42 |
#define AOS_IOCHANNEL_ATTACHED ((aos_iochannelflag_t)(1 << 0))
|
|
40 | 43 |
|
41 | 44 |
/** |
42 | 45 |
* @brief Channel flag to indicate whether the channel is set as input. |
43 | 46 |
*/ |
44 |
#define AOS_IOCHANNEL_INPUT_ENABLE (1 << 1)
|
|
47 |
#define AOS_IOCHANNEL_INPUT_ENABLE ((aos_iochannelflag_t)(1 << 1))
|
|
45 | 48 |
|
46 | 49 |
/** |
47 | 50 |
* @brief Channel flag to indicate whether the channel is set as output. |
48 | 51 |
*/ |
49 |
#define AOS_IOCHANNEL_OUTPUT_ENABLE (1 << 2)
|
|
52 |
#define AOS_IOCHANNEL_OUTPUT_ENABLE ((aos_iochannelflag_t)(1 << 2))
|
|
50 | 53 |
|
51 |
/* |
|
52 |
* forward definitions |
|
53 |
*/ |
|
54 |
typedef struct aos_iochannel AosIOChannel; |
|
55 |
typedef struct aos_ostream AosIOStream; |
|
54 |
/******************************************************************************/ |
|
55 |
/* SETTINGS */ |
|
56 |
/******************************************************************************/ |
|
57 |
|
|
58 |
/******************************************************************************/ |
|
59 |
/* CHECKS */ |
|
60 |
/******************************************************************************/ |
|
61 |
|
|
62 |
/******************************************************************************/ |
|
63 |
/* DATA STRUCTURES AND TYPES */ |
|
64 |
/******************************************************************************/ |
|
65 |
|
|
66 |
typedef uint8_t aos_iochannelflag_t; |
|
56 | 67 |
|
57 | 68 |
/** |
58 |
* @brief AosI=Channel specific methods.
|
|
69 |
* @brief AosIOChannel specific methods.
|
|
59 | 70 |
*/ |
60 | 71 |
#define _aos_iochannel_methods \ |
61 | 72 |
_base_asynchronous_channel_methods |
... | ... | |
67 | 78 |
/* pointer to a BaseAsynchronousChannel object */ \ |
68 | 79 |
BaseAsynchronousChannel* asyncchannel; \ |
69 | 80 |
/* pointer to the next channel in a AosIOStream */ \ |
70 |
AosIOChannel* next; \
|
|
81 |
struct aos_iochannel* next; \
|
|
71 | 82 |
/* flags related to the channel */ \ |
72 |
uint8_t flags;
|
|
83 |
aos_iochannelflag_t flags;
|
|
73 | 84 |
|
74 | 85 |
/** |
75 | 86 |
* @extends BaseAsynchronousChannelVMT |
... | ... | |
86 | 97 |
* @brief I/O Channel class. |
87 | 98 |
* @details This class implements an asynchronous I/O channel. |
88 | 99 |
*/ |
89 |
struct aos_iochannel { |
|
100 |
typedef struct aos_iochannel {
|
|
90 | 101 |
/** @brief Virtual Methods Table. */ |
91 | 102 |
const struct AosIOChannelVMT* vmt; |
92 | 103 |
_aos_iochannel_data |
93 |
}; |
|
104 |
} AosIOChannel;
|
|
94 | 105 |
|
95 | 106 |
/** |
96 | 107 |
* @brief AosIOStream methods. |
... | ... | |
121 | 132 |
* @details This class implements an base sequential stream. |
122 | 133 |
* @todo So far only output but no input is supported. |
123 | 134 |
*/ |
124 |
struct aos_ostream { |
|
135 |
typedef struct aos_ostream {
|
|
125 | 136 |
const struct AosIOStreamVMT* vmt; |
126 | 137 |
_aos_iostream_data |
127 |
}; |
|
138 |
} AosIOStream; |
|
139 |
|
|
140 |
/******************************************************************************/ |
|
141 |
/* MACROS */ |
|
142 |
/******************************************************************************/ |
|
143 |
|
|
144 |
/******************************************************************************/ |
|
145 |
/* EXTERN DECLARATIONS */ |
|
146 |
/******************************************************************************/ |
|
128 | 147 |
|
129 | 148 |
#ifdef __cplusplus |
130 | 149 |
extern "C" { |
... | ... | |
141 | 160 |
} |
142 | 161 |
#endif |
143 | 162 |
|
163 |
/******************************************************************************/ |
|
164 |
/* INLINE FUNCTIONS */ |
|
165 |
/******************************************************************************/ |
|
166 |
|
|
144 | 167 |
#endif /* AMIROOS_IOSTREAM_H */ |
145 | 168 |
|
146 | 169 |
/** @} */ |
core/inc/aos_shell.h | ||
---|---|---|
32 | 32 |
#include <hal.h> |
33 | 33 |
#include <aos_types.h> |
34 | 34 |
#include <aos_debug.h> |
35 |
/******************************************************************************/ |
|
36 |
/* CONSTANTS */ |
|
37 |
/******************************************************************************/ |
|
35 | 38 |
|
36 | 39 |
/** |
37 | 40 |
* @brief Shell event flag that is emitted when the thread starts. |
... | ... | |
98 | 101 |
*/ |
99 | 102 |
#define AOS_SHELLCHANNEL_OUTPUT_ENABLED (1 << 2) |
100 | 103 |
|
101 |
/* |
|
102 |
* forward definitions |
|
103 |
*/ |
|
104 |
typedef struct aos_shellchannel AosShellChannel; |
|
105 |
typedef struct aos_shellstream AosShellStream; |
|
104 |
/******************************************************************************/ |
|
105 |
/* SETTINGS */ |
|
106 |
/******************************************************************************/ |
|
107 |
|
|
108 |
/******************************************************************************/ |
|
109 |
/* CHECKS */ |
|
110 |
/******************************************************************************/ |
|
111 |
|
|
112 |
/******************************************************************************/ |
|
113 |
/* DATA STRUCTURES AND TYPES */ |
|
114 |
/******************************************************************************/ |
|
106 | 115 |
|
107 | 116 |
/** |
108 | 117 |
* @brief AosShellChannel specific methods. |
... | ... | |
119 | 128 |
/* event listener for the associated BaseAsynchronousChannel */ \ |
120 | 129 |
event_listener_t listener; \ |
121 | 130 |
/* pointer to the next chennal in a AosShellStream */ \ |
122 |
AosShellChannel* next; \
|
|
131 |
struct aos_shellchannel* next; \
|
|
123 | 132 |
/* flags related to the channel */ \ |
124 | 133 |
uint8_t flags; |
125 | 134 |
|
... | ... | |
138 | 147 |
* @brief Shell channel class. |
139 | 148 |
* @details This class implements an asynchronous I/O channel. |
140 | 149 |
*/ |
141 |
struct aos_shellchannel { |
|
150 |
typedef struct aos_shellchannel {
|
|
142 | 151 |
/** @brief Virtual Methods Table. */ |
143 | 152 |
const struct AosShellChannelVMT* vmt; |
144 | 153 |
_aos_shell_channel_data |
145 |
}; |
|
154 |
} AosShellChannel;
|
|
146 | 155 |
|
147 | 156 |
/** |
148 | 157 |
* @brief AosShellStream methods. |
... | ... | |
173 | 182 |
* @details This class implements an base sequential stream. |
174 | 183 |
* @todo So far only output but no input is supported. |
175 | 184 |
*/ |
176 |
struct aos_shellstream { |
|
185 |
typedef struct aos_shellstream {
|
|
177 | 186 |
const struct AosShellStreamVMT* vmt; |
178 | 187 |
_aos_shellstream_data |
179 |
}; |
|
188 |
} AosShellStream;
|
|
180 | 189 |
|
181 | 190 |
/** |
182 | 191 |
* @brief Shell command calback type. |
... | ... | |
351 | 360 |
uint8_t config; |
352 | 361 |
} aos_shell_t; |
353 | 362 |
|
363 |
/******************************************************************************/ |
|
364 |
/* MACROS */ |
|
365 |
/******************************************************************************/ |
|
366 |
|
|
367 |
/******************************************************************************/ |
|
368 |
/* EXTERN DECLARATIONS */ |
|
369 |
/******************************************************************************/ |
|
370 |
|
|
354 | 371 |
#ifdef __cplusplus |
355 | 372 |
extern "C" { |
356 | 373 |
#endif |
... | ... | |
371 | 388 |
} |
372 | 389 |
#endif |
373 | 390 |
|
391 |
/******************************************************************************/ |
|
392 |
/* INLINE FUNCTIONS */ |
|
393 |
/******************************************************************************/ |
|
394 |
|
|
374 | 395 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
375 | 396 |
|
376 | 397 |
#endif /* AMIROOS_SHELL_H */ |
core/inc/aos_system.h | ||
---|---|---|
34 | 34 |
#include <aos_time.h> |
35 | 35 |
#include <chprintf.h> |
36 | 36 |
|
37 |
/******************************************************************************/ |
|
38 |
/* CONSTANTS */ |
|
39 |
/******************************************************************************/ |
|
40 |
|
|
37 | 41 |
/** |
38 | 42 |
* @brief Resolution of the system time measurement. |
39 | 43 |
*/ |
... | ... | |
64 | 68 |
*/ |
65 | 69 |
#define AOS_SYSTEM_EVENTFLAGS_RESTART (AOS_SYSTEM_EVENTFLAGS_SHUTDOWN | (eventflags_t)(1 << 4)) |
66 | 70 |
|
67 |
/** |
|
68 |
* @brief Enumerator to identify shutdown types. |
|
69 |
*/ |
|
70 |
typedef enum aos_shutdown { |
|
71 |
AOS_SHUTDOWN_NONE, /**< Default value if no shutdown action was initiated */ |
|
72 |
AOS_SHUTDOWN_PASSIVE, /**< Passive shutdown (initiated by another module). */ |
|
73 |
AOS_SHUTDOWN_HIBERNATE, /**< Active shutdown to hibernate mode. */ |
|
74 |
AOS_SHUTDOWN_DEEPSLEEP, /**< Active shutdown to deepsleep mode. */ |
|
75 |
AOS_SHUTDOWN_TRANSPORTATION, /**< Active shutdown to transportation mode. */ |
|
76 |
AOS_SHUTDOWN_RESTART, /**< Active saystem restart request. */ |
|
77 |
} aos_shutdown_t; |
|
78 |
|
|
79 | 71 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__) |
80 | 72 |
|
81 | 73 |
/** |
... | ... | |
94 | 86 |
*/ |
95 | 87 |
#define AOS_SYSTEM_SSSP_TIMEOUT (10 * AMIROOS_CFG_SSSP_SIGNALDELAY) |
96 | 88 |
|
89 |
#endif /* AMIROOS_CFG_SSSP_ENABLE == true */ |
|
90 |
|
|
91 |
/******************************************************************************/ |
|
92 |
/* SETTINGS */ |
|
93 |
/******************************************************************************/ |
|
94 |
|
|
95 |
/******************************************************************************/ |
|
96 |
/* CHECKS */ |
|
97 |
/******************************************************************************/ |
|
98 |
|
|
99 |
/******************************************************************************/ |
|
100 |
/* DATA STRUCTURES AND TYPES */ |
|
101 |
/******************************************************************************/ |
|
102 |
|
|
103 |
/** |
|
104 |
* @brief Enumerator to identify shutdown types. |
|
105 |
*/ |
|
106 |
typedef enum aos_shutdown { |
|
107 |
AOS_SHUTDOWN_NONE, /**< Default value if no shutdown action was initiated */ |
|
108 |
AOS_SHUTDOWN_PASSIVE, /**< Passive shutdown (initiated by another module). */ |
|
109 |
AOS_SHUTDOWN_HIBERNATE, /**< Active shutdown to hibernate mode. */ |
|
110 |
AOS_SHUTDOWN_DEEPSLEEP, /**< Active shutdown to deepsleep mode. */ |
|
111 |
AOS_SHUTDOWN_TRANSPORTATION, /**< Active shutdown to transportation mode. */ |
|
112 |
AOS_SHUTDOWN_RESTART, /**< Active saystem restart request. */ |
|
113 |
} aos_shutdown_t; |
|
114 |
|
|
115 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__) |
|
116 |
|
|
97 | 117 |
/** |
98 | 118 |
* @brief Enumerator of the several stages of SSSP. |
99 | 119 |
*/ |
... | ... | |
176 | 196 |
|
177 | 197 |
} aos_system_t; |
178 | 198 |
|
179 |
/** |
|
180 |
* @brief Global system object. |
|
181 |
*/ |
|
182 |
extern aos_system_t aos; |
|
199 |
/******************************************************************************/ |
|
200 |
/* MACROS */ |
|
201 |
/******************************************************************************/ |
|
183 | 202 |
|
184 | 203 |
/** |
185 | 204 |
* @brief Printf function that uses the default system I/O stream. |
... | ... | |
188 | 207 |
*/ |
189 | 208 |
#define aosprintf(fmt, ...) chprintf((BaseSequentialStream*)&aos.iostream, fmt, ##__VA_ARGS__) |
190 | 209 |
|
210 |
/******************************************************************************/ |
|
211 |
/* EXTERN DECLARATIONS */ |
|
212 |
/******************************************************************************/ |
|
213 |
|
|
214 |
/** |
|
215 |
* @brief Global system object. |
|
216 |
*/ |
|
217 |
extern aos_system_t aos; |
|
218 |
|
|
191 | 219 |
#ifdef __cplusplus |
192 | 220 |
extern "C" { |
193 | 221 |
#endif |
... | ... | |
211 | 239 |
} |
212 | 240 |
#endif |
213 | 241 |
|
242 |
/******************************************************************************/ |
|
243 |
/* INLINE FUNCTIONS */ |
|
244 |
/******************************************************************************/ |
|
245 |
|
|
214 | 246 |
/** |
215 | 247 |
* @brief Retrieves the system uptime. |
216 | 248 |
* |
core/inc/aos_thread.h | ||
---|---|---|
29 | 29 |
|
30 | 30 |
#include <aos_time.h> |
31 | 31 |
#include <aos_system.h> |
32 |
/******************************************************************************/ |
|
33 |
/* CONSTANTS */ |
|
34 |
/******************************************************************************/ |
|
32 | 35 |
|
33 | 36 |
/** |
34 | 37 |
* @brief Minimum thread priority. |
... | ... | |
95 | 98 |
*/ |
96 | 99 |
#define AOS_THD_MAX_SLEEP_US (chTimeI2US(AOS_THD_MAX_SLEEP_ST) - 1) |
97 | 100 |
|
101 |
/******************************************************************************/ |
|
102 |
/* SETTINGS */ |
|
103 |
/******************************************************************************/ |
|
104 |
|
|
105 |
/******************************************************************************/ |
|
106 |
/* CHECKS */ |
|
107 |
/******************************************************************************/ |
|
108 |
|
|
109 |
/******************************************************************************/ |
|
110 |
/* DATA STRUCTURES AND TYPES */ |
|
111 |
/******************************************************************************/ |
|
112 |
|
|
113 |
/******************************************************************************/ |
|
114 |
/* MACROS */ |
|
115 |
/******************************************************************************/ |
|
116 |
|
|
117 |
/******************************************************************************/ |
|
118 |
/* EXTERN DECLARATIONS */ |
|
119 |
/******************************************************************************/ |
|
120 |
|
|
98 | 121 |
#ifdef __cplusplus |
99 | 122 |
extern "C" { |
100 | 123 |
#endif |
... | ... | |
106 | 129 |
} |
107 | 130 |
#endif |
108 | 131 |
|
132 |
/******************************************************************************/ |
|
133 |
/* INLINE FUNCTIONS */ |
|
134 |
/******************************************************************************/ |
|
135 |
|
|
109 | 136 |
/** |
110 | 137 |
* @brief Lets the calling thread sleep the specified amount of microseconds. |
111 | 138 |
* |
core/inc/aos_time.h | ||
---|---|---|
29 | 29 |
|
30 | 30 |
#include <stdint.h> |
31 | 31 |
|
32 |
/** |
|
33 |
* @brief Generic time to represent long time frames at high precision. |
|
34 |
* @note By definition the temporal resolution is 1us. |
|
35 |
*/ |
|
36 |
typedef uint64_t aos_timestamp_t; |
|
37 |
|
|
38 |
/** |
|
39 |
* @brief generic time to represent medium length time frames at high precision. |
|
40 |
* @note By definition the temporal resolution is 1us. |
|
41 |
*/ |
|
42 |
typedef uint32_t aos_interval_t; |
|
43 |
|
|
44 |
/** |
|
45 |
* @brief Generic time to represent long time frames at high precision. |
|
46 |
* @note By definition the temporal resolution is 1us. |
|
47 |
*/ |
|
48 |
typedef aos_timestamp_t aos_longinterval_t; |
|
32 |
/******************************************************************************/ |
|
33 |
/* CONSTANTS */ |
|
34 |
/******************************************************************************/ |
|
49 | 35 |
|
50 | 36 |
#define MICROSECONDS_PER_MICROSECOND ((uint8_t) (1)) |
51 | 37 |
#define MILLISECONDS_PER_MILLISECOND ((uint8_t) (1)) |
... | ... | |
212 | 198 |
#define MILLENIUMS_PER_DECADE ((float)MILLENIUMS_PER_MILLENIUM / (float)DECADES_PER_MILLENIUM) |
213 | 199 |
#define MILLENIUMS_PER_CENTURY ((float)MILLENIUMS_PER_MILLENIUM / (float)CENTURIES_PER_MILLENIUM) |
214 | 200 |
|
201 |
/******************************************************************************/ |
|
202 |
/* SETTINGS */ |
|
203 |
/******************************************************************************/ |
|
204 |
|
|
205 |
/******************************************************************************/ |
|
206 |
/* CHECKS */ |
|
207 |
/******************************************************************************/ |
|
208 |
|
|
209 |
/******************************************************************************/ |
|
210 |
/* DATA STRUCTURES AND TYPES */ |
|
211 |
/******************************************************************************/ |
|
212 |
|
|
213 |
/** |
|
214 |
* @brief Generic time to represent long time frames at high precision. |
|
215 |
* @note By definition the temporal resolution is 1us. |
|
216 |
*/ |
|
217 |
typedef uint64_t aos_timestamp_t; |
|
218 |
|
|
219 |
/** |
|
220 |
* @brief generic time to represent medium length time frames at high precision. |
|
221 |
* @note By definition the temporal resolution is 1us. |
|
222 |
*/ |
|
223 |
typedef uint32_t aos_interval_t; |
|
224 |
|
|
225 |
/** |
|
226 |
* @brief Generic time to represent long time frames at high precision. |
|
227 |
* @note By definition the temporal resolution is 1us. |
|
228 |
*/ |
|
229 |
typedef aos_timestamp_t aos_longinterval_t; |
|
230 |
|
|
231 |
/******************************************************************************/ |
|
232 |
/* MACROS */ |
|
233 |
/******************************************************************************/ |
|
234 |
|
|
235 |
/******************************************************************************/ |
|
236 |
/* EXTERN DECLARATIONS */ |
|
237 |
/******************************************************************************/ |
|
238 |
|
|
215 | 239 |
#ifdef __cplusplus |
216 | 240 |
extern "C" { |
217 | 241 |
#endif |
... | ... | |
220 | 244 |
} |
221 | 245 |
#endif |
222 | 246 |
|
247 |
/******************************************************************************/ |
|
248 |
/* INLINE FUNCTIONS */ |
|
249 |
/******************************************************************************/ |
|
250 |
|
|
223 | 251 |
#endif /* AMIROOS_TIME_H */ |
224 | 252 |
|
225 | 253 |
/** @} */ |
core/inc/aos_timer.h | ||
---|---|---|
29 | 29 |
|
30 | 30 |
#include <ch.h> |
31 | 31 |
#include <aos_time.h> |
32 |
/******************************************************************************/ |
|
33 |
/* CONSTANTS */ |
|
34 |
/******************************************************************************/ |
|
32 | 35 |
|
33 | 36 |
/** |
34 | 37 |
* @brief Maximum timer interval that can be set in system ticks. |
... | ... | |
50 | 53 |
*/ |
51 | 54 |
#define AOS_TIMER_MAX_INTERVAL_US (chTimeI2US(AOS_TIMER_MAX_INTERVAL_ST) - 1) |
52 | 55 |
|
56 |
/******************************************************************************/ |
|
57 |
/* SETTINGS */ |
|
58 |
/******************************************************************************/ |
|
59 |
|
|
60 |
/******************************************************************************/ |
|
61 |
/* CHECKS */ |
|
62 |
/******************************************************************************/ |
|
63 |
|
|
64 |
/******************************************************************************/ |
|
65 |
/* DATA STRUCTURES AND TYPES */ |
|
66 |
/******************************************************************************/ |
|
67 |
|
|
53 | 68 |
/** |
54 | 69 |
* @brief Timer stucture. |
55 | 70 |
*/ |
... | ... | |
100 | 115 |
void* cbparam; |
101 | 116 |
} aos_periodictimer_t; |
102 | 117 |
|
118 |
/******************************************************************************/ |
|
119 |
/* MACROS */ |
|
120 |
/******************************************************************************/ |
|
121 |
|
|
122 |
/******************************************************************************/ |
|
123 |
/* EXTERN DECLARATIONS */ |
|
124 |
/******************************************************************************/ |
|
125 |
|
|
103 | 126 |
#ifdef __cplusplus |
104 | 127 |
extern "C" { |
105 | 128 |
#endif |
... | ... | |
114 | 137 |
} |
115 | 138 |
#endif |
116 | 139 |
|
140 |
/******************************************************************************/ |
|
141 |
/* INLINE FUNCTIONS */ |
|
142 |
/******************************************************************************/ |
|
143 |
|
|
117 | 144 |
/** |
118 | 145 |
* @brief Set timer to fire at an absolute system time. |
119 | 146 |
* |
core/inc/aos_types.h | ||
---|---|---|
29 | 29 |
|
30 | 30 |
#include <ch.h> |
31 | 31 |
|
32 |
/** |
|
33 |
* @brief Converts a GPIO pad number to a unique event flag. |
|
34 |
*/ |
|
35 |
#define AOS_IOEVENT_FLAG(pad) ((eventflags_t)1 << pad) |
|
32 |
/******************************************************************************/ |
|
33 |
/* CONSTANTS */ |
|
34 |
/******************************************************************************/ |
|
35 |
|
|
36 |
/******************************************************************************/ |
|
37 |
/* SETTINGS */ |
|
38 |
/******************************************************************************/ |
|
39 |
|
|
40 |
/******************************************************************************/ |
|
41 |
/* CHECKS */ |
|
42 |
/******************************************************************************/ |
|
43 |
|
|
44 |
/******************************************************************************/ |
|
45 |
/* DATA STRUCTURES AND TYPES */ |
|
46 |
/******************************************************************************/ |
|
36 | 47 |
|
37 | 48 |
/** |
38 | 49 |
* @brief Error codes used in AMiRo-OS. |
... | ... | |
47 | 58 |
} aos_status_t; |
48 | 59 |
|
49 | 60 |
|
61 |
/******************************************************************************/ |
|
62 |
/* MACROS */ |
|
63 |
/******************************************************************************/ |
|
64 |
|
|
65 |
/** |
|
66 |
* @brief Converts a GPIO pad number to a unique event flag. |
|
67 |
*/ |
|
68 |
#define AOS_IOEVENT_FLAG(pad) ((eventflags_t)1 << pad) |
|
69 |
|
|
70 |
/******************************************************************************/ |
|
71 |
/* EXTERN DECLARATIONS */ |
|
72 |
/******************************************************************************/ |
|
73 |
|
|
74 |
/******************************************************************************/ |
|
75 |
/* INLINE FUNCTIONS */ |
|
76 |
/******************************************************************************/ |
|
77 |
|
|
50 | 78 |
#endif /* AMIROOS_TYPES_H */ |
79 |
|
|
51 | 80 |
/** @} */ |
core/inc/aos_unittest.h | ||
---|---|---|
31 | 31 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
32 | 32 |
#include <hal.h> |
33 | 33 |
#include <aos_shell.h> |
34 |
/******************************************************************************/ |
|
35 |
/* CONSTANTS */ |
|
36 |
/******************************************************************************/ |
|
37 |
|
|
38 |
/******************************************************************************/ |
|
39 |
/* SETTINGS */ |
|
40 |
/******************************************************************************/ |
|
41 |
|
|
42 |
/******************************************************************************/ |
|
43 |
/* CHECKS */ |
|
44 |
/******************************************************************************/ |
|
45 |
|
|
46 |
/******************************************************************************/ |
|
47 |
/* DATA STRUCTURES AND TYPES */ |
|
48 |
/******************************************************************************/ |
|
34 | 49 |
|
35 | 50 |
/* |
36 |
* Forward declarations.
|
|
51 |
* forward declarations
|
|
37 | 52 |
*/ |
38 |
typedef struct aos_unittest aos_unittest_t; |
|
39 | 53 |
typedef struct aos_utresult aos_utresult_t; |
54 |
typedef struct aos_unittest aos_unittest_t; |
|
40 | 55 |
|
41 | 56 |
/** |
42 | 57 |
* @brief Unit test interface function definition. |
... | ... | |
46 | 61 |
* |
47 | 62 |
* @return A result containing the number of passed and failed tests. |
48 | 63 |
*/ |
49 |
typedef aos_utresult_t (*aos_utfunction_t)(BaseSequentialStream* stream, aos_unittest_t* ut);
|
|
64 |
typedef aos_utresult_t (*aos_utfunction_t)(BaseSequentialStream*, aos_unittest_t*);
|
|
50 | 65 |
|
51 | 66 |
/** |
52 | 67 |
* @brief Unit test result struct. |
... | ... | |
93 | 108 |
void* data; |
94 | 109 |
}; |
95 | 110 |
|
111 |
|
|
112 |
/******************************************************************************/ |
|
113 |
/* MACROS */ |
|
114 |
/******************************************************************************/ |
|
115 |
|
|
116 |
/******************************************************************************/ |
|
117 |
/* EXTERN DECLARATIONS */ |
|
118 |
/******************************************************************************/ |
|
119 |
|
|
96 | 120 |
#ifdef __cplusplus |
97 | 121 |
extern "C" { |
98 | 122 |
#endif |
... | ... | |
110 | 134 |
} |
111 | 135 |
#endif |
112 | 136 |
|
137 |
/******************************************************************************/ |
|
138 |
/* INLINE FUNCTIONS */ |
|
139 |
/******************************************************************************/ |
|
140 |
|
|
113 | 141 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
114 | 142 |
|
115 | 143 |
#endif /* AMIROOS_UNITTEST_H */ |
core/src/aos_iostream.c | ||
---|---|---|
27 | 27 |
|
28 | 28 |
#include <aos_iostream.h> |
29 | 29 |
|
30 |
#include <aos_debug.h> |
|
31 |
#include <chprintf.h> |
|
30 |
/******************************************************************************/ |
|
31 |
/* LOCAL DEFINITIONS */ |
|
32 |
/******************************************************************************/ |
|
33 |
|
|
34 |
/******************************************************************************/ |
|
35 |
/* EXPORTED VARIABLES */ |
|
36 |
/******************************************************************************/ |
|
37 |
|
|
38 |
/******************************************************************************/ |
|
39 |
/* LOCAL TYPES */ |
|
40 |
/******************************************************************************/ |
|
41 |
|
|
42 |
/******************************************************************************/ |
|
43 |
/* LOCAL VARIABLES */ |
|
44 |
/******************************************************************************/ |
|
45 |
|
|
46 |
/* |
|
47 |
* forward declarations |
|
48 |
*/ |
|
49 |
static size_t _channelwrite(void *instance, const uint8_t *bp, size_t n); |
|
50 |
static size_t _channelread(void *instance, uint8_t *bp, size_t n); |
|
51 |
static msg_t _channelput(void *instance, uint8_t b); |
|
52 |
static msg_t _channelget(void *instance); |
|
53 |
static msg_t _channelputt(void *instance, uint8_t b, sysinterval_t time); |
|
54 |
static msg_t _channelgett(void *instance, sysinterval_t time); |
|
55 |
static size_t _channelwritet(void *instance, const uint8_t *bp, size_t n, sysinterval_t time); |
|
56 |
static size_t _channelreadt(void *instance, uint8_t *bp, size_t n, sysinterval_t time); |
|
57 |
static msg_t _channelctl(void *instance, unsigned int operation, void *arg); |
|
58 |
static size_t _streamwrite(void *instance, const uint8_t *bp, size_t n); |
|
59 |
static size_t _stremread(void *instance, uint8_t *bp, size_t n); |
|
60 |
static msg_t _streamput(void *instance, uint8_t b); |
|
61 |
static msg_t _streamget(void *instance); |
|
62 |
|
|
63 |
/** |
|
64 |
* @brief Virtual methods table for all AosIOChannel objects. |
|
65 |
*/ |
|
66 |
static const struct AosIOChannelVMT _channelvmt = { |
|
67 |
(size_t) 0, |
|
68 |
_channelwrite, |
|
69 |
_channelread, |
|
70 |
_channelput, |
|
71 |
_channelget, |
|
72 |
_channelputt, |
|
73 |
_channelgett, |
|
74 |
_channelwritet, |
|
75 |
_channelreadt, |
|
76 |
_channelctl, |
|
77 |
}; |
|
78 |
|
|
79 |
/** |
|
80 |
* @brief Virtual methods table for all AosIOStream objects. |
|
81 |
*/ |
|
82 |
static const struct AosIOStreamVMT _streamvmt = { |
|
83 |
(size_t) 0, |
|
84 |
_streamwrite, |
|
85 |
_stremread, |
|
86 |
_streamput, |
|
87 |
_streamget, |
|
88 |
}; |
|
89 |
|
|
90 |
/******************************************************************************/ |
|
91 |
/* LOCAL FUNCTIONS */ |
|
92 |
/******************************************************************************/ |
|
32 | 93 |
|
33 | 94 |
/** |
34 | 95 |
* @brief Implementation of the BaseAsynchronousChannel write() method (inherited from BaseSequentialStream). |
... | ... | |
139 | 200 |
} |
140 | 201 |
|
141 | 202 |
/** |
142 |
* @brief Virtual methods table for all AosIOChannel objects. |
|
143 |
*/ |
|
144 |
static const struct AosIOChannelVMT _channelvmt = { |
|
145 |
(size_t) 0, |
|
146 |
_channelwrite, |
|
147 |
_channelread, |
|
148 |
_channelput, |
|
149 |
_channelget, |
|
150 |
_channelputt, |
|
151 |
_channelgett, |
|
152 |
_channelwritet, |
|
153 |
_channelreadt, |
|
154 |
_channelctl, |
|
155 |
}; |
|
156 |
|
|
157 |
/** |
|
158 | 203 |
* @brief Implementation of the BaseSequentialStream write() method. |
159 | 204 |
*/ |
160 | 205 |
static size_t _streamwrite(void *instance, const uint8_t *bp, size_t n) |
... | ... | |
219 | 264 |
return 0; |
220 | 265 |
} |
221 | 266 |
|
222 |
/** |
|
223 |
* @brief Virtual methods table for all AosIOStream objects. |
|
224 |
*/ |
|
225 |
static const struct AosIOStreamVMT _streamvmt = { |
|
226 |
(size_t) 0, |
|
227 |
_streamwrite, |
|
228 |
_stremread, |
|
229 |
_streamput, |
|
230 |
_streamget, |
|
231 |
}; |
|
267 |
/******************************************************************************/ |
|
268 |
/* EXPORTED FUNCTIONS */ |
|
269 |
/******************************************************************************/ |
|
232 | 270 |
|
233 | 271 |
/** |
234 | 272 |
* @brief Initializes an aos_iostream_t object. |
core/src/aos_main.cpp | ||
---|---|---|
36 | 36 |
#include AMIROOS_CFG_MAIN_EXTRA_INCLUDE_HEADER |
37 | 37 |
#endif |
38 | 38 |
|
39 |
/******************************************************************************/ |
|
40 |
/* LOCAL DEFINITIONS */ |
|
41 |
/******************************************************************************/ |
|
42 |
|
|
39 | 43 |
/** |
40 | 44 |
* @brief Event mask to identify I/O events. |
41 | 45 |
*/ |
... | ... | |
92 | 96 |
*/ |
93 | 97 |
#define CALENDERSYNC_CANMSGID 0x004 |
94 | 98 |
|
99 |
/******************************************************************************/ |
|
100 |
/* EXPORTED VARIABLES */ |
|
101 |
/******************************************************************************/ |
|
102 |
|
|
103 |
/******************************************************************************/ |
|
104 |
/* LOCAL TYPES */ |
|
105 |
/******************************************************************************/ |
|
106 |
|
|
107 |
/******************************************************************************/ |
|
108 |
/* LOCAL VARIABLES */ |
|
109 |
/******************************************************************************/ |
|
110 |
|
|
95 | 111 |
/** |
96 | 112 |
* @brief Listener object for I/O events. |
97 | 113 |
*/ |
... | ... | |
123 | 139 |
AMIROOS_CFG_MAIN_EXTRA_STATIC_VARIABLES |
124 | 140 |
#endif |
125 | 141 |
|
142 |
/******************************************************************************/ |
|
143 |
/* LOCAL FUNCTIONS */ |
|
144 |
/******************************************************************************/ |
|
145 |
|
|
126 | 146 |
/** |
127 | 147 |
* @brief Prints an error message about an unexpected event. |
128 | 148 |
* |
... | ... | |
1334 | 1354 |
return -1; |
1335 | 1355 |
} |
1336 | 1356 |
|
1357 |
/******************************************************************************/ |
|
1358 |
/* EXPORTED FUNCTIONS */ |
|
1359 |
/******************************************************************************/ |
|
1360 |
|
|
1337 | 1361 |
/** @} */ |
core/src/aos_shell.c | ||
---|---|---|
32 | 32 |
#include <aos_time.h> |
33 | 33 |
#include <aos_system.h> |
34 | 34 |
#include <string.h> |
35 |
/******************************************************************************/ |
|
36 |
/* LOCAL DEFINITIONS */ |
|
37 |
/******************************************************************************/ |
|
35 | 38 |
|
36 | 39 |
/** |
37 | 40 |
* @brief Event mask to be set on OS related events. |
... | ... | |
43 | 46 |
*/ |
44 | 47 |
#define AOS_SHELL_EVENTMASK_INPUT EVENT_MASK(1) |
45 | 48 |
|
49 |
/******************************************************************************/ |
|
50 |
/* EXPORTED VARIABLES */ |
|
51 |
/******************************************************************************/ |
|
52 |
|
|
53 |
/******************************************************************************/ |
|
54 |
/* LOCAL TYPES */ |
|
55 |
/******************************************************************************/ |
|
56 |
|
|
57 |
/* |
|
58 |
* forward declarations |
|
59 |
*/ |
|
60 |
static size_t _channelwrite(void *instance, const uint8_t *bp, size_t n); |
|
61 |
static size_t _channelread(void *instance, uint8_t *bp, size_t n); |
|
62 |
static msg_t _channelput(void *instance, uint8_t b); |
|
63 |
static msg_t _channelget(void *instance); |
|
64 |
static msg_t _channelputt(void *instance, uint8_t b, sysinterval_t time); |
|
65 |
static msg_t _channelgett(void *instance, sysinterval_t time); |
|
66 |
static size_t _channelwritet(void *instance, const uint8_t *bp, size_t n, sysinterval_t time); |
|
67 |
static size_t _channelreadt(void *instance, uint8_t *bp, size_t n, sysinterval_t time); |
|
68 |
static msg_t _channelctl(void *instance, unsigned int operation, void *arg); |
|
69 |
static size_t _streamwrite(void *instance, const uint8_t *bp, size_t n); |
|
70 |
static size_t _stremread(void *instance, uint8_t *bp, size_t n); |
|
71 |
static msg_t _streamput(void *instance, uint8_t b); |
|
72 |
static msg_t _streamget(void *instance); |
|
73 |
|
|
74 |
static const struct AosShellChannelVMT _channelvmt = { |
|
75 |
(size_t) 0, |
|
76 |
_channelwrite, |
|
77 |
_channelread, |
|
78 |
_channelput, |
|
79 |
_channelget, |
|
80 |
_channelputt, |
|
81 |
_channelgett, |
|
82 |
_channelwritet, |
|
83 |
_channelreadt, |
|
84 |
_channelctl, |
|
85 |
}; |
|
86 |
|
|
87 |
static const struct AosShellStreamVMT _streamvmt = { |
|
88 |
(size_t) 0, |
|
89 |
_streamwrite, |
|
90 |
_stremread, |
|
91 |
_streamput, |
|
92 |
_streamget, |
|
93 |
}; |
|
94 |
|
|
95 |
/** |
|
96 |
* @brief Enumerator of special keyboard keys. |
|
97 |
*/ |
|
98 |
typedef enum special_key { |
|
99 |
KEY_UNKNOWN, /**< any/unknow key */ |
|
100 |
KEY_AMBIGUOUS, /**< key is ambiguous */ |
|
101 |
KEY_TAB, /**< tabulator key */ |
|
102 |
KEY_ESCAPE, /**< escape key */ |
|
103 |
KEY_BACKSPACE, /**< backspace key */ |
|
104 |
KEY_INSERT, /**< insert key */ |
|
105 |
KEY_DELETE, /**< delete key */ |
|
106 |
KEY_HOME, /**< home key */ |
|
107 |
KEY_END, /**< end key */ |
|
108 |
KEY_PAGE_UP, /**< page up key */ |
|
109 |
KEY_PAGE_DOWN, /**< page down key */ |
|
110 |
KEY_ARROW_UP, /**< arrow up key */ |
|
111 |
KEY_ARROW_DOWN, /**< arrow down key */ |
|
112 |
KEY_ARROW_LEFT, /**< arrow left key */ |
|
113 |
KEY_ARROW_RIGHT, /**< arrow right key */ |
|
114 |
} special_key_t; |
|
115 |
|
|
116 |
/** |
|
117 |
* @brief Enumerator for case (in)sensitive character matching. |
|
118 |
*/ |
|
119 |
typedef enum charmatch { |
|
120 |
CHAR_MATCH_NOT = 0, /**< Characters do not match at all. */ |
|
121 |
CHAR_MATCH_NCASE = 1, /**< Characters would match case insensitive. */ |
|
122 |
CHAR_MATCH_CASE = 2, /**< Characters do match with case. */ |
|
123 |
} charmatch_t; |
|
124 |
|
|
125 |
/******************************************************************************/ |
|
126 |
/* LOCAL VARIABLES */ |
|
127 |
/******************************************************************************/ |
|
128 |
|
|
129 |
/******************************************************************************/ |
|
130 |
/* LOCAL FUNCTIONS */ |
|
131 |
/******************************************************************************/ |
|
132 |
|
|
46 | 133 |
/** |
47 | 134 |
* @brief Implementation of the BaseAsynchronous write() method (inherited from BaseSequentialStream). |
48 | 135 |
*/ |
... | ... | |
142 | 229 |
/** |
143 | 230 |
* @brief Implementation of the BaseAsynchronousChannel ctl() method. |
144 | 231 |
*/ |
145 |
static msg_t _channelctl(void *instance, unsigned int operation, void *arg) { |
|
232 |
static msg_t _channelctl(void *instance, unsigned int operation, void *arg) |
|
233 |
{ |
|
146 | 234 |
(void) instance; |
147 | 235 |
|
148 | 236 |
switch (operation) { |
... | ... | |
158 | 246 |
return MSG_OK; |
159 | 247 |
} |
160 | 248 |
|
161 |
static const struct AosShellChannelVMT _channelvmt = { |
|
162 |
(size_t) 0, |
|
163 |
_channelwrite, |
|
164 |
_channelread, |
|
165 |
_channelput, |
|
166 |
_channelget, |
|
167 |
_channelputt, |
|
168 |
_channelgett, |
|
169 |
_channelwritet, |
|
170 |
_channelreadt, |
|
171 |
_channelctl, |
|
172 |
}; |
|
173 |
|
|
174 | 249 |
static size_t _streamwrite(void *instance, const uint8_t *bp, size_t n) |
175 | 250 |
{ |
176 | 251 |
aosDbgCheck(instance != NULL); |
... | ... | |
224 | 299 |
return 0; |
225 | 300 |
} |
226 | 301 |
|
227 |
static const struct AosShellStreamVMT _streamvmt = { |
|
228 |
(size_t) 0, |
|
229 |
_streamwrite, |
|
230 |
_stremread, |
|
231 |
_streamput, |
|
232 |
_streamget, |
|
233 |
}; |
|
234 |
|
|
235 |
/** |
|
236 |
* @brief Enumerator of special keyboard keys. |
|
237 |
*/ |
|
238 |
typedef enum special_key { |
|
239 |
KEY_UNKNOWN, /**< any/unknow key */ |
|
240 |
KEY_AMBIGUOUS, /**< key is ambiguous */ |
|
241 |
KEY_TAB, /**< tabulator key */ |
|
242 |
KEY_ESCAPE, /**< escape key */ |
|
243 |
KEY_BACKSPACE, /**< backspace key */ |
|
244 |
KEY_INSERT, /**< insert key */ |
|
245 |
KEY_DELETE, /**< delete key */ |
|
246 |
KEY_HOME, /**< home key */ |
|
247 |
KEY_END, /**< end key */ |
|
248 |
KEY_PAGE_UP, /**< page up key */ |
|
249 |
KEY_PAGE_DOWN, /**< page down key */ |
|
250 |
KEY_ARROW_UP, /**< arrow up key */ |
|
251 |
KEY_ARROW_DOWN, /**< arrow down key */ |
|
252 |
KEY_ARROW_LEFT, /**< arrow left key */ |
|
253 |
KEY_ARROW_RIGHT, /**< arrow right key */ |
|
254 |
} special_key_t; |
|
255 |
|
|
256 |
/** |
|
257 |
* @brief Enumerator for case (in)sensitive character matching. |
|
258 |
*/ |
|
259 |
typedef enum charmatch { |
|
260 |
CHAR_MATCH_NOT = 0, /**< Characters do not match at all. */ |
|
261 |
CHAR_MATCH_NCASE = 1, /**< Characters would match case insensitive. */ |
|
262 |
CHAR_MATCH_CASE = 2, /**< Characters do match with case. */ |
|
263 |
} charmatch_t; |
|
264 |
|
|
265 | 302 |
/** |
266 | 303 |
* @brief Print the shell prompt |
267 | 304 |
* @details Depending on the configuration flags, the system uptime is printed before the prompt string. |
... | ... | |
1095 | 1132 |
return arg; |
1096 | 1133 |
} |
1097 | 1134 |
|
1135 |
/******************************************************************************/ |
|
1136 |
/* EXPORTED FUNCTIONS */ |
|
1137 |
/******************************************************************************/ |
|
1138 |
|
|
1098 | 1139 |
/** |
1099 | 1140 |
* @brief Initializes a shell object with the specified parameters. |
1100 | 1141 |
* |
core/src/aos_system.c | ||
---|---|---|
37 | 37 |
#include <rt_test_root.h> |
38 | 38 |
#endif |
39 | 39 |
|
40 |
/******************************************************************************/ |
|
41 |
/* LOCAL DEFINITIONS */ |
|
42 |
/******************************************************************************/ |
|
43 |
|
|
40 | 44 |
/** |
41 | 45 |
* @brief Period of the system timer. |
42 | 46 |
*/ |
... | ... | |
52 | 56 |
*/ |
53 | 57 |
#define SYSTEM_INFO_NAMEWIDTH 14 |
54 | 58 |
|
55 |
/* forward declarations */ |
|
56 |
static void _printSystemInfo(BaseSequentialStream* stream); |
|
57 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) |
|
59 |
#if ((AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__) |
|
60 |
|
|
61 |
/** |
|
62 |
* @brief Weighting factor for the low-pass filter used for calculating the @p _syssyncskew value. |
|
63 |
*/ |
|
64 |
#define SYSTEM_SYSSYNCSKEW_LPFACTOR (0.1f / AOS_SYSTEM_TIME_RESOLUTION) |
|
65 |
|
|
66 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true) */ |
|
67 |
|
|
68 |
/******************************************************************************/ |
|
69 |
/* EXPORTED VARIABLES */ |
|
70 |
/******************************************************************************/ |
|
71 |
|
|
72 |
/** |
|
73 |
* @brief Global system object. |
|
74 |
*/ |
|
75 |
aos_system_t aos; |
|
76 |
|
|
77 |
/******************************************************************************/ |
|
78 |
/* LOCAL TYPES */ |
|
79 |
/******************************************************************************/ |
|
80 |
|
|
81 |
/******************************************************************************/ |
|
82 |
/* LOCAL VARIABLES */ |
|
83 |
/******************************************************************************/ |
|
84 |
|
|
85 |
/* |
|
86 |
* forward declarations |
|
87 |
*/ |
|
88 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
|
58 | 89 |
static int _shellcmd_configcb(BaseSequentialStream* stream, int argc, char* argv[]); |
59 | 90 |
static int _shellcmd_infocb(BaseSequentialStream* stream, int argc, char* argv[]); |
60 | 91 |
static int _shellcmd_shutdowncb(BaseSequentialStream* stream, int argc, char* argv[]); |
61 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) |
|
92 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
|
|
62 | 93 |
static int _shellcmd_kerneltestcb(BaseSequentialStream* stream, int argc, char* argv[]); |
63 | 94 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
64 | 95 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
... | ... | |
88 | 119 |
* @brief Last uptime of system wide time synchronization. |
89 | 120 |
*/ |
90 | 121 |
static aos_timestamp_t _syssynctime; |
91 |
#endif |
|
122 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER == true) */
|
|
92 | 123 |
|
93 | 124 |
#if ((AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__) |
94 | 125 |
/** |
... | ... | |
96 | 127 |
*/ |
97 | 128 |
static float _syssyncskew; |
98 | 129 |
|
99 |
/** |
|
100 |
* @brief Weighting factor for the low-pass filter used for calculating the @p _syssyncskew value. |
|
101 |
*/ |
|
102 |
#define SYSTEM_SYSSYNCSKEW_LPFACTOR (0.1f / AOS_SYSTEM_TIME_RESOLUTION) |
|
103 | 130 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true) */ |
104 | 131 |
|
105 | 132 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
... | ... | |
161 | 188 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
162 | 189 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
163 | 190 |
|
164 |
/** |
|
165 |
* @brief Global system object. |
|
166 |
*/ |
|
167 |
aos_system_t aos; |
|
191 |
/******************************************************************************/ |
|
192 |
/* LOCAL FUNCTIONS */ |
|
193 |
/******************************************************************************/ |
|
168 | 194 |
|
169 | 195 |
/** |
170 | 196 |
* @brief Print a separator line. |
... | ... | |
751 | 777 |
} |
752 | 778 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER == true) */ |
753 | 779 |
|
780 |
/******************************************************************************/ |
|
781 |
/* EXPORTED FUNCTIONS */ |
|
782 |
/******************************************************************************/ |
|
783 |
|
|
754 | 784 |
/** |
755 | 785 |
* @brief AMiRo-OS system initialization. |
756 | 786 |
* @note Must be called from the system control thread (usually main thread). |
core/src/aos_thread.c | ||
---|---|---|
25 | 25 |
*/ |
26 | 26 |
|
27 | 27 |
#include <aos_thread.h> |
28 |
/******************************************************************************/ |
|
29 |
/* LOCAL DEFINITIONS */ |
|
30 |
/******************************************************************************/ |
|
31 |
|
|
32 |
/******************************************************************************/ |
|
33 |
/* EXPORTED VARIABLES */ |
|
34 |
/******************************************************************************/ |
|
35 |
|
|
36 |
/******************************************************************************/ |
|
37 |
/* LOCAL TYPES */ |
|
38 |
/******************************************************************************/ |
|
39 |
|
|
40 |
/******************************************************************************/ |
|
41 |
/* LOCAL VARIABLES */ |
|
42 |
/******************************************************************************/ |
|
43 |
|
|
44 |
/******************************************************************************/ |
|
45 |
/* LOCAL FUNCTIONS */ |
|
46 |
/******************************************************************************/ |
|
47 |
|
|
48 |
/******************************************************************************/ |
|
49 |
/* EXPORTED FUNCTIONS */ |
|
50 |
/******************************************************************************/ |
|
28 | 51 |
|
29 | 52 |
/** |
30 | 53 |
* @brief Lets the calling thread sleep until the specifide system uptime. |
core/src/aos_time.c | ||
---|---|---|
26 | 26 |
|
27 | 27 |
#include <aos_time.h> |
28 | 28 |
|
29 |
/******************************************************************************/ |
|
30 |
/* LOCAL DEFINITIONS */ |
|
31 |
/******************************************************************************/ |
|
32 |
|
|
33 |
/******************************************************************************/ |
|
34 |
/* EXPORTED VARIABLES */ |
|
35 |
/******************************************************************************/ |
|
36 |
|
|
37 |
/******************************************************************************/ |
|
38 |
/* LOCAL TYPES */ |
|
39 |
/******************************************************************************/ |
|
40 |
|
|
41 |
/******************************************************************************/ |
|
42 |
/* LOCAL VARIABLES */ |
|
43 |
/******************************************************************************/ |
|
44 |
|
|
45 |
/******************************************************************************/ |
|
46 |
/* LOCAL FUNCTIONS */ |
|
47 |
/******************************************************************************/ |
|
48 |
|
|
49 |
/******************************************************************************/ |
|
50 |
/* EXPORTED FUNCTIONS */ |
|
51 |
/******************************************************************************/ |
|
29 | 52 |
#include <aos_debug.h> |
30 | 53 |
#include <aos_system.h> |
31 | 54 |
|
core/src/aos_timer.c | ||
---|---|---|
27 | 27 |
|
28 | 28 |
#include <aos_timer.h> |
29 | 29 |
|
30 |
/******************************************************************************/ |
|
31 |
/* LOCAL DEFINITIONS */ |
|
32 |
/******************************************************************************/ |
|
33 |
|
|
34 |
/******************************************************************************/ |
|
35 |
/* EXPORTED VARIABLES */ |
|
36 |
/******************************************************************************/ |
|
37 |
|
|
38 |
/******************************************************************************/ |
|
39 |
/* LOCAL TYPES */ |
|
40 |
/******************************************************************************/ |
|
41 |
|
|
42 |
/******************************************************************************/ |
|
43 |
/* LOCAL VARIABLES */ |
|
44 |
/******************************************************************************/ |
|
45 |
|
|
46 |
/******************************************************************************/ |
|
47 |
/* LOCAL FUNCTIONS */ |
|
48 |
/******************************************************************************/ |
|
30 | 49 |
#include <aos_system.h> |
31 | 50 |
|
32 | 51 |
/* |
33 |
* Forward declarations.
|
|
52 |
* forward declarations
|
|
34 | 53 |
*/ |
35 |
static inline void _setupTimer(aos_timer_t* timer); |
|
36 |
static inline void _setupPeriodicTimer(aos_periodictimer_t* ptimer); |
|
37 | 54 |
static void _intermediateCb(void* timer); |
38 |
static void _fireCb(void* timer);
|
|
55 |
static void _fireCb(void *timer);
|
|
39 | 56 |
static void _periodicCb(void* ptimer); |
40 | 57 |
|
41 | 58 |
/** |
... | ... | |
134 | 151 |
_setupPeriodicTimer((aos_periodictimer_t*)ptimer); |
135 | 152 |
} |
136 | 153 |
|
154 |
/******************************************************************************/ |
|
155 |
/* EXPORTED FUNCTIONS */ |
|
156 |
/******************************************************************************/ |
|
157 |
|
|
137 | 158 |
/** |
138 | 159 |
* @brief Initialize a aos_timer_t object. |
139 | 160 |
* |
core/src/aos_unittest.c | ||
---|---|---|
32 | 32 |
#include <aos_debug.h> |
33 | 33 |
#include <chprintf.h> |
34 | 34 |
#include <string.h> |
35 |
/******************************************************************************/ |
|
36 |
/* LOCAL DEFINITIONS */ |
|
37 |
/******************************************************************************/ |
|
38 |
|
|
39 |
/******************************************************************************/ |
|
40 |
/* EXPORTED VARIABLES */ |
|
41 |
/******************************************************************************/ |
|
42 |
|
|
43 |
/******************************************************************************/ |
|
44 |
/* LOCAL TYPES */ |
|
45 |
/******************************************************************************/ |
|
46 |
|
|
47 |
/******************************************************************************/ |
|
48 |
/* LOCAL VARIABLES */ |
|
49 |
/******************************************************************************/ |
|
50 |
|
|
51 |
/******************************************************************************/ |
|
52 |
/* LOCAL FUNCTIONS */ |
|
53 |
/******************************************************************************/ |
|
54 |
|
|
55 |
/******************************************************************************/ |
|
56 |
/* EXPORTED FUNCTIONS */ |
|
57 |
/******************************************************************************/ |
|
35 | 58 |
|
36 | 59 |
/** |
37 | 60 |
* @brief Retrieve the total number of tests (passed and failed). |
unittests/lld/inc/ut_lld_adc.h | ||
---|---|---|
23 | 23 |
|
24 | 24 |
#if ((AMIROOS_CFG_TESTS_ENABLE == true) && (HAL_USE_ADC == TRUE))|| defined(__DOXYGEN__) |
25 | 25 |
|
26 |
/******************************************************************************/ |
|
27 |
/* CONSTANTS */ |
|
28 |
/******************************************************************************/ |
|
29 |
|
|
30 |
/******************************************************************************/ |
|
31 |
/* SETTINGS */ |
|
32 |
/******************************************************************************/ |
|
33 |
|
|
34 |
/******************************************************************************/ |
|
35 |
/* CHECKS */ |
|
36 |
/******************************************************************************/ |
|
37 |
|
|
38 |
/******************************************************************************/ |
|
39 |
/* DATA STRUCTURES AND TYPES */ |
|
40 |
/******************************************************************************/ |
|
41 |
|
|
26 | 42 |
/** |
27 | 43 |
* @brief Custom data structure for the unit test. |
28 | 44 |
*/ |
... | ... | |
38 | 54 |
ADCConversionGroup* convgroup; |
39 | 55 |
} ut_adcdata_t; |
40 | 56 |
|
57 |
/******************************************************************************/ |
|
58 |
/* MACROS */ |
|
59 |
/******************************************************************************/ |
|
60 |
|
|
61 |
/******************************************************************************/ |
|
62 |
/* EXTERN DECLARATIONS */ |
|
63 |
/******************************************************************************/ |
|
64 |
|
|
41 | 65 |
#ifdef __cplusplus |
42 | 66 |
extern "C" { |
43 | 67 |
#endif |
... | ... | |
46 | 70 |
} |
47 | 71 |
#endif |
48 | 72 |
|
73 |
/******************************************************************************/ |
|
74 |
/* INLINE FUNCTIONS */ |
|
75 |
/******************************************************************************/ |
|
76 |
|
|
49 | 77 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && (HAL_USE_ADC == TRUE) */ |
50 | 78 |
|
51 | 79 |
#endif /* AMIROOS_UT_LLD_ADC_H */ |
unittests/lld/src/ut_lld_adc.c | ||
---|---|---|
20 | 20 |
|
21 | 21 |
#if ((AMIROOS_CFG_TESTS_ENABLE == true) && (HAL_USE_ADC == TRUE))|| defined(__DOXYGEN__) |
22 | 22 |
|
23 |
/******************************************************************************/ |
|
24 |
/* LOCAL DEFINITIONS */ |
|
25 |
/******************************************************************************/ |
|
23 | 26 |
#include <aos_debug.h> |
24 | 27 |
#include <aos_thread.h> |
25 | 28 |
#include <chprintf.h> |
... | ... | |
34 | 37 |
*/ |
35 | 38 |
#define _adcWdgThreshold (uint16_t)(9.0f / 5.0f / 3.3f * ((1 << 12) - 1) + 0.5f) |
36 | 39 |
|
40 |
/******************************************************************************/ |
|
41 |
/* EXPORTED VARIABLES */ |
|
42 |
/******************************************************************************/ |
|
43 |
|
Also available in: Unified diff