PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
MAX6675_Demo.cpp

Read the current temperature and print it to the terminal

cmake_minimum_required(VERSION 3.12)
find_package(PropWare REQUIRED)
project(MAX6675_Demo)
create_simple_executable(${PROJECT_NAME} MAX6675_Demo.cpp)
static const Port::Mask MOSI = Port::Mask::P0;
static const Port::Mask MISO = Port::Mask::P1;
static const Port::Mask SCLK = Port::Mask::P2;
static const Port::Mask CS = Port::Mask::P5;
int main() {
SPI spi = SPI::get_instance();
MAX6675 thermo(spi, MOSI, MISO, SCLK, CS);
// Though this functional call is not necessary (default value is 0), I
// want to bring attention to this function. It will determine whether the
// thermo.read* functions will always explicitly set the SPI modes before
// each call, or assume that the SPI driver is still running in the proper
// configuration
thermo.always_set_spi_mode(1);
pwOut << "Welcome to the MAX6675 demo!\n";
uint16_t data;
while (1) {
data = thermo.read();
pwOut.printf("Temp: %u.%uC\n", data >> 2, (data & 0x3) * 25);
}
}
CS
static const Port::Mask CS
Definition: MAX6675_Demo.cpp:40
PropWare::Printer::printf
void printf(const char fmt[], const T first, const Targs... remaining) const
Similar in functionality to the C-standard function printf.
Definition: printer.h:497
PropWare::SPI
SPI serial communications library; Core functionality comes from a dedicated assembly cog.
Definition: spi.h:43
SCLK
static const Port::Mask SCLK
Definition: MAX6675_Demo.cpp:38
max6675.h
PropWare::Port
Flexible port that can have any pin enabled or disabled. Pins are independent of each other.
Definition: port.h:38
main
int main(void)
Definition: GraphicsTest.c:20
PropWare.h
CLKFREQ
#define CLKFREQ
Returns the current clock frequency.
Definition: propeller.h:46
MISO
static const Port::Mask MISO
Definition: MAX6675_Demo.cpp:36
pwOut
PropWare::Printer pwOut
Most common use of printing in PropWare applications (not thread safe; see PropWare::pwSyncOut for mu...
waitcnt
#define waitcnt(a)
Wait until system counter reaches a value.
Definition: propeller.h:176
CNT
#define CNT
The system clock count.
Definition: propeller1.h:151
MOSI
static const Port::Mask MOSI
Definition: MAX6675_Demo.cpp:34
SPI
Definition: SPI.h:11
PropWare
Generic definitions and functions for the Parallax Propeller.
Definition: runnable.h:33
PropWare::MAX6675
K-type thermocouple amplifier driver using SPI communication for the Parallax Propeller.
Definition: max6675.h:36