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_CAN_API_H
mbotkinl 0:2cc6bb4d7fea 17 #define MBED_CAN_API_H
mbotkinl 0:2cc6bb4d7fea 18
mbotkinl 0:2cc6bb4d7fea 19 #include "device.h"
mbotkinl 0:2cc6bb4d7fea 20
mbotkinl 0:2cc6bb4d7fea 21 #if DEVICE_CAN
mbotkinl 0:2cc6bb4d7fea 22
mbotkinl 0:2cc6bb4d7fea 23 #include "PinNames.h"
mbotkinl 0:2cc6bb4d7fea 24 #include "PeripheralNames.h"
mbotkinl 0:2cc6bb4d7fea 25 #include "can_helper.h"
mbotkinl 0:2cc6bb4d7fea 26
mbotkinl 0:2cc6bb4d7fea 27 #ifdef __cplusplus
mbotkinl 0:2cc6bb4d7fea 28 extern "C" {
mbotkinl 0:2cc6bb4d7fea 29 #endif
mbotkinl 0:2cc6bb4d7fea 30
mbotkinl 0:2cc6bb4d7fea 31 typedef enum {
mbotkinl 0:2cc6bb4d7fea 32 IRQ_RX,
mbotkinl 0:2cc6bb4d7fea 33 IRQ_TX,
mbotkinl 0:2cc6bb4d7fea 34 IRQ_ERROR,
mbotkinl 0:2cc6bb4d7fea 35 IRQ_OVERRUN,
mbotkinl 0:2cc6bb4d7fea 36 IRQ_WAKEUP,
mbotkinl 0:2cc6bb4d7fea 37 IRQ_PASSIVE,
mbotkinl 0:2cc6bb4d7fea 38 IRQ_ARB,
mbotkinl 0:2cc6bb4d7fea 39 IRQ_BUS,
mbotkinl 0:2cc6bb4d7fea 40 IRQ_READY
mbotkinl 0:2cc6bb4d7fea 41 } CanIrqType;
mbotkinl 0:2cc6bb4d7fea 42
mbotkinl 0:2cc6bb4d7fea 43
mbotkinl 0:2cc6bb4d7fea 44 typedef enum {
mbotkinl 0:2cc6bb4d7fea 45 MODE_RESET,
mbotkinl 0:2cc6bb4d7fea 46 MODE_NORMAL,
mbotkinl 0:2cc6bb4d7fea 47 MODE_SILENT,
mbotkinl 0:2cc6bb4d7fea 48 MODE_TEST_GLOBAL,
mbotkinl 0:2cc6bb4d7fea 49 MODE_TEST_LOCAL,
mbotkinl 0:2cc6bb4d7fea 50 MODE_TEST_SILENT
mbotkinl 0:2cc6bb4d7fea 51 } CanMode;
mbotkinl 0:2cc6bb4d7fea 52
mbotkinl 0:2cc6bb4d7fea 53 typedef void (*can_irq_handler)(uint32_t id, CanIrqType type);
mbotkinl 0:2cc6bb4d7fea 54
mbotkinl 0:2cc6bb4d7fea 55 typedef struct can_s can_t;
mbotkinl 0:2cc6bb4d7fea 56
mbotkinl 0:2cc6bb4d7fea 57 void can_init (can_t *obj, PinName rd, PinName td);
mbotkinl 0:2cc6bb4d7fea 58 void can_free (can_t *obj);
mbotkinl 0:2cc6bb4d7fea 59 int can_frequency(can_t *obj, int hz);
mbotkinl 0:2cc6bb4d7fea 60
mbotkinl 0:2cc6bb4d7fea 61 void can_irq_init (can_t *obj, can_irq_handler handler, uint32_t id);
mbotkinl 0:2cc6bb4d7fea 62 void can_irq_free (can_t *obj);
mbotkinl 0:2cc6bb4d7fea 63 void can_irq_set (can_t *obj, CanIrqType irq, uint32_t enable);
mbotkinl 0:2cc6bb4d7fea 64
mbotkinl 0:2cc6bb4d7fea 65 int can_write (can_t *obj, CAN_Message, int cc);
mbotkinl 0:2cc6bb4d7fea 66 int can_read (can_t *obj, CAN_Message *msg, int handle);
mbotkinl 0:2cc6bb4d7fea 67 int can_mode (can_t *obj, CanMode mode);
mbotkinl 0:2cc6bb4d7fea 68 int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle);
mbotkinl 0:2cc6bb4d7fea 69 void can_reset (can_t *obj);
mbotkinl 0:2cc6bb4d7fea 70 unsigned char can_rderror (can_t *obj);
mbotkinl 0:2cc6bb4d7fea 71 unsigned char can_tderror (can_t *obj);
mbotkinl 0:2cc6bb4d7fea 72 void can_monitor (can_t *obj, int silent);
mbotkinl 0:2cc6bb4d7fea 73
mbotkinl 0:2cc6bb4d7fea 74 #ifdef __cplusplus
mbotkinl 0:2cc6bb4d7fea 75 };
mbotkinl 0:2cc6bb4d7fea 76 #endif
mbotkinl 0:2cc6bb4d7fea 77
mbotkinl 0:2cc6bb4d7fea 78 #endif // MBED_CAN_API_H
mbotkinl 0:2cc6bb4d7fea 79
mbotkinl 0:2cc6bb4d7fea 80 #endif