-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
26 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Author: Dmitry Ponomarev <[email protected]> | ||
*/ | ||
|
||
#include "application.hpp" | ||
#include <can_driver.h> | ||
#include <array> | ||
#include <bitset> | ||
#include "peripheral/adc/circuit_periphery.hpp" | ||
|
@@ -13,7 +13,7 @@ | |
#include "module.hpp" | ||
#include "main.h" | ||
|
||
#include "peripheral/led/led.hpp" | ||
#include "application.hpp" | ||
#include "peripheral/gpio/gpio.hpp" | ||
#include "peripheral/iwdg/iwdg.hpp" | ||
|
||
|
@@ -41,6 +41,14 @@ static int8_t init_board_periphery() { | |
return 0; | ||
} | ||
|
||
static int8_t init_can_driver() { | ||
int16_t res = canDriverInit(1000000, CAN_DRIVER_FIRST); | ||
return res; | ||
} | ||
static int8_t get_can_driver_protocol() { | ||
return canDriverGetProtocol(CAN_DRIVER_FIRST); | ||
} | ||
|
||
/** | ||
* @brief Since v2 hardware version all boards have an internal RGB LED and comply with the | ||
* RaccoonLab LED indication standard. | ||
|
@@ -82,10 +90,16 @@ static void blink_board_led() { | |
|
||
__attribute__((noreturn)) void application_entry_point() { | ||
init_board_periphery(); | ||
init_can_driver(); | ||
ModuleManager::init(); | ||
|
||
int8_t can_driver_protocol = CanProtocol::CAN_PROTOCOL_UNKNOWN; | ||
while (true) { | ||
ModuleManager::process(); | ||
if (can_driver_protocol == CanProtocol::CAN_PROTOCOL_UNKNOWN) { | ||
can_driver_protocol = get_can_driver_protocol(); | ||
ModuleManager::set_protocol(static_cast<Module::Protocol>(can_driver_protocol)); | ||
} else { | ||
ModuleManager::process(); | ||
} | ||
blink_board_led(); | ||
HAL::Watchdog::refresh(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters