You are on page 1of 1

*************************************************************************************

Psuedo-code for MotorWrite service

MotorInit
Parameter: Motor_t Motor

Set PMW Tiva Frequency to PMW_FREQUENCY_HZ


Set PMW Tiva Duty to 0
End of MotorInit

MotorSetSpeed
Parameters: Motor_t Motor, uint8_t SpeedPercent
Returns bool if correctly set speed

Local Variable: NewDuty


Set NewDuty to SpeedPercent correctly clamped to not pass min or max speed
If NewDuty is out of range
Return False
EndIf
Set PWM Duty
Return True
End of MotorSetSpeed

MotorStop
Parameters: Motor_t Motor
Returns bool if motor stopped
Set PWM Duty to zero
Return true
End of MotorStop
End of MotorWrite

You might also like