io.h File Reference

Basic I/O level handling functions. More...


Typedefs

typedef uint8_t BusData_t
 Bus data type.

Functions

int IO_Open (int Vendor, int Product, int HardIfaces)
 Opens and initilizes the hardware interface.
int IO_Close (void)
 Close and release the hardware interface.
int IO_SetBaudRate (int Baud)
 Change the hardware baudrate.
BusData_t IO_DirMaskRead (void)
 Reads back the full port direction register.
int IO_DirMaskWrite (BusData_t DirMask)
 Sets the full port direction register.
BusData_t IO_DirMaskBitRead (uint16_t Bit)
 Reads back a single bit of direction register.
int IO_DirMaskBitWrite (uint16_t Bit, BusData_t Dir)
 Writes a single bit of direction register.
BusData_t IO_OutDataRead (void)
 Reads back the output data register.
BusData_t IO_InDataRead (void)
 Reads the input data register.
void IO_OutDataWrite (BusData_t Data)
 Writes a new value to the output data register.
BusData_t IO_BitRead (uint16_t Bit)
 Reads a single input bit value.
void IO_BitWrite (uint16_t Bit, BusData_t Value)
 Writes a single output bit value.


Detailed Description

Basic I/O level handling functions.

Author:
Alessandro Accattini
Date:
17 Gen 2020
I/O level is the lowest available level, at this level it is possible to handle single I/O bits (aka single data lines).

Typedef Documentation

typedef uint8_t BusData_t

Bus data type.

Hardware bus is represented by 8 data lines; each line can be configured as input or output indipendently from the others. We need a data type to represent the full bus at once.


Function Documentation

BusData_t IO_BitRead ( uint16_t  Bit  ) 

Reads a single input bit value.

Parameters:
Bit Bit number.
Returns:
Bit value (0 or 1).
Returns a sincronously updated input bit value if Bit is configured as input; returns the last set bit value if Bit is configured as output (i.e. the last value written with IO_BitWrite()).

void IO_BitWrite ( uint16_t  Bit,
BusData_t  Value 
)

Writes a single output bit value.

Parameters:
Bit Bit number (starting from 0).
Value new bit value.
Writes a single output bit value. Writing to a bit configured as input do nothing.

int IO_Close ( void   ) 

Close and release the hardware interface.

Returns:
0 on success.
Close the hardware interface and free all resources; after this call is not possible to call any other function.

BusData_t IO_DirMaskBitRead ( uint16_t  Bit  ) 

Reads back a single bit of direction register.

Parameters:
Bit Bit number (starting from 0).
Returns:
Bit direction.
Reads back a single bit of direction register, bit value is right aligned so that returned value is always 0 or 1.

int IO_DirMaskBitWrite ( uint16_t  Bit,
BusData_t  Dir 
)

Writes a single bit of direction register.

Parameters:
Bit Bit number (starting from 0).
Dir New bit direction (0 or 1).
Returns:
0 on success.
Used to change the direction of a single I/O bit without affecting all the others.

BusData_t IO_DirMaskRead ( void   ) 

Reads back the full port direction register.

Returns:
The bus direction mask.
Used to read back the full bus direction register: each bit in the register defines direction of the corresponding data bit.

int IO_DirMaskWrite ( BusData_t  DirMask  ) 

Sets the full port direction register.

Parameters:
DirMask new direction mask.
Returns:
0 on success.
Overwrite the full bus direction register.

BusData_t IO_InDataRead ( void   ) 

Reads the input data register.

Returns:
The input data register value.
All input data lines are read sincronously.

int IO_Open ( int  Vendor,
int  Product,
int  HardIfaces 
)

Opens and initilizes the hardware interface.

Parameters:
Vendor vendor ID.
Product product ID.
HardIfaces ignored.
Returns:
0 on success.
Searches for hardware interface and initializes low hardware level, must be called before any other function. If this function ends with success all has gone well, in other case hardware interface is not connected or cannot be found. An error message is printed on stderr.

BusData_t IO_OutDataRead ( void   ) 

Reads back the output data register.

Returns:
The output data register value.
Reads back the content of the output data register, to read input data register use IO_InDataRead() instead.

void IO_OutDataWrite ( BusData_t  Data  ) 

Writes a new value to the output data register.

Parameters:
Data New register value.
Writes a new value to the output data register. All output data lines update sincronously.

int IO_SetBaudRate ( int  Baud  ) 

Change the hardware baudrate.

Parameters:
Baud the new baudrate.
Returns:
0 on success.
Changing baudrate can influence the bus speed.


Generated on Tue Apr 14 22:08:57 2020 for libdrivers by  doxygen 1.5.6