Official Sheffield ARMBand micro:bit program

Committer:
MrBedfordVan
Date:
Mon Oct 17 12:41:20 2016 +0000
Revision:
0:b9164b348919
Official Sheffield ARMBand Micro:bit program

Who changed what in which revision?

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