diff --git a/src/simplified/xf/port/idf-stm32/eventqueue.cpp b/src/simplified/xf/port/idf-stm32/eventqueue.cpp index 5848984..104a095 100644 --- a/src/simplified/xf/port/idf-stm32/eventqueue.cpp +++ b/src/simplified/xf/port/idf-stm32/eventqueue.cpp @@ -5,7 +5,37 @@ #include #include "eventqueue.h" -// TODO: Implement code for XFEventQueue class +// TODO done: Implement code for XFEventQueue class + +XFEventQueue::XFEventQueue(){ + +} + +XFEventQueue::~XFEventQueue(){ + +} + +bool XFEventQueue::empty() const { + return queue_.empty(); +} + +bool XFEventQueue::push(const XFEvent *pEvent, bool fromISR) { + if(!fromISR) mutex_.lock(); + queue_.push(pEvent); + if(!fromISR) mutex_.unlock(); + return true; +} + +const XFEvent* XFEventQueue::front() { + return queue_.front(); +} + +void XFEventQueue::pop() { + mutex_.lock(); + queue_.pop(); + mutex_.unlock(); +} + bool XFEventQueue::pend() { diff --git a/src/simplified/xf/port/idf-stm32/mutex.cpp b/src/simplified/xf/port/idf-stm32/mutex.cpp index 5b918d7..1016e53 100644 --- a/src/simplified/xf/port/idf-stm32/mutex.cpp +++ b/src/simplified/xf/port/idf-stm32/mutex.cpp @@ -8,17 +8,23 @@ /** * @brief Implementation of interface::XFMutex::create method. */ -interface::XFMutex * interface::XFMutex::create() -{ +interface::XFMutex * interface::XFMutex::create() { return new ::XFMutex; } void XFMutex::lock() { + enterCritical(); } void XFMutex::unlock() { + exitCritical(); } -// TODO: Implement code for XFMutex class +bool XFMutex::tryLock(int32_t timeout) { + XFMutex::lock(); + return true; +} + +// TODO done: Implement code for XFMutex class #endif // USE_XF_IDF_STM32_MUTEX_CLASS diff --git a/src/simplified/xf/port/idf-stm32/xf.cpp b/src/simplified/xf/port/idf-stm32/xf.cpp index 8075f7d..d8b00b6 100644 --- a/src/simplified/xf/port/idf-stm32/xf.cpp +++ b/src/simplified/xf/port/idf-stm32/xf.cpp @@ -9,21 +9,47 @@ using interface::XFTimeoutManager; -void XF_initialize(int timeInterval) -{ +void XF_initialize(int timeInterval) { XF::initialize(timeInterval); } -void XF_exec() -{ +void XF_exec() { XF::exec(); } -void XF_execOnce() -{ +void XF_execOnce() { XF::execOnce(); } // TODO: Implement code for XF class +bool XF::isInitialized_ = false; +bool XF::isRunning_ = false; + +void XF::initialize(int timeInterval, int argc, char *argv[]){ + + if(!isInitialized_) { + interface::XFTimeoutManager::getInstance()->initialize(timeInterval); + + isInitialized_ = true; + } +} + +int XF::exec(){ + int foo; + foo = interface::XFDispatcher::getInstance()->execute(); + isRunning_ = true; + return foo; +} + +int XF::execOnce() { + int foo; + foo = interface::XFDispatcher::getInstance()->execute(); + return foo; +} + +bool XF::isRunning() { + return isRunning_; +} + #endif // USE_XF_IDF_STM32_XF_CLASS diff --git a/test-bench/test1/ide-cubeide-test1-idf/.settings/language.settings.xml b/test-bench/test1/ide-cubeide-test1-idf/.settings/language.settings.xml index 227b466..ceba674 100644 --- a/test-bench/test1/ide-cubeide-test1-idf/.settings/language.settings.xml +++ b/test-bench/test1/ide-cubeide-test1-idf/.settings/language.settings.xml @@ -6,7 +6,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/test-bench/test2/ide-cubeide-test2-idf/.settings/language.settings.xml b/test-bench/test2/ide-cubeide-test2-idf/.settings/language.settings.xml index 1761298..8afe402 100644 --- a/test-bench/test2/ide-cubeide-test2-idf/.settings/language.settings.xml +++ b/test-bench/test2/ide-cubeide-test2-idf/.settings/language.settings.xml @@ -6,7 +6,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/test-bench/test3/ide-cubeide-test3-idf/.settings/language.settings.xml b/test-bench/test3/ide-cubeide-test3-idf/.settings/language.settings.xml index 6c6a232..4032b03 100644 --- a/test-bench/test3/ide-cubeide-test3-idf/.settings/language.settings.xml +++ b/test-bench/test3/ide-cubeide-test3-idf/.settings/language.settings.xml @@ -6,7 +6,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/test-bench/test4/ide-cubeide-test4-idf/.settings/language.settings.xml b/test-bench/test4/ide-cubeide-test4-idf/.settings/language.settings.xml index c7ea00f..24fea82 100644 --- a/test-bench/test4/ide-cubeide-test4-idf/.settings/language.settings.xml +++ b/test-bench/test4/ide-cubeide-test4-idf/.settings/language.settings.xml @@ -6,7 +6,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/test-bench/test5/ide-cubeide-test5-idf/.settings/language.settings.xml b/test-bench/test5/ide-cubeide-test5-idf/.settings/language.settings.xml index 3d74852..4e42cf8 100644 --- a/test-bench/test5/ide-cubeide-test5-idf/.settings/language.settings.xml +++ b/test-bench/test5/ide-cubeide-test5-idf/.settings/language.settings.xml @@ -6,7 +6,7 @@ - + @@ -18,7 +18,7 @@ - +