ADD threads dispatcher and drive reset with event

This commit is contained in:
fastium
2024-12-30 16:56:04 +01:00
parent da79a18cd9
commit 69bc8785a8
3 changed files with 56 additions and 144 deletions

View File

@@ -26,9 +26,10 @@
// from advembsof
#include "EventQueue.h"
#include "display_device.hpp"
#include "task_logger.hpp"
#include "cpu_logger.hpp"
#include "display_device.hpp"
#include "mbed.h"
#include "task_logger.hpp"
// from common
#include "sensor_device.hpp"
@@ -75,22 +76,16 @@ class BikeSystem {
void displayTask2();
void cpuTask();
// stop flag, used for stopping the super-loop (set in stop())
bool _stopFlag = false;
std::chrono::microseconds _resetTime = std::chrono::microseconds::zero();
volatile bool _resetFlag = false;
// timer instance used for loggint task time and used by ResetDevice
Timer _timer;
// data member that represents the device for manipulating the gear
GearDevice _gearDevice;
uint8_t _currentGear = bike_computer::kMinGear;
uint8_t _currentGear = bike_computer::kMinGear;
uint8_t _currentGearSize = bike_computer::kMinGearSize;
// data member that represents the device for manipulating the pedal rotation
// speed/time
PedalDevice _pedalDevice;
float _currentSpeed = 0.0f;
float _currentSpeed = 0.0f;
float _traveledDistance = 0.0f;
// data member that represents the device used for resetting
ResetDevice _resetDevice;
@@ -109,7 +104,15 @@ class BikeSystem {
advembsof::CPULogger _cpuLogger;
// Event queues
EventQueue * _isrEventQueue;
EventQueue _isrEventQueue;
EventQueue _eventQueue;
// Tread for isr events
Thread _isrEventThread;
Thread _mainEventThread;
void dispatch_isr_events();
void dispatch_events();
};
} // namespace static_scheduling
} // namespace multi_tasking