Академический Документы
Профессиональный Документы
Культура Документы
h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
"inc/hw_memmap.h"
"inc/hw_gpio.h"
"inc/hw_pwm.h"
"inc/hw_sysctl.h"
"inc/hw_types.h"
"inc/hw_timer.h"
"inc/hw_nvic.h"
"bitdefs.h"
"driverlib/sysctl.h"
"driverlib/gpio.h"
"driverlib/interrupt.h"
"utils/uartstdio.h"
"ES_Port.h"
"termio.h"
"DriveMotorService.h"
#include
#include
#include
#include
#include
"ES_Configure.h"
"ES_Timers.h"
"ES_Framework.h"
"ES_Types.h"
"ES_Events.h"
#define
#define
#define
#define
PERIOD_TOLLERANCE .4
RPM_TOLERANCE 60
UpdateTime 100
MAX_RPM 75
// Filtering parameter
// Filtering parameter
// Time is MS for when wheels are stopped
// MAX_RPM parater for filtering
bits
__enable_irq();
// now kick the timer off by enabling it and enabling the timer to
// stall while stopped by the debugger
HWREG(WTIMER0_BASE+TIMER_O_CTL) |= (TIMER_CTL_TAEN| TIMER_CTL_TASTALL);
HWREG(WTIMER0_BASE+TIMER_O_CTL) |= (TIMER_CTL_TBEN| TIMER_CTL_TBSTALL);
// Start Interrupt Timers to timeout when wheels are stopped
ES_Timer_InitTimer(InterruptTimerLeft,UpdateTime);
ES_Timer_InitTimer(InterruptTimerRight,UpdateTime);
// Start RPM at 0
RPMLeft = 0;
RPMRight = 0;
return true;
LastCaptureL = ThisCapture;
RPMLeft = (PeriodToRPM/EnPeriodL);
// Reject Speeds above RPM_TOLERANCE
// Note: This is here because of noise on the Slot Sensor Output lines
if(RPMLeft > RPM_TOLERANCE) {
RPMLeft = LastRPMLeft;
LeftEnCounts--;
}
LastRPMLeft = RPMLeft;
// Keep RPM Constant from last
edge
LeftEnCounts++;
// increment
counts
edge
// increment counts
return RPMLeft;
}
int GetRPMRight(void) {
return RPMRight;
}
//--------------------------------------Encoder
stuff-------------------------------------// Functions to return Encoder Counts
int GetLeftEnCounts(void) {
return LeftEnCounts;
}
int GetRightEnCounts(void) {
return RightEnCounts;
}
// Function to reset Encoder Counts to 0
void ResetEnCounts(void) {
LeftEnCounts = 0;
RightEnCounts = 0;
}