SRVCTL - Sets period required to handle a servo motor, - Provides a APIs to move the servo motor in order to change car direction.

Dependents:   frdm_MasterVehicle

Revision:
0:b0455b6a805a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srvctl.cpp	Tue Oct 14 03:52:35 2014 +0000
@@ -0,0 +1,21 @@
+#include "srvctl.h"
+
+/**********************************************************************************
+* Object declaration
+***********************************************************************************/
+PwmOut SRVCTL__xServo(PTD0);
+
+void SRVCTL_vInit(void)
+{
+    /* Set the period required to move the servomotor */
+    SRVCTL__xServo.period_ms(SERVO_PERIOD);
+}
+
+void SRVCTL_vSetPosition( uint16_t u16PosVal, const uint16_t u16MaxVal )
+{
+    uint16_t u16PulseWidth = MIDDLE_POINT;
+    /* Adapt value to write into pwm channel */
+    u16PulseWidth = START_POS + ( (FINAL_POS - START_POS) / u16MaxVal ) * (u16PosVal);
+    /* Set duty cycle */
+    SRVCTL__xServo. pulsewidth_us(u16PulseWidth);
+}
\ No newline at end of file