PROJ515 / Mbed 2 deprecated PROJ514-MASTER

Dependencies:   mbed mbed-rtos ShiftReg2 TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Control.cpp Source File

Control.cpp

00001 #include "Control.hpp"
00002 int PWM_on_time = 0;
00003 int PWM_off_time = 100;
00004 ShiftReg SR(PA_10, PA_12, PA_15, PA_11);    //data, store, clock, output enable
00005 int Output = 0;
00006 int Data = 0;
00007 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
00008 {
00009     Control_Shift_Regs(0xF0F0,20);//Pass in the muscle and fan selection along with the PWM
00010 }
00011 void Control_Shift_Regs(uint16_t Selection, int PWM)//Controling the output of the shift registers
00012 {
00013     if(PWM < 0 || PWM > 100)
00014     {
00015         PWM = 0;
00016         //Also run an error   
00017     }
00018     PWM_on_time = PWM;
00019     PWM_off_time = PWM_off_time - PWM;
00020     while(1)
00021     {
00022         SR.Write(0x0000);//All off
00023         SR.Write(Selection);//Turn the selection on
00024         Thread::wait(PWM_on_time);//20ms on
00025         SR.Write(0x0000);
00026         Thread::wait(PWM_off_time);//80ms off
00027     }
00028 }
00029 void Control_Post()//The POST function runs here
00030 {
00031     POST();//Run the power on self test routine
00032 }
00033