|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
22 static void pulse_outCtr(
int pin,
int time);
23 static int servo_start(
void);
24 static void servo(
void *par);
27 static volatile unsigned int servoCog = 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};
47 return servo_set(pin, degreeTenths + 500);
61 int result = servo_start();
62 if(result == 0)
return -1;
63 if(result == -1)
return -2;
65 int s =
sizeof(p)/
sizeof(
int);
68 for(i = 0; i < s; i++)
102 int s =
sizeof(p)/
sizeof(
int);
105 for(i = 0; i < s; i++)
121 int s =
sizeof(p)/
sizeof(
int);
123 for(i = 0; i < s; i++)
143 static void servo(
void *par)
145 int dtpw = (
CLKFREQ/1000000)*2500;
148 int dtTw = (
CLKFREQ/1000000)*20000;
152 int s =
sizeof(p)/
sizeof(
int);
157 for(i = 0; i < s; i++)
170 int diff = tPulse - tp[i];
179 tPulse = tp[i] + step;
181 pulse_outCtr(p[i], tPulse);
186 while((
CNT - pw) <= dtpw);
191 while((
CNT - pw) <= dtpw);
219 static int servo_start(
void)
222 if(lockID == -1)
return -1;
225 servoCog =
cogstart(servo, NULL, stack,
231 static int ta = 0, tb = 0, dta = 0, dtb = 0;
233 static void pulse_outCtr(
int pin,
int time)
242 signed long phsVal = -time *
st_iodt;
253 if(ta == 0 || (dta && (
CNT - ta > dta)))
264 else if(tb == 0 || (dtb && (
CNT - tb > dtb)))
#define PHSB
Counter B phase accumulation register.
int servo_angle(int pin, int degreeTenths)
Set Parallax Standard Servo to angle from 0 to 180 in tenths of a degree.
void servo_stop(void)
Stops the servo process and frees a cog.
#define PHSA
Counter A phase accumulation register.
#define FRQA
Counter A frequency register.
int servo_get(int pin)
Reports the number of microseconds of the pulse most recently sent to a given servo.
Control up to 14 servos in another core. For up to 28, add the servoAux library to your project....
#define FRQB
Counter B frequency register.
#define lockset(lockid)
Set a lock.
int servo_speed(int pin, int speed)
Set Parallax Continuous Rotation servo speed.
#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.
int servo_disable(int pin)
Temporarily or permanently disable a servo by stopping its control signals, setting its I/O pin to in...
#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 servo_set(int pin, int time)
Sets servo control signal to servo connected to a given pin for microsecond pulse durations.
int servo_setramp(int pin, int stepSize)
Set the maximum change in control signal a servo will change in a given 20 ms time period.
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.