mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
api/FunctionPointer.h@148:e70627d019e9, 2016-09-28 (annotated)
- Committer:
- StevieWray
- Date:
- Wed Sep 28 08:45:18 2016 +0000
- Revision:
- 148:e70627d019e9
- Parent:
- 144:ef7eb2e8f9f7
Fixed DAC output on STM32F3 boards to allow 3 outputs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /* mbed Microcontroller Library |
<> | 144:ef7eb2e8f9f7 | 2 | * Copyright (c) 2006-2015 ARM Limited |
<> | 144:ef7eb2e8f9f7 | 3 | * |
<> | 144:ef7eb2e8f9f7 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 144:ef7eb2e8f9f7 | 5 | * you may not use this file except in compliance with the License. |
<> | 144:ef7eb2e8f9f7 | 6 | * You may obtain a copy of the License at |
<> | 144:ef7eb2e8f9f7 | 7 | * |
<> | 144:ef7eb2e8f9f7 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 144:ef7eb2e8f9f7 | 9 | * |
<> | 144:ef7eb2e8f9f7 | 10 | * Unless required by applicable law or agreed to in writing, software |
<> | 144:ef7eb2e8f9f7 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 144:ef7eb2e8f9f7 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 144:ef7eb2e8f9f7 | 13 | * See the License for the specific language governing permissions and |
<> | 144:ef7eb2e8f9f7 | 14 | * limitations under the License. |
<> | 144:ef7eb2e8f9f7 | 15 | */ |
<> | 144:ef7eb2e8f9f7 | 16 | #ifndef MBED_FUNCTIONPOINTER_H |
<> | 144:ef7eb2e8f9f7 | 17 | #define MBED_FUNCTIONPOINTER_H |
<> | 144:ef7eb2e8f9f7 | 18 | |
<> | 144:ef7eb2e8f9f7 | 19 | #include "Callback.h" |
<> | 144:ef7eb2e8f9f7 | 20 | #include "toolchain.h" |
<> | 144:ef7eb2e8f9f7 | 21 | #include <string.h> |
<> | 144:ef7eb2e8f9f7 | 22 | #include <stdint.h> |
<> | 144:ef7eb2e8f9f7 | 23 | |
<> | 144:ef7eb2e8f9f7 | 24 | namespace mbed { |
<> | 144:ef7eb2e8f9f7 | 25 | |
<> | 144:ef7eb2e8f9f7 | 26 | |
<> | 144:ef7eb2e8f9f7 | 27 | // Declarations for backwards compatibility |
<> | 144:ef7eb2e8f9f7 | 28 | // To be foward compatible, code should adopt the Callback class |
<> | 144:ef7eb2e8f9f7 | 29 | template <typename R, typename A1> |
<> | 144:ef7eb2e8f9f7 | 30 | class FunctionPointerArg1 : public Callback<R(A1)> { |
<> | 144:ef7eb2e8f9f7 | 31 | public: |
<> | 144:ef7eb2e8f9f7 | 32 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 144:ef7eb2e8f9f7 | 33 | "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>") |
<> | 144:ef7eb2e8f9f7 | 34 | FunctionPointerArg1(R (*function)(A1) = 0) |
<> | 144:ef7eb2e8f9f7 | 35 | : Callback<R(A1)>(function) {} |
<> | 144:ef7eb2e8f9f7 | 36 | |
<> | 144:ef7eb2e8f9f7 | 37 | template<typename T> |
<> | 144:ef7eb2e8f9f7 | 38 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 144:ef7eb2e8f9f7 | 39 | "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>") |
<> | 144:ef7eb2e8f9f7 | 40 | FunctionPointerArg1(T *object, R (T::*member)(A1)) |
<> | 144:ef7eb2e8f9f7 | 41 | : Callback<R(A1)>(object, member) {} |
<> | 144:ef7eb2e8f9f7 | 42 | |
<> | 144:ef7eb2e8f9f7 | 43 | R (*get_function())(A1) { |
<> | 144:ef7eb2e8f9f7 | 44 | return *reinterpret_cast<R (**)(A1)>(this); |
<> | 144:ef7eb2e8f9f7 | 45 | } |
<> | 144:ef7eb2e8f9f7 | 46 | }; |
<> | 144:ef7eb2e8f9f7 | 47 | |
<> | 144:ef7eb2e8f9f7 | 48 | template <typename R> |
<> | 144:ef7eb2e8f9f7 | 49 | class FunctionPointerArg1<R, void> : public Callback<R()> { |
<> | 144:ef7eb2e8f9f7 | 50 | public: |
<> | 144:ef7eb2e8f9f7 | 51 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 144:ef7eb2e8f9f7 | 52 | "FunctionPointer has been replaced by Callback<void()>") |
<> | 144:ef7eb2e8f9f7 | 53 | FunctionPointerArg1(R (*function)() = 0) |
<> | 144:ef7eb2e8f9f7 | 54 | : Callback<R()>(function) {} |
<> | 144:ef7eb2e8f9f7 | 55 | |
<> | 144:ef7eb2e8f9f7 | 56 | template<typename T> |
<> | 144:ef7eb2e8f9f7 | 57 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 144:ef7eb2e8f9f7 | 58 | "FunctionPointer has been replaced by Callback<void()>") |
<> | 144:ef7eb2e8f9f7 | 59 | FunctionPointerArg1(T *object, R (T::*member)()) |
<> | 144:ef7eb2e8f9f7 | 60 | : Callback<R()>(object, member) {} |
<> | 144:ef7eb2e8f9f7 | 61 | |
<> | 144:ef7eb2e8f9f7 | 62 | R (*get_function())() { |
<> | 144:ef7eb2e8f9f7 | 63 | return *reinterpret_cast<R (**)()>(this); |
<> | 144:ef7eb2e8f9f7 | 64 | } |
<> | 144:ef7eb2e8f9f7 | 65 | }; |
<> | 144:ef7eb2e8f9f7 | 66 | |
<> | 144:ef7eb2e8f9f7 | 67 | typedef FunctionPointerArg1<void, void> FunctionPointer; |
<> | 144:ef7eb2e8f9f7 | 68 | |
<> | 144:ef7eb2e8f9f7 | 69 | |
<> | 144:ef7eb2e8f9f7 | 70 | } // namespace mbed |
<> | 144:ef7eb2e8f9f7 | 71 | |
<> | 144:ef7eb2e8f9f7 | 72 | #endif |