new battery bar

Dependencies:   CAN_IDs CanControl Dashboard PinDetect PowerControl mbed-rtos mbed

Committer:
kwasymodo
Date:
Fri May 12 20:19:56 2017 +0000
Revision:
4:dfd10f43cc8b
Parent:
3:b164662f9740
Child:
11:005a50dd7db5
Child:
12:f753bc59c2e8
changed PowerControl ; changed pinout

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kwasymodo 1:c5d8ea5d049b 1 /*******************************************************************************
kwasymodo 4:dfd10f43cc8b 2 This software is especially designed for Solarboat Twente for the use in their Solarboat v1.0
kwasymodo 1:c5d8ea5d049b 3
kwasymodo 1:c5d8ea5d049b 4 Written by:
kwasymodo 1:c5d8ea5d049b 5 Niels Leijen, Jesse van Rhijn, Bram Seinhorst
kwasymodo 1:c5d8ea5d049b 6
kwasymodo 1:c5d8ea5d049b 7 Thanks to:
kwasymodo 1:c5d8ea5d049b 8 Jasper Admiraal, Hidde Pik (hihihihi), Lisa Postma, Heleen Jeurink, Ruben Peters,
kwasymodo 1:c5d8ea5d049b 9 Martijn Groot Jebbink, Martijn Wilpshaar, Bram Seinhorst, Robert Geels, Arnoud Meutstege,
kwasymodo 4:dfd10f43cc8b 10 Jeroen te Braake, Ids de Vos, Jesse van Rhijn, Sam Benou, Niels Leijen and Mark Bruijn
kwasymodo 1:c5d8ea5d049b 11
kwasymodo 1:c5d8ea5d049b 12 DISCLAIMER:
kwasymodo 1:c5d8ea5d049b 13 THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT.
kwasymodo 1:c5d8ea5d049b 14 SOLARBOATTWENTE ASSUMES NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
kwasymodo 1:c5d8ea5d049b 15 *******************************************************************************/
kwasymodo 1:c5d8ea5d049b 16
kwasymodo 1:c5d8ea5d049b 17 // uncomment to send debug information
kwasymodo 1:c5d8ea5d049b 18 #define DEBUG
kwasymodo 1:c5d8ea5d049b 19
kwasymodo 1:c5d8ea5d049b 20 //include 3rd party libraries
kwasymodo 4:dfd10f43cc8b 21 #include "mbed.h" //needs to be revision 136 else SD filesystem will not work
kwasymodo 1:c5d8ea5d049b 22 #include "rtos.h"
kwasymodo 1:c5d8ea5d049b 23
kwasymodo 1:c5d8ea5d049b 24 // include Solarboat libraries
kwasymodo 1:c5d8ea5d049b 25 #include "pinout.h"
kwasymodo 1:c5d8ea5d049b 26 #include "PowerControl.h"
kwasymodo 1:c5d8ea5d049b 27
kwasymodo 1:c5d8ea5d049b 28 // initialize serial connection for debug
kwasymodo 1:c5d8ea5d049b 29 #ifdef DEBUG
kwasymodo 3:b164662f9740 30 RawSerial pc(SERIAL_TX, SERIAL_RX);
kwasymodo 1:c5d8ea5d049b 31 #endif
kwasymodo 1:c5d8ea5d049b 32
kwasymodo 1:c5d8ea5d049b 33 // initialize canbus
kwasymodo 1:c5d8ea5d049b 34 CAN can(CAN_RD, CAN_TD);
kwasymodo 1:c5d8ea5d049b 35
kwasymodo 1:c5d8ea5d049b 36 // initialze onboard leds
kwasymodo 1:c5d8ea5d049b 37 DigitalOut ledError(LED3);
kwasymodo 1:c5d8ea5d049b 38 DigitalOut ledRelay(LED2);
kwasymodo 1:c5d8ea5d049b 39 DigitalOut ledSD(LED1);
kwasymodo 1:c5d8ea5d049b 40 DigitalOut ledFona(LED5);
kwasymodo 1:c5d8ea5d049b 41 DigitalOut led24V(LED4);
kwasymodo 1:c5d8ea5d049b 42
kwasymodo 4:dfd10f43cc8b 43 //DigitalOut buckCan(BUCK2);
kwasymodo 4:dfd10f43cc8b 44 //DigitalOut buckXSens(BUCK3);
kwasymodo 4:dfd10f43cc8b 45 //DigitalOut buckScreen(BUCK4);
kwasymodo 4:dfd10f43cc8b 46 //DigitalOut buck24V(BUCK5);
kwasymodo 1:c5d8ea5d049b 47
kwasymodo 1:c5d8ea5d049b 48
kwasymodo 1:c5d8ea5d049b 49 // Thread 1 - Power
kwasymodo 1:c5d8ea5d049b 50 void power(){
kwasymodo 4:dfd10f43cc8b 51 PowerControl powercontrol(PUSH_GREEN);
kwasymodo 4:dfd10f43cc8b 52
kwasymodo 1:c5d8ea5d049b 53 #ifdef DEBUG
kwasymodo 4:dfd10f43cc8b 54 pc.printf("Thread 1 - Power started\r\n ");
kwasymodo 1:c5d8ea5d049b 55 #endif
kwasymodo 1:c5d8ea5d049b 56
kwasymodo 4:dfd10f43cc8b 57 Thread::wait(osWaitForever);
kwasymodo 1:c5d8ea5d049b 58 }
kwasymodo 1:c5d8ea5d049b 59
kwasymodo 1:c5d8ea5d049b 60
kwasymodo 1:c5d8ea5d049b 61 // Thread 0 - DO NOT CHANGE THIS!
kwasymodo 1:c5d8ea5d049b 62 int main() {
kwasymodo 1:c5d8ea5d049b 63 #ifdef DEBUG
kwasymodo 1:c5d8ea5d049b 64 pc.baud(115200);
kwasymodo 3:b164662f9740 65 pc.printf("Starting SOS V1.0\n");
kwasymodo 1:c5d8ea5d049b 66 #endif
kwasymodo 1:c5d8ea5d049b 67 // change CAN frequency
kwasymodo 1:c5d8ea5d049b 68 can.frequency(250000);
kwasymodo 1:c5d8ea5d049b 69
kwasymodo 1:c5d8ea5d049b 70 // initialze threads
kwasymodo 1:c5d8ea5d049b 71 Thread thread1;
kwasymodo 1:c5d8ea5d049b 72 //Thread thread2;
kwasymodo 1:c5d8ea5d049b 73 //Thread thread3;
kwasymodo 1:c5d8ea5d049b 74 //Thread thread4;
kwasymodo 1:c5d8ea5d049b 75 //Thread thread5;
kwasymodo 1:c5d8ea5d049b 76
kwasymodo 1:c5d8ea5d049b 77 // change thread priority
kwasymodo 1:c5d8ea5d049b 78 //thread2.set_priority(osPriorityBelowNormal);
kwasymodo 1:c5d8ea5d049b 79
kwasymodo 1:c5d8ea5d049b 80 // start threads
kwasymodo 1:c5d8ea5d049b 81 thread1.start(&power);
kwasymodo 1:c5d8ea5d049b 82 //thread2.start(&calcPi);
kwasymodo 1:c5d8ea5d049b 83 //thread3.start(&motorTest);
kwasymodo 1:c5d8ea5d049b 84 //thread4.start(&canReceive);
kwasymodo 1:c5d8ea5d049b 85 //thread5.start(&relaisOn);
kwasymodo 1:c5d8ea5d049b 86
kwasymodo 1:c5d8ea5d049b 87 //stop this thread while keeping the other threads running
kwasymodo 1:c5d8ea5d049b 88 Thread::wait(osWaitForever);
kwasymodo 1:c5d8ea5d049b 89 }