![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
All tasks complete
Dependencies: mbed MCP23017 mbed-rtos WattBob_TextLCD
main.cpp@14:25241ed5b056, 2019-04-03 (annotated)
- Committer:
- aingks
- Date:
- Wed Apr 03 02:49:34 2019 +0000
- Revision:
- 14:25241ed5b056
- Parent:
- 12:f4052a23ddc7
- Child:
- 16:b66cb760fb3b
mail queue code added not tested;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aingks | 0:0943f040009c | 1 | #include "header.h" |
aingks | 1:c4f62ef9b5b7 | 2 | /* |
aingks | 1:c4f62ef9b5b7 | 3 | Embedded Software: Assignment 3 |
aingks | 1:c4f62ef9b5b7 | 4 | |
aingks | 1:c4f62ef9b5b7 | 5 | Description: |
aingks | 1:c4f62ef9b5b7 | 6 | |
aingks | 1:c4f62ef9b5b7 | 7 | |
aingks | 0:0943f040009c | 8 | |
aingks | 0:0943f040009c | 9 | |
aingks | 3:f88d667629e6 | 10 | Version 0.2 Aingkaran Suppiah |
aingks | 1:c4f62ef9b5b7 | 11 | */ |
aingks | 1:c4f62ef9b5b7 | 12 | |
aingks | 4:27340b291c09 | 13 | SDATA speed = SDATA(); |
aingks | 4:27340b291c09 | 14 | CARINFO info = CARINFO(); |
aingks | 4:27340b291c09 | 15 | SIMU_DATA sim = SIMU_DATA(); |
aingks | 4:27340b291c09 | 16 | |
aingks | 4:27340b291c09 | 17 | |
aingks | 4:27340b291c09 | 18 | |
aingks | 8:3f3f2c2e2046 | 19 | MCP23017 *par_port; // pointer to 16-bit parallel I/O object **was = NULL |
aingks | 8:3f3f2c2e2046 | 20 | WattBob_TextLCD *display; // pointer to 2*16 chacater LCD object **was = NULL |
aingks | 4:27340b291c09 | 21 | |
aingks | 14:25241ed5b056 | 22 | |
aingks | 14:25241ed5b056 | 23 | //Thread delcaration |
aingks | 12:f4052a23ddc7 | 24 | Thread thread_1; |
aingks | 12:f4052a23ddc7 | 25 | Thread thread_2; |
aingks | 12:f4052a23ddc7 | 26 | Thread thread_3; |
aingks | 12:f4052a23ddc7 | 27 | Thread thread_4; |
aingks | 12:f4052a23ddc7 | 28 | Thread thread_5; |
aingks | 12:f4052a23ddc7 | 29 | Thread thread_6; |
aingks | 12:f4052a23ddc7 | 30 | Thread thread_7; |
aingks | 12:f4052a23ddc7 | 31 | Thread thread_8; |
aingks | 12:f4052a23ddc7 | 32 | Thread thread_9; |
aingks | 12:f4052a23ddc7 | 33 | Thread thread_10; |
aingks | 4:27340b291c09 | 34 | |
aingks | 14:25241ed5b056 | 35 | //mail queue |
aingks | 14:25241ed5b056 | 36 | Thread MailQueue; |
aingks | 4:27340b291c09 | 37 | |
aingks | 14:25241ed5b056 | 38 | //Mutex |
aingks | 4:27340b291c09 | 39 | Mutex simuXS; |
aingks | 4:27340b291c09 | 40 | Mutex speedXS; |
aingks | 4:27340b291c09 | 41 | Mutex carstateXS; |
aingks | 0:0943f040009c | 42 | |
aingks | 14:25241ed5b056 | 43 | //mailbox |
aingks | 14:25241ed5b056 | 44 | Mail<SIMU_DATA, 16> mail_box; |
aingks | 14:25241ed5b056 | 45 | |
aingks | 8:3f3f2c2e2046 | 46 | int main() { |
aingks | 8:3f3f2c2e2046 | 47 | |
aingks | 12:f4052a23ddc7 | 48 | // set up for the LCD |
aingks | 12:f4052a23ddc7 | 49 | |
aingks | 8:3f3f2c2e2046 | 50 | par_port = new MCP23017(p9, p10, 0x40); // initialise 16-bit I/O chip |
aingks | 8:3f3f2c2e2046 | 51 | |
aingks | 8:3f3f2c2e2046 | 52 | display = new WattBob_TextLCD(par_port); // initialise 2*26 char display |
aingks | 8:3f3f2c2e2046 | 53 | |
aingks | 8:3f3f2c2e2046 | 54 | par_port->write_bit(1,BL_BIT); // turn LCD backlight ON |
aingks | 8:3f3f2c2e2046 | 55 | |
aingks | 14:25241ed5b056 | 56 | //task initialization |
aingks | 8:3f3f2c2e2046 | 57 | |
aingks | 12:f4052a23ddc7 | 58 | thread_1.start(task1readbrake); |
aingks | 12:f4052a23ddc7 | 59 | thread_2.start(task2readaccel); |
aingks | 12:f4052a23ddc7 | 60 | thread_3.start(task3enginestate); |
aingks | 12:f4052a23ddc7 | 61 | thread_4.start(task4average); |
aingks | 12:f4052a23ddc7 | 62 | thread_5.start(task5brakeLED); |
aingks | 12:f4052a23ddc7 | 63 | thread_6.start(task6speedmonitor); |
aingks | 12:f4052a23ddc7 | 64 | thread_7.start(task7displayvalues); |
aingks | 12:f4052a23ddc7 | 65 | thread_8.start(task8sidelights); |
aingks | 12:f4052a23ddc7 | 66 | thread_9.start(task9indLED); |
aingks | 12:f4052a23ddc7 | 67 | thread_10.start(taskXserialdump); |
aingks | 14:25241ed5b056 | 68 | |
aingks | 14:25241ed5b056 | 69 | //mail queue |
aingks | 14:25241ed5b056 | 70 | MailQueue.start(callback(send_thread)); |
aingks | 8:3f3f2c2e2046 | 71 | |
aingks | 8:3f3f2c2e2046 | 72 | |
aingks | 3:f88d667629e6 | 73 | |
aingks | 12:f4052a23ddc7 | 74 | |
aingks | 8:3f3f2c2e2046 | 75 | |
aingks | 0:0943f040009c | 76 | |
aingks | 14:25241ed5b056 | 77 | while(true){ |
aingks | 8:3f3f2c2e2046 | 78 | |
aingks | 8:3f3f2c2e2046 | 79 | } |
aingks | 0:0943f040009c | 80 | } |