mbed-os
Fork of mbed-os by
hal/can_api.h@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | |
elessair | 0:f269e3021894 | 2 | /** \addtogroup hal */ |
elessair | 0:f269e3021894 | 3 | /** @{*/ |
elessair | 0:f269e3021894 | 4 | /* mbed Microcontroller Library |
elessair | 0:f269e3021894 | 5 | * Copyright (c) 2006-2016 ARM Limited |
elessair | 0:f269e3021894 | 6 | * |
elessair | 0:f269e3021894 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
elessair | 0:f269e3021894 | 8 | * you may not use this file except in compliance with the License. |
elessair | 0:f269e3021894 | 9 | * You may obtain a copy of the License at |
elessair | 0:f269e3021894 | 10 | * |
elessair | 0:f269e3021894 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
elessair | 0:f269e3021894 | 12 | * |
elessair | 0:f269e3021894 | 13 | * Unless required by applicable law or agreed to in writing, software |
elessair | 0:f269e3021894 | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
elessair | 0:f269e3021894 | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
elessair | 0:f269e3021894 | 16 | * See the License for the specific language governing permissions and |
elessair | 0:f269e3021894 | 17 | * limitations under the License. |
elessair | 0:f269e3021894 | 18 | */ |
elessair | 0:f269e3021894 | 19 | #ifndef MBED_CAN_API_H |
elessair | 0:f269e3021894 | 20 | #define MBED_CAN_API_H |
elessair | 0:f269e3021894 | 21 | |
elessair | 0:f269e3021894 | 22 | #include "device.h" |
elessair | 0:f269e3021894 | 23 | |
elessair | 0:f269e3021894 | 24 | #if DEVICE_CAN |
elessair | 0:f269e3021894 | 25 | |
elessair | 0:f269e3021894 | 26 | #include "PinNames.h" |
elessair | 0:f269e3021894 | 27 | #include "PeripheralNames.h" |
elessair | 0:f269e3021894 | 28 | #include "hal/can_helper.h" |
elessair | 0:f269e3021894 | 29 | |
elessair | 0:f269e3021894 | 30 | #ifdef __cplusplus |
elessair | 0:f269e3021894 | 31 | extern "C" { |
elessair | 0:f269e3021894 | 32 | #endif |
elessair | 0:f269e3021894 | 33 | |
elessair | 0:f269e3021894 | 34 | typedef enum { |
elessair | 0:f269e3021894 | 35 | IRQ_RX, |
elessair | 0:f269e3021894 | 36 | IRQ_TX, |
elessair | 0:f269e3021894 | 37 | IRQ_ERROR, |
elessair | 0:f269e3021894 | 38 | IRQ_OVERRUN, |
elessair | 0:f269e3021894 | 39 | IRQ_WAKEUP, |
elessair | 0:f269e3021894 | 40 | IRQ_PASSIVE, |
elessair | 0:f269e3021894 | 41 | IRQ_ARB, |
elessair | 0:f269e3021894 | 42 | IRQ_BUS, |
elessair | 0:f269e3021894 | 43 | IRQ_READY |
elessair | 0:f269e3021894 | 44 | } CanIrqType; |
elessair | 0:f269e3021894 | 45 | |
elessair | 0:f269e3021894 | 46 | |
elessair | 0:f269e3021894 | 47 | typedef enum { |
elessair | 0:f269e3021894 | 48 | MODE_RESET, |
elessair | 0:f269e3021894 | 49 | MODE_NORMAL, |
elessair | 0:f269e3021894 | 50 | MODE_SILENT, |
elessair | 0:f269e3021894 | 51 | MODE_TEST_LOCAL, |
elessair | 0:f269e3021894 | 52 | MODE_TEST_GLOBAL, |
elessair | 0:f269e3021894 | 53 | MODE_TEST_SILENT |
elessair | 0:f269e3021894 | 54 | } CanMode; |
elessair | 0:f269e3021894 | 55 | |
elessair | 0:f269e3021894 | 56 | typedef void (*can_irq_handler)(uint32_t id, CanIrqType type); |
elessair | 0:f269e3021894 | 57 | |
elessair | 0:f269e3021894 | 58 | typedef struct can_s can_t; |
elessair | 0:f269e3021894 | 59 | |
elessair | 0:f269e3021894 | 60 | void can_init (can_t *obj, PinName rd, PinName td); |
elessair | 0:f269e3021894 | 61 | void can_free (can_t *obj); |
elessair | 0:f269e3021894 | 62 | int can_frequency(can_t *obj, int hz); |
elessair | 0:f269e3021894 | 63 | |
elessair | 0:f269e3021894 | 64 | void can_irq_init (can_t *obj, can_irq_handler handler, uint32_t id); |
elessair | 0:f269e3021894 | 65 | void can_irq_free (can_t *obj); |
elessair | 0:f269e3021894 | 66 | void can_irq_set (can_t *obj, CanIrqType irq, uint32_t enable); |
elessair | 0:f269e3021894 | 67 | |
elessair | 0:f269e3021894 | 68 | int can_write (can_t *obj, CAN_Message, int cc); |
elessair | 0:f269e3021894 | 69 | int can_read (can_t *obj, CAN_Message *msg, int handle); |
elessair | 0:f269e3021894 | 70 | int can_mode (can_t *obj, CanMode mode); |
elessair | 0:f269e3021894 | 71 | int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle); |
elessair | 0:f269e3021894 | 72 | void can_reset (can_t *obj); |
elessair | 0:f269e3021894 | 73 | unsigned char can_rderror (can_t *obj); |
elessair | 0:f269e3021894 | 74 | unsigned char can_tderror (can_t *obj); |
elessair | 0:f269e3021894 | 75 | void can_monitor (can_t *obj, int silent); |
elessair | 0:f269e3021894 | 76 | |
elessair | 0:f269e3021894 | 77 | #ifdef __cplusplus |
elessair | 0:f269e3021894 | 78 | }; |
elessair | 0:f269e3021894 | 79 | #endif |
elessair | 0:f269e3021894 | 80 | |
elessair | 0:f269e3021894 | 81 | #endif // MBED_CAN_API_H |
elessair | 0:f269e3021894 | 82 | |
elessair | 0:f269e3021894 | 83 | #endif |
elessair | 0:f269e3021894 | 84 | |
elessair | 0:f269e3021894 | 85 | /** @}*/ |