generated from RaccoonlabDev/mini_v2_node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.cpp
42 lines (33 loc) · 1.16 KB
/
application.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/// This software is distributed under the terms of the MIT License.
/// Copyright (c) 2022-2023 Dmitry Ponomarev.
/// Author: Dmitry Ponomarev <[email protected]>
#include "application.hpp"
#include "cyphal.hpp"
#include "cyphal_registers.hpp"
#include "main.h"
#include "string_params.hpp"
#include "params.hpp"
#include "lights/lights.hpp"
#include "periphery/led/led.hpp"
#include "periphery/adc/adc.hpp"
void init_persistent_storage() {
paramsInit(static_cast<uint8_t>(IntParamsIndexes::INTEGER_PARAMS_AMOUNT), NUM_OF_STR_PARAMS);
paramsLoadFromFlash();
auto node_name_param_idx = static_cast<ParamIndex_t>(IntParamsIndexes::INTEGER_PARAMS_AMOUNT);
paramsSetStringValue(node_name_param_idx, 21, (const uint8_t*)"co.raccoonlab.lights");
}
void application_entry_point() {
AdcPeriphery::init();
LedPeriphery::reset();
init_persistent_storage();
cyphal::NodeGetInfoSubscriber::setHardwareVersion(2, 1);
cyphal::Cyphal cyphal;
int init_res = cyphal.init();
RgbLights lights(&cyphal);
init_res |= lights.init();
while (true) {
LedPeriphery::toggle();
cyphal.process();
lights.update();
}
}