]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/hal/serial_api.h
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / hal / serial_api.h
1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #ifndef MBED_SERIAL_API_H
17 #define MBED_SERIAL_API_H
18
19 #include "device.h"
20
21 #if DEVICE_SERIAL
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 typedef enum {
28 ParityNone = 0,
29 ParityOdd = 1,
30 ParityEven = 2,
31 ParityForced1 = 3,
32 ParityForced0 = 4
33 } SerialParity;
34
35 typedef enum {
36 RxIrq,
37 TxIrq
38 } SerialIrq;
39
40 typedef enum {
41 FlowControlNone,
42 FlowControlRTS,
43 FlowControlCTS,
44 FlowControlRTSCTS
45 } FlowControl;
46
47 typedef void (*uart_irq_handler)(uint32_t id, SerialIrq event);
48
49 typedef struct serial_s serial_t;
50
51 void serial_init (serial_t *obj, PinName tx, PinName rx);
52 void serial_free (serial_t *obj);
53 void serial_baud (serial_t *obj, int baudrate);
54 void serial_format (serial_t *obj, int data_bits, SerialParity parity, int stop_bits);
55
56 void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id);
57 void serial_irq_set (serial_t *obj, SerialIrq irq, uint32_t enable);
58
59 int serial_getc (serial_t *obj);
60 void serial_putc (serial_t *obj, int c);
61 int serial_readable (serial_t *obj);
62 int serial_writable (serial_t *obj);
63 void serial_clear (serial_t *obj);
64
65 void serial_break_set (serial_t *obj);
66 void serial_break_clear(serial_t *obj);
67
68 void serial_pinout_tx(PinName tx);
69
70 void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif
77
78 #endif
Imprint / Impressum