mbed library sources: Modified to operate FRDM-KL25Z at 48MHz from internal 32kHz oscillator (nothing else changed).
Fork of mbed-src by
CAN.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #include "CAN.h" 00017 00018 #if DEVICE_CAN 00019 00020 #include "cmsis.h" 00021 00022 namespace mbed { 00023 00024 CAN::CAN(PinName rd, PinName td) { 00025 can_init(&_can, rd, td); 00026 can_irq_init(&_can, (&CAN::_irq_handler), (uint32_t)this); 00027 } 00028 00029 CAN::~CAN() { 00030 can_free(&_can); 00031 can_irq_free(&_can); 00032 } 00033 00034 int CAN::frequency(int f) { 00035 return can_frequency(&_can, f); 00036 } 00037 00038 int CAN::write(CANMessage msg) { 00039 return can_write(&_can, msg, 0); 00040 } 00041 00042 int CAN::read(CANMessage &msg) { 00043 return can_read(&_can, &msg); 00044 } 00045 00046 void CAN::reset() { 00047 can_reset(&_can); 00048 } 00049 00050 unsigned char CAN::rderror() { 00051 return can_rderror(&_can); 00052 } 00053 00054 unsigned char CAN::tderror() { 00055 return can_tderror(&_can); 00056 } 00057 00058 void CAN::monitor(bool silent) { 00059 can_monitor(&_can, (silent) ? 1 : 0); 00060 } 00061 00062 int CAN::mode(Mode mode) { 00063 return can_mode(&_can, (CanMode)mode); 00064 } 00065 00066 void CAN::attach(void (*fptr)(void), IrqType type) { 00067 if (fptr) { 00068 _irq[(CanIrqType)type].attach(fptr); 00069 can_irq_set(&_can, (CanIrqType)type, 1); 00070 } else { 00071 can_irq_set(&_can, (CanIrqType)type, 0); 00072 } 00073 } 00074 00075 void CAN::_irq_handler(uint32_t id, CanIrqType type) { 00076 CAN *handler = (CAN*)id; 00077 handler->_irq[type].call(); 00078 } 00079 00080 } // namespace mbed 00081 00082 #endif
Generated on Wed Jul 13 2022 19:29:54 by 1.7.2