test

Dependents:   robotic_fish_6

Committer:
juansal12
Date:
Fri Dec 03 23:00:34 2021 +0000
Revision:
0:c792b17d9f78
uploaded sofi code ;

Who changed what in which revision?

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