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