DHCOM_HAL
Hardware-abstraction library (HAL) for multiple targets, including DHCOM modules
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
UART.h
Go to the documentation of this file.
1 /*
2  * Uart.h
3  *
4  * Created on: Nov 27, 2012
5  * Author: Peter Kishalov (PK), DH electronics GmbH
6  */
7 
8 #ifndef UART_H_
9 #define UART_H_
10 
11 
12 #include <DHCOM_HAL.h>
13 #include <hal/Types.h>
14 #include <stddef.h>
15 
16 
17 namespace dhcom
18 {
19 
20 
21 class System;
22 class UARTImpl;
23 
24 
26 {
27 public:
29  enum DEVICE
30  {
31  DEVICE_UART0 = 0,
32  DEVICE_UART1, DEVICE_UART2, DEVICE_UART3,
33  DEVICE_UART4, DEVICE_UART5, DEVICE_UART6,
34  DEVICE_UART7, DEVICE_UART8, DEVICE_UART9,
35  DEVICE_UART10, DEVICE_UART11, DEVICE_UART12,
36  DEVICE_UART13, DEVICE_UART14, DEVICE_UART15,
37  DEVICE_UART16, DEVICE_UART17, DEVICE_UART18,
39  };
40 
42  enum BAUDRATE
43  {
44  BAUDRATE_110, BAUDRATE_300,
45  BAUDRATE_600, BAUDRATE_1200, BAUDRATE_2400,
46  BAUDRATE_4800, BAUDRATE_9600, BAUDRATE_19200, BAUDRATE_38400,
47  BAUDRATE_57600, BAUDRATE_115200,
48  };
49 
51  enum PARITY
52  {
53 #undef PARITY_NONE
54 #undef PARITY_ODD
55 #undef PARITY_EVEN
56  PARITY_NONE, PARITY_ODD, PARITY_EVEN,
57  };
58 
60  enum STOPBITS
61  {
64  };
65 
68  {
72  };
73 
75  enum IPIN
76  {
81  };
82 
84  enum OPIN
85  {
88  };
89 
90  UART(const System &sys, DEVICE device);
91  ~UART();
92 
93  STATUS setCommParams(BAUDRATE baudRate, PARITY parity, STOPBITS stopBits, FLOWCONTROL flowControl);
94 
95  STATUS open();
96  STATUS close();
97  bool isOpen() const;
98  uint32_t write(const uint8_t *buffer, uint32_t size, STATUS *status = NULL);
99  uint32_t read(uint8_t *buffer, uint32_t size, STATUS *status = NULL);
100 
101  STATUS setPin(OPIN pin, bool value);
102  bool getPin(IPIN pin, STATUS *status = NULL) const;
103 
104 private:
105  UARTImpl * const impl_;
106 };
107 
108 
109 
198 } // namespace dhcom
199 
200 
201 #endif /* UART_H_ */