DigitalIO Module

Description

Provides the common functions for declaring, defining, configuring, reading, and writing IO data in an object-oriented fashion, so that lower-level functions do not directly read, write, or change IO port data.

 

C32Register

Custom datatype that must be defined as the standard port register bit-width.  For the C32 this is an unsigned char.

InputT

InputT is a custom structure containing all of the information necessary for reading data from an input port.

            DirPort – type C32Register - holder for the pointer to the direction register

Port – type C32Register - holder for the pointer to the data register

            BitMask - type C32Register - defines which bits are configured as an input

OutputT

OutputT is a custom structure containing all of the information necessary for readingand writing data to an output port.

            DirPort – type C32Register - holder for the pointer to the direction register

Port – type C32Register - holder for the pointer to the data register

            BitMask - type C32Register - defines which bits are configured as an output.

CreatePortEInput(BitMask),
CreatePortTInput(BitMask),
CreatePortMInput(BitMask),
CreatePortADInput(BitMask)

These functions create input variables and possibly configure bits for each port.  They return type InputT with Input configuration data.

BitMask - type C32Register - the configuration for each bit. 1 means that bit will be configured/used as an input.

CreatePortTOutput(BitMask),
CreatePortMOutput(BitMask),
CreatePortADOutput(BitMask)

These functions create output variables and possibly configure bits for each port and return type OutputT with Output configuration data.

BitMask - type C32Register - the configuration for each bit. 1 means that bit will be configured/used as an output

InputRead(Input)

InputRead() reads the value of input bits located in the configured Input variable.  InputRead() only returns the value of bits configured in Input, and sets all other bits to zero, in type C32Register

Input - type InputT - holds configuration data

OutputRead(Output)

OutputRead() reads the value of output bits located in the configured Output variable.  OutputRead() only returns the value of bits configured in Output, and sets all other bits to zero, in type C32Register

Output- type OutputT - holds configuration data

OutputWrite(Output,Value)

This function takes 2 variables an OutputT and a number of type and returns nothing

It writes the value in the second variable into the output indicated

InputConfig(DirPort,Port,BitMask)

InputConfig is a module function for modifying direction registers on configurable IO ports. Returns type InputT with Input configuration data.

            DirPort - type C32Register - the pointer to the direction register

            Port - type C32Register - the pointer to the data register

            BitMask - type C32Register - the configuration for each bit. 1 means that bit will be configured/used as an input

OutputConfig(DirPort,Port,BitMask)

OutputConfig is a module function for modifying direction registers on configurable IO ports.  Returns type OutputT with Output configuration data.

            DirPort - type C32Register - the pointer to the direction register

            Port - type C32Register - the pointer to the data register

BitMask - type C32Register - the configuration for each bit. 1 means that bit will be configured/used as an output

Implementation

CreatePortEInput(BitMask)

Create variable Input of type InputT

Update the internal memory of Input with pointers for port E.

Set the bitmask for Input equal to BitMask

Return Input

CreatePortTInput(BitMask)

return the result of InputConfig with pointers for port T and BitMask

CreatePortMInput(BitMask)

Return the result of InputConfig with pointers for port M and BitMask

CreatePortADInput(BitMask)

Create variable Input of type InputT

Update the internal memory of Input with pointers for port AD.

Set the bitmask for Input equal to BitMask

Return Input

CreatePortTOutput(BitMask)

Return the result of OutputConfig with pointers for port T and BitMask

OutputT CreatePortMOutput(C32Register BitMask)

Return the result of OutputConfig with pointers for port M and BitMask

OutputT CreatePortADOutput(C32Register BitMask)

Create variable Output of type OutputT

Update the internal memory of Output with pointers for port AD

Set output.bitmask equal to BitMask.

Return Output

InputConfig(*DirPort, *Port, BitMask)

Create variable Input of type InputT

Set internal variables equal to input variables

Modify the port's direction register with 0's in the bitmasked locations   

Return Input

OutputConfig(*DirPort, *Port, BitMask)

Create variable Output of type OutputT

Set internal variables equal to input variables

Modify the port's direction register with 1's in the bitmasked locations   

Return Output

InputRead(Input)

Return the data register bitmasked with Input.BitMask

OutputRead(Output)

Return the data register bitmasked with Output.BitMask

OutputWrite(Output, Value)

Create temporary variables a and b of type C32Register

Set a equal to the bits we want to change

Set b equal to the bits we don't want to change

Bitwise-or a and b together and set the data register equal to that value.