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