Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

SPI Digital I/O
[Special Hardware]

Collaboration diagram for SPI Digital I/O:


Detailed Description

SPI controlled digital input and output ports.

This simple driver supports digital I/O ports like relay outputs and optocoupler inputs.


Functions

u_long SpiDigitalGet (ureg_t num)
 Query digital inputs.
void SpiDigitalSet (ureg_t num, u_long bits)
 Set digital outputs.
void SpiDigitalInit (ureg_t *inputs, ureg_t *outputs)
 Initialize the digital I/O shift register interface.


Function Documentation

u_long SpiDigitalGet ureg_t  num  ) 
 

Query digital inputs.

SpiDigitalInit() must have been called by the application before calling this function.

This routine does not check the validity of the parameter.

Parameters:
num Number of bits to query, typically 8, 16, 24 or the maximum value of 32. This number should exactly match the number of input pins. If it is lower, only the most significant bits are returned. However, this may be used by an application to scan these bits more often with reduced overhead.
Returns:
Binary value of the requested inputs. Only the specified number of bits are used. Bit 0 is the one, which has been shifted out last.

void SpiDigitalSet ureg_t  num,
u_long  bits
 

Set digital outputs.

SpiDigitalInit() must have been called by the application before calling this function.

This routine does not check the validity of any parameter.

Parameters:
num Number of bits to set, typically 8, 16, 24 or 32, which is the maximum. The number must not be lower than the number of shift register output bits.
bits The bit value to set. Only the number of bits specified are used, of which the most significant bit is shifted in first.

void SpiDigitalInit ureg_t *  inputs,
ureg_t *  outputs
 

Initialize the digital I/O shift register interface.

This routine must be called before using the interface.

Automatically detects the number of digital inputs and outputs. However, the method used is limited and may fail on fast changing inputs. The application should check the result for plausibility. It is save to call the routine more than once.

Parameters:
inputs Pointer to an 8-bit value, where the number of detected inputs will be stored.
outputs Pointer to an 8-bit value, where the number of detected outputs will be stored.


© 2000-2006 by egnite Software GmbH - visit http://www.ethernut.de/