++

Fork of mbed-stm32l0/l1-src by lzbp li

Committer:
mbed_official
Date:
Thu Apr 30 09:15:06 2015 +0100
Revision:
530:2939f5396008
Parent:
42:7ca0bbba899b
Synchronized with git revision 334b3418dfe6e5d09d62fee80232883fcd1cbb1e

Full URL: https://github.com/mbedmicro/mbed/commit/334b3418dfe6e5d09d62fee80232883fcd1cbb1e/

Implement some CAN modes for the LPC1549/LPC11Cxx/LPC1768

Who changed what in which revision?

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