Peritoneal Dialysis Capstone
Controlling catheter for peritoneal dialysis
Loading...
Searching...
No Matches
ArduinoHAL Class Reference

An implementation of IHAL for Arduino. More...

#include <ArduinoHAL.h>

Inheritance diagram for ArduinoHAL:
Collaboration diagram for ArduinoHAL:

Public Member Functions

 ArduinoHAL (int serialBaud)
AnalogValue analogRead (int pin) override
 Samples an analog input pin.
void analogWrite (int pin, AnalogValue value) override
 Drives an analog output pin.
AnalogValue getMaxAnalogReadQuant () const override
 Returns the maximum quantized value of an analog read.
AnalogValue getMaxAnalogWriteQuant () const override
 Returns the maximum quantized value of an analog write.
void configurePin (int pin, PinMode mode) override
 Configures a pin for use as an input or output.
DigitalValue digitalRead (int pin) override
 Samples a digital input pin.
void digitalWrite (int pin, DigitalValue value) override
 Drives a digital output pin.
void beginSerial () override
 Initializes the serial interface.
size_t print (const char *s) override
 Transmits an ASCII string over serial.
size_t println (const char *s) override
 Transmits an ASCII string with trailing newline over serial.
void delayMs (unsigned long durationMs) override
 Suspends execution for a specified duration in milliseconds.
unsigned long getTimeMs () override
 Returns the number of milliseconds elapsed since the start of execution, modulo ULONG_MAX-1.
Public Member Functions inherited from IHAL
virtual ~IHAL ()=default

Private Attributes

int m_serialBaud

Static Private Attributes

static constexpr AnalogValue MAX_ANALOG_READ_QUANT = 1023
static constexpr AnalogValue MAX_ANALOG_WRITE_QUANT = 255

Detailed Description

An implementation of IHAL for Arduino.

This class provides Arduino-specific implementations of all hardware operations defined in the IHAL interface.

Constructor & Destructor Documentation

◆ ArduinoHAL()

ArduinoHAL::ArduinoHAL ( int serialBaud)

Member Function Documentation

◆ analogRead()

AnalogValue ArduinoHAL::analogRead ( int pin)
overridevirtual

Samples an analog input pin.

The pin must be valid for analog reading.

Parameters
pinThe pin number.
Returns
The quantized value in the range [0, N] where N is the maximum value indicated by getMaxAnalogReadQuant.

Implements IHAL.

◆ analogWrite()

void ArduinoHAL::analogWrite ( int pin,
AnalogValue value )
overridevirtual

Drives an analog output pin.

The pin must be valid for analog writing.

Parameters
pinThe pin number.
valueThe quantized value to write. Must be in the range [0, N] where N is the maximum value indicated by getMaxAnalogWriteQuant.

Implements IHAL.

◆ beginSerial()

void ArduinoHAL::beginSerial ( )
overridevirtual

Initializes the serial interface.

This method must be called before using the serial print functions.

Implements IHAL.

◆ configurePin()

void ArduinoHAL::configurePin ( int pin,
PinMode mode )
overridevirtual

Configures a pin for use as an input or output.

Parameters
pinThe pin number.
modeThe mode (input or output) to set.

Implements IHAL.

◆ delayMs()

void ArduinoHAL::delayMs ( unsigned long durationMs)
overridevirtual

Suspends execution for a specified duration in milliseconds.

Parameters
durationMsThe duration in milliseconds.

Implements IHAL.

◆ digitalRead()

DigitalValue ArduinoHAL::digitalRead ( int pin)
overridevirtual

Samples a digital input pin.

The pin must be valid for digital reading.

Parameters
pinThe pin number.
Returns
The digital value.

Implements IHAL.

◆ digitalWrite()

void ArduinoHAL::digitalWrite ( int pin,
DigitalValue value )
overridevirtual

Drives a digital output pin.

The pin must be valid for digital writing.

Parameters
pinThe pin number.
valueThe digital value to write.

Implements IHAL.

◆ getMaxAnalogReadQuant()

AnalogValue ArduinoHAL::getMaxAnalogReadQuant ( ) const
overridevirtual

Returns the maximum quantized value of an analog read.

For an analog read, a real input value in the range [0, 1] can be obtained by dividing the quantized value by this maximum value.

Implements IHAL.

◆ getMaxAnalogWriteQuant()

AnalogValue ArduinoHAL::getMaxAnalogWriteQuant ( ) const
overridevirtual

Returns the maximum quantized value of an analog write.

For an analog write, a real output value in the range [0, 1] can be converted to a quantized value by multiplying by this maximum value.

Implements IHAL.

◆ getTimeMs()

unsigned long ArduinoHAL::getTimeMs ( )
overridevirtual

Returns the number of milliseconds elapsed since the start of execution, modulo ULONG_MAX-1.

Implements IHAL.

◆ print()

size_t ArduinoHAL::print ( const char * s)
overridevirtual

Transmits an ASCII string over serial.

Parameters
sThe NUL-terminated ASCII string to write.
Returns
The number of bytes written.

Implements IHAL.

◆ println()

size_t ArduinoHAL::println ( const char * s)
overridevirtual

Transmits an ASCII string with trailing newline over serial.

The string s is written, followed by an appropriate end-of-line indicator (e.g., CR-LF).

Parameters
sThe NUL-terminated ASCII string to write.
Returns
The number of bytes written.

Implements IHAL.

Member Data Documentation

◆ m_serialBaud

int ArduinoHAL::m_serialBaud
private

◆ MAX_ANALOG_READ_QUANT

AnalogValue ArduinoHAL::MAX_ANALOG_READ_QUANT = 1023
staticconstexprprivate

◆ MAX_ANALOG_WRITE_QUANT

AnalogValue ArduinoHAL::MAX_ANALOG_WRITE_QUANT = 255
staticconstexprprivate

The documentation for this class was generated from the following files: