mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers can_api.h Source File

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 
00025 #if DEVICE_CAN
00026 
00027 #include "PinNames.h"
00028 #include "PeripheralNames.h"
00029 #include "hal/can_helper.h"
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00035 typedef enum {
00036     IRQ_RX,
00037     IRQ_TX,
00038     IRQ_ERROR,
00039     IRQ_OVERRUN,
00040     IRQ_WAKEUP,
00041     IRQ_PASSIVE,
00042     IRQ_ARB,
00043     IRQ_BUS,
00044     IRQ_READY
00045 } CanIrqType;
00046 
00047 
00048 typedef enum {
00049     MODE_RESET,
00050     MODE_NORMAL,
00051     MODE_SILENT,
00052     MODE_TEST_LOCAL,
00053     MODE_TEST_GLOBAL,
00054     MODE_TEST_SILENT
00055 } CanMode;
00056 
00057 typedef void (*can_irq_handler)(uint32_t id, CanIrqType type);
00058 
00059 typedef struct can_s can_t;
00060 
00061 void          can_init(can_t *obj, PinName rd, PinName td);
00062 void          can_init_freq(can_t *obj, PinName rd, PinName td, int hz);
00063 void          can_free(can_t *obj);
00064 int           can_frequency(can_t *obj, int hz);
00065 
00066 void          can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id);
00067 void          can_irq_free(can_t *obj);
00068 void          can_irq_set(can_t *obj, CanIrqType irq, uint32_t enable);
00069 
00070 int           can_write(can_t *obj, CAN_Message, int cc);
00071 int           can_read(can_t *obj, CAN_Message *msg, int handle);
00072 int           can_mode(can_t *obj, CanMode mode);
00073 int           can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle);
00074 void          can_reset(can_t *obj);
00075 unsigned char can_rderror(can_t *obj);
00076 unsigned char can_tderror(can_t *obj);
00077 void          can_monitor(can_t *obj, int silent);
00078 
00079 #ifdef __cplusplus
00080 };
00081 #endif
00082 
00083 #endif    // MBED_CAN_API_H
00084 
00085 #endif
00086 
00087 /** @}*/