Nut/OS  4.10.3
API Reference
AHDLC

AHDLC Driver. More...

Collaboration diagram for AHDLC:

Defines

#define IN_ACC_MAP(c, m)   (( ((uint8_t) (c)) < 0x20) && ((m) & (1UL << (c))) != 0)
#define NUT_THREAD_AHDLCRXSTACK   2048

Functions

int AhdlcOutput (NUTDEVICE *dev, NETBUF *nb)
 Send HDLC frame.
int AhdlcAt91IOCtl (NUTDEVICE *dev, int req, void *conf)
 Perform on-chip UART control functions.
int AhdlcAt91Init (NUTDEVICE *dev)
 Initialize asynchronous HDLC device.
int AhdlcAt91Read (NUTFILE *fp, void *buffer, int size)
 Read from the asynchronous HDLC device.
int AhdlcAt91Put (NUTDEVICE *dev, CONST void *buffer, int len, int pflg)
 Write to the asynchronous HDLC device.
int AhdlcAt91Write (NUTFILE *fp, CONST void *buffer, int len)
 Write to the asynchronous HDLC device.
int AhdlcAt91Write_P (NUTFILE *fp, PGM_P buffer, int len)
 Write to the asynchronous HDLC device.
NUTFILEAhdlcAt91Open (NUTDEVICE *dev, CONST char *name, int mode, int acc)
 Open the asynchronous HDLC device.
int AhdlcAt91Close (NUTFILE *fp)
 Close the asynchronous HDLC device.

Variables

NUTDEVICE devAhdlc1
 Device information structure.
NUTDEVICE devAhdlc0
 Device information structure.
NUTDEVICE devAhdlc1
 Device information structure.

UART1 RTS Handshake Control

UART1_RTS_BIT must be defined in arch/avr.h

void 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.
NUTFILEAhdlcAvrOpen (NUTDEVICE *dev, CONST char *name, int mode, int acc)
 Open the asynchronous HDLC device.
int AhdlcAvrClose (NUTFILE *fp)
 Close the asynchronous HDLC device.
#define IN_ACC_MAP(c, m)   in_acc_map(c, &(m))
#define NUT_THREAD_AHDLCRXSTACK   512

Detailed Description

AHDLC Driver.

This code contains a modified UART driver with some speed optimizations for PPP, like table driven FCS calculation. It also implements simple modem handshaking (RTS, CTS and DTR).


Define Documentation

#define IN_ACC_MAP (   c,
 
)    (( ((uint8_t) (c)) < 0x20) && ((m) & (1UL << (c))) != 0)

Checks the 32-bit ACCM to see if the byte needs un-escaping

Definition at line 171 of file at91_ahdlc.c.

#define NUT_THREAD_AHDLCRXSTACK   2048

Definition at line 174 of file at91_ahdlc.c.

Referenced by AhdlcAt91Init().

#define IN_ACC_MAP (   c,
 
)    in_acc_map(c, &(m))

Checks the 32-bit ACCM to see if the byte needs un-escaping

Definition at line 284 of file ahdlcavr.c.

#define NUT_THREAD_AHDLCRXSTACK   512

Definition at line 313 of file ahdlcavr.c.

Referenced by AhdlcAvrInit().


Function Documentation

int AhdlcOutput ( NUTDEVICE dev,
NETBUF nb 
)

Send HDLC frame.

Parameters:
devIdentifies the device to use.
nbNetwork 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.

Definition at line 318 of file at91_ahdlc.c.

References AHDLC_FLAG, AHDLC_INITFCS, _AHDLCDCB::dcb_modeflags, _AHDLCDCB::dcb_tx_mru, _NUTDEVICE::dev_dcb, _NETBUF::nb_ap, _NETBUF::nb_dl, _NETBUF::nb_nw, _NETBUF::nb_tp, _NBDATA::sz, UART_MF_RAWMODE, and _NBDATA::vp.

Referenced by AhdlcRx().

int AhdlcAt91IOCtl ( NUTDEVICE dev,
int  req,
void *  conf 
)

Perform on-chip UART control functions.

Parameters:
devIdentifies the device that receives the device-control function.
reqRequested control function. May be set to one of the following constants:
  • UART_SETSPEED, conf points to an uint32_t value containing the baudrate.
  • UART_GETSPEED, conf points to an uint32_t value receiving the current baudrate.
  • UART_SETSTATUS, conf points to an uint32_t value containing the changes for the control lines.
  • UART_GETSTATUS, conf points to an uint32_t value receiving the state of the control lines and the device.
  • UART_SETREADTIMEOUT, conf points to an uint32_t value containing the read timeout.
  • UART_GETREADTIMEOUT, conf points to an uint32_t value receiving the read timeout.
  • UART_SETWRITETIMEOUT, conf points to an uint32_t value containing the write timeout.
  • UART_GETWRITETIMEOUT, conf points to an uint32_t value receiving the write timeout.
  • UART_SETLOCALECHO, conf points to an uint32_t value containing 0 (off) or 1 (on).
  • UART_GETLOCALECHO, conf points to an uint32_t value receiving 0 (off) or 1 (on).
  • UART_SETFLOWCONTROL, conf points to an uint32_t value containing combined UART_FCTL_ values.
  • UART_GETFLOWCONTROL, conf points to an uint32_t value containing receiving UART_FCTL_ values.
  • UART_SETCOOKEDMODE, conf points to an uint32_t value containing 0 (off) or 1 (on).
  • UART_GETCOOKEDMODE, conf points to an uint32_t value receiving 0 (off) or 1 (on).
  • UART_SETRAWMODE, conf points to an uint32_t value containing 0 (off) or 1 (on).
  • UART_GETRAWMODE, conf points to an uint32_t 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.
confPoints 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.
Note:
For ATmega103, only 8 data bits, 1 stop bit and no parity are allowed.

Definition at line 730 of file at91_ahdlc.c.

References _AHDLCDCB::dcb_base, _AHDLCDCB::dcb_mf_evt, _AHDLCDCB::dcb_modeflags, _AHDLCDCB::dcb_rtimeout, _AHDLCDCB::dcb_rx_rdy, _AHDLCDCB::dcb_wtimeout, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _NUTDEVICE::dev_type, devUsartAt910, HDLC_GETIFNET, HDLC_SETIFNET, IFTYP_CHAR, IFTYP_NET, inr, NutEventPost(), NutGetCpuClock(), outr, UART_GETFLOWCONTROL, UART_GETLOCALECHO, UART_GETRAWMODE, UART_GETREADTIMEOUT, UART_GETSPEED, UART_GETSTATUS, UART_GETWRITETIMEOUT, UART_MF_LOCALECHO, UART_MF_RAWMODE, UART_SETFLOWCONTROL, UART_SETLOCALECHO, UART_SETRAWMODE, UART_SETREADTIMEOUT, UART_SETSPEED, UART_SETSTATUS, UART_SETWRITETIMEOUT, US_BRGR_OFF, US_CLKS, US_CLKS_MCK, US_CLKS_MCK8, US_MR_OFF, and USART1_BASE.

Here is the call graph for this function:

int AhdlcAt91Init ( NUTDEVICE dev)

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:
devIdentifies the device to initialize.
Returns:
0 on success, -1 otherwise.

Definition at line 878 of file at91_ahdlc.c.

References _BV, AhdlcRx(), _AHDLCDCB::dcb_base, _AHDLCDCB::dcb_rx_buf, _AHDLCDCB::dcb_rx_mru, _AHDLCDCB::dcb_tx_accm, _AHDLCDCB::dcb_tx_buf, _AHDLCDCB::dcb_tx_mru, _NUTDEVICE::dev_base, _NUTDEVICE::dev_dcb, memset(), NUT_AHDLC_RECV_DMA_SIZE, NUT_THREAD_AHDLCRXSTACK, NUT_THREAD_STACK_ADD, NUT_THREAD_STACK_MULT, NutGetCpuClock(), NutHeapAlloc, NutHeapFree, NutRegisterIrqHandler(), NutThreadCreate(), outr, PDC_RXTDIS, PERIPH_PTCR_OFF, PERIPH_RCR_OFF, PERIPH_RNCR_OFF, PERIPH_RNPR_OFF, PERIPH_RPR_OFF, PMC_PCER, SIG_UART, US1_BRGR, US1_CR, US1_ID, US1_IDR, US1_MR, US_CHMODE_NORMAL, US_CHRL_8, US_GPIO_PINS, US_NBSTOP_1, US_PAR_NO, US_RSTRX, US_RSTTX, US_RXDIS, US_TXDIS, and USART1_BASE.

Here is the call graph for this function:

int AhdlcAt91Read ( 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:
fpPointer to a _NUTFILE structure, obtained by a previous call to AhdlcOpen().
bufferPointer to the buffer that receives the data. If zero, then all characters in the input buffer will be removed.
sizeMaximum 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.

Definition at line 981 of file at91_ahdlc.c.

References _AHDLCDCB::dcb_rd_idx, _AHDLCDCB::dcb_rtimeout, _AHDLCDCB::dcb_rx_buf, _AHDLCDCB::dcb_rx_idx, _AHDLCDCB::dcb_rx_rdy, _NUTDEVICE::dev_dcb, _NUTFILE::nf_dev, and NutEventWait().

Here is the call graph for this function:

int AhdlcAt91Put ( NUTDEVICE dev,
CONST void *  buffer,
int  len,
int  pflg 
)

Write to the asynchronous HDLC device.

Parameters:
devPointer to a previously registered NUTDEVICE structure.
bufferPointer the data to write.
lenNumber of data bytes to write.
pflgIf 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.

Definition at line 1021 of file at91_ahdlc.c.

References CONST, _NUTDEVICE::dev_dcb, NutEnterCritical, NutExitCritical, outr, PRG_RDB, US1_IER, and US_TXRDY.

Referenced by AhdlcAt91Write(), and AhdlcAt91Write_P().

int AhdlcAt91Write ( 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:
fpPointer to a _NUTFILE structure, obtained by a previous call to AhldcOpen().
bufferPointer to the data to be written. If zero, then the output buffer will be flushed.
lenNumber 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.

Definition at line 1072 of file at91_ahdlc.c.

References AhdlcAt91Put(), and _NUTFILE::nf_dev.

Here is the call graph for this function:

int AhdlcAt91Write_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:
fpPointer to a NUTFILE structure, obtained by a previous call to AhdlcOpen().
bufferPointer to the data in program space to be written.
lenNumber 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.

Definition at line 1098 of file at91_ahdlc.c.

References AhdlcAt91Put(), CONST, and _NUTFILE::nf_dev.

Here is the call graph for this function:

NUTFILE* AhdlcAt91Open ( NUTDEVICE dev,
CONST char *  name,
int  mode,
int  acc 
)

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:
devPointer to the NUTDEVICE structure.
nameIgnored, should point to an empty string.
modeOperation mode. Any of the following values may be or-ed:
accIgnored, should be zero.
Returns:
Pointer to a NUTFILE structure if successful or NUTFILE_EOF otherwise.

Definition at line 1119 of file at91_ahdlc.c.

References _NUTFILE::nf_dev, _NUTFILE::nf_fcb, _NUTFILE::nf_next, NutEnterCritical, NutExitCritical, NUTFILE_EOF, NutHeapAlloc, NutIrqEnable(), outr, PDC_RXTEN, PERIPH_PTCR_OFF, SIG_UART, UART_RECEIVER_TIMEOUT, US1_CR, US1_IER, US1_RTOR, US_ENDRX, US_RXBUFF, US_RXEN, US_STTTO, US_TIMEOUT, US_TXEN, and USART1_BASE.

Here is the call graph for this function:

int AhdlcAt91Close ( NUTFILE fp)

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:
fpPointer to a _NUTFILE structure, obtained by a previous call to UsartOpen().
Returns:
0 on success or -1 otherwise.
Todo:
We may support shared open and use dev_irq as an open counter.

Definition at line 1159 of file at91_ahdlc.c.

References NUTFILE_EOF, and NutHeapFree.

int AhdlcAvrIOCtl ( NUTDEVICE dev,
int  req,
void *  conf 
)

Perform on-chip UART control functions.

Parameters:
devIdentifies the device that receives the device-control function.
reqRequested control function. May be set to one of the following constants:
  • UART_SETSPEED, conf points to an uint32_t value containing the baudrate.
  • UART_GETSPEED, conf points to an uint32_t value receiving the current baudrate.
  • UART_SETDATABITS, conf points to an uint32_t value containing the number of data bits, 5, 6, 7 or 8.
  • UART_GETDATABITS, conf points to an uint32_t value receiving the number of data bits, 5, 6, 7 or 8.
  • UART_SETPARITY, conf points to an uint32_t value containing the parity, 0 (no), 1 (odd) or 2 (even).
  • UART_GETPARITY, conf points to an uint32_t value receiving the parity, 0 (no), 1 (odd) or 2 (even).
  • UART_SETSTOPBITS, conf points to an uint32_t value containing the number of stop bits 1 or 2.
  • UART_GETSTOPBITS, conf points to an uint32_t value receiving the number of stop bits 1 or 2.
  • UART_SETSTATUS, conf points to an uint32_t value containing the changes for the control lines.
  • UART_GETSTATUS, conf points to an uint32_t value receiving the state of the control lines and the device.
  • UART_SETREADTIMEOUT, conf points to an uint32_t value containing the read timeout.
  • UART_GETREADTIMEOUT, conf points to an uint32_t value receiving the read timeout.
  • UART_SETWRITETIMEOUT, conf points to an uint32_t value containing the write timeout.
  • UART_GETWRITETIMEOUT, conf points to an uint32_t value receiving the write timeout.
  • UART_SETLOCALECHO, conf points to an uint32_t value containing 0 (off) or 1 (on).
  • UART_GETLOCALECHO, conf points to an uint32_t value receiving 0 (off) or 1 (on).
  • UART_SETFLOWCONTROL, conf points to an uint32_t value containing combined UART_FCTL_ values.
  • UART_GETFLOWCONTROL, conf points to an uint32_t value containing receiving UART_FCTL_ values.
  • UART_SETCOOKEDMODE, conf points to an uint32_t value containing 0 (off) or 1 (on).
  • UART_GETCOOKEDMODE, conf points to an uint32_t value receiving 0 (off) or 1 (on).
  • UART_SETRAWMODE, conf points to an uint32_t value containing 0 (off) or 1 (on).
  • UART_GETRAWMODE, conf points to an uint32_t 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.
  • HDLC_SETTXACCM, conf points to an uint32_t value containing the ACC Map in host endian.
  • HDLC_GETTXACCM, conf points to an uint32_t value receiving the ACC Map in host endian.
confPoints 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.
Note:
For ATmega103, only 8 data bits, 1 stop bit and no parity are allowed.

Definition at line 941 of file ahdlcavr.c.

References _AHDLCDCB::dcb_mf_evt, _AHDLCDCB::dcb_modeflags, _AHDLCDCB::dcb_rtimeout, _AHDLCDCB::dcb_rx_mru, _AHDLCDCB::dcb_rx_rdy, _AHDLCDCB::dcb_tx_accm, _AHDLCDCB::dcb_tx_mru, _AHDLCDCB::dcb_wtimeout, _NUTDEVICE::dev_base, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _NUTDEVICE::dev_type, devUart0, HDLC_GETIFNET, HDLC_GETTXACCM, HDLC_SETIFNET, HDLC_SETTXACCM, IFTYP_CHAR, IFTYP_NET, inb, NutEventPost(), NutGetCpuClock(), outb, UART_GETDATABITS, UART_GETFLOWCONTROL, UART_GETLOCALECHO, UART_GETPARITY, UART_GETRAWMODE, UART_GETREADTIMEOUT, UART_GETSPEED, UART_GETSTATUS, UART_GETSTOPBITS, UART_GETWRITETIMEOUT, UART_MF_LOCALECHO, UART_MF_RAWMODE, UART_SETDATABITS, UART_SETFLOWCONTROL, UART_SETLOCALECHO, UART_SETPARITY, UART_SETRAWMODE, UART_SETREADTIMEOUT, UART_SETSPEED, UART_SETSTATUS, UART_SETSTOPBITS, UART_SETWRITETIMEOUT, and UBRR.

Referenced by AhdlcAvrInit().

Here is the call graph for this function:

int AhdlcAvrInit ( NUTDEVICE dev)

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:
devIdentifies the device to initialize.
Returns:
0 on success, -1 otherwise.

Definition at line 1197 of file ahdlcavr.c.

References AhdlcAvrIOCtl(), AhdlcRx(), cbi, _AHDLCDCB::dcb_base, _AHDLCDCB::dcb_rx_buf, _AHDLCDCB::dcb_rx_mru, _AHDLCDCB::dcb_tx_accm, _AHDLCDCB::dcb_tx_buf, _AHDLCDCB::dcb_tx_mru, _NUTDEVICE::dev_base, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, EICR, memset(), NUT_THREAD_AHDLCRXSTACK, NUT_THREAD_STACK_ADD, NUT_THREAD_STACK_MULT, NutHeapAlloc, NutHeapFree, NutRegisterIrqHandler(), NutThreadCreate(), sbi, sig_UART0_DATA, sig_UART0_RECV, sig_UART1_DATA, sig_UART1_RECV, and UART_SETSPEED.

Here is the call graph for this function:

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:
fpPointer to a _NUTFILE structure, obtained by a previous call to AhdlcOpen().
bufferPointer to the buffer that receives the data. If zero, then all characters in the input buffer will be removed.
sizeMaximum 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.

Definition at line 1335 of file ahdlcavr.c.

References _AHDLCDCB::dcb_rd_idx, _AHDLCDCB::dcb_rtimeout, _AHDLCDCB::dcb_rx_buf, _AHDLCDCB::dcb_rx_idx, _AHDLCDCB::dcb_rx_rdy, _NUTDEVICE::dev_dcb, _NUTFILE::nf_dev, and NutEventWait().

Here is the call graph for this function:

int AhdlcAvrPut ( NUTDEVICE dev,
CONST void *  buffer,
int  len,
int  pflg 
)

Write to the asynchronous HDLC device.

Parameters:
devPointer to a previously registered NUTDEVICE structure.
bufferPointer the data to write.
lenNumber of data bytes to write.
pflgIf 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.

Definition at line 1375 of file ahdlcavr.c.

References CONST, _NUTDEVICE::dev_base, _NUTDEVICE::dev_dcb, PRG_RDB, sbi, UCR, and UDRIE.

Referenced by AhdlcAvrWrite(), and AhdlcAvrWrite_P().

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:
fpPointer to a _NUTFILE structure, obtained by a previous call to AhldcOpen().
bufferPointer to the data to be written. If zero, then the output buffer will be flushed.
lenNumber 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.

Definition at line 1429 of file ahdlcavr.c.

References AhdlcAvrPut(), and _NUTFILE::nf_dev.

Here is the call graph for this function:

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:
fpPointer to a NUTFILE structure, obtained by a previous call to AhdlcOpen().
bufferPointer to the data in program space to be written.
lenNumber 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.

Definition at line 1455 of file ahdlcavr.c.

References AhdlcAvrPut(), CONST, and _NUTFILE::nf_dev.

Here is the call graph for this function:

NUTFILE* AhdlcAvrOpen ( NUTDEVICE dev,
CONST char *  name,
int  mode,
int  acc 
)

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:
devPointer to the NUTDEVICE structure.
nameIgnored, should point to an empty string.
modeOperation mode. Any of the following values may be or-ed:
accIgnored, should be zero.
Returns:
Pointer to a NUTFILE structure if successful or NUTFILE_EOF otherwise.

Definition at line 1476 of file ahdlcavr.c.

References cbi, _NUTDEVICE::dev_base, _NUTFILE::nf_dev, _NUTFILE::nf_fcb, _NUTFILE::nf_next, NUTFILE_EOF, and NutHeapAlloc.

int AhdlcAvrClose ( NUTFILE fp)

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:
fpPointer to a _NUTFILE structure, obtained by a previous call to UsartOpen().
Returns:
0 on success or -1 otherwise.
Todo:
We may support shared open and use dev_irq as an open counter.

Definition at line 1522 of file ahdlcavr.c.

References _NUTDEVICE::dev_base, _NUTFILE::nf_dev, NUTFILE_EOF, NutHeapFree, and sbi.


Variable Documentation

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '1', 0, 0, 0, 0},      
    IFTYP_CHAR,                 
    1,                          
    0,                          
    0,                          
    &dcb_ahdlc,                 
    AhdlcAt91Init,              
    AhdlcAt91IOCtl,             
    AhdlcAt91Read,              
    AhdlcAt91Write,             
    AhdlcAt91Open,              
    AhdlcAt91Close,             
    0                           
}

Device information structure.

A pointer to this structure must be passed to NutRegisterDevice() to bind this device driver to the Nut/OS kernel.

Definition at line 109 of file at91_ahdlc.c.

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '0', 0, 0, 0, 0},      
    IFTYP_CHAR,                 
    0,                          
    0,                          
    0,                          
    &dcb_ahdlc,                 
    AhdlcAvrInit,               
    AhdlcAvrIOCtl,              
    AhdlcAvrRead,               
    AhdlcAvrWrite,              
    AhdlcAvrWrite_P,            
    AhdlcAvrOpen,               
    AhdlcAvrClose,              
    0                           
}

Device information structure.

A pointer to this structure must be passed to NutRegisterDevice() to bind this device driver to the Nut/OS kernel.

Definition at line 62 of file ahdlc0.c.

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '1', 0, 0, 0, 0},      
    IFTYP_CHAR,                 
    1,                          
    0,                          
    0,                          
    &dcb_ahdlc,                 
    AhdlcAvrInit,               
    AhdlcAvrIOCtl,              
    AhdlcAvrRead,               
    AhdlcAvrWrite,              
    AhdlcAvrWrite_P,            
    AhdlcAvrOpen,               
    AhdlcAvrClose,              
    0                           
}

Device information structure.

A pointer to this structure must be passed to NutRegisterDevice() to bind this device driver to the Nut/OS kernel.

Definition at line 62 of file ahdlc1.c.