PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Examples
Simple_libadcACpropab
libadcACpropab.c
1
/*
2
* @file libadcACpropab.c
3
*
4
* @author Andy Lindsay
5
*
6
* @copyright
7
* Copyright (C) Parallax, Inc. 2013. All Rights MIT Licensed.
8
*
9
* @brief Project and test harness for the adcACpropab library.
10
*/
11
12
#include "
simpletools.h
"
13
14
#include "
simpletools.h
"
// Include simpletools
15
#include "
adcACpropab.h
"
// Include adcACpropab
16
17
int
adcVal[4];
// Required by adcPropABac
18
19
int
main
()
// Main function
20
{
21
pause
(1000);
// Wait 1 s for Terminal app
22
23
adc_start
(19, 18, 20, 21,
// CS=21, SCL=20, DO=19, DI=18
24
0b0101,
// Ch3 off, 2 on, 1 off, 0 on
25
adcVal);
// Array for measurements
26
27
int
i = 0;
// Index variable
28
while
(1)
// Loop repeats indefinitely
29
{
30
print
(
"adcVal[%d] = %d%c\n"
, i,
// Display raw ADC
31
adcVal[i],
CLREOL
);
32
pause
(100);
// Wait 1/10 s
33
34
i++;
// Add 1 to index
35
if
(i == 4)
// After index = 3
36
{
37
i = 0;
// Reset to zero
38
print
(
"%c"
,
HOME
);
// Cursor home
39
}
40
}
41
}
42
HOME
#define HOME
HOME character (1) sends SimpleIDE Terminal's cursor to top-left "home" position.
Definition:
simpletools.h:233
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
adcACpropab.h
Measure ADC124S021 for signal recording and measurements. For the voltmeter version,...
adc_start
int adc_start(int doPin, int diPin, int clkPin, int csPin, int pattern, int *arrayAddr)
Launch A/D converter process into other cog.
Definition:
adcACpropab.c:20
CLREOL
#define CLREOL
CLREOL character (11) erases all SimpleIDE Terminal characters to the right of the cursor.
Definition:
simpletools.h:323
Generated on Fri May 20 2022 16:48:01 for PropWare by
1.8.17