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: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
DC_DC/DC_DC.cpp@6:6a04210a3f4f, 2014-10-10 (annotated)
- Committer:
- martydd3
- Date:
- Fri Oct 10 20:24:22 2014 +0000
- Revision:
- 6:6a04210a3f4f
- Child:
- 10:db13782f05d9
Added Watchdog timer, put DC_DC converter and FanPump code into their own classes.; To do: Look into how to call class member functions in a thread. Current thread functions are not members of classes.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| martydd3 | 6:6a04210a3f4f | 1 | #include "mbed.h" |
| martydd3 | 6:6a04210a3f4f | 2 | #include "DC_DC.h" |
| martydd3 | 6:6a04210a3f4f | 3 | |
| martydd3 | 6:6a04210a3f4f | 4 | DigitalOut dc_pin(p20); |
| martydd3 | 6:6a04210a3f4f | 5 | FanPump *fanPump; |
| martydd3 | 6:6a04210a3f4f | 6 | CANBuffer *tx_DC_Buffer; |
| martydd3 | 6:6a04210a3f4f | 7 | bool status; |
| martydd3 | 6:6a04210a3f4f | 8 | |
| martydd3 | 6:6a04210a3f4f | 9 | DC::DC(FanPump *fp, CANBuffer *can){ |
| martydd3 | 6:6a04210a3f4f | 10 | status = false; |
| martydd3 | 6:6a04210a3f4f | 11 | dc_pin = !status; |
| martydd3 | 6:6a04210a3f4f | 12 | tx_DC_Buffer = can; |
| martydd3 | 6:6a04210a3f4f | 13 | fanPump = fp; |
| martydd3 | 6:6a04210a3f4f | 14 | } |
| martydd3 | 6:6a04210a3f4f | 15 | |
| martydd3 | 6:6a04210a3f4f | 16 | bool DC::is_on(){ |
| martydd3 | 6:6a04210a3f4f | 17 | return status; |
| martydd3 | 6:6a04210a3f4f | 18 | } |
| martydd3 | 6:6a04210a3f4f | 19 | |
| martydd3 | 6:6a04210a3f4f | 20 | void DC::set(bool s){ |
| martydd3 | 6:6a04210a3f4f | 21 | status = s; |
| martydd3 | 6:6a04210a3f4f | 22 | if(!status){ |
| martydd3 | 6:6a04210a3f4f | 23 | fanPump->shutdown_all(); |
| martydd3 | 6:6a04210a3f4f | 24 | } |
| martydd3 | 6:6a04210a3f4f | 25 | |
| martydd3 | 6:6a04210a3f4f | 26 | dc_pin = !status; |
| martydd3 | 6:6a04210a3f4f | 27 | } |
| martydd3 | 6:6a04210a3f4f | 28 | |
| martydd3 | 6:6a04210a3f4f | 29 | void update(const void *arg){ |
| martydd3 | 6:6a04210a3f4f | 30 | char data[4] = {0}; |
| martydd3 | 6:6a04210a3f4f | 31 | while(1){ |
| martydd3 | 6:6a04210a3f4f | 32 | data[0] = status; |
| martydd3 | 6:6a04210a3f4f | 33 | CANMessage txMessage(TX_DC_DC_ID, data, 4); |
| martydd3 | 6:6a04210a3f4f | 34 | CANMessage msg(1); |
| martydd3 | 6:6a04210a3f4f | 35 | tx_DC_Buffer->txWrite(msg); |
| martydd3 | 6:6a04210a3f4f | 36 | |
| martydd3 | 6:6a04210a3f4f | 37 | Thread::wait(100); //10 Hz update |
| martydd3 | 6:6a04210a3f4f | 38 | } |
| martydd3 | 6:6a04210a3f4f | 39 | } |
| martydd3 | 6:6a04210a3f4f | 40 | |
| martydd3 | 6:6a04210a3f4f | 41 | void DC::start_update(){ |
| martydd3 | 6:6a04210a3f4f | 42 | Thread update_thread(update); |
| martydd3 | 6:6a04210a3f4f | 43 | } |
