|
|
 |
|
|
 |
XAhdlcAvr
|
Defines |
|
#define | NUT_THREAD_AHDLCRXSTACK |
Functions |
| int | AhdlcOutput (NUTDEVICE *dev, NETBUF *nb) |
| | Send HDLC frame.
|
| | AhdlcRx (void *arg) |
| | Asynchronous HDLC receiver thread.
|
| int | AhdlcAvrIOCtl (NUTDEVICE *dev, int req, void *conf) |
| | Perform on-chip UART control functions.
|
| int | AhdlcAvrInit (NUTDEVICE *dev) |
| | Initialize asynchronous HDLC device.
|
| int | AhdlcAvrRead (NUTFILE *fp, void *buffer, int size) |
| | Read from the asynchronous HDLC device.
|
| int | AhdlcAvrPut (NUTDEVICE *dev, CONST void *buffer, int len, int pflg) |
| | Write to the asynchronous HDLC device.
|
| int | AhdlcAvrWrite (NUTFILE *fp, CONST void *buffer, int len) |
| | Write to the asynchronous HDLC device.
|
| int | AhdlcAvrWrite_P (NUTFILE *fp, PGM_P buffer, int len) |
| | Write to the asynchronous HDLC device.
|
| NUTFILE * | AhdlcAvrOpen (NUTDEVICE *dev, CONST char *name, int mode, int acc) |
| | Open the asynchronous HDLC device.
|
| int | AhdlcAvrClose (NUTFILE *fp) |
| | Close the asynchronous HDLC device.
|
Function Documentation
|
|
Close the asynchronous HDLC device.
This function is called by the low level close routine of the C runtime library, using the _NUTDEVICE::dev_close entry.
- Parameters:
-
- Returns:
- 0 on success or -1 otherwise.
|
|
|
Initialize asynchronous HDLC device.
This function will be called during device registration. It initializes the hardware, registers all required interrupt handlers and initializes all internal data structures used by this driver.
- Parameters:
-
| dev | Identifies the device to initialize. |
- Returns:
- 0 on success, -1 otherwise.
|
| int AhdlcAvrIOCtl |
( |
NUTDEVICE * |
dev, |
|
|
int |
req, |
|
|
void * |
conf |
|
) |
|
|
|
|
Perform on-chip UART control functions.
- Parameters:
-
| dev | Identifies the device that receives the device-control function. |
| req | Requested control function. May be set to one of the following constants:
- UART_SETSPEED, conf points to an u_long value containing the baudrate.
- UART_GETSPEED, conf points to an u_long value receiving the current baudrate.
- UART_SETDATABITS, conf points to an u_long value containing the number of data bits, 5, 6, 7 or 8.
- UART_GETDATABITS, conf points to an u_long value receiving the number of data bits, 5, 6, 7 or 8.
- UART_SETPARITY, conf points to an u_long value containing the parity, 0 (no), 1 (odd) or 2 (even).
- UART_GETPARITY, conf points to an u_long value receiving the parity, 0 (no), 1 (odd) or 2 (even).
- UART_SETSTOPBITS, conf points to an u_long value containing the number of stop bits 1 or 2.
- UART_GETSTOPBITS, conf points to an u_long value receiving the number of stop bits 1 or 2.
- UART_SETSTATUS
- UART_GETSTATUS
- UART_SETREADTIMEOUT, conf points to an u_long value containing the read timeout.
- UART_GETREADTIMEOUT, conf points to an u_long value receiving the read timeout.
- UART_SETWRITETIMEOUT, conf points to an u_long value containing the write timeout.
- UART_GETWRITETIMEOUT, conf points to an u_long value receiving the write timeout.
- UART_SETLOCALECHO, conf points to an u_long value containing 0 (off) or 1 (on).
- UART_GETLOCALECHO, conf points to an u_long value receiving 0 (off) or 1 (on).
- UART_SETFLOWCONTROL, conf points to an u_long value containing combined UART_FCTL_ values.
- UART_GETFLOWCONTROL, conf points to an u_long value containing receiving UART_FCTL_ values.
- UART_SETCOOKEDMODE, conf points to an u_long value containing 0 (off) or 1 (on).
- UART_GETCOOKEDMODE, conf points to an u_long value receiving 0 (off) or 1 (on).
- HDLC_SETIFNET, conf points to a pointer containing the address of the network device's NUTDEVICE structure.
- HDLC_GETIFNET, conf points to a pointer receiving the address of the network device's NUTDEVICE structure.
|
| conf | Points to a buffer that contains any data required for the given control function or receives data from that function. |
- Returns:
- 0 on success, -1 otherwise.
- Warning:
- Timeout values are given in milliseconds and are limited to the granularity of the system timer.
|
|
|
Open the asynchronous HDLC device.
This function is called by the low level open routine of the C runtime library, using the _NUTDEVICE::dev_open entry.
- Parameters:
-
| dev | Pointer to the NUTDEVICE structure. |
| name | Ignored, should point to an empty string. |
| mode | Operation mode. Any of the following values may be or-ed:
|
| acc | Ignored, should be zero. |
- Returns:
- Pointer to a NUTFILE structure if successful or NUTFILE_EOF otherwise.
|
| int AhdlcAvrPut |
( |
NUTDEVICE * |
dev, |
|
|
CONST void * |
buffer, |
|
|
int |
len, |
|
|
int |
pflg |
|
) |
|
|
|
|
Write to the asynchronous HDLC device.
- Parameters:
-
| dev | Pointer to a previously registered NUTDEVICE structure. |
| buffer | Pointer the data to write. |
| len | Number of data bytes to write. |
| pflg | If this flag is set, then the buffer is located in program space. |
- Returns:
- The number of bytes written. In case of a write timeout, this may be less than the specified length.
|
| int AhdlcAvrRead |
( |
NUTFILE * |
fp, |
|
|
void * |
buffer, |
|
|
int |
size |
|
) |
|
|
|
|
Read from the asynchronous HDLC device.
This function is called by the low level input routines of the C runtime library, using the _NUTDEVICE::dev_read entry.
The function may block the calling thread until at least one character has been received or a timeout occurs.
It is recommended to set a proper read timeout with software handshake. In this case a timeout may occur, if the communication peer lost our last XON character. The application may then use ioctl() to disable the receiver and do the read again. This will send out another XON.
- Parameters:
-
| fp | Pointer to a _NUTFILE structure, obtained by a previous call to AhdlcOpen(). |
| buffer | Pointer to the buffer that receives the data. If zero, then all characters in the input buffer will be removed. |
| size | Maximum number of bytes to read. |
- Returns:
- The number of bytes read, which may be less than the number of bytes specified. A return value of -1 indicates an error, while zero is returned in case of a timeout.
|
| int AhdlcAvrWrite |
( |
NUTFILE * |
fp, |
|
|
CONST void * |
buffer, |
|
|
int |
len |
|
) |
|
|
|
|
Write to the asynchronous HDLC device.
This function is called by the low level output routines of the C runtime library, using the _NUTDEVICE::dev_write entry.
The function may block the calling thread.
- Parameters:
-
| fp | Pointer to a _NUTFILE structure, obtained by a previous call to AhldcOpen(). |
| buffer | Pointer to the data to be written. If zero, then the output buffer will be flushed. |
| len | Number of bytes to write. |
- Returns:
- The number of bytes written, which may be less than the number of bytes specified if a timeout occured. A return value of -1 indicates an error.
|
| int AhdlcAvrWrite_P |
( |
NUTFILE * |
fp, |
|
|
PGM_P |
buffer, |
|
|
int |
len |
|
) |
|
|
|
|
Write to the asynchronous HDLC device.
Similar to AhdlcWrite() except that the data is located in program memory.
This function is called by the low level output routines of the C runtime library, using the _NUTDEVICE::dev_write_P entry.
The function may block the calling thread.
- Parameters:
-
| fp | Pointer to a NUTFILE structure, obtained by a previous call to AhdlcOpen(). |
| buffer | Pointer to the data in program space to be written. |
| len | Number of bytes to write. |
- Returns:
- The number of bytes written, which may be less than the number of bytes specified if a timeout occured. A return value of -1 indicates an error.
|
|
|
Send HDLC frame.
- Parameters:
-
| dev | Identifies the device to use. |
| nb | Network buffer structure containing the packet to be sent. The structure must have been allocated by a previous call NutNetBufAlloc(). |
- Returns:
- 0 on success, -1 in case of any errors.
|
|
|
Asynchronous HDLC receiver thread.
Running at high priority. |
|
 |
|