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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
can_api.h
00001 00002 /** \addtogroup hal */ 00003 /** @{*/ 00004 /* mbed Microcontroller Library 00005 * Copyright (c) 2006-2016 ARM Limited 00006 * SPDX-License-Identifier: Apache-2.0 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); 00009 * you may not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 */ 00020 #ifndef MBED_CAN_API_H 00021 #define MBED_CAN_API_H 00022 00023 #include "device.h" 00024 #include "pinmap.h" 00025 00026 #if DEVICE_CAN 00027 00028 #include "PinNames.h" 00029 #include "PeripheralNames.h" 00030 #include "hal/can_helper.h" 00031 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00036 typedef enum { 00037 IRQ_RX, 00038 IRQ_TX, 00039 IRQ_ERROR, 00040 IRQ_OVERRUN, 00041 IRQ_WAKEUP, 00042 IRQ_PASSIVE, 00043 IRQ_ARB, 00044 IRQ_BUS, 00045 IRQ_READY 00046 } CanIrqType; 00047 00048 00049 typedef enum { 00050 MODE_RESET, 00051 MODE_NORMAL, 00052 MODE_SILENT, 00053 MODE_TEST_LOCAL, 00054 MODE_TEST_GLOBAL, 00055 MODE_TEST_SILENT 00056 } CanMode; 00057 00058 typedef struct { 00059 int peripheral; 00060 PinName rd_pin; 00061 int rd_function; 00062 PinName td_pin; 00063 int td_function; 00064 } can_pinmap_t; 00065 00066 typedef void (*can_irq_handler)(uint32_t id, CanIrqType type); 00067 00068 typedef struct can_s can_t; 00069 00070 void can_init(can_t *obj, PinName rd, PinName td); 00071 void can_init_direct(can_t *obj, const can_pinmap_t *pinmap); 00072 void can_init_freq(can_t *obj, PinName rd, PinName td, int hz); 00073 void can_init_freq_direct(can_t *obj, const can_pinmap_t *pinmap, int hz); 00074 void can_free(can_t *obj); 00075 int can_frequency(can_t *obj, int hz); 00076 00077 void can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id); 00078 void can_irq_free(can_t *obj); 00079 void can_irq_set(can_t *obj, CanIrqType irq, uint32_t enable); 00080 00081 int can_write(can_t *obj, CAN_Message, int cc); 00082 int can_read(can_t *obj, CAN_Message *msg, int handle); 00083 int can_mode(can_t *obj, CanMode mode); 00084 int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle); 00085 void can_reset(can_t *obj); 00086 unsigned char can_rderror(can_t *obj); 00087 unsigned char can_tderror(can_t *obj); 00088 void can_monitor(can_t *obj, int silent); 00089 00090 /** Get the pins that support CAN RD 00091 * 00092 * Return a PinMap array of pins that support CAN RD. The 00093 * array is terminated with {NC, NC, 0}. 00094 * 00095 * @return PinMap array 00096 */ 00097 const PinMap *can_rd_pinmap(void); 00098 00099 /** Get the pins that support CAN TD 00100 * 00101 * Return a PinMap array of pins that support CAN TD. The 00102 * array is terminated with {NC, NC, 0}. 00103 * 00104 * @return PinMap array 00105 */ 00106 const PinMap *can_td_pinmap(void); 00107 00108 #ifdef __cplusplus 00109 }; 00110 #endif 00111 00112 #endif // MBED_CAN_API_H 00113 00114 #endif 00115 00116 /** @}*/
Generated on Tue Jul 12 2022 13:54:04 by
