System Management code

Dependencies:   CANBuffer mbed SystemManagement mbed-rtos

Dependents:   SystemManagement

System Management code for Penn Electric Racing

Functions:

Controls Fans and Pumps via instruction from CAN Messages, ramps them up over time to prevent damage

Turns on/off DC-DC converter via instruction from CAN Messages

Committer:
martydd3
Date:
Fri Oct 10 20:59:36 2014 +0000
Revision:
7:5f6e31faa08e
Parent:
6:6a04210a3f4f
PollSwitch code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
martydd3 6:6a04210a3f4f 1 #ifndef _FILE_FANPUMP_H
martydd3 6:6a04210a3f4f 2 #define _FILE_FANPUMP_H
martydd3 6:6a04210a3f4f 3
martydd3 6:6a04210a3f4f 4 #include "mbed.h"
martydd3 6:6a04210a3f4f 5 #include "rtos.h"
martydd3 6:6a04210a3f4f 6 #include "CANBuffer.h"
martydd3 6:6a04210a3f4f 7
martydd3 6:6a04210a3f4f 8 typedef enum {
martydd3 6:6a04210a3f4f 9 Pump = 0,
martydd3 6:6a04210a3f4f 10 Fan1 = 1,
martydd3 6:6a04210a3f4f 11 Fan2 = 2,
martydd3 6:6a04210a3f4f 12 Fan3 = 3,
martydd3 6:6a04210a3f4f 13 } FanSelect;
martydd3 6:6a04210a3f4f 14
martydd3 6:6a04210a3f4f 15 typedef struct{
martydd3 6:6a04210a3f4f 16 unsigned char cur_duty;
martydd3 6:6a04210a3f4f 17 unsigned char new_duty;
martydd3 6:6a04210a3f4f 18 PwmOut *pin;
martydd3 6:6a04210a3f4f 19 } PinStatus;
martydd3 6:6a04210a3f4f 20
martydd3 6:6a04210a3f4f 21 const int PIN_NUM = 4;
martydd3 6:6a04210a3f4f 22 const int TX_FAN_ID = ((4 << 8) | 4);
martydd3 6:6a04210a3f4f 23 const int RX_FAN_ID = ((4 << 8) | 12);
martydd3 6:6a04210a3f4f 24
martydd3 6:6a04210a3f4f 25 class FanPump{
martydd3 6:6a04210a3f4f 26 public:
martydd3 6:6a04210a3f4f 27 FanPump(CANBuffer *can);
martydd3 6:6a04210a3f4f 28 void set_fan(FanSelect fan, unsigned char duty);
martydd3 6:6a04210a3f4f 29 void shutdown(FanSelect fan);
martydd3 6:6a04210a3f4f 30 void shutdown_all();
martydd3 6:6a04210a3f4f 31 void start_update();
martydd3 6:6a04210a3f4f 32
martydd3 6:6a04210a3f4f 33 private:
martydd3 6:6a04210a3f4f 34 Thread *pin_threads[PIN_NUM];
martydd3 6:6a04210a3f4f 35 void free_pin(FanSelect fan);
martydd3 6:6a04210a3f4f 36 };
martydd3 6:6a04210a3f4f 37 #endif