summaryrefslogtreecommitdiff
path: root/flash/uart_boot/uart.h
blob: a0c10d1a0f13514899bd95b332050f109270b4ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// A general definition for the required UART functionality.
// This will be used to gain platform abstraction.

#ifndef _UART_H
#define _UART_H

// data types

typedef void* tUartHandle;
#define INVALID_UART_HANDLE (tUartHandle)-1

typedef enum
{
	eNOPARITY,
	eODDPARITY, 
	eEVENPARITY,
	eMARKPARITY,
	eSPACEPARITY,
} tParity;

typedef enum
{
	eONESTOPBIT,
	eONE5STOPBITS,
	eTWOSTOPBITS,
} tStopBits;


// prototypes

tUartHandle UartOpen(   // returns NULL on error
	char* szPortName);  // COMx for windows

bool UartConfig(         // returns true on success, false on error
	tUartHandle handle,  // the handle returned from UartOpen()
	long lBaudRate,      // must be one of the "standard" baudrates
	tParity nParity,     // what kind of parity
	tStopBits nStopBits, // how many stop bits
	int nByteSize);      // size of the "payload", can be 5 to 8

long UartWrite(           // returns how much data was actually transmitted
	tUartHandle handle,   // the handle returned from UartOpen()
	unsigned char* pData, // pointer to the data to be transmitted
	long lSize);          // how many bytes

long UartRead(              // returns how much data was actually received
	tUartHandle handle,     // the handle returned from UartOpen()
	unsigned char* pBuffer, // pointer to the destination
	long lSize);            // how many bytes to read (pBuffer must have enough room)


void UartClose(tUartHandle handle);



#endif // _UART_H