Arrrgh. Fix red now. :\
[kugel-rb.git] / flash / uart_boot / uart.h
bloba0c10d1a0f13514899bd95b332050f109270b4ca
1 // A general definition for the required UART functionality.
2 // This will be used to gain platform abstraction.
4 #ifndef _UART_H
5 #define _UART_H
7 // data types
9 typedef void* tUartHandle;
10 #define INVALID_UART_HANDLE (tUartHandle)-1
12 typedef enum
14 eNOPARITY,
15 eODDPARITY,
16 eEVENPARITY,
17 eMARKPARITY,
18 eSPACEPARITY,
19 } tParity;
21 typedef enum
23 eONESTOPBIT,
24 eONE5STOPBITS,
25 eTWOSTOPBITS,
26 } tStopBits;
29 // prototypes
31 tUartHandle UartOpen( // returns NULL on error
32 char* szPortName); // COMx for windows
34 bool UartConfig( // returns true on success, false on error
35 tUartHandle handle, // the handle returned from UartOpen()
36 long lBaudRate, // must be one of the "standard" baudrates
37 tParity nParity, // what kind of parity
38 tStopBits nStopBits, // how many stop bits
39 int nByteSize); // size of the "payload", can be 5 to 8
41 long UartWrite( // returns how much data was actually transmitted
42 tUartHandle handle, // the handle returned from UartOpen()
43 unsigned char* pData, // pointer to the data to be transmitted
44 long lSize); // how many bytes
46 long UartRead( // returns how much data was actually received
47 tUartHandle handle, // the handle returned from UartOpen()
48 unsigned char* pBuffer, // pointer to the destination
49 long lSize); // how many bytes to read (pBuffer must have enough room)
52 void UartClose(tUartHandle handle);
56 #endif // _UART_H