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