Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of CANnucleo by
can_api.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * Modified by Zoltan Hudak <hudakz@inbox.com> 00017 * 00018 */ 00019 #ifndef MBED_CAN_API_H 00020 #define MBED_CAN_API_H 00021 00022 #include "device.h" 00023 #include "PinNames.h" 00024 #include "PeripheralNames.h" 00025 #include "can_helper.h" 00026 00027 //#define DEBUG 1 00028 00029 #undef CAN 00030 00031 #if defined(TARGET_NUCLEO_F072RB) || \ 00032 defined(TARGET_NUCLEO_F091RC) 00033 #include "stm32f0xx_hal_msp.h" 00034 #elif defined(TARGET_NUCLEO_F103RB) 00035 #include "stm32f1xx_hal_msp.h" 00036 #elif defined(TARGET_NUCLEO_F302R8) || \ 00037 defined(TARGET_NUCLEO_F303RE) || \ 00038 defined(TARGET_NUCLEO_F303K8) || \ 00039 defined(TARGET_NUCLEO_F334R8) || \ 00040 defined(TARGET_DISCO_F334C8) 00041 #include "stm32f3xx_hal_msp.h" 00042 #elif defined(TARGET_NUCLEO_F446RE) 00043 #include "stm32f4xx_hal_msp.h" 00044 #endif 00045 00046 #ifdef __cplusplus 00047 extern "C" { 00048 #endif 00049 00050 typedef enum { 00051 IRQ_RX, 00052 IRQ_TX, 00053 IRQ_ERROR, 00054 IRQ_OVERRUN, 00055 IRQ_WAKEUP, 00056 IRQ_PASSIVE, 00057 IRQ_ARB, 00058 IRQ_BUS, 00059 IRQ_READY 00060 } CanIrqType; 00061 00062 00063 typedef enum { 00064 MODE_RESET, 00065 MODE_NORMAL, 00066 MODE_SILENT, 00067 MODE_TEST_GLOBAL, 00068 MODE_TEST_LOCAL, 00069 MODE_TEST_SILENT 00070 } CanMode; 00071 00072 typedef void (*can_irq_handler)(uint32_t id, CanIrqType type); 00073 00074 struct can_s { 00075 CAN_TypeDef *dev; 00076 int index; 00077 }; 00078 00079 typedef struct can_s can_t; 00080 00081 void can_init (can_t *obj, PinName rd, PinName td, FunctionalState abom); 00082 void can_free (can_t *obj); 00083 int can_frequency(can_t *obj, int hz); 00084 00085 void can_irq_init (can_t *obj, can_irq_handler handler, uint32_t id); 00086 void can_irq_free (can_t *obj); 00087 //void can_irq_set (can_t *obj, CanIrqType irq, uint32_t enable); 00088 void can_irq_set(void (*fptr)(void)); 00089 00090 00091 int can_write (can_t *obj, CAN_Message, int cc); 00092 int can_read (can_t *obj, CAN_Message *msg, int handle); 00093 int can_mode (can_t *obj, CanMode mode); 00094 int can_filter (can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle); 00095 void can_reset (can_t *obj); 00096 unsigned char can_rderror (can_t *obj); 00097 unsigned char can_tderror (can_t *obj); 00098 void can_monitor (can_t *obj, int silent); 00099 00100 #ifdef __cplusplus 00101 }; 00102 #endif 00103 00104 #endif // MBED_CAN_API_H 00105 00106
Generated on Tue Jul 12 2022 20:03:31 by
1.7.2
