Mbed SDK for XRange SX1272 LoRa module

Dependents:   XRangePingPong XRange-LoRaWAN-lmic-app lora-transceiver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers serial_api.h Source File

serial_api.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef MBED_SERIAL_API_H
00017 #define MBED_SERIAL_API_H
00018 
00019 #include "device.h"
00020 
00021 #if DEVICE_SERIAL
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 typedef enum {
00028     ParityNone = 0,
00029     ParityOdd = 1,
00030     ParityEven = 2,
00031     ParityForced1 = 3,
00032     ParityForced0 = 4
00033 } SerialParity;
00034 
00035 typedef enum {
00036     RxIrq,
00037     TxIrq
00038 } SerialIrq;
00039 
00040 typedef enum {
00041     FlowControlNone,
00042     FlowControlRTS,
00043     FlowControlCTS,
00044     FlowControlRTSCTS
00045 } FlowControl;
00046 
00047 typedef void (*uart_irq_handler)(uint32_t id, SerialIrq event);
00048 
00049 typedef struct serial_s serial_t;
00050 
00051 void serial_init       (serial_t *obj, PinName tx, PinName rx);
00052 void serial_free       (serial_t *obj);
00053 void serial_baud       (serial_t *obj, int baudrate);
00054 void serial_format     (serial_t *obj, int data_bits, SerialParity parity, int stop_bits);
00055 
00056 void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id);
00057 void serial_irq_set    (serial_t *obj, SerialIrq irq, uint32_t enable);
00058 
00059 int  serial_getc       (serial_t *obj);
00060 void serial_putc       (serial_t *obj, int c);
00061 int  serial_readable   (serial_t *obj);
00062 int  serial_writable   (serial_t *obj);
00063 void serial_clear      (serial_t *obj);
00064 
00065 void serial_break_set  (serial_t *obj);
00066 void serial_break_clear(serial_t *obj);
00067 
00068 void serial_pinout_tx(PinName tx);
00069 
00070 void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
00071 
00072 #ifdef __cplusplus
00073 }
00074 #endif
00075 
00076 #endif
00077 
00078 #endif