Developer Docs v3

Macros

#define ADC_PINBASE   65
 
#define ANALOG_OUT_PIN   1
 
#define ARRAY_SIZE(x)   (sizeof((x)) / sizeof((x)[0]))
 
#define DOUT_PINBASE   100
 
#define MAX_INPUT   13
 
#define MAX_OUTPUT   8
 

Functions

void finalizeHardware ()
 Resource clearing. More...
 
void initializeHardware ()
 Initialization procedures. More...
 
int mcp_adcRead (int chan)
 
int mcp_adcSetup (int i2cAddress)
 
void * readAdcThread (void *args)
 
void sleep_ms (int milliseconds)
 
void updateBuffersIn ()
 Update internal buffers. More...
 
void updateBuffersOut ()
 Update output buffers. More...
 

Variables

int adc_fd
 
unsigned int adcBuffer [2]
 
std::mutex adcBufferLock
 
const int inputPinMask [MAX_INPUT] = { 7, 7, 0, 2, 4, 3, 5, 14, 11, 10, 13, 6, 12 }
 

Detailed Description

Macro Definition Documentation

◆ ADC_PINBASE

#define ADC_PINBASE   65

Definition at line 44 of file unipi.cpp.

◆ ANALOG_OUT_PIN

#define ANALOG_OUT_PIN   1

Definition at line 47 of file unipi.cpp.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   x)    (sizeof((x)) / sizeof((x)[0]))

Definition at line 40 of file unipi.cpp.

◆ DOUT_PINBASE

#define DOUT_PINBASE   100

Definition at line 43 of file unipi.cpp.

◆ MAX_INPUT

#define MAX_INPUT   13

Definition at line 45 of file unipi.cpp.

◆ MAX_OUTPUT

#define MAX_OUTPUT   8

Definition at line 46 of file unipi.cpp.

Function Documentation

◆ finalizeHardware()

void finalizeHardware ( )

Resource clearing.

This function is called by the main OpenPLC routine when it is finalizing. Resource clearing procedures should be here.

Definition at line 200 of file unipi.cpp.

◆ initializeHardware()

void initializeHardware ( )

Initialization procedures.

This function is called by the main OpenPLC routine when it is initializing. Hardware initialization procedures should be here.

Definition at line 164 of file unipi.cpp.

◆ mcp_adcRead()

int mcp_adcRead ( int  chan)

Definition at line 146 of file unipi.cpp.

◆ mcp_adcSetup()

int mcp_adcSetup ( int  i2cAddress)

Definition at line 135 of file unipi.cpp.

◆ readAdcThread()

void* readAdcThread ( void *  args)

Definition at line 67 of file unipi.cpp.

◆ sleep_ms()

void sleep_ms ( int  milliseconds)

Definition at line 59 of file unipi.cpp.

◆ updateBuffersIn()

void updateBuffersIn ( )

Update internal buffers.

This function is called by the OpenPLC in a loop. Here the internal buffers must be updated to reflect the actual Input state. The mutex bufferLock must be used to protect access to the buffers on a threaded environment.

Definition at line 209 of file unipi.cpp.

◆ updateBuffersOut()

void updateBuffersOut ( )

Update output buffers.

This function is called by the OpenPLC in a loop. Here the internal buffers must be updated to reflect the actual Output state. The mutex bufferLock must be used to protect access to the buffers on a threaded environment.

Definition at line 232 of file unipi.cpp.

Variable Documentation

◆ adc_fd

int adc_fd

Definition at line 50 of file unipi.cpp.

◆ adcBuffer

unsigned int adcBuffer[2]

Definition at line 51 of file unipi.cpp.

◆ adcBufferLock

std::mutex adcBufferLock

Definition at line 53 of file unipi.cpp.

◆ inputPinMask

const int inputPinMask[MAX_INPUT] = { 7, 7, 0, 2, 4, 3, 5, 14, 11, 10, 13, 6, 12 }

Definition at line 49 of file unipi.cpp.