Professional Documents
Culture Documents
<stdint.h>
<stdbool.h>
<stdio.h>
"driverlib/sysctl.h"
"driverlib/pin_map.h"
"driverlib/gpio.h"
"driverlib/pwm.h"
#include
#include
#include
#include
#include
#include
#include
#include
"ES_Port.h"
"termio.h"
"inc/hw_memmap.h"
"inc/hw_types.h"
"inc/hw_gpio.h"
"inc/hw_sysctl.h"
"driverlib/gpio.h"
"hoop.h"
Description
translate the hoop number from bit number to direct number control servo
Final Edit: Dongao Yang 11/25/14
****************************************************************************/
uint8_t decodeHoopNum(uint8_t hoopNum) {
// return 2, if input is BIT0HI
if(hoopNum == BIT0HI) return 2; //right hoop
// return 3, if input is BIT1HI
else if(hoopNum == BIT1HI) return 3; //center hoop
// return 0, if input is BIT2HI
else if(hoopNum == BIT2HI) return 0; //left hoop
else return 4;//error
}
/****************************************************************************
Function
MoveHoopUp
Parameters
uint8_t, the bit number indicate the hoop
Returns
nothing
Description
Open the corresponding hoop with the input
Final Edit: Dongao Yang 11/25/14
****************************************************************************/
void MoveHoopUp(uint8_t hoopNum)
{
//translate the servo channel number by input
uint8_t channelNum = decodeHoopNum(hoopNum);
//set pulse width at this servo channel, to lift cap
PWM_TIVA_SetPulseWidth(800,channelNum);
}
/****************************************************************************
Function
MoveHoopDown
Parameters
uint8_t, the bit number indicate the hoop
Returns
nothing
Description
Close the corresponding hoop with the input
Final Edit: Dongao Yang 11/25/14
****************************************************************************/
void MoveHoopDown(uint8_t hoopNum) {
//translate the servo channel number by input
uint8_t channelNum = decodeHoopNum(hoopNum);
//set pulse width at this servo channel, to close cap
PWM_TIVA_SetPulseWidth(3300,channelNum);
}
// test harness
#ifdef test
int main()
{
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
| SYSCTL_XTAL_16MHZ);
TERMIO_Init();
clrScrn();
InitHoops();
ES_Return_t ErrorType;
puts("test harness for hoop");
while(1)
{
MoveHoopUp(1);
MoveHoopUp(2);
MoveHoopUp(3);
getchar();
MoveHoopDown(1);
MoveHoopDown(2);
MoveHoopDown(3);
getchar();
}
}
#endif