Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Revision:
13:fbd9b3f5a07c
Parent:
12:e0adb697fcdb
Child:
17:c9ce210f6654
--- a/FanPump/FanPump.h	Tue Oct 21 23:44:15 2014 +0000
+++ b/FanPump/FanPump.h	Fri Oct 24 22:09:04 2014 +0000
@@ -2,38 +2,22 @@
 #define _FILE_FANPUMP_H
 
 #include "mbed.h"
-#include "rtos.h"
-#include "CANBuffer.h"
-
-typedef enum {
-    Pump1 = 0,
-    Pump2 = 1,
-    Fan1 = 2,
-    Fan2 = 3,
-} FanPumpSelect;
-
-typedef struct{
-    float cur_duty;
-    float new_duty;
-    PwmOut *pin;    
-} PinStatus;
-
-const int PIN_NUM = 4;
-const int TX_FAN_ID = ((0x4 << 8) | 0x11);
-const int RX_FAN_ID = ((0x4 << 8) | 0x81);
-const int TX_PUMP_ID = ((0x4 << 8) | 0x10);
-const int RX_PUMP_ID = ((0x4 << 8) | 0x80);
 
 class FanPump{
 public:
-    FanPump(CANBuffer *can);
-    void set_fan_pump(FanPumpSelect fan, float duty);
-    void shutdown(FanPumpSelect fan);
-    void shutdown_all();
-    void start_update();
+    // Takes Pwmout pin, period (seconds), duty cycle slew rate in second^-1 (1 means duty 0 to 1 occurs over 1 second, 0 means no slew)
+    // Use slew rate to implement soft start
+    FanPump(PinName pin, float period, float slew);
+    void write(float duty);
+    float read();       // Read the last setpoint
+    float readRaw();    // Read the raw current duty (may be mid-transition)
     
+    void slew();        // Slew rate callback function
 private:
-    Thread *pin_threads[PIN_NUM];
-    void free_pin(FanPumpSelect fan);
+    PwmOut pwm;         // mbed PWM out
+    int pin;            // pwm channel#
+    static uint32_t period_us; // Period in microseconds (shared by all channels)
+    uint32_t setPoint_us;
+    uint32_t maxChange_us;     // Max pulsewidth change allowed to achieve the slew rate
 };
 #endif
\ No newline at end of file