implement STM not tested
This commit is contained in:
		@@ -5,7 +5,37 @@
 | 
			
		||||
#include <cassert>
 | 
			
		||||
#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()
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user