![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
All tasks complete
Dependencies: mbed MCP23017 mbed-rtos WattBob_TextLCD
assignment3tasks.cpp
- Committer:
- aingks
- Date:
- 2019-03-26
- Revision:
- 5:f5dda79b93cb
- Parent:
- 4:27340b291c09
- Child:
- 6:abbd51d9b045
File content as of revision 5:f5dda79b93cb:
#include "header.h" //definitions of tasks //lock and unlock variables in struct when performing calculations //pedals AnalogIn brake_pedal(pin_analog_1); AnalogIn accel_pedal(pin_analog_2); //switches DigitalIn ngene(pin_digital_1); DigitalIn leftsw(pin_digital_2); DigitalIn rightsw(pin_digital_3); DigitalIn sidesw(pin_digital_4); //indicators DigitalOut ngeneind(pin_LED1); PwmOut leftind(pin_LED2); //was digitalout PwmOut rightind(pin_LED3);//was digitalout DigitalOut sideind(pin_LED4); //RED box lights DigitalOut brakeind(pin_LED5); DigitalOut overspeedind(pin_LED6); // extern SDATA speed; extern CARINFO info; extern SIMU_DATA sim; // LCD extern WattBob_TextLCD *display; // MUTEX extern Mutex simuXS; extern Mutex speedXS; extern Mutex carstateXS; // void task1readbrake() { speedXS.lock();//lock speed.brakevalue = brake_pedal.read(); speedXS.unlock();//unlock } void task2readaccel() { speedXS.lock();//lock speed.accelvalue = accel_pedal.read(); speedXS.unlock();//unlock } void task3enginestate() { //lock carstateXS.lock(); uint8_t engineonoff = ngene.read(); info.ENGINESTATE = engineonoff; carstateXS.unlock(); //unlock if(engineonoff == 1){ ngeneind = 1; } else{ ngeneind = 0; } } void task4average() { //lock for(int i = 0; i < SAMPLESIZE ; i++){ //speed.raw = (speed.accelvalue - speed.brakevalue)*MAXSPEED; speed.average += speed.array[i]; speed.average = (speed.average / SAMPLESIZE); } //unlock }