mbed library for NZ32-SC151

Committer:
modtronix-com
Date:
Fri Aug 19 15:46:42 2016 +1000
Revision:
17:639ed60ce759
Parent:
1:71204b8406f2
Added tag v1.1 for changeset 076cbe3e55be

Who changed what in which revision?

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