PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
freqout.c
1 /*
2  * @file freqout.c
3  */
4 
5 #include "simpletools.h"
6 
7 int int_fraction(int a, int b, int shift);
8 void square_wave_setup(int pin, int freq, int* ctr, int* frq);
9 
10 void freqout(int pin, int msTime, int frequency)
11 {
12  int ctr, frq, channel;
13  //char s[32];
14  square_wave_setup(pin, frequency, &ctr, &frq);
15  if(!CTRA)
16  {
17  channel = 0;
18  FRQA = frq;
19  CTRA = ctr;
20  low(pin);
21  }
22  else
23  {
24  channel = 1;
25  FRQB = frq;
26  CTRB = ctr;
27  low(pin);
28  }
29  pause(msTime);
30  if(!channel)
31  {
32  FRQA = 0;
33  CTRA = 0;
34  input(pin);
35  }
36  else
37  {
38  FRQB = 0;
39  CTRB = 0;
40  input(pin);
41  }
42 }
43 
freqout
void freqout(int pin, int msTime, int frequency)
Use same cog to send square wave of a certain frequency for a certain amount of time....
Definition: freqout.c:10
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition: libws2812.c:125
low
void low(int pin)
Set an I/O pin to output-low.
Definition: low.c:19
FRQA
#define FRQA
Counter A frequency register.
Definition: propeller1.h:169
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
FRQB
#define FRQB
Counter B frequency register.
Definition: propeller1.h:171
input
int input(int pin)
Set an I/O pin to input and return 1 if pin detects a high signal, or 0 if it detects low.
Definition: input.c:19
CTRB
#define CTRB
Counter B control register.
Definition: propeller1.h:167
CTRA
#define CTRA
Counter A control register.
Definition: propeller1.h:165