~aleteoryx/muditaos

ref: 6e76dc3e5f1381725ee1de3c11c35d74fd9242d2 muditaos/module-bsp/board/rt1051/puretx/board.cpp -rw-r--r-- 1.2 KiB
6e76dc3e — Mateusz Szczesny [BH-1787] Reboot to MSC endpoint 2 years ago
                                                                                
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
43
44
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "bsp.hpp"
#include "board.h"
#include "drivers/gpio/DriverGPIO.hpp"
#include <board/BoardDefinitions.hpp>

namespace
{
    void board_shutdown()
    {
        /// No memory allocation here as this specific GPIO was initialized at the startup. We are just grabbing here a
        /// reference to the already existing object.
        using namespace drivers;
        auto gpio_power = DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::POWER_SWITCH_HOLD_GPIO),
                                             DriverGPIOParams{});
        gpio_power->WritePin(static_cast<uint32_t>(BoardDefinitions::POWER_SWITCH_HOLD_BUTTON), 0);
    }

    void board_reset()
    {
        NVIC_SystemReset();
    }
} // namespace

namespace bsp
{
    void board_exit(rebootState state)
    {
        switch (state) {
        case rebootState::none:
            break;
        case rebootState::poweroff:
            board_shutdown();
            break;
        case rebootState::reboot:
            board_reset();
            break;
        }

        while (true) {}
    }
} // namespace bsp