mbed

Dependents:   DHTSensor_Test K64F_eCompass_OneNET_JW

Committer:
mbotkinl
Date:
Wed Feb 25 20:22:22 2015 +0000
Revision:
0:2cc6bb4d7fea
Working code to read Temperature and Humidity readings

Who changed what in which revision?

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