Fork of mbed-src file paths change. LPC1114FN28 use only.
Fork of mbed-src by
Information
この情報は2013/10/28時点での解決方法です。
現在はmbed-src、標準ライブラリで問題なくコンパイルが可能です。
・使う物
LPC1114FN28
mbed SDK
LPC1114FN28でmbed-SDKのLibraryを使うとCompile出来ない。(2013/10/28)
パスが通ってないだけのようなのでファイルを以下に移動する。
mbed-src\targets\cmsis\TARGET_NXP\TARGET_LPC11XX_11CXX\ mbed-src\targets\cmsis\TARGET_NXP\TARGET_LPC11XX_11CXX\TARGET_LPC11XX\ |
にあるファイルをすべて
mbed-src\targets\cmsis\TARGET_NXP\ |
へ移動
mbed-src\targets\cmsis\TARGET_NXP\TARGET_LPC11XX_11CXX\にある
TOOLCHAIN_ARM_MICRO |
をフォルダごと
mbed-src\targets\cmsis\TARGET_NXP\ |
へ移動
mbed-src\targets\hal\TARGET_NXP\TARGET_LPC11XX_11CXX\ mbed-src\targets\hal\TARGET_NXP\TARGET_LPC11XX_11CXX\TARGET_LPC11XX\ |
にあるファイルをすべて
mbed-src\targets\hal\TARGET_NXP\ |
へ移動
移動後は以下のような構成になると思います。
※不要なファイルは削除してあります。
ファイルの移動が面倒なので以下に本家からフォークしたライブラリを置いておきます。
Import librarymbed-src-LPC1114FN28
Fork of mbed-src file paths change. LPC1114FN28 use only.
エラーが出力される場合
"TOOLCHAIN_ARM_MICRO"が無いとエラーになる。
Error: Undefined symbol _initial_sp (referred from entry2.o). Error: Undefined symbol _heap_base (referred from malloc.o). Error: Undefined symbol _heap_limit (referred from malloc.o). |
LPC1114FN28はMicrolibを使ってCompileされるため上記のエラーになるようです。
Diff: api/InterruptIn.h
- Revision:
- 15:4892fe388435
- Parent:
- 13:0645d8841f51
- Child:
- 35:371630885ad6
--- a/api/InterruptIn.h Mon Aug 05 14:54:27 2013 +0000 +++ b/api/InterruptIn.h Wed Aug 07 16:43:59 2013 +0300 @@ -24,6 +24,7 @@ #include "gpio_irq_api.h" #include "FunctionPointer.h" +#include "CallChain.h" namespace mbed { @@ -72,37 +73,167 @@ /** Attach a function to call when a rising edge occurs on the input * * @param fptr A pointer to a void function, or 0 to set as none + * + * @returns + * The function object created for 'fptr' */ - void rise(void (*fptr)(void)); + pFunctionPointer_t rise(void (*fptr)(void)); + + /** Add a function to be called when a rising edge occurs at the end of the call chain + * + * @param fptr the function to add + * + * @returns + * The function object created for 'fptr' + */ + pFunctionPointer_t rise_add(void (*fptr)(void)) { + return rise_add_common(fptr); + } + + /** Add a function to be called when a rising edge occurs at the beginning of the call chain + * + * @param fptr the function to add + * + * @returns + * The function object created for 'fptr' + */ + pFunctionPointer_t rise_add_front(void (*fptr)(void)) { + return rise_add_common(fptr, true); + } /** Attach a member function to call when a rising edge occurs on the input * * @param tptr pointer to the object to call the member function on * @param mptr pointer to the member function to be called + * + * @returns + * The function object created for 'tptr' and 'mptr' + */ + template<typename T> + pFunctionPointer_t rise(T* tptr, void (T::*mptr)(void)) { + _rise.clear(); + pFunctionPointer_t pf = _rise.add(tptr, mptr); + gpio_irq_set(&gpio_irq, IRQ_RISE, 1); + return pf; + } + + /** Add a function to be called when a rising edge occurs at the end of the call chain + * + * @param tptr pointer to the object to call the member function on + * @param mptr pointer to the member function to be called + * + * @returns + * The function object created for 'tptr' and 'mptr' */ template<typename T> - void rise(T* tptr, void (T::*mptr)(void)) { - _rise.attach(tptr, mptr); - gpio_irq_set(&gpio_irq, IRQ_RISE, 1); + pFunctionPointer_t rise_add(T* tptr, void (T::*mptr)(void)) { + return rise_add_common(tptr, mptr); } + /** Add a function to be called when a rising edge occurs at the beginning of the call chain + * + * @param tptr pointer to the object to call the member function on + * @param mptr pointer to the member function to be called + * + * @returns + * The function object created for 'tptr' and 'mptr' + */ + template<typename T> + pFunctionPointer_t rise_add_front(T* tptr, void (T::*mptr)(void)) { + return rise_add_common(tptr, mptr, true); + } + + /** Remove a function from the list of functions to be called when a rising edge occurs + * + * @param pf the function object to remove + * + * @returns + * true if the function was found and removed, false otherwise + */ + bool rise_remove(pFunctionPointer_t pf); + /** Attach a function to call when a falling edge occurs on the input * * @param fptr A pointer to a void function, or 0 to set as none + * + * @returns + * The function object created for 'fptr' */ - void fall(void (*fptr)(void)); + pFunctionPointer_t fall(void (*fptr)(void)); + + /** Add a function to be called when a falling edge occurs at the end of the call chain + * + * @param fptr the function to add + * + * @returns + * The function object created for 'fptr' + */ + pFunctionPointer_t fall_add(void (*fptr)(void)) { + return fall_add_common(fptr); + } + + /** Add a function to be called when a falling edge occurs at the beginning of the call chain + * + * @param fptr the function to add + * + * @returns + * The function object created for 'fptr' + */ + pFunctionPointer_t fall_add_front(void (*fptr)(void)) { + return fall_add_common(fptr, true); + } /** Attach a member function to call when a falling edge occurs on the input * * @param tptr pointer to the object to call the member function on * @param mptr pointer to the member function to be called + * + * @returns + * The function object created for 'tptr' and 'mptr' + */ + template<typename T> + pFunctionPointer_t fall(T* tptr, void (T::*mptr)(void)) { + _fall.clear(); + pFunctionPointer_t pf = _fall.add(tptr, mptr); + gpio_irq_set(&gpio_irq, IRQ_FALL, 1); + return pf; + } + + /** Add a function to be called when a falling edge occurs at the end of the call chain + * + * @param tptr pointer to the object to call the member function on + * @param mptr pointer to the member function to be called + * + * @returns + * The function object created for 'tptr' and 'mptr' */ template<typename T> - void fall(T* tptr, void (T::*mptr)(void)) { - _fall.attach(tptr, mptr); - gpio_irq_set(&gpio_irq, IRQ_FALL, 1); + pFunctionPointer_t fall_add(T* tptr, void (T::*mptr)(void)) { + return fall_add_common(tptr, mptr); } + /** Add a function to be called when a falling edge occurs at the beginning of the call chain + * + * @param tptr pointer to the object to call the member function on + * @param mptr pointer to the member function to be called + * + * @returns + * The function object created for 'tptr' and 'mptr' + */ + template<typename T> + pFunctionPointer_t fall_add_front(T* tptr, void (T::*mptr)(void)) { + return fall_add_common(tptr, mptr, true); + } + + /** Remove a function from the list of functions to be called when a falling edge occurs + * + * @param pf the function object to remove + * + * @returns + * true if the function was found and removed, false otherwise + */ + bool fall_remove(pFunctionPointer_t pf); + /** Set the input pin mode * * @param mode PullUp, PullDown, PullNone @@ -112,11 +243,27 @@ static void _irq_handler(uint32_t id, gpio_irq_event event); protected: + pFunctionPointer_t rise_add_common(void (*fptr)(void), bool front=false); + pFunctionPointer_t fall_add_common(void (*fptr)(void), bool front=false); + + template<typename T> + pFunctionPointer_t rise_add_common(T* tptr, void (T::*mptr)(void), bool front=false) { + pFunctionPointer_t pf = front ? _rise.add_front(tptr, mptr) : _rise.add(tptr, mptr); + gpio_irq_set(&gpio_irq, IRQ_RISE, 1); + return pf; + } + template<typename T> + pFunctionPointer_t fall_add_common(T* tptr, void (T::*mptr)(void), bool front=false) { + pFunctionPointer_t pf = front ? _fall.add_front(tptr, mptr) : _fall.add(tptr, mptr); + gpio_irq_set(&gpio_irq, IRQ_FALL, 1); + return pf; + } + gpio_t gpio; gpio_irq_t gpio_irq; - FunctionPointer _rise; - FunctionPointer _fall; + CallChain _rise; + CallChain _fall; }; } // namespace mbed