forked
Embed:
(wiki syntax)
Show/hide line numbers
can_api.h
00001 00002 /** \addtogroup hal */ 00003 /** @{*/ 00004 /* mbed Microcontroller Library 00005 * Copyright (c) 2006-2016 ARM Limited 00006 * 00007 * Licensed under the Apache License, Version 2.0 (the "License"); 00008 * you may not use this file except in compliance with the License. 00009 * You may obtain a copy of the License at 00010 * 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, 00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 * See the License for the specific language governing permissions and 00017 * limitations under the License. 00018 */ 00019 #ifndef MBED_CAN_API_H 00020 #define MBED_CAN_API_H 00021 00022 #include "device.h" 00023 00024 #if DEVICE_CAN 00025 00026 #include "PinNames.h" 00027 #include "PeripheralNames.h" 00028 #include "hal/can_helper.h" 00029 00030 #ifdef __cplusplus 00031 extern "C" { 00032 #endif 00033 00034 typedef enum { 00035 IRQ_RX, 00036 IRQ_TX, 00037 IRQ_ERROR, 00038 IRQ_OVERRUN, 00039 IRQ_WAKEUP, 00040 IRQ_PASSIVE, 00041 IRQ_ARB, 00042 IRQ_BUS, 00043 IRQ_READY 00044 } CanIrqType; 00045 00046 00047 typedef enum { 00048 MODE_RESET, 00049 MODE_NORMAL, 00050 MODE_SILENT, 00051 MODE_TEST_LOCAL, 00052 MODE_TEST_GLOBAL, 00053 MODE_TEST_SILENT 00054 } CanMode; 00055 00056 typedef void (*can_irq_handler)(uint32_t id, CanIrqType type); 00057 00058 typedef struct can_s can_t; 00059 00060 void can_init (can_t *obj, PinName rd, PinName td); 00061 void can_init_freq (can_t *obj, PinName rd, PinName td, int hz); 00062 void can_free (can_t *obj); 00063 int can_frequency (can_t *obj, int hz); 00064 00065 void can_irq_init (can_t *obj, can_irq_handler handler, uint32_t id); 00066 void can_irq_free (can_t *obj); 00067 void can_irq_set (can_t *obj, CanIrqType irq, uint32_t enable); 00068 00069 int can_write (can_t *obj, CAN_Message, int cc); 00070 int can_read (can_t *obj, CAN_Message *msg, int handle); 00071 int can_mode (can_t *obj, CanMode mode); 00072 int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle); 00073 void can_reset (can_t *obj); 00074 unsigned char can_rderror (can_t *obj); 00075 unsigned char can_tderror (can_t *obj); 00076 void can_monitor (can_t *obj, int silent); 00077 00078 #ifdef __cplusplus 00079 }; 00080 #endif 00081 00082 #endif // MBED_CAN_API_H 00083 00084 #endif 00085 00086 /** @}*/
Generated on Tue Jul 12 2022 16:02:31 by 1.7.2