NetBurner 3.5.0
PDF Version
 
Extra FD Circular Buffer

The NetBurner system software has support for implementing your own custom I/O device using a File Descriptor. It is Extra File Descriptors are defines in the 'iointernal.h' header file.

This is a simple example that creates a circular buffer and treats it as an I/O device by using a file descriptor. The I/O device is a 256 byte circular buffer that you can than write() to and read() from. The 256 byte buffer size makes the circular buffer wrap around simple for a byte array.

The 6 fd status functions are interrupt safe:

void SetDataAvail( int fd ); void ClrDataAvail( int fd ); void SetWriteAvail( int fd ); void ClrWriteAvail( int fd ); void SetHaveError( int fd ); void ClrHaveError( int fd );

Side note: If you have an I/O device and wish to use interrupts, after adding the appropriate interrupt code that is specific to your device, you would use USER_ENTER_CRITICAL and USER_EXIT_CRITICAL to protect the internal data structures.