|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
19 void dac_loop(
void *par);
25 if(channel > 1) tda.daCog = -1;
else tda.daCog =
cogid();
27 tda.daBitX = 32 - bits;
36 if(
cogid() != da->daCog)
42 if(da->daCh == 0)
CTRA = da->daCtr;
else CTRB = da->daCtr;
43 if(da->daCh == 0)
FRQA = value << da->daBitX;
else FRQB = value << da->daBitX;
44 DIRA |= (1 << da->daPin);
62 if(da0->daBitX < 0) da0->daBitX = - da0->daBitX;
69 if(da1->daBitX < 0) da1->daBitX = - da1->daBitX;
71 int mycog =
cogstart(dac_loop, &temp, mem.stack,
sizeof(mem.stack));
72 if(da0)
while(da0->daCog == -1);
73 if(da1)
while(da1->daCog == -1);
79 void dac_loop(
void *par)
83 unsigned int dt = dacAddr -> daDt;
85 dac* da0 = dacAddr->da0;
86 dac* da1 = dacAddr->da1;
88 if(da0) da0->daCog =
cogid();
89 if(da1) da1->daCog =
cogid();
91 if(da0->daVal < 0) da0->daVal = -da0->daVal;
92 if(da1->daVal < 0) da1->daVal = -da1->daVal;
97 DIRA |= (1 << da0->daPin);
102 DIRA |= (1 << da1->daPin);
114 FRQA = da0->daVal << da0->daBitX;
115 FRQB = da1->daVal << da1->daBitX;
123 DIRA &= ~(1<<da->daPin);
int dac_start(dacmem mem, int sampleRate, dac *da0, dac *da1)
Start D/A converter in new cog that sets voltages on either one or two pins.
int dac_stop(int cogid)
Stops a dac cog and frees up a cog and all its resources for other uses.
#define FRQA
Counter A frequency register.
dac dac_setup(int pin, int channel, int bits)
Configure an I/O pin to set a voltage with digital to analog (D/A) conversion.
#define FRQB
Counter B frequency register.
#define CLKFREQ
Returns the current clock frequency.
This file provides convenience functions for digital to analog conversion using using counter modules...
void dac_close(dac *da)
Clear a D/A converter that's running in the same cog and reclaim the I/O pin and counter module for o...
#define CTRB
Counter B control register.
#define waitcnt(a)
Wait until system counter reaches a value.
#define cogstop(a)
Stop a COG.
#define CNT
The system clock count.
#define cogid()
Return the id of the current cog.
void dac_set(dac *da, int value)
Set the D/A converter's output.
#define DIRA
Use to set pins to input (0) or output (1).
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.