mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-08-06 09:37:34 +00:00
Can bus start without handle
This commit is contained in:
@@ -2,17 +2,16 @@
|
||||
#ifdef STA_CAN_BUS_ENABLE
|
||||
|
||||
#include <sta/tacos/can_bus.hpp>
|
||||
#include <sta/rtos/system/can_bus.hpp>
|
||||
#include <sta/debug/debug.hpp>
|
||||
#include <sta/debug/assert.hpp>
|
||||
|
||||
// TODO fix this shit
|
||||
extern CAN_HandleTypeDef hcan1;
|
||||
namespace sta
|
||||
{
|
||||
namespace tacos
|
||||
{
|
||||
CanBus::CanBus(CAN_HandleTypeDef * controller)
|
||||
CanBus::CanBus()
|
||||
: TacosThread{"Can Bus", STA_TACOS_CAN_BUS_PRIORITY},
|
||||
canBusController_(new STM32CanController(controller)),
|
||||
canBusController_(new STM32CanController(&STA_STM32_CAN_HANDLE)),
|
||||
canBusSysQueue_(STA_RTOS_CAN_BUS_QUEUE_LENGTH),
|
||||
canBusDataQueue_(STA_RTOS_CAN_BUS_QUEUE_LENGTH),
|
||||
canBus_{canBusController_, HAL_GetTick, sta::tacos::handleSysMessage, sta::tacos::handleDataMessage}
|
||||
@@ -26,8 +25,10 @@ namespace sta
|
||||
|
||||
void CanBus::func()
|
||||
{
|
||||
uint32_t flags = osThreadFlagsWait(STA_RTOS_THREAD_FLAGS_VALID_BITS, osFlagsWaitAny, 50);
|
||||
messageEvent.clear(STA_RTOS_CAN_ANY);
|
||||
uint32_t flags = messageEvent.wait(STA_RTOS_CAN_ANY, osWaitForever);
|
||||
|
||||
STA_DEBUG_PRINTLN("CanBus received Flag");
|
||||
if (flags != static_cast<uint32_t>(osErrorTimeout))
|
||||
{
|
||||
STA_ASSERT_MSG((flags & osStatusReserved) == flags, "Unexpected error occurred in wait");
|
||||
@@ -38,6 +39,7 @@ namespace sta
|
||||
CanSysMsg msg;
|
||||
while (CanBus::_instance->getCanBusMsg(&msg, 0))
|
||||
{
|
||||
STA_DEBUG_PRINTLN("CanBus about to send");
|
||||
canBus_.send(msg);
|
||||
}
|
||||
}
|
||||
@@ -76,8 +78,9 @@ namespace sta
|
||||
|
||||
if (canBusDataQueue_.put(msg, timeout))
|
||||
{
|
||||
// Signal thread
|
||||
notify(STA_RTOS_CAN_FLAG_DATA_QUEUED);
|
||||
// Signal task
|
||||
messageEvent.set(STA_RTOS_CAN_FLAG_DATA_QUEUED);
|
||||
messageEvent.clear(STA_RTOS_CAN_ANY);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -92,8 +95,9 @@ namespace sta
|
||||
|
||||
if (canBusSysQueue_.put(msg, timeout))
|
||||
{
|
||||
// Signal thread
|
||||
notify(STA_RTOS_CAN_FLAG_SYS_QUEUED);
|
||||
// Signal tasek
|
||||
messageEvent.set(STA_RTOS_CAN_FLAG_SYS_QUEUED);
|
||||
messageEvent.clear(STA_RTOS_CAN_ANY);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -115,6 +119,8 @@ namespace sta
|
||||
|
||||
CanBus* CanBus::_instance = nullptr;
|
||||
|
||||
RtosEvent CanBus::messageEvent;
|
||||
|
||||
} /* namespace tacos */
|
||||
} /* namespace sta */
|
||||
|
||||
@@ -193,4 +199,4 @@ namespace sta {
|
||||
} // namespace tacos
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_CAN_BUS_ENABLE
|
||||
#endif // STA_CAN_BUS_ENABLE
|
||||
|
@@ -154,7 +154,7 @@ namespace sta
|
||||
{
|
||||
onCanBusInit();
|
||||
|
||||
CanBus::instance(getCanController())->start();
|
||||
CanBus::instance()->start();
|
||||
}
|
||||
#endif //STA_CAN_BUS_ENABLE
|
||||
} // namespace tacos
|
||||
|
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <sta/tacos.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
namespace tacos
|
||||
@@ -26,6 +25,11 @@ namespace sta
|
||||
{
|
||||
Statemachine::instance()->requestTimedStateTransition(from, to, millis, lockout);
|
||||
}
|
||||
/*bool queueCanBusMsg(const CanDataMsg & msg, uint32_t timeout){
|
||||
//extern CAN_HandleTypeDef hcan1;
|
||||
//return CanBus::instance(STA_STM32_CAN_HANDLE)->queueCanBusMsg(msg, timeout);
|
||||
return false;
|
||||
}*/
|
||||
} // namespace tacos
|
||||
|
||||
} // namespace sta
|
||||
|
Reference in New Issue
Block a user