csi_hwserial.h File Reference

Hardware dependent serial driver interface. More...

#include "csi_const.h"
#include "csi_err.h"
#include "csi_types.h"
#include "csi_plfabstr.h"
+ Include dependency graph for csi_hwserial.h:
+ This graph shows which files directly or indirectly include this file:

Functions

CSI_API long CsiHwBufWr (struct CsiSerChannel *pChan, const uint8_t *pTxBuf, uint32_t BufSize)
 Transmit data from buffer over serial channel. More...
 
CSI_API void CsiHwFreePortList (char **PortNames)
 Frees resources allocated by a call to CsiHwListPortNames. More...
 
CSI_API long CsiHwListPortNames (char ***PortNames)
 Returns a list of available ports. More...
 
CSI_API long CsiHwSerChangeBaudrate (struct CsiSerChannel *pChan, uint32_t Baudrate)
 Change baudrate of open serial channel. More...
 
CSI_API long CsiHwSerCloseChannel (struct CsiSerChannel *pChan)
 Closes serial connection. More...
 
CSI_API long CsiHwSerGetChar (struct CsiSerChannel *pChan, uint8_t *pRxChar)
 Reads one single serial character from serial channel. More...
 
CSI_API long CsiHwSerGetCharNonblock (struct CsiSerChannel *pChan, uint8_t *pRxChar)
 Reads one single serial character from serial channel. More...
 
CSI_API long CsiHwSerGetCharTimeout (struct CsiSerChannel *pChan, uint8_t *pRxChar, uint32_t MsTimeout)
 Reads one single serial character from serial channel. More...
 
CSI_API long CsiHwSerOpenChannel (struct CsiSerChannel *pChan)
 Initializes serial channel configuration data and opens serial connection. More...
 
CSI_API long CsiHwSerPurgeRxBuf (struct CsiSerChannel *pChan, uint32_t MsTimeout)
 Purges receive buffer. More...
 
CSI_API long CsiHwSerPutChar (struct CsiSerChannel *pChan, uint8_t TxChar)
 Send one single serial character over serial channel. More...
 
CSI_API long CsiHwSerRead (struct CsiSerChannel *pChan, uint8_t *pRxBuf, uint32_t BufSize, uint32_t MsTimeout)
 Read bytes from the specified serial port. More...
 
CSI_API long CsiSerOpenChannel (struct CsiSerChannel *pChan, const char *DeviceName, uint32_t BaudRate)
 This is a hardware independent function to open a serial channel. More...
 

Detailed Description

Hardware dependent serial driver interface.

Author
Uwe Kindler (UK)
Date
2009/08/25 This file defines the interface for the hardware dependent serial device driver. This driver need to be implemented by the user of the RS232 Common Serial Interface (CSI) library. The hardware independent driver calls into the hardware dependent driver to execute data transfers.

Function Documentation

CSI_API long CsiHwBufWr ( struct CsiSerChannel pChan,
const uint8_t *  pTxBuf,
uint32_t  BufSize 
)

Transmit data from buffer over serial channel.

Parameters
[in]pChanSerial transmit channel
[in]pTxBufpTxBuf Points to buffer containing transmit data
[in]BufSizeNumber of bytes in pTxBuf
Returns
Number of bytes written to serial channel
CSI_API void CsiHwFreePortList ( char **  PortNames)

Frees resources allocated by a call to CsiHwListPortNames.

Parameters
[in]PortNamesA list of dynamically allocated port names to free
Note
You need to call CsiHwFreePortList afterwards to free resources allocated by this function.
CSI_API long CsiHwListPortNames ( char ***  PortNames)

Returns a list of available ports.

Note
You need to call CsiHwFreePortList afterwards to free resources allocated by this function.
Parameters
[out]PortNamesReturns a array of port names allocated on the heap
Return values
>=0 Number of list entries in PortNames
-1Error occurred listing port names
CSI_API long CsiHwSerChangeBaudrate ( struct CsiSerChannel pChan,
uint32_t  Baudrate 
)

Change baudrate of open serial channel.

Parameters
[in]pChanSerial channel to change
[in]BaudrateNew baudrate value to set
Returns
Error code - CSI_ERR_NOERR indicates success
CSI_API long CsiHwSerCloseChannel ( struct CsiSerChannel pChan)

Closes serial connection.

Parameters
[in]pChanSerial channel to close
Returns
Error code - CSI_ERR_NOERR indicates success

Referenced by CsiBusClose().

CSI_API long CsiHwSerGetChar ( struct CsiSerChannel pChan,
uint8_t *  pRxChar 
)

Reads one single serial character from serial channel.

This is a blocking call. That means, the function does not return until one character was received sucesfully.

Parameters
[in]pChanSerial channel to read from
[out]pRxCharBuffer for received character
Returns
Error code - CSI_ERR_NOERR indicates success
CSI_API long CsiHwSerGetCharNonblock ( struct CsiSerChannel pChan,
uint8_t *  pRxChar 
)

Reads one single serial character from serial channel.

This is a nonblocking call. If no character is available or was received by hardware then this function returns immediatelly

Parameters
[in]pChanSerial channel to read from
[out]pRxCharBuffer for received character
Return values
CSI_ERR_NOERRChar successful received
-ERR_COMM_DLL_TIMEOUTNo character received
CSI_API long CsiHwSerGetCharTimeout ( struct CsiSerChannel pChan,
uint8_t *  pRxChar,
uint32_t  MsTimeout 
)

Reads one single serial character from serial channel.

This is a nonblocking call. The call returns after a character was succesfully received or after the timeout expired.

Parameters
[in]pChanSerial channel to read from
[out]pRxCharBuffer for received character
[in]MsTimeoutTimeout in milliseconds the function waits for char
Return values
ERR_NOERR= success
-ERR_DLL_TIMEOUTtimeout
<0 Error
CSI_API long CsiHwSerOpenChannel ( struct CsiSerChannel pChan)

Initializes serial channel configuration data and opens serial connection.

Parameters
[in]pChanSerial channel to initialise
Returns
Error code - CSI_ERR_NOERR indicates success

Referenced by CsiBusOpen(), and CsiSerOpenChannel().

CSI_API long CsiHwSerPurgeRxBuf ( struct CsiSerChannel pChan,
uint32_t  MsTimeout 
)

Purges receive buffer.

Parameters
[in]pChanSerial channel to purge rx buffer
[in]MsTimeoutTimeout in milliseconds
Returns
Error code. CSI_ERR_ENOERR indicates success
CSI_API long CsiHwSerPutChar ( struct CsiSerChannel pChan,
uint8_t  TxChar 
)

Send one single serial character over serial channel.

Parameters
[in]pChanSerial channel
[in]TxCharCharacter to send
Returns
Error code - CSI_ERR_ENOERR indicates success
CSI_API long CsiHwSerRead ( struct CsiSerChannel pChan,
uint8_t *  pRxBuf,
uint32_t  BufSize,
uint32_t  MsTimeout 
)

Read bytes from the specified serial port.

Parameters
[in]pChanSerial transmit channel
[in]pRxBufpTxBuf Points to buffer that store received bytes
[in]BufSizeSize of buffer given in pRxBuf and number of bytes to read
[in]MsTimeoutTimeout in milliseconds. A value of 0 indicates a nonblocking call all all available bytes are read. If a timeout is given, the function blocks until the BufSize bytes have been read or until timeout.
Return values
>=0 Number of bytes read from serial port. A value < BufSize indicates a timeout
<0Error code
CSI_API long CsiSerOpenChannel ( struct CsiSerChannel pChan,
const char *  DeviceName,
uint32_t  BaudRate 
)

This is a hardware independent function to open a serial channel.

This function calls CsiHwSerOpenChannel to open the serial channel with the given parameters

Parameters
[in]pChanSerial channel to initialize
[in]DeviceNameName of the serial device to open (i.e. COM1)
[in]BaudRateThe baud rate to use for communication
Returns
Error code - CSI_ERR_NOERR indicates success
21 {
22  pChan->pPriv = 0;
23  pChan->BaudRate = BaudRate;
24  strncpy(pChan->DeviceName, DeviceName, sizeof(pChan->DeviceName));
25  return CsiHwSerOpenChannel(pChan);
26 }
CSI_API long CsiHwSerOpenChannel(struct CsiSerChannel *pChan)
Initializes serial channel configuration data and opens serial connection.
char DeviceName[64]
stores the device name
Definition: csi_types.h:59
uint32_t BaudRate
baudrate of serial channel
Definition: csi_types.h:57
void * pPriv
pointer to private data
Definition: csi_types.h:58

+ Here is the call graph for this function: