This repo contains the libraries of Mbed for LPC1549 with following changes: - IAP commands. - EEPROM write and read. - UART write and read (public) - CAN can_s -> LPC_C_CAN0_Type *can
Ticker.h
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 #ifndef MBED_TICKER_H 00017 #define MBED_TICKER_H 00018 00019 #include "TimerEvent.h" 00020 #include "FunctionPointer.h" 00021 00022 namespace mbed { 00023 00024 /** A Ticker is used to call a function at a recurring interval 00025 * 00026 * You can use as many seperate Ticker objects as you require. 00027 * 00028 * Example: 00029 * @code 00030 * // Toggle the blinking led after 5 seconds 00031 * 00032 * #include "mbed.h" 00033 * 00034 * Ticker timer; 00035 * DigitalOut led1(LED1); 00036 * DigitalOut led2(LED2); 00037 * 00038 * int flip = 0; 00039 * 00040 * void attime() { 00041 * flip = !flip; 00042 * } 00043 * 00044 * int main() { 00045 * timer.attach(&attime, 5); 00046 * while(1) { 00047 * if(flip == 0) { 00048 * led1 = !led1; 00049 * } else { 00050 * led2 = !led2; 00051 * } 00052 * wait(0.2); 00053 * } 00054 * } 00055 * @endcode 00056 */ 00057 class Ticker : public TimerEvent { 00058 00059 public: 00060 00061 /** Attach a function to be called by the Ticker, specifiying the interval in seconds 00062 * 00063 * @param fptr pointer to the function to be called 00064 * @param t the time between calls in seconds 00065 */ 00066 void attach(void (*fptr)(void), float t) { 00067 attach_us(fptr, t * 1000000.0f); 00068 } 00069 00070 /** Attach a member function to be called by the Ticker, specifiying the interval in seconds 00071 * 00072 * @param tptr pointer to the object to call the member function on 00073 * @param mptr pointer to the member function to be called 00074 * @param t the time between calls in seconds 00075 */ 00076 template<typename T> 00077 void attach(T* tptr, void (T::*mptr)(void), float t) { 00078 attach_us(tptr, mptr, t * 1000000.0f); 00079 } 00080 00081 /** Attach a function to be called by the Ticker, specifiying the interval in micro-seconds 00082 * 00083 * @param fptr pointer to the function to be called 00084 * @param t the time between calls in micro-seconds 00085 */ 00086 void attach_us(void (*fptr)(void), timestamp_t t) { 00087 _function.attach(fptr); 00088 setup(t); 00089 } 00090 00091 /** Attach a member function to be called by the Ticker, specifiying the interval in micro-seconds 00092 * 00093 * @param tptr pointer to the object to call the member function on 00094 * @param mptr pointer to the member function to be called 00095 * @param t the time between calls in micro-seconds 00096 */ 00097 template<typename T> 00098 void attach_us(T* tptr, void (T::*mptr)(void), timestamp_t t) { 00099 _function.attach(tptr, mptr); 00100 setup(t); 00101 } 00102 00103 virtual ~Ticker() { 00104 detach(); 00105 } 00106 00107 /** Detach the function 00108 */ 00109 void detach(); 00110 00111 protected: 00112 void setup(timestamp_t t); 00113 virtual void handler(); 00114 00115 protected: 00116 timestamp_t _delay; /**< Time delay (in microseconds) for re-setting the multi-shot callback. */ 00117 FunctionPointer _function; /**< Callback. */ 00118 }; 00119 00120 } // namespace mbed 00121 00122 #endif
Generated on Wed Jul 13 2022 17:09:46 by 1.7.2