ModmataC  1.0
A C library for Arduino communication
Functions
ModmataC.c File Reference
#include "ModmataC.h"
Include dependency graph for ModmataC.c:

Functions

void closeConnection ()
 
void delay (int millis)
 
void delayMicroseconds (int micros)
 
int isValidPin (int pinNum)
 
int connectArduino (char *port, int baudRate, int id)
 
void pinMode (uint8_t pinNum, uint8_t mode)
 
void digitalWrite (uint8_t pinNum, uint8_t input)
 
int digitalRead (uint8_t pinNum)
 
void analogWrite (uint8_t pinNum, uint16_t input)
 
int analogRead (uint16_t pinNum)
 
void servoAttach (uint16_t pinNum)
 
void servoDetach (uint16_t pinNum)
 
void servoWrite (uint16_t pinNum, uint16_t input)
 
int servoRead (uint16_t pinNum)
 
void wireBegin ()
 
void wireEnd ()
 
void wireSetClock (uint32_t clock_speed)
 
void wireWrite (uint8_t addr, uint8_t reg, uint8_t num_bytes, uint8_t *data)
 
uint8_t * wireRead (uint8_t addr, uint8_t reg, int num_bytes)
 
void spiBegin ()
 
uint8_t * spiTransferBuf (int CS_pin, uint8_t *buf, uint8_t length)
 
void spiSettings (uint32_t speed, uint8_t order, uint8_t mode)
 
void spiEnd ()
 
void transmitRegisters (uint8_t fn_code, uint8_t argc, uint8_t *argv)
 

Function Documentation

◆ analogRead()

int analogRead ( uint16_t  pinNum)

Reads the value of an analog pin

Parameters
(uint8_t)address
(uint8_t)register
(uint8_t)number of bytes to read
Returns
(uint8_t*) pointer to the data that was read
Examples
pot.c, and pot_servo.c.

◆ analogWrite()

void analogWrite ( uint8_t  pinNum,
uint16_t  input 
)

Writes an analog value to a pin

Parameters
(uint8_t)pin number
(uint16_t)value to write
Returns
(void)
Examples
pot.c.

◆ closeConnection()

void closeConnection ( )

disconnect modbus connection if the program does not have an infinite loop

Parameters
none
Returns
void
Examples
ds1631_temperature.c, lcd.c, nrf24l01_radio.c, and servo.c.

◆ connectArduino()

int connectArduino ( char *  port,
int  baudRate,
int  id 
)

Start serial connection using specified port and baud rate

Parameters
(char*)path to the port on which Leonardo is connected
(int)baud rate
(int)slave id for Leonardo
Returns
(int) 1 if successful, 0 if unsuccessful
Examples
blink.c, button.c, ds1631_temperature.c, lcd.c, nrf24l01_radio.c, pot.c, pot_servo.c, and servo.c.

◆ delay()

void delay ( int  millis)

Causes the system to delay a number of miliseconds

Parameters
(int)milliseconds
Returns
void
Examples
blink.c, ds1631_temperature.c, nrf24l01_radio.c, and servo.c.

◆ delayMicroseconds()

void delayMicroseconds ( int  micros)
Examples
nrf24l01_radio.c.

◆ digitalRead()

int digitalRead ( uint8_t  pinNum)

Reads the value of a digital pin

Parameters
(uint8_t)pin number
Returns
(int) value
Examples
button.c, and nrf24l01_radio.c.

◆ digitalWrite()

void digitalWrite ( uint8_t  pinNum,
uint8_t  input 
)

Writes a HIGH or LOW value to a digital pin

Parameters
(uint8_t)pin number
(uint8_t)input, should be 1 or 0
Returns
(void)
Examples
blink.c, button.c, and nrf24l01_radio.c.

◆ isValidPin()

int isValidPin ( int  pinNum)

Checks if a pin number is valid The leonardo has pins 1-30

Parameters
(int)pint number
Returns
(int) 1 if pin is valid, 0 if invalid

◆ pinMode()

void pinMode ( uint8_t  pinNum,
uint8_t  mode 
)

Sets pin mode

Parameters
(uint8_t)pin number
(uint8_t)pin mode
Returns
(void)
Examples
blink.c, button.c, nrf24l01_radio.c, pot.c, and pot_servo.c.

◆ servoAttach()

void servoAttach ( uint16_t  pinNum)

Attach servo to a pin

Parameters
(uint16_t)pin number
Returns
(void)
Examples
pot_servo.c, and servo.c.

◆ servoDetach()

void servoDetach ( uint16_t  pinNum)

Detach servo from a pin

Parameters
(uint16_t)pin number
Returns
(void)
Examples
servo.c.

◆ servoRead()

int servoRead ( uint16_t  pinNum)

Reads the last value written to a servo

Parameters
(uint16_t)pin number
Returns
(int) the last value written to the servo

◆ servoWrite()

void servoWrite ( uint16_t  pinNum,
uint16_t  input 
)

Write values to a servo assigned pin

Parameters
(uint16_t)pin number
(uint16_t)angle value to be written
Returns
(void)
Examples
pot_servo.c, and servo.c.

◆ spiBegin()

void spiBegin ( )

Begins SPI communication with default settings (4 Mbps, MSBFIRST, SPI_MODE0)

Returns
(void)
Examples
nrf24l01_radio.c.

◆ spiEnd()

void spiEnd ( )

End SPI communication

Returns
(void)

◆ spiSettings()

void spiSettings ( uint32_t  speed,
uint8_t  order,
uint8_t  mode 
)

Set specific SPI settings such as communication speed, bit order, and mode

Parameters
(uint32_t)Communication speed
(uint8_t)bit order (MSBFIRST or LSBFIRST)
(uint8_t)data mode (SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3)
Returns
(void)

◆ spiTransferBuf()

uint8_t* spiTransferBuf ( int  CS_pin,
uint8_t *  buf,
uint8_t  length 
)

Transfer an array of bytes over SPI

Parameters
(int)Chip Select pin number
(uint8_t*)Array of bytes to transfer over MOSI
(uint8_t)Array length
Returns
(uint8_t*) Array of bytes sent back over MISO
Examples
nrf24l01_radio.c.

◆ transmitRegisters()

void transmitRegisters ( uint8_t  fn_code,
uint8_t  argc,
uint8_t *  argv 
)

Send bytes over Modmata. For use in custom Modmata functions

Returns
(void)
Examples
lcd.c.

◆ wireBegin()

void wireBegin ( )

Begins an I2C connection

Returns
(void)
Examples
ds1631_temperature.c.

◆ wireEnd()

void wireEnd ( )

Terminates an I2C connection

Returns
(void)

◆ wireRead()

uint8_t* wireRead ( uint8_t  addr,
uint8_t  reg,
int  num_bytes 
)

Reads data from an I2C connection

Parameters
(uint8_t)address
(uint8_t)register
(uint8_t)number of bytes to read
Returns
(uint8_t*) pointer to the data that was read
Examples
ds1631_temperature.c.

◆ wireSetClock()

void wireSetClock ( uint32_t  clock_speed)

Sets I2C clock speed

Parameters
(int)clock speed
Returns
(void)

◆ wireWrite()

void wireWrite ( uint8_t  addr,
uint8_t  reg,
uint8_t  num_bytes,
uint8_t *  data 
)

Writes data over an I2C connection

Parameters
(uint8_t)address
(uint8_t)register
(uint8_t)number of bytes to be written
(uint8_t)data being written
Returns
(void)
Examples
ds1631_temperature.c.