Modmata  v0
An arduino communications server using Modbus
Classes | Macros | Functions
Functions.h File Reference

Header file for 'Functions.cpp'. More...

#include <stdlib.h>
#include <stdint.h>
#include <Arduino.h>
#include <Servo.h>
#include <Wire.h>
#include <SPI.h>
Include dependency graph for Functions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  registers
 A data structure to describe function arguments and return values. More...
 
struct  spi_settings
 A data structure to describe a SPI connection's configuration settings. Essentially the same as Arduino's 'SPIsettings' object. More...
 

Macros

#define makeDWord(i0, i1, i2, i3)   ((uint32_t) (i0 << 24 | i1 << 16 | i2 << 8 | i3))
 Combine four 8-bit integral types into one 32-bit integral type, or in simpler terms, reassemble a uint32_t from four uint8_t's.
 
#define IDLE   0
 
#define PINMODE   1
 
#define DIGITALWRITE   2
 
#define DIGITALREAD   3
 
#define ANALOGREFERENCE   4
 
#define ANALOGWRITE   5
 
#define ANALOGREAD   6
 
#define SERVOATTACH   7
 
#define SERVODETACH   8
 
#define SERVOWRITE   9
 
#define SERVOREAD   10
 
#define WIREBEGIN   11
 
#define WIREEND   12
 
#define WIRECLOCK   13
 
#define WIREWRITE   14
 
#define WIREREAD   15
 
#define SPIBEGIN   16
 
#define SPISETTINGS   17
 
#define SPITRANSFER   18
 
#define SPIEND   19
 

Functions

struct registers pinMode (uint8_t argc, uint8_t *argv)
 Change the settings of the Arduino I/O pins. More...
 
struct registers digitalWrite (uint8_t argc, uint8_t *argv)
 Write a digital (HIGH/LOW) value to the Arduino I/O pins. More...
 
struct registers digitalRead (uint8_t argc, uint8_t *argv)
 Read a digital value (HIGH/LOW) from the Arduino I/O pins. More...
 
struct registers analogWrite (uint8_t argc, uint8_t *argv)
 Write an analog value (0-255) to the Arduino I/O pins. More...
 
struct registers analogRead (uint8_t argc, uint8_t *argv)
 Read an analog value (0-1023) from the Arduino I/O pins. More...
 
struct registers servoAttach (uint8_t argc, uint8_t *argv)
 Attach a connected servo to a control interface. More...
 
struct registers servoDetach (uint8_t argc, uint8_t *argv)
 Detach a servo from the the control interface. More...
 
struct registers servoWrite (uint8_t argc, uint8_t *argv)
 Write a value to the connected servo. More...
 
struct registers servoRead (uint8_t argc, uint8_t *argv)
 Read a value from the connected servo. More...
 
struct registers wireBegin (uint8_t argc, uint8_t *argv)
 Begin an I2C connection between the Arduino and a peripheral. More...
 
struct registers wireEnd (uint8_t argc, uint8_t *argv)
 End an I2C connection between the Arduino and a peripheral. More...
 
struct registers wireSetClock (uint8_t argc, uint8_t *argv)
 Change the clock speed settings of the I2C connection. More...
 
struct registers wireWrite (uint8_t argc, uint8_t *argv)
 Write data to the connected I2C peripheral. More...
 
struct registers wireRead (uint8_t argc, uint8_t *argv)
 Read data from the connected I2C peripheral. More...
 
struct registers spiBegin (uint8_t argc, uint8_t *argv)
 Begin a SPI connection between the Arduino and a peripheral. More...
 
struct registers spiSettings (uint8_t argc, uint8_t *argv)
 Change the settings of the SPI connection. More...
 
struct registers spiTransferBuf (uint8_t argc, uint8_t *argv)
 Exchange data over the SPI connection (Read + Write) More...
 
struct registers spiEnd (uint8_t argc, uint8_t *argv)
 End a SPI connection between the Arduino and a peripheral. More...
 

Detailed Description

Header file for 'Functions.cpp'.

Author
Sam Hutcherson, Chase Wallendorff, Iris Astrid
Date
2023-04-06

Definition in file Functions.h.


Class Documentation

◆ registers

struct registers

A data structure to describe function arguments and return values.

Parameters
countThe number of arguments contained within the array 'value'.
valueA pointer to an array of bytes (8-bit integral types) that contains the values of the arguments or return values for a command.

Definition at line 59 of file Functions.h.

Class Members
uint8_t count

The number of arguments contained within the array 'value'.

uint8_t * value

A pointer to an array of bytes (8-bit integral types) that contains the values of the arguments or return values for a command.

◆ spi_settings

struct spi_settings

A data structure to describe a SPI connection's configuration settings. Essentially the same as Arduino's 'SPIsettings' object.

Parameters
speedThe baud rate/clock speed of the connection.
orderThe order of bits sent over the wire
modeThe clock polarity and phase

Definition at line 74 of file Functions.h.

Class Members
uint8_t mode

The clock polarity and phase.

bool order

The order of bits sent over the wire.

uint32_t speed

The baud rate/clock speed of the connection.

Function Documentation

◆ analogRead()

struct registers analogRead ( uint8_t  argc,
uint8_t *  argv 
)

Read an analog value (0-1023) from the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (1)
argvThe arguments to use within the function (pin #)
Returns
struct containing the value of pin (10-bit unsigned int contained within a uint16_t)

Definition at line 29 of file Functions.cpp.

◆ analogWrite()

struct registers analogWrite ( uint8_t  argc,
uint8_t *  argv 
)

Write an analog value (0-255) to the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (3)
argvThe arguments to use within the function (pin #, 16-bit value split into 2 8-bit values)
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ digitalRead()

struct registers digitalRead ( uint8_t  argc,
uint8_t *  argv 
)

Read a digital value (HIGH/LOW) from the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (1)
argvThe arguments to use within the function (pin #)
Returns
struct containing the value of pin (1 uint8_t)

Definition at line 29 of file Functions.cpp.

◆ digitalWrite()

struct registers digitalWrite ( uint8_t  argc,
uint8_t *  argv 
)

Write a digital (HIGH/LOW) value to the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (2)
argvThe arguments to use within the function (pin #, value)
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ pinMode()

struct registers pinMode ( uint8_t  argc,
uint8_t *  argv 
)

Change the settings of the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (2)
argvThe arguments to use within the function (pin #, mode)
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ servoAttach()

struct registers servoAttach ( uint8_t  argc,
uint8_t *  argv 
)

Attach a connected servo to a control interface.

Parameters
argcThe number of arguments contained within the 'argv' array (1)
argvThe arguments to use within the function (pin #)
Returns
struct containing the ServoIndex (uint8_t), I have no idea what it actually means though (undocumented on Arduino???)

Definition at line 29 of file Functions.cpp.

◆ servoDetach()

struct registers servoDetach ( uint8_t  argc,
uint8_t *  argv 
)

Detach a servo from the the control interface.

Parameters
argcThe number of arguments contained within the 'argv' array (1)
argvThe arguments to use within the function (pin #)
Returns
struct containing the boolean value of the operation's success (uint8_t)

Definition at line 29 of file Functions.cpp.

◆ servoRead()

struct registers servoRead ( uint8_t  argc,
uint8_t *  argv 
)

Read a value from the connected servo.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
struct containing the last value written to the servo (uint8_t)

Definition at line 29 of file Functions.cpp.

◆ servoWrite()

struct registers servoWrite ( uint8_t  argc,
uint8_t *  argv 
)

Write a value to the connected servo.

Parameters
argcThe number of arguments contained within the 'argv' array (2)
argvThe arguments to use within the function (pin #, value)
Returns
struct containing the boolean value of the operation's success (uint8_t)

Definition at line 29 of file Functions.cpp.

◆ spiBegin()

struct registers spiBegin ( uint8_t  argc,
uint8_t *  argv 
)

Begin a SPI connection between the Arduino and a peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ spiEnd()

struct registers spiEnd ( uint8_t  argc,
uint8_t *  argv 
)

End a SPI connection between the Arduino and a peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array (0)
argvThe arguments to use within the function (None)
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ spiSettings()

struct registers spiSettings ( uint8_t  argc,
uint8_t *  argv 
)

Change the settings of the SPI connection.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ spiTransferBuf()

struct registers spiTransferBuf ( uint8_t  argc,
uint8_t *  argv 
)

Exchange data over the SPI connection (Read + Write)

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
struct containing the response to the command written (argc - 1 * uint8_t)

Definition at line 29 of file Functions.cpp.

◆ wireBegin()

struct registers wireBegin ( uint8_t  argc,
uint8_t *  argv 
)

Begin an I2C connection between the Arduino and a peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ wireEnd()

struct registers wireEnd ( uint8_t  argc,
uint8_t *  argv 
)

End an I2C connection between the Arduino and a peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ wireRead()

struct registers wireRead ( uint8_t  argc,
uint8_t *  argv 
)

Read data from the connected I2C peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
struct containing the bytes read (num_bytes * uint8_t)

Definition at line 29 of file Functions.cpp.

◆ wireSetClock()

struct registers wireSetClock ( uint8_t  argc,
uint8_t *  argv 
)

Change the clock speed settings of the I2C connection.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ wireWrite()

struct registers wireWrite ( uint8_t  argc,
uint8_t *  argv 
)

Write data to the connected I2C peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.