aboutsummaryrefslogtreecommitdiffstats
path: root/include/task.h
blob: 6456bdc23c48a675caad2bce41588c58a44acfd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
 * @file task.h
 * Provides multitasking functionality
 */

#ifndef TASK_H_
#define TASK_H_

#include <stdint.h>

typedef struct {
	void *next;
	uint32_t *stack;
	uint32_t *sp;
} task_t;

/**
 * Enters multitasking mode. The given function acts as the initial thread.
 * This task is given a 4kb stack.
 * @param init the initial thread to run
 */
void task_init(void (*init)(void));

/**
 * Starts a new task.
 * @param task the code to run
 * @param stackSize how many bytes of stack to give the thread
 */
void task_start(void (*task)(void), uint16_t stackSize);

/**
 * Allows task switching to be disabled, for low-level actions.
 * Multiple holds can be placed, and all must be removed to continue task
 * switching.
 * @param hold non-zero for hold, zero to remove hold
 */
void task_hold(uint8_t hold);

#endif // TASK_H_