Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

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