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