Code for an autonomous plane I'm building. Includes process scheduling, process communication, and hardware sensor interfacing (via I2C). NOTE: currently in development, source code will be updated frequently.
control.h@4:44a5b1e8fd27, 2013-11-02 (annotated)
- Committer:
- teamgoat
- Date:
- Sat Nov 02 08:47:14 2013 +0000
- Revision:
- 4:44a5b1e8fd27
- Parent:
- 2:452dd766d212
added process memory and communication via output buffer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
teamgoat | 0:0c627ff4c5ed | 1 | #ifndef CONTROL_H |
teamgoat | 0:0c627ff4c5ed | 2 | #define CONTROL_H |
teamgoat | 0:0c627ff4c5ed | 3 | |
teamgoat | 4:44a5b1e8fd27 | 4 | #define OUTPUT_SIZE 512 |
teamgoat | 4:44a5b1e8fd27 | 5 | #define MAX_SID_LEN 32 |
teamgoat | 2:452dd766d212 | 6 | |
teamgoat | 4:44a5b1e8fd27 | 7 | char* get_output(int); |
teamgoat | 4:44a5b1e8fd27 | 8 | void init(); |
teamgoat | 4:44a5b1e8fd27 | 9 | void schedule(); |
teamgoat | 4:44a5b1e8fd27 | 10 | int schedule_proc(char *sid, int (*funcptr)(int)); |
teamgoat | 0:0c627ff4c5ed | 11 | |
teamgoat | 0:0c627ff4c5ed | 12 | typedef enum |
teamgoat | 0:0c627ff4c5ed | 13 | { |
teamgoat | 0:0c627ff4c5ed | 14 | READY, |
teamgoat | 0:0c627ff4c5ed | 15 | BLOCKED, |
teamgoat | 0:0c627ff4c5ed | 16 | ZOMBIE, |
teamgoat | 0:0c627ff4c5ed | 17 | EMPTY |
teamgoat | 0:0c627ff4c5ed | 18 | } proc_stat; |
teamgoat | 0:0c627ff4c5ed | 19 | |
teamgoat | 4:44a5b1e8fd27 | 20 | typedef struct |
teamgoat | 4:44a5b1e8fd27 | 21 | { |
teamgoat | 4:44a5b1e8fd27 | 22 | // process status |
teamgoat | 4:44a5b1e8fd27 | 23 | unsigned int status; |
teamgoat | 4:44a5b1e8fd27 | 24 | // if status == BLOCKED, wait till block_pid's status is ZOMBIE |
teamgoat | 4:44a5b1e8fd27 | 25 | unsigned int block_pid; |
teamgoat | 4:44a5b1e8fd27 | 26 | // function. each "process" is a function with a number of properties and storage space |
teamgoat | 4:44a5b1e8fd27 | 27 | int (*start)(int); |
teamgoat | 4:44a5b1e8fd27 | 28 | char sid[MAX_SID_LEN]; |
teamgoat | 4:44a5b1e8fd27 | 29 | char output[OUTPUT_SIZE]; |
teamgoat | 4:44a5b1e8fd27 | 30 | } process; |
teamgoat | 4:44a5b1e8fd27 | 31 | |
teamgoat | 0:0c627ff4c5ed | 32 | #endif //CONTROL_H |