Streaming Devices (BLACKSheep OS)

Aus BECOM Systems Support
Version vom 31. Oktober 2023, 09:03 Uhr von Peter (Diskussion | Beiträge) (1 Version importiert)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Introduction

The streaming devices are similar to the block devices. The main difference is that not only an entire block can be written to the device but also single characters. Another difference is the T_DEVICE_INFO block that contains important information about the device. The meaning of each entry in the T_DEVICE_INFO structure differs between block devices and character devices. Please refer to the appropriate code documentation to get more information about the meaning of each entry in the T_DEVICE_INFO structure.

Such as the block devices also character based devices provides a common interface to the device manager consisting of the three functions fnBlockRead, fnBlockWrite and fnInfo. To be consistent in the names they are also named fnBlockRead and fnBlockWrite although only single characters are written or read from the device instead of entire blocks.

Supported Devices

UART

Files associated: devUART.c , devUART.h

Directories: BLACKSheep/common/msd

The UART streaming device driver uses the low level UART driver to communicate over the on-chip UART. Similar to the block devices the file devUART.c provides the three functions needed by the device manager to communicate with the character device.

Interface to the device manager: <source lang="c"> signed long dev_uart_blockRead(void *pa_pDevHandle, unsigned long pa_nBlockAddr, unsigned long pa_nBlockCount, unsigned char *pa_pcData); signed long dev_uart_blockWrite(void *pa_pDevHandle, unsigned long pa_nBlockAddr, unsigned long pa_nBlockCount, unsigned char *pa_pcData); T_ERROR_CODE dev_uart_info( void *pa_pDevHandle, T_DEVICE_INFO *pa_pstDeviceInfo); </source>

The UART Streaming Device is used if the macro _USE_UART_ is defined Environment.h .

BSUART

Files associated: devBSUART.c , devBSUART.h

Directories: BLACKSheep/common/msd

The BSUART streaming device driver uses the low level BSUART driver to communicate over the on-chip UART. Similar to the block devices the file devBSUART.c provides the three functions needed by the device manager to communicate with the character device.

Interface to the device manager: <source lang="c"> signed long dev_bsuart_blockRead(void *pa_pDevHandle, unsigned long pa_nBlockAddr, unsigned long pa_nBlockCount, unsigned char *pa_pcData); signed long dev_bsuart_blockWrite(void *pa_pDevHandle, unsigned long pa_nBlockAddr, unsigned long pa_nBlockCount, unsigned char *pa_pcData); T_ERROR_CODE dev_bsuart_info(void *pa_pDevHandle, T_DEVICE_INFO *pa_pstDeviceInfo); </source>

The BSUART Streaming Device is used if the macro _USE_BSUART_ is defined Environment.h .

IO-Buffer

Files associated: IOBUFconfig.c , IOBUFconfig.h , devIOBUF.c , devIOBUF.h

Directories: BLACKSheep/common/msd

The io-buffer device implements either a FIFO or a FILO buffer, selectable at runtime by a parameter in the initialization function. The buffer size can be specified at runtime by a setup parameter.

Prototypes: <source lang="c"> T_IOBUF_HANDLE iobuf_open ( unsigned char pa_cBufferType, unsigned char pa_cBufFullHandle, unsigned short pa_nBufferSize); T_ERROR_CODE iobuf_writeData (T_IOBUF_HANDLE pa_hDevice, unsigned char pa_nData); unsigned char iobuf_readData ( T_IOBUF_HANDLE pa_hDevice, T_ERROR_CODE *pa_cError); unsigned short iobuf_close(T_IOBUF_HANDLE pa_hDevice); unsigned short iobuf_getBytesInBuffer (T_IOBUF_HANDLE pa_hDevice);

// pa_cBufferType: Specifies the buffer type // pa_cBufFullHandle: Specifies how to handle a buffer full condition // pa_nBufferSize: Size of the buffer in byte </source>

Example:

The example shows how to initialize the io-buffer as FIFO buffer. <source lang="c"> T_IOBUF_HANDLE hIObuf = iobuf_open(IOBUF_FIFO, IOBUF_BLOCK_RW, 512); </source>

The macros are declared in the file IOBUFconfig.h .

Interface to the device manager: <source lang="c"> signed long dev_iobuf_blockRead(void *pa_pDevHandle, unsigned long pa_nBlockAddr, unsigned long pa_nBlockCount, unsigned char *pa_pcData); signed long dev_iobuf_blockWrite(void *pa_pDevHandle, unsigned long pa_nBlockAddr, unsigned long pa_nBlockCount, unsigned char *pa_pcData); T_ERROR_CODE dev_iobuf_info ( void *pa_pDevHandle, T_DEVICE_INFO *pa_pstDeviceInfo); </source>