diff options
Diffstat (limited to 'firmware/API')
-rw-r--r-- | firmware/API | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/firmware/API b/firmware/API index 52f4876af2..c74aa20b0d 100644 --- a/firmware/API +++ b/firmware/API | |||
@@ -201,6 +201,10 @@ Various | |||
201 | 201 | ||
202 | #include <kernel.h> | 202 | #include <kernel.h> |
203 | 203 | ||
204 | void kernel_init(void) | ||
205 | |||
206 | Inits the kernel and starts the tick interrupt | ||
207 | |||
204 | void sleep(ticks) | 208 | void sleep(ticks) |
205 | 209 | ||
206 | Sleep a specified number of ticks, we have HZ ticks per second. | 210 | Sleep a specified number of ticks, we have HZ ticks per second. |
@@ -211,3 +215,48 @@ Various | |||
211 | for something or similar, and also if you do anything that takes "a long | 215 | for something or similar, and also if you do anything that takes "a long |
212 | time". This function is the entire foundation that our "cooperative | 216 | time". This function is the entire foundation that our "cooperative |
213 | multitasking" is based on. Use it. | 217 | multitasking" is based on. Use it. |
218 | |||
219 | int set_irq_level(int level) | ||
220 | |||
221 | Sets the interrupt level (0 = lowest, 15 = highest) and returns the | ||
222 | previous level. | ||
223 | |||
224 | void queue_init(struct event_queue *q) | ||
225 | |||
226 | Initialize an event queue. The maximum number of events in a queue is | ||
227 | QUEUE_LENGTH-1. | ||
228 | |||
229 | void queue_wait(struct event_queue *q, struct event *ev) | ||
230 | |||
231 | Receive an event in a queue, blocking the thread if the queue is empty. | ||
232 | |||
233 | void queue_post(struct event_queue *q, int id, void *data) | ||
234 | |||
235 | Post an event to a queue. | ||
236 | |||
237 | bool queue_empty(struct event_queue* q) | ||
238 | |||
239 | Returns true if the queue is empty. | ||
240 | |||
241 | int tick_add_task(void (*f)(void)) | ||
242 | |||
243 | Add a task to the tick task queue. The argument is a pointer to a | ||
244 | function that will be called every tick interrupt. | ||
245 | At most MAX_NUM_TICK_TASKS can be active at the same time. | ||
246 | |||
247 | int tick_remove_task(void (*f)(void)) | ||
248 | |||
249 | Remove a task from the task queue. | ||
250 | |||
251 | void mutex_init(struct mutex *m) | ||
252 | |||
253 | Initialize a mutex. | ||
254 | |||
255 | void mutex_lock(struct mutex *m) | ||
256 | |||
257 | Lock a mutex. This will block the thread if the mutex is already locked. | ||
258 | Note that you will geta deadlock if you lock the mutex twice! | ||
259 | |||
260 | void mutex_unlock(struct mutex *m) | ||
261 | |||
262 | Unlock a mutex. | ||