|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
22 static void pulse_outCtrAux(
int pin,
int time);
23 static int servoAux_start(
void);
24 static void servoAux(
void *par);
27 static volatile unsigned int servoAuxCog = 0;
28 static volatile unsigned int lockID;
29 static unsigned int stack[44 + 24];
31 static volatile int p[14] = {-1, -1, -1, -1,
32 -1, -1, -1, -1, -1, -1,
34 static volatile int t[14] = {-1, -1, -1, -1,
35 -1, -1, -1, -1, -1, -1,
37 static volatile int tp[14] = {-1, -1, -1, -1,
38 -1, -1, -1, -1, -1, -1,
40 static volatile int r[14] = {2000, 2000, 2000, 2000,
41 2000, 2000, 2000, 2000, 2000,
42 2000, 2000, 2000, 2000, 2000};
59 int result = servoAux_start();
60 if(result == 0)
return -1;
61 if(result == -1)
return -2;
63 int s =
sizeof(p)/
sizeof(
int);
66 for(i = 0; i < s; i++)
100 int s =
sizeof(p)/
sizeof(
int);
103 for(i = 0; i < s; i++)
119 int s =
sizeof(p)/
sizeof(
int);
121 for(i = 0; i < s; i++)
132 static void servoAux(
void *par)
134 int dtpw = (
CLKFREQ/1000000)*2500;
137 int dtTw = (
CLKFREQ/1000000)*20000;
141 int s =
sizeof(p)/
sizeof(
int);
147 for(i = 0; i < s; i++)
160 int diff = tPulse - tp[i];
169 tPulse = tp[i] + step;
171 pulse_outCtrAux(p[i], tPulse);
176 while((
CNT - pw) <= dtpw);
181 while((
CNT - pw) <= dtpw);
208 static int servoAux_start(
void)
211 if(lockID == -1)
return -1;
214 servoAuxCog =
cogstart(servoAux, NULL, stack,
220 static int ta = 0, tb = 0, dta = 0, dtb = 0;
222 static void pulse_outCtrAux(
int pin,
int time)
231 signed long phsVal = -time *
st_iodt;
242 if(ta == 0 || (dta && (
CNT - ta > dta)))
253 else if(tb == 0 || (dtb && (
CNT - tb > dtb)))
#define PHSB
Counter B phase accumulation register.
If the servo library is already busy with 14 servos, you can use this library to control up to 14 mor...
int servoAux_set(int pin, int time)
Sets servo control signal to servo connected to a given pin for microsecond pulse durations.
void servoAux_stop(void)
Stops the servo process and frees a cog.
#define PHSA
Counter A phase accumulation register.
int servoAux_get(int pin)
Reports the number of microseconds of the pulse most recently sent to a given servo.
#define FRQA
Counter A frequency register.
int servoAux_setRamp(int pin, int stepSize)
Set the maximum change in control signal a servo will change in a given 20 ms time period.
#define FRQB
Counter B frequency register.
#define lockset(lockid)
Set a lock.
#define CLKFREQ
Returns the current clock frequency.
#define CTRB
Counter B control register.
#define lockret(lockid)
Return lock to pool.
#define lockclr(lockid)
Clear lock.
#define cogstop(a)
Stop a COG.
#define CNT
The system clock count.
#define locknew()
Get a new lock from the pool of Propeller hardware locks.
int servoAux_speed(int pin, int speed)
Set Parallax Continuous Rotation servo speed.
int servoAux_angle(int pin, int degreeTenths)
Set Parallax Standard Servo to angle from 0 to 180 in tenths of a degree.
int cogstart(void(*func)(void *), void *par, void *stack, size_t stacksize)
Start a new propeller LMM function/thread in another COG.
#define CTRA
Counter A control register.