mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-08-06 09:37:34 +00:00
CAN Bus shifted to TACOS from rtos
This commit is contained in:
@@ -1,24 +1,11 @@
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_RTOS_CAN_BUS_ENABLE
|
||||
#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>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
namespace rtos
|
||||
{
|
||||
|
||||
void initCanBus()
|
||||
{
|
||||
sta::tacos::CanBus::instance(getCanController())->start();
|
||||
}
|
||||
|
||||
} // namespace rtos
|
||||
} // namespace sta
|
||||
|
||||
namespace sta
|
||||
{
|
||||
namespace tacos
|
||||
@@ -206,4 +193,4 @@ namespace sta {
|
||||
} // namespace tacos
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_RTOS_CAN_BUS_ENABLE
|
||||
#endif // STA_CAN_BUS_ENABLE
|
@@ -29,7 +29,10 @@
|
||||
#include <sta/tacos/manager.hpp>
|
||||
#include <sta/tacos/statemachine.hpp>
|
||||
#include <sta/tacos/watchdog.hpp>
|
||||
#include <sta/tacos/can_bus.hpp>
|
||||
|
||||
// TODO: WHY DO I HAVE TO PUT THIS HERE???? DO YOU THINK YOU ARE SPECIAL, HUH MR. HCAN1? WHY CAN'T YOU BE NORMAL LIKE HUART
|
||||
extern CAN_HandleTypeDef hcan1;
|
||||
|
||||
// The UART mutex defined in freertos.c
|
||||
extern osMutexId_t uartMutexHandle;
|
||||
@@ -39,12 +42,6 @@ extern osMutexId_t uartMutexHandle;
|
||||
* @ingroup tacos
|
||||
* @brief Functions that are called during startup.
|
||||
*/
|
||||
|
||||
// CAN Handle
|
||||
#ifdef STA_RTOS_CAN_BUS_ENABLE
|
||||
extern CAN_HandleTypeDef hcan1;
|
||||
#endif /* STA_RTOS_CAN_BUS_ENABLE */
|
||||
|
||||
namespace sta
|
||||
{
|
||||
#ifdef STA_DEBUGGING_ENABLED
|
||||
@@ -63,6 +60,18 @@ namespace sta
|
||||
return &STA_STM32_USART_HANDLE;
|
||||
}
|
||||
|
||||
#if defined(STA_CAN_BUS_ENABLE) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief Function that returns the CAN handle used for the CAN bus. Override it in userspace to adjust.
|
||||
*
|
||||
* @ingroup tacos_startup
|
||||
*/
|
||||
STA_WEAK
|
||||
CAN_HandleTypeDef * getCanController(){
|
||||
return &STA_STM32_CAN_HANDLE;
|
||||
}
|
||||
#endif /* STA_CAN_BUS_ENABLE */
|
||||
|
||||
/**
|
||||
* @brief Function that initializes the printable object given by getUARThandle().
|
||||
*
|
||||
@@ -134,6 +143,23 @@ namespace sta
|
||||
extern CAN_HandleTypeDef hcan1;
|
||||
return new STM32CanController(&hcan1);
|
||||
}
|
||||
/**
|
||||
* @brief Function that is called before the Can Bus task is started. Override it to adjust
|
||||
* the Can bus to your specifications.
|
||||
*
|
||||
* @ingroup tacos_startup
|
||||
*/
|
||||
STA_WEAK
|
||||
void onCanBusInit()
|
||||
{}
|
||||
|
||||
void initCanBus()
|
||||
{
|
||||
onCanBusInit();
|
||||
|
||||
CanBus::instance(getCanController())->start();
|
||||
}
|
||||
|
||||
} // namespace tacos
|
||||
|
||||
|
||||
@@ -153,15 +179,11 @@ namespace sta
|
||||
#ifdef STA_TACOS_WATCHDOG_ENABLED
|
||||
tacos::initWatchdog();
|
||||
#endif // STA_TACOS_WATCHDOG_ENABLED
|
||||
}
|
||||
|
||||
#ifdef STA_RTOS_CAN_BUS_ENABLE
|
||||
STA_WEAK
|
||||
CAN_HandleTypeDef * getCanController(){
|
||||
return &hcan1;
|
||||
#ifdef STA_CAN_BUS_ENABLE
|
||||
tacos::initCanBus();
|
||||
#endif // STA_CAN_BUS_ENABLE
|
||||
}
|
||||
#endif /* STA_RTOS_CAN_BUS_ENABLE */
|
||||
|
||||
} // namespace rtos
|
||||
} // namespace sta
|
||||
|
||||
|
Reference in New Issue
Block a user