PROJ515-MASTER-No-PWM
Dependencies: mbed mbed-rtos ShiftReg2 TextLCD
Control/Control.cpp@4:020f93d35f6e, 2019-05-07 (annotated)
- Committer:
- thomasmorris
- Date:
- Tue May 07 21:55:57 2019 +0000
- Revision:
- 4:020f93d35f6e
- Child:
- 5:dbb984e01ded
Added mutex and safey coding needs more. Added board and serial functions that need testing. As well as a more thorough post function.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 4:020f93d35f6e | 1 | #include "Control.hpp" |
thomasmorris | 4:020f93d35f6e | 2 | int PWM_on_time = 0; |
thomasmorris | 4:020f93d35f6e | 3 | int PWM_off_time = 100; |
thomasmorris | 4:020f93d35f6e | 4 | ShiftReg SR(PA_10, PA_12, PA_15, PA_11); //data, store, clock, output enable |
thomasmorris | 4:020f93d35f6e | 5 | int Output = 0; |
thomasmorris | 4:020f93d35f6e | 6 | int Data = 0; |
thomasmorris | 4:020f93d35f6e | 7 | void Control_Main()//This is where the control of the board will be run from, just to not have all of the code inside of the main |
thomasmorris | 4:020f93d35f6e | 8 | { |
thomasmorris | 4:020f93d35f6e | 9 | Control_Shift_Regs(0xF0F0,20);//Pass in the muscle and fan selection along with the PWM |
thomasmorris | 4:020f93d35f6e | 10 | } |
thomasmorris | 4:020f93d35f6e | 11 | void Control_Shift_Regs(uint16_t Selection, int PWM)//Controling the output of the shift registers |
thomasmorris | 4:020f93d35f6e | 12 | { |
thomasmorris | 4:020f93d35f6e | 13 | if(PWM < 0 || PWM > 100) |
thomasmorris | 4:020f93d35f6e | 14 | { |
thomasmorris | 4:020f93d35f6e | 15 | PWM = 0; |
thomasmorris | 4:020f93d35f6e | 16 | //Also run an error |
thomasmorris | 4:020f93d35f6e | 17 | } |
thomasmorris | 4:020f93d35f6e | 18 | PWM_on_time = PWM; |
thomasmorris | 4:020f93d35f6e | 19 | PWM_off_time = PWM_off_time - PWM; |
thomasmorris | 4:020f93d35f6e | 20 | while(1) |
thomasmorris | 4:020f93d35f6e | 21 | { |
thomasmorris | 4:020f93d35f6e | 22 | SR.Write(0x0000);//All off |
thomasmorris | 4:020f93d35f6e | 23 | SR.Write(Selection);//Turn the selection on |
thomasmorris | 4:020f93d35f6e | 24 | Thread::wait(PWM_on_time);//20ms on |
thomasmorris | 4:020f93d35f6e | 25 | SR.Write(0x0000); |
thomasmorris | 4:020f93d35f6e | 26 | Thread::wait(PWM_off_time);//80ms off |
thomasmorris | 4:020f93d35f6e | 27 | } |
thomasmorris | 4:020f93d35f6e | 28 | } |
thomasmorris | 4:020f93d35f6e | 29 | void Control_Post()//The POST function runs here |
thomasmorris | 4:020f93d35f6e | 30 | { |
thomasmorris | 4:020f93d35f6e | 31 | POST();//Run the power on self test routine |
thomasmorris | 4:020f93d35f6e | 32 | } |
thomasmorris | 4:020f93d35f6e | 33 |