Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Servo mbed-rtos mbed
Diff: main.cpp
- Revision:
- 2:7dfc8dd6aab3
- Parent:
- 1:79b1ee0f97ef
- Child:
- 3:bfc20ec72b15
--- a/main.cpp Mon Aug 31 22:25:57 2015 +0000 +++ b/main.cpp Thu Oct 08 13:36:17 2015 +0000 @@ -2,23 +2,28 @@ #include "car_config.hpp" #include "rtos.h" +#include "can.hpp" #include "led.hpp" #include "body.hpp" #include "engine.hpp" #include "driver.hpp" #include "clock.hpp" +//initialize the system: +//- single components: body, clock, driver (diagnosis), engine +//- hardware: leds, can +//- threads int init(); int main() { - init(); + //system setup + init(); - while(1) {}; + //main loop + while(1) {}; } -void init_eeprom(); - Thread *th_body; Thread *th_can; Thread *th_engine; @@ -27,74 +32,28 @@ void init_threads () { - th_body = new Thread(thread_body); - th_engine = new Thread(thread_engine); - th_can = new Thread(thread_can); - th_driver = new Thread(thread_driver); - th_clock = new Thread(thread_clock); + th_body = new Thread(thread_body); + th_engine = new Thread(thread_engine); + th_can = new Thread(thread_can); + th_driver = new Thread(thread_driver); + th_clock = new Thread(thread_clock); } int init () { - init_body(); - init_clock(); - init_driver(); - init_engine(); - - printf("INIT LED\r\n"); - init_led(); - -/* - printf("INIT EEPROM\r\n"); - init_eeprom(); -*/ + init_body(); + init_clock(); + init_driver(); + init_engine(); - printf("INIT CAN\r\n"); - init_can(); - - printf("INIT THREAD\r\n"); - init_threads(); - - return true; -} - - -/****************** EEPROM ******************/ -/* -eeprom_t eeprom(p7, p5, p6, p9, PAGENUMBER, PAGESIZE); + //printf("INIT LED\r\n"); + init_led(); -t_eeprom_data eeprom_data[] = { - //SIZE, ADDR - { 2, 0}, //SOFTWARE VERSION - { 2, 2}, //DATA VERSION - { 4, 4}, //NUMBER OF STARTS - { 4, 20}, //T_MISSING - { 4, 40}, //ENGINE_LAST_MISSING - { 4, 44} //BODY_LAST_MISSING -}; - -void init_eeprom () -{ - eeprom.init(eeprom_data, sizeof(eeprom_data)/sizeof(t_eeprom_data)); + //printf("INIT CAN\r\n"); + init_can(); - uint16 sw = 0; - uint16 dd = 0; - uint32 num = 0; - if ((eeprom.read(EEPROM_DATA_SW_VERS, (uint8*)(&sw)) != 2) || - (eeprom.read(EEPROM_DATA_DD_VERS, (uint8*)(&dd)) != 2) || - (sw != SW_VERSION) || (dd != DD_VERSION)) - { - //error - eeprom.reset(); - sw = SW_VERSION; - eeprom.write(EEPROM_DATA_SW_VERS, (uint8*)(&sw)); - dd = DD_VERSION; - eeprom.write(EEPROM_DATA_DD_VERS, (uint8*)(&dd)); - } + //printf("INIT THREAD\r\n"); + init_threads(); - if (eeprom.read(EEPROM_DATA_NSTARTS, (uint8*)(&num)) != 4) - num = 0xffffffff; - num++; - eeprom.write(EEPROM_DATA_NSTARTS, (unsigned char*)(&num)); + return true; } -*/