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