|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Go to the documentation of this file.
38 static const MCP3xxx::PartNumber
PART_NUMBER = MCP3xxx::PartNumber::MCP300x;
39 static const MCP3xxx::Channel CHANNEL = MCP3xxx::Channel::CHANNEL_1;
42 static const Port::Mask
MOSI = Port::Mask::P0;
44 static const Port::Mask
MISO = Port::Mask::P1;
46 static const Port::Mask
SCLK = Port::Mask::P2;
48 static const Port::Mask
CS = Port::Mask::P3;
58 const uint16_t DIVISOR = 1024 / 8;
61 uint8_t scaledValue, i;
76 pwOut <<
"Welcome to the MCP3xxx demo!\n";
79 loopCounter = SECOND / 2 +
CNT;
83 while (abs(loopCounter -
CNT) > MILLISECOND) {
84 data = adc.
read(CHANNEL);
87 scaledValue = (uint8_t) ((data + DIVISOR / 2 - 1) / DIVISOR);
89 for (i = 0; i < scaledValue; ++i)
90 ledOutput = (ledOutput << 1) | 1;
91 scale.
write(ledOutput);
94 pwOut.
printf(
"Channel %d is reading: %d\n",
static_cast<int>(CHANNEL), data);
void printf(const char fmt[], const T first, const Targs... remaining) const
Similar in functionality to the C-standard function printf.
void always_set_spi_mode(const bool alwaysSetMode)
Choose whether to always set the SPI mode and bitmode before reading or writing to the ADC; Useful wh...
void write(uint32_t value) const
Allow easy writing to a port w/o destroying data elsewhere in the port; A shift is performed before w...
SPI serial communications library; Core functionality comes from a dedicated assembly cog.
static const Port::Mask CS
Utility class to handle general purpose I/O pins.
uint16_t read(const MCP3xxx::Channel channel)
Read a specific channel's data in single-ended mode.
static const Port::Mask SCLK
Flexible port that can have any pin enabled or disabled. Pins are independent of each other.
MCP3xxx-series ADC driver using SPI communication for the Parallax Propeller. Compatible with the fol...
PropWare::Printer pwOut
Most common use of printing in PropWare applications (not thread safe; see PropWare::pwSyncOut for mu...
#define CNT
The system clock count.
static const Port::Mask MISO
The PropWare::SimplePort is the recommended way to use data ports on the Propeller....
static const MCP3xxx::PartNumber PART_NUMBER
static const Port::Mask MOSI