Hardware dependent serial driver interface. More...
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.
- 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] pChan Serial transmit channel [in] pTxBuf pTxBuf Points to buffer containing transmit data [in] BufSize Number 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] PortNames A 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] PortNames Returns a array of port names allocated on the heap
- Return values
-
>= 0 Number of list entries in PortNames -1 Error occurred listing port names
CSI_API long CsiHwSerChangeBaudrate | ( | struct CsiSerChannel * | pChan, |
uint32_t | Baudrate | ||
) |
Change baudrate of open serial channel.
- Parameters
-
[in] pChan Serial channel to change [in] Baudrate New baudrate value to set
- Returns
- Error code - CSI_ERR_NOERR indicates success
CSI_API long CsiHwSerCloseChannel | ( | struct CsiSerChannel * | pChan | ) |
Closes serial connection.
- Parameters
-
[in] pChan Serial 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] pChan Serial channel to read from [out] pRxChar Buffer 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] pChan Serial channel to read from [out] pRxChar Buffer for received character
- Return values
-
CSI_ERR_NOERR Char successful received -ERR_COMM_DLL_TIMEOUT No 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] pChan Serial channel to read from [out] pRxChar Buffer for received character [in] MsTimeout Timeout in milliseconds the function waits for char
- Return values
-
ERR_NOERR = success -ERR_DLL_TIMEOUT timeout < 0 Error
CSI_API long CsiHwSerOpenChannel | ( | struct CsiSerChannel * | pChan | ) |
Initializes serial channel configuration data and opens serial connection.
- Parameters
-
[in] pChan Serial 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] pChan Serial channel to purge rx buffer [in] MsTimeout Timeout 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] pChan Serial channel [in] TxChar Character 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] pChan Serial transmit channel [in] pRxBuf pTxBuf Points to buffer that store received bytes [in] BufSize Size of buffer given in pRxBuf and number of bytes to read [in] MsTimeout Timeout 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 <0 Error 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] pChan Serial channel to initialize [in] DeviceName Name of the serial device to open (i.e. COM1) [in] BaudRate The baud rate to use for communication
- Returns
- Error code - CSI_ERR_NOERR indicates success