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