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