test

Dependents:   robotic_fish_7

Committer:
juansal12
Date:
Tue Jan 14 19:14:29 2020 +0000
Revision:
0:44931ff4a3ed
Sofi 7 code;

Who changed what in which revision?

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