PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Convert
libspi_adc
spi_adc.h
1
/*
2
* spi_adc.h
3
* Use Serial Peripheral Interface to communicate with
4
* an MCP3x02 to measure voltage across channels 0 and 1 to ground.
5
*
6
* Don't forget to double check your hardware, and post problems
7
* on the Parallax forums!
8
*
9
* Written by Andrew Enright
10
*/
11
#include "
simpletools.h
"
12
13
/* Function MCP3X02_getVolts gets a measurement from a SPI ADC.
14
* spi_adc can be called directly if you know how many bits your ADC is,
15
* or you can call one of the MCP3x02 (3202 or 3002) cover methods
16
* that tell you how many bits it is.
17
* PARAMETERS:
18
* ch = Channel, either 0 or 1 (anything but a zero will return measures from channel 1)
19
* mosi = Master Out, Slave In
20
* miso = Master In, Slave Out
21
* clk = bus clock
22
* cs_adc = ADC Chip Select, active low (leave high when not in use)
23
* vref = reference voltage, 2.7-5.5V. Recommend measuring with voltmeter for best results.
24
*
25
* RETURN: Returns a floating-point value which is the voltage on the MCP3002, which should be
26
* somewhere between GND and VREF.
27
* Returns -1.0 if MOSI, MISO, CLK, CS, or VREF are -1 (happens when not initialized).
28
*/
29
30
float
MCP3202_getVolts(
int
ch,
int
mosi,
int
miso,
int
clk,
int
csin
,
float
vref);
31
32
float
MCP3002_getVolts(
int
ch,
int
mosi,
int
miso,
int
clk,
int
csin
,
float
vref);
33
34
float
spi_adc(
int
ch,
int
mosi,
int
miso,
int
clk,
int
csin
,
float
vref,
int
bits);
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
csin
double complex csin(double complex z)
Complex sine function.
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17