M module-bsp/board/linux/board.cpp => module-bsp/board/linux/board.cpp +4 -4
@@ 1,19 1,19 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
namespace bsp
{
- void BoardInit()
+ void board_init()
{
// dummy
}
- void BoardPowerOff()
+ void board_power_off()
{
// dummy
}
- void BoardReboot()
+ void board_restart()
{
// dummy
}
M module-bsp/board/linux/hal/battery_charger/BatteryCharger.cpp => module-bsp/board/linux/hal/battery_charger/BatteryCharger.cpp +3 -2
@@ 67,8 67,9 @@ namespace hal::battery
BatteryCharger::~BatteryCharger()
{
- shouldRun = false;
- notificationChannel = nullptr;
+ shouldRun = false;
+ /// The worker operates in taskDelay intervals. Give it at least taskDelay to handle the close procedure.
+ vTaskDelay(taskDelay * 2);
}
AbstractBatteryCharger::Voltage BatteryCharger::getBatteryVoltage() const
M module-bsp/board/rt1051/CMakeLists.txt => module-bsp/board/rt1051/CMakeLists.txt +1 -1
@@ 24,7 24,7 @@ target_sources(module-bsp
bsp/lpm/ClockState.cpp
bsp/lpm/CpuFreqLPM.cpp
bsp/lpm/Oscillator.cpp
- bsp/lpm/RT1051LPM.cpp
+ bsp/lpm/RT1051LPMCommon.cpp
bsp/magnetometer/ALS31300.cpp
bsp/pit/pit.cpp
bsp/rtc/rtc.cpp
M module-bsp/board/rt1051/bellpx/CMakeLists.txt => module-bsp/board/rt1051/bellpx/CMakeLists.txt +2 -1
@@ 20,6 20,7 @@ target_sources(
bsp/bell_temp_sensor/bell_temp_sensor.cpp
bsp/eink/eink_pin_config.cpp
bsp/lpm/PowerProfile.cpp
+ bsp/lpm/RT1051LPM.cpp
bsp/rotary_encoder/rotary_encoder.cpp
bsp/switches/switches.cpp
@@ 28,7 29,7 @@ target_sources(
debug_console.cpp
irq_gpio.cpp
pin_mux.c
-
+ board.cpp
PUBLIC
eink-config.h
A module-bsp/board/rt1051/bellpx/board.cpp => module-bsp/board/rt1051/bellpx/board.cpp +52 -0
@@ 0,0 1,52 @@
+// Copyright (c) 2017-2022, 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
+{
+ using namespace drivers;
+
+ void board_power_off()
+ {
+ /// 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
+ auto gpio_wakeup =
+ DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::BELL_WAKEUP_GPIO), DriverGPIOParams{});
+
+ gpio_wakeup->ConfPin(DriverGPIOPinParams{.dir = DriverGPIOPinParams::Direction::Input,
+ .irqMode = DriverGPIOPinParams::InterruptMode::IntRisingEdge,
+ .defLogic = 0,
+ .pin = static_cast<std::uint32_t>(BoardDefinitions::BELL_WAKEUP)});
+ gpio_wakeup->ClearPortInterrupts(1 << static_cast<std::uint32_t>(BoardDefinitions::BELL_WAKEUP));
+ gpio_wakeup->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_WAKEUP));
+
+ SNVS->LPCR |= SNVS_LPCR_TOP(1); /// Enter SNVS mode
+ }
+
+ void board_reset()
+ {
+ NVIC_SystemReset();
+ }
+} // namespace
+
+namespace bsp
+{
+ void board_exit(rebootState state)
+ {
+ switch (state) {
+ case rebootState::none:
+ break;
+ case rebootState::poweroff:
+ board_power_off();
+ break;
+ case rebootState::reboot:
+ board_reset();
+ break;
+ }
+ while (true) {}
+ }
+} // namespace bsp
M module-bsp/board/rt1051/bellpx/board/BoardDefinitions.hpp => module-bsp/board/rt1051/bellpx/board/BoardDefinitions.hpp +9 -9
@@ 145,15 145,15 @@ enum class BoardDefinitions
BELL_TEMP_SENSOR_I2C = static_cast<int>(drivers::I2CInstances::I2C4),
BELL_TEMP_SENSOR_I2C_BAUDRATE = I2C_STD_BAUDRATE,
- BELL_SWITCHES_GPIO = static_cast<int>(drivers::GPIOInstances::GPIO_2),
- BELL_SWITCHES_CENTER = 16, // GPIO_B1_00
- BELL_SWITCHES_RIGHT = 24, // GPIO_B1_08
- BELL_SWITCHES_LEFT = 25, // GPIO_B1_09
- BELL_SWITCHES_LATCH = 26, // GPIO_B1_10
- BELL_SWITCHES_DOME = 27, // GPIO_B1_11
-
- BELL_WAKEUP_GPIO = static_cast<int>(drivers::GPIOInstances::GPIO_5),
- BELL_WAKEUP = 0, // SNVS_WAKEUP_GPIO5_IO00
+ BELL_SWITCHES_GPIO = static_cast<int>(drivers::GPIOInstances ::GPIO_2),
+ BELL_SWITCHES_RIGHT = 24, // GPIO_B1_08
+ BELL_SWITCHES_LEFT = 25, // GPIO_B1_09
+ BELL_SWITCHES_LATCH = 26, // GPIO_B1_10
+
+ BELL_WAKEUP_GPIO = static_cast<int>(drivers::GPIOInstances ::GPIO_5),
+ BELL_WAKEUP = 0, // SNVS_WAKEUP_GPIO5_IO00
+ BELL_CENTER_SWITCH_GPIO = BELL_WAKEUP_GPIO,
+ BELL_CENTER_SWITCH = BELL_WAKEUP,
BELL_BATTERY_CHARGER_GPIO = static_cast<int>(drivers::GPIOInstances::GPIO_2),
BELL_BATTERY_CHARGER_CHGEN_PIN = 23,
M module-bsp/board/rt1051/bellpx/board/pin_mux.h => module-bsp/board/rt1051/bellpx/board/pin_mux.h +2 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
/*
@@ 145,7 145,6 @@ extern "C"
*/
#define PINMUX_BUTTON_SW1 IOMUXC_GPIO_B1_08_GPIO2_IO24
#define PINMUX_BUTTON_SW2 IOMUXC_GPIO_B1_09_GPIO2_IO25
-#define PINMUX_BUTTON_SW_ENC IOMUXC_GPIO_B1_00_GPIO2_IO16
#define PINMUX_BUTTON_SW_PUSH IOMUXC_GPIO_B1_10_GPIO2_IO26
void PINMUX_InitButtons(void);
@@ 173,7 172,7 @@ extern "C"
/**
* BELL WDOG_B
*/
-#define PINMUX_WDOG_B IOMUXC_GPIO_B1_13_GPIO2_IO29
+#define PINMUX_WDOG_B IOMUXC_GPIO_B1_13_WDOG1_B
void PINMUX_WDOG_B_Init(void);
/**
M module-bsp/board/rt1051/bellpx/bsp/KeyInputCommon.hpp => module-bsp/board/rt1051/bellpx/bsp/KeyInputCommon.hpp +1 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 15,8 15,6 @@ namespace bsp
lightCenterKeyRelease,
latchKeyPress,
latchKeyRelease,
- wakeupEvent,
- wakeupEventRelease,
rotaryEncoder,
Invalid = 0xFF
};
A module-bsp/board/rt1051/bellpx/bsp/lpm/RT1051LPM.cpp => module-bsp/board/rt1051/bellpx/bsp/lpm/RT1051LPM.cpp +15 -0
@@ 0,0 1,15 @@
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "RT1051LPM.hpp"
+#include <board.h>
+#include <board/BoardDefinitions.hpp>
+
+namespace bsp
+{
+ void RT1051LPM::EnableDcdcPowerSaveMode()
+ {}
+
+ void RT1051LPM::DisableDcdcPowerSaveMode()
+ {}
+} // namespace bsp
A module-bsp/board/rt1051/bellpx/bsp/lpm/RT1051LPM.hpp => module-bsp/board/rt1051/bellpx/bsp/lpm/RT1051LPM.hpp +16 -0
@@ 0,0 1,16 @@
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+#include <bsp/lpm/RT1051LPMCommon.hpp>
+
+namespace bsp
+{
+ class RT1051LPM : public RT1051LPMCommon
+ {
+ public:
+ void EnableDcdcPowerSaveMode() final;
+ void DisableDcdcPowerSaveMode() final;
+ };
+
+} // namespace bsp
M module-bsp/board/rt1051/bellpx/bsp/rotary_encoder/rotary_encoder.cpp => module-bsp/board/rt1051/bellpx/bsp/rotary_encoder/rotary_encoder.cpp +2 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "rotary_encoder.hpp"
@@ 86,7 86,7 @@ namespace bsp::rotary_encoder
return out;
}
- BaseType_t IRQHandler(uint32_t mask)
+ BaseType_t IRQHandler()
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (gHandleIrq != nullptr) {
M module-bsp/board/rt1051/bellpx/bsp/rotary_encoder/rotary_encoder.hpp => module-bsp/board/rt1051/bellpx/bsp/rotary_encoder/rotary_encoder.hpp +2 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 17,7 17,7 @@ namespace bsp
void init(xQueueHandle qHandle);
void deinit();
std::vector<KeyEvent> getKeyEvents();
- BaseType_t IRQHandler(uint32_t mask);
+ BaseType_t IRQHandler();
} // namespace rotary_encoder
} // namespace bsp
M module-bsp/board/rt1051/bellpx/bsp/switches/switches.cpp => module-bsp/board/rt1051/bellpx/bsp/switches/switches.cpp +33 -56
@@ 40,7 40,6 @@ namespace bsp::bell_switches
rightSideSwitch,
lightCenterSwitch,
latchSwitch,
- wakeup,
Invalid
};
@@ 114,7 113,7 @@ namespace bsp::bell_switches
static xQueueHandle qHandleIrq{};
std::shared_ptr<DriverGPIO> gpio_sw;
- std::shared_ptr<DriverGPIO> gpio_wakeup;
+ std::shared_ptr<DriverGPIO> gpio_center;
NotificationSource getNotificationSource(KeyId keyId, KeyEvents state)
{
@@ 133,9 132,6 @@ namespace bsp::bell_switches
case KeyId::latchSwitch:
val = NotificationSource::latchKeyRelease;
break;
- case KeyId::wakeup:
- val = NotificationSource::wakeupEventRelease;
- break;
default:
break;
}
@@ 154,9 150,6 @@ namespace bsp::bell_switches
case KeyId::latchSwitch:
val = NotificationSource::latchKeyPress;
break;
- case KeyId::wakeup:
- val = NotificationSource::wakeupEvent;
- break;
default:
break;
}
@@ 250,14 243,16 @@ namespace bsp::bell_switches
}
}
- void configureSwitch(BoardDefinitions boardSwitch, DriverGPIOPinParams::InterruptMode mode)
+ void configureSwitch(BoardDefinitions boardSwitch,
+ DriverGPIOPinParams::InterruptMode mode,
+ std::shared_ptr<drivers::DriverGPIO> gpio)
{
- gpio_sw->ClearPortInterrupts(1 << magic_enum::enum_integer(boardSwitch));
- gpio_sw->ConfPin(DriverGPIOPinParams{.dir = DriverGPIOPinParams::Direction::Input,
- .irqMode = mode,
- .defLogic = 1,
- .pin = static_cast<uint32_t>(boardSwitch)});
+ gpio->ClearPortInterrupts(1 << magic_enum::enum_integer(boardSwitch));
+ gpio->ConfPin(DriverGPIOPinParams{.dir = DriverGPIOPinParams::Direction::Input,
+ .irqMode = mode,
+ .defLogic = 1,
+ .pin = static_cast<uint32_t>(boardSwitch)});
}
int32_t init(xQueueHandle qHandle)
@@ 267,25 262,25 @@ namespace bsp::bell_switches
// Switches
gpio_sw =
DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::BELL_SWITCHES_GPIO), DriverGPIOParams{});
- // wakeup
- gpio_wakeup =
- DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::BELL_WAKEUP_GPIO), DriverGPIOParams{});
-
- configureSwitch(BoardDefinitions::BELL_SWITCHES_LATCH,
- DriverGPIOPinParams::InterruptMode::IntRisingOrFallingEdge);
- configureSwitch(BoardDefinitions::BELL_SWITCHES_LEFT,
- DriverGPIOPinParams::InterruptMode::IntRisingOrFallingEdge);
- configureSwitch(BoardDefinitions::BELL_SWITCHES_RIGHT,
- DriverGPIOPinParams::InterruptMode::IntRisingOrFallingEdge);
- configureSwitch(BoardDefinitions::BELL_SWITCHES_CENTER, DriverGPIOPinParams::InterruptMode::IntRisingEdge);
- configureSwitch(BoardDefinitions::BELL_WAKEUP, DriverGPIOPinParams::InterruptMode::IntFallingEdge);
+
+ gpio_center = DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::BELL_CENTER_SWITCH_GPIO),
+ DriverGPIOParams{});
+
+ configureSwitch(
+ BoardDefinitions::BELL_SWITCHES_LATCH, DriverGPIOPinParams::InterruptMode::IntRisingOrFallingEdge, gpio_sw);
+ configureSwitch(
+ BoardDefinitions::BELL_SWITCHES_LEFT, DriverGPIOPinParams::InterruptMode::IntRisingOrFallingEdge, gpio_sw);
+ configureSwitch(
+ BoardDefinitions::BELL_SWITCHES_RIGHT, DriverGPIOPinParams::InterruptMode::IntRisingOrFallingEdge, gpio_sw);
+ configureSwitch(
+ BoardDefinitions::BELL_CENTER_SWITCH, DriverGPIOPinParams::InterruptMode::IntFallingEdge, gpio_center);
addDebounceTimer(DebounceTimerState{KeyId::leftSideSwitch, gpio_sw, BoardDefinitions::BELL_SWITCHES_LEFT});
addDebounceTimer(DebounceTimerState{KeyId::rightSideSwitch, gpio_sw, BoardDefinitions::BELL_SWITCHES_RIGHT});
- addDebounceTimer(DebounceTimerState{KeyId::lightCenterSwitch, gpio_sw, BoardDefinitions::BELL_SWITCHES_CENTER});
+ addDebounceTimer(
+ DebounceTimerState{KeyId::lightCenterSwitch, gpio_center, BoardDefinitions::BELL_CENTER_SWITCH});
addLatchDebounceTimer(DebounceTimerState{
KeyId::latchSwitch, gpio_sw, BoardDefinitions::BELL_SWITCHES_LATCH, KeyEvents::Released});
- addDebounceTimer(DebounceTimerState{KeyId::wakeup, gpio_wakeup, BoardDefinitions::BELL_WAKEUP});
if (getLatchState() == KeyEvents::Pressed) {
latchEventFlag.setPressed(LatchEventFlag::NO_STATE_CHANGE_INDICATION);
@@ 310,7 305,7 @@ namespace bsp::bell_switches
debounceTimers.clear();
gpio_sw.reset();
- gpio_wakeup.reset();
+ gpio_center.reset();
return kStatus_Success;
}
@@ 332,22 327,17 @@ namespace bsp::bell_switches
}
}
- BaseType_t IRQHandler(uint32_t mask)
+ BaseType_t GPIO2SwitchesIRQHandler(uint32_t mask)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
auto timerId = KeyId::Invalid;
- gpio_sw->ClearPortInterrupts(1U << mask);
-
if (mask & (1 << magic_enum::enum_integer(BoardDefinitions::BELL_SWITCHES_LEFT))) {
timerId = KeyId::leftSideSwitch;
}
else if (mask & (1 << magic_enum::enum_integer(BoardDefinitions::BELL_SWITCHES_RIGHT))) {
timerId = KeyId::rightSideSwitch;
}
- else if (mask & (1 << magic_enum::enum_integer(BoardDefinitions::BELL_SWITCHES_CENTER))) {
- timerId = KeyId::lightCenterSwitch;
- }
else if (mask & (1 << magic_enum::enum_integer(BoardDefinitions::BELL_SWITCHES_LATCH))) {
timerId = KeyId::latchSwitch;
}
@@ 357,41 347,34 @@ namespace bsp::bell_switches
return xHigherPriorityTaskWoken;
}
- BaseType_t wakeupIRQHandler()
+ BaseType_t GPIO5SwitchesIRQHandler(uint32_t mask)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
- gpio_wakeup->ClearPortInterrupts(1U << static_cast<uint32_t>(BoardDefinitions::BELL_WAKEUP));
-
- getDebounceTimer(xHigherPriorityTaskWoken, KeyId::wakeup);
+ auto keyID = KeyId::Invalid;
+ if (mask & (1 << magic_enum::enum_integer(BoardDefinitions::BELL_CENTER_SWITCH))) {
+ keyID = KeyId::lightCenterSwitch;
+ }
+ getDebounceTimer(xHigherPriorityTaskWoken, keyID);
return xHigherPriorityTaskWoken;
}
void enableIRQ()
{
- gpio_sw->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_CENTER));
+ gpio_center->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_CENTER_SWITCH));
gpio_sw->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_LEFT));
gpio_sw->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_RIGHT));
gpio_sw->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_LATCH));
}
- void enableWakeupIRQ()
- {
- gpio_wakeup->EnableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_WAKEUP));
- }
-
void disableIRQ()
{
- gpio_sw->DisableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_CENTER));
+ gpio_center->DisableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_CENTER_SWITCH));
gpio_sw->DisableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_LEFT));
gpio_sw->DisableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_RIGHT));
gpio_sw->DisableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_LATCH));
}
- void disableWakeupIRQ()
- {
- gpio_wakeup->DisableInterrupt(1 << static_cast<uint32_t>(BoardDefinitions::BELL_WAKEUP));
- }
std::vector<KeyEvent> getKeyEvents(NotificationSource notification)
{
@@ 439,12 422,6 @@ namespace bsp::bell_switches
keyEvent = {KeyCodes::JoystickLeft, KeyEvents::Moved};
out.push_back(keyEvent);
break;
- case NotificationSource::wakeupEvent:
- /* Implement wakeup event */
- break;
- case NotificationSource::wakeupEventRelease:
- /* Implement wakeup event */
- break;
}
return out;
}
M module-bsp/board/rt1051/bellpx/bsp/switches/switches.hpp => module-bsp/board/rt1051/bellpx/bsp/switches/switches.hpp +3 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 21,9 21,9 @@ namespace bsp::bell_switches
void disableIRQ();
- BaseType_t IRQHandler(uint32_t mask);
+ BaseType_t GPIO2SwitchesIRQHandler(std::uint32_t mask);
- BaseType_t wakeupIRQHandler();
+ BaseType_t GPIO5SwitchesIRQHandler(std::uint32_t mask);
void clearStartupLatchInterrupt();
M module-bsp/board/rt1051/bellpx/hal/key_input/KeyInput.cpp => module-bsp/board/rt1051/bellpx/hal/key_input/KeyInput.cpp +11 -11
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "KeyInput.hpp"
@@ 39,19 39,19 @@ namespace hal::key_input
}
}
- BaseType_t generalIRQHandler(std::uint32_t irqMask)
+ BaseType_t EncoderIRQHandler()
{
- constexpr std::uint32_t encoderMask{99};
- if (irqMask == encoderMask) {
- return bsp::rotary_encoder::IRQHandler(irqMask);
- }
- else {
- return bsp::bell_switches::IRQHandler(irqMask);
- }
+ return bsp::rotary_encoder::IRQHandler();
}
- BaseType_t wakeupIRQHandler()
+ BaseType_t GPIO2SwitchesIRQHandler(std::uint32_t irqMask)
{
- return bsp::bell_switches::wakeupIRQHandler();
+ return bsp::bell_switches::GPIO2SwitchesIRQHandler(irqMask);
}
+
+ BaseType_t GPIO5SwitchesIRQHandler(std::uint32_t irqMask)
+ {
+ return bsp::bell_switches::GPIO5SwitchesIRQHandler(irqMask);
+ }
+
} // namespace hal::key_input
M module-bsp/board/rt1051/bellpx/hal/key_input/KeyInput.hpp => module-bsp/board/rt1051/bellpx/hal/key_input/KeyInput.hpp +6 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 13,7 13,10 @@ namespace hal::key_input
void init(xQueueHandle) final;
void deinit() final;
std::vector<bsp::KeyEvent> getKeyEvents(KeyNotificationSource) final;
-
- BaseType_t wakeupIRQHandler();
};
+
+ BaseType_t EncoderIRQHandler();
+ BaseType_t GPIO2SwitchesIRQHandler(std::uint32_t irqMask);
+ BaseType_t GPIO5SwitchesIRQHandler(std::uint32_t irqMask);
+
} // namespace hal::key_input
M module-bsp/board/rt1051/bellpx/irq_gpio.cpp => module-bsp/board/rt1051/bellpx/irq_gpio.cpp +22 -14
@@ 9,12 9,14 @@
#include "queue.h"
#include "fsl_common.h"
#include <fsl_qtmr.h>
+#include <fsl_gpc.h>
#include "board/rt1051/bsp/eink/bsp_eink.h"
#include <hal/key_input/KeyInput.hpp>
#include <hal/battery_charger/BatteryChargerIRQ.hpp>
#include "board/BoardDefinitions.hpp"
#include "bsp/light_sensor/light_sensor.hpp"
+#include <bsp/lpm/RT1051LPM.hpp>
namespace bsp
{
@@ 28,11 30,12 @@ namespace bsp
DisableIRQ(GPIO3_Combined_16_31_IRQn);
DisableIRQ(GPIO5_Combined_0_15_IRQn);
DisableIRQ(TMR3_IRQn);
+ DisableIRQ(RTWDOG_IRQn);
GPIO_PortDisableInterrupts(GPIO1, UINT32_MAX);
GPIO_PortDisableInterrupts(GPIO2, UINT32_MAX);
GPIO_PortDisableInterrupts(GPIO3, UINT32_MAX);
- GPIO_PortClearInterruptFlags(GPIO5, UINT32_MAX);
+ GPIO_PortDisableInterrupts(GPIO5, UINT32_MAX);
// Clear all IRQs
GPIO_PortClearInterruptFlags(GPIO1, UINT32_MAX);
@@ 59,11 62,15 @@ namespace bsp
EnableIRQ(GPIO3_Combined_16_31_IRQn);
NVIC_SetPriority(GPIO3_Combined_16_31_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY);
+ NVIC_ClearPendingIRQ(GPIO5_Combined_0_15_IRQn);
EnableIRQ(GPIO5_Combined_0_15_IRQn);
- NVIC_SetPriority(GPIO5_Combined_0_15_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY);
+ GPC_EnableIRQ(GPC, GPIO5_Combined_0_15_IRQn);
EnableIRQ(TMR3_IRQn);
NVIC_SetPriority(TMR3_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY);
+
+ NVIC_ClearPendingIRQ(RTWDOG_IRQn);
+ EnableIRQ(RTWDOG_IRQn);
}
extern "C"
@@ 125,11 132,10 @@ namespace bsp
BaseType_t xHigherPriorityTaskWoken = 0;
uint32_t irq_mask = GPIO_GetPinsInterruptFlags(GPIO2);
- if (irq_mask & ((1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_CENTER)) |
- (1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_RIGHT)) |
+ if (irq_mask & ((1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_RIGHT)) |
(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_LEFT)) |
(1 << static_cast<uint32_t>(BoardDefinitions::BELL_SWITCHES_LATCH)))) {
- xHigherPriorityTaskWoken |= hal::key_input::generalIRQHandler(irq_mask);
+ xHigherPriorityTaskWoken |= hal::key_input::GPIO2SwitchesIRQHandler(irq_mask);
}
if (irq_mask & (1 << static_cast<uint32_t>(BoardDefinitions::BELL_BATTERY_CHARGER_ACOK_PIN))) {
@@ 162,14 168,10 @@ namespace bsp
void GPIO5_Combined_0_15_IRQHandler(void)
{
- BaseType_t xHigherPriorityTaskWoken = 0;
- uint32_t irq_mask = GPIO_GetPinsInterruptFlags(GPIO5);
-
- if (irq_mask & (1 << static_cast<uint32_t>(BoardDefinitions::BELL_WAKEUP))) {
-
- xHigherPriorityTaskWoken |= hal::key_input::wakeupIRQHandler();
- }
+ uint32_t irq_mask = GPIO_GetPinsInterruptFlags(GPIO5);
+ BaseType_t xHigherPriorityTaskWoken = hal::key_input::GPIO5SwitchesIRQHandler(
+ 1 << static_cast<uint32_t>(BoardDefinitions::BELL_CENTER_SWITCH));
// Clear all IRQs on the GPIO5 port
GPIO_PortClearInterruptFlags(GPIO5, irq_mask);
@@ 183,8 185,14 @@ namespace bsp
kQTMR_Channel_0,
kQTMR_CompareFlag | kQTMR_Compare1Flag | kQTMR_Compare2Flag | kQTMR_OverflowFlag |
kQTMR_EdgeFlag);
- const uint8_t QTMR3_mask = 99;
- hal::key_input::generalIRQHandler(QTMR3_mask);
+ hal::key_input::EncoderIRQHandler();
+ }
+
+ void RTWDOG_IRQHandler(void)
+ {
+ // Asserting WDOG_B pin to provide power reset of whole board
+ // Way to do it is via WDOG1 built-in assertion, RTWDOG does not provide it
+ WDOG1->WCR &= ~WDOG_WCR_WDA_MASK;
}
}
} // namespace bsp
M module-bsp/board/rt1051/bellpx/pin_mux.c => module-bsp/board/rt1051/bellpx/pin_mux.c +7 -16
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
/*
@@ 1166,8 1166,6 @@ void PINMUX_InitButtons(void)
IOMUXC_SetPinMux(PINMUX_BUTTON_SW2, 0U); /* Software Input On Field: Input Path is determined by functionality */
- IOMUXC_SetPinMux(PINMUX_BUTTON_SW_ENC, 0U); /* Software Input On Field: Input Path is determined by functionality */
-
IOMUXC_SetPinMux(PINMUX_BUTTON_SW_PUSH,
0U); /* Software Input On Field: Input Path is determined by functionality */
@@ 1179,11 1177,6 @@ void PINMUX_InitButtons(void)
PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_DISABLED | PAD_CONFIG_SPEED_SLOW_50MHz |
PAD_CONFIG_PULL_KEEPER_DISABLED | PAD_CONFIG_SELECT_PULL | PAD_CONFIG_PULL_UP_22kOhm);
- IOMUXC_SetPinConfig(PINMUX_BUTTON_SW_ENC,
- PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_DISABLED | PAD_CONFIG_SPEED_SLOW_50MHz |
- PAD_CONFIG_DRIVER_STRENGTH_LVL_6 | PAD_CONFIG_PULL_KEEPER_ENABLED | PAD_CONFIG_SELECT_PULL |
- PAD_CONFIG_PULL_UP_100kOhm);
-
IOMUXC_SetPinConfig(PINMUX_BUTTON_SW_PUSH,
PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_DISABLED | PAD_CONFIG_SPEED_SLOW_50MHz |
PAD_CONFIG_PULL_KEEPER_ENABLED | PAD_CONFIG_SELECT_PULL | PAD_CONFIG_PULL_UP_22kOhm |
@@ 1220,11 1213,10 @@ void PINMUX_DomeSwitch(void)
void PINMUX_WDOG_B_Init(void)
{
IOMUXC_SetPinMux(PINMUX_WDOG_B, 0U); /* Software Input On Field: Input Path is determined by functionality */
-
IOMUXC_SetPinConfig(PINMUX_WDOG_B,
-
- PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_DISABLED | PAD_CONFIG_SPEED_SLOW_50MHz |
- PAD_CONFIG_PULL_KEEPER_ENABLED | PAD_CONFIG_SELECT_PULL | PAD_CONFIG_PULL_UP_100kOhm);
+ PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_OPEN_DRAIN_DISABLED | PAD_CONFIG_SPEED_MEDIUM_1_100MHz |
+ PAD_CONFIG_PULL_KEEPER_ENABLED | PAD_CONFIG_SELECT_KEEPER |
+ PAD_CONFIG_DRIVER_STRENGTH_LVL_6 | PAD_CONFIG_HYSTERESIS_DISABLED);
}
void PINMUX_InitI2C4(void)
@@ 1264,12 1256,11 @@ void PINMUX_Wakeup(void)
{
CLOCK_EnableClock(kCLOCK_IomuxcSnvs);
- IOMUXC_SetPinMux(PINMUX_WAKEUP, 1U); /* Software Input On Field: Input Path is determined by functionality */
+ IOMUXC_SetPinMux(PINMUX_WAKEUP, 0U); /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinConfig(PINMUX_WAKEUP,
-
- PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_DISABLED | PAD_CONFIG_SPEED_SLOW_50MHz |
- PAD_CONFIG_PULL_KEEPER_DISABLED | PAD_CONFIG_SELECT_PULL | PAD_CONFIG_PULL_UP_100kOhm);
+ PAD_CONFIG_HYSTERESIS_ENABLED | PAD_CONFIG_PULL_UP_22kOhm | PAD_CONFIG_SELECT_PULL |
+ PAD_CONFIG_PULL_KEEPER_ENABLED | PAD_CONFIG_OPEN_DRAIN_DISABLED);
}
void PINMUX_InitFuelGauge(void)
R module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp => module-bsp/board/rt1051/bsp/lpm/RT1051LPMCommon.cpp +17 -46
@@ 1,12 1,11 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "RT1051LPM.hpp"
+#include "RT1051LPMCommon.hpp"
#include "board.h"
#include "reboot_codes.hpp"
#include <log/log.hpp>
-#include "board/BoardDefinitions.hpp"
#include "bsp/watchdog/watchdog.hpp"
#include <board/clock_config.h>
#include <fsl_clock.h>
@@ 21,37 20,19 @@ namespace bsp
using namespace drivers;
- RT1051LPM::RT1051LPM()
+ RT1051LPMCommon::RT1051LPMCommon()
{
driverSEMC = drivers::DriverSEMC::Create(drivers::name::ExternalRAM);
- gpio_1 = DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::POWER_SWITCH_HOLD_GPIO),
- DriverGPIOParams{});
- gpio_2 = DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::DCDC_INVERTER_MODE_GPIO),
- DriverGPIOParams{});
-
- gpio_1->ConfPin(DriverGPIOPinParams{.dir = DriverGPIOPinParams::Direction::Output,
- .irqMode = DriverGPIOPinParams::InterruptMode::NoIntmode,
- .defLogic = 1,
- .pin = static_cast<uint32_t>(BoardDefinitions::POWER_SWITCH_HOLD_BUTTON)});
-
- gpio_2->ConfPin(DriverGPIOPinParams{.dir = DriverGPIOPinParams::Direction::Output,
- .irqMode = DriverGPIOPinParams::InterruptMode::NoIntmode,
- .defLogic = 0,
- .pin = static_cast<uint32_t>(BoardDefinitions::DCDC_INVERTER_MODE_PIN)});
-
- gpio_1->WritePin(static_cast<uint32_t>(BoardDefinitions::POWER_SWITCH_HOLD_BUTTON), 1);
- DisableDcdcPowerSaveMode();
-
CpuFreq = std::make_unique<CpuFreqLPM>();
}
- int32_t RT1051LPM::PowerOff()
+ int32_t RT1051LPMCommon::PowerOff()
{
- bsp::BoardPowerOff();
+ board_power_off();
return 0;
}
- int32_t RT1051LPM::Reboot(RebootType reason)
+ int32_t RT1051LPMCommon::Reboot(RebootType reason)
{
switch (reason) {
case RebootType::GoToUpdaterUpdate:
@@ 70,7 51,7 @@ namespace bsp
SNVS->LPGPR[0] = bsp::rebootCode::rebootNormalCode;
break;
}
- BoardReboot();
+ board_restart();
return 0;
}
@@ 80,7 61,7 @@ namespace bsp
Down
};
- CpuFrequencyMHz RT1051LPM::onChangeUp(CpuFrequencyMHz freq, bsp::CpuFrequencyMHz newFrequency)
+ CpuFrequencyMHz RT1051LPMCommon::onChangeUp(CpuFrequencyMHz freq, bsp::CpuFrequencyMHz newFrequency)
{
if ((freq <= CpuFrequencyMHz::Level_1) && (newFrequency > CpuFrequencyMHz::Level_1)) {
// connect internal the load resistor
@@ 104,7 85,7 @@ namespace bsp
return newFrequency;
}
- void RT1051LPM::onChangeDown(CpuFrequencyMHz newFrequency)
+ void RT1051LPMCommon::onChangeDown(CpuFrequencyMHz newFrequency)
{
if (newFrequency <= bsp::CpuFrequencyMHz::Level_1) {
// Enable weak 2P5 and 1P1 LDO and Turn off regular 2P5 and 1P1 LDO
@@ 123,7 104,7 @@ namespace bsp
}
}
- void RT1051LPM::SetCpuFrequency(bsp::CpuFrequencyMHz freq)
+ void RT1051LPMCommon::SetCpuFrequency(bsp::CpuFrequencyMHz freq)
{
if (currentFrequency == freq) {
return;
@@ 163,17 144,17 @@ namespace bsp
currentFrequency = freq;
}
- void RT1051LPM::SetHighestCoreVoltage()
+ void RT1051LPMCommon::SetHighestCoreVoltage()
{
CpuFreq->SetHighestCoreVoltage();
}
- uint32_t RT1051LPM::GetCpuFrequency() const noexcept
+ uint32_t RT1051LPMCommon::GetCpuFrequency() const noexcept
{
return CLOCK_GetCpuClkFreq();
}
- void RT1051LPM::SwitchOscillatorSource(bsp::LowPowerMode::OscillatorSource source)
+ void RT1051LPMCommon::SwitchOscillatorSource(bsp::LowPowerMode::OscillatorSource source)
{
if (source == bsp::LowPowerMode::OscillatorSource::Internal) {
cpp_freertos::CriticalSection::Enter();
@@ 187,32 168,22 @@ namespace bsp
}
}
- void RT1051LPM::SetBootSuccess()
+ void RT1051LPMCommon::SetBootSuccess()
{
SNVS->LPGPR[0] = bsp::rebootCode::rebootNormalCode;
}
- void RT1051LPM::EnableDcdcPowerSaveMode()
- {
- gpio_2->WritePin(static_cast<uint32_t>(BoardDefinitions::DCDC_INVERTER_MODE_PIN), 0);
- }
-
- void RT1051LPM::DisableDcdcPowerSaveMode()
- {
- gpio_2->WritePin(static_cast<uint32_t>(BoardDefinitions::DCDC_INVERTER_MODE_PIN), 1);
- }
-
- void RT1051LPM::DisconnectInternalLoadResistor()
+ void RT1051LPMCommon::DisconnectInternalLoadResistor()
{
DCDC->REG1 &= ~DCDC_REG1_REG_RLOAD_SW_MASK;
}
- void RT1051LPM::ConnectInternalLoadResistor()
+ void RT1051LPMCommon::ConnectInternalLoadResistor()
{
DCDC->REG1 |= DCDC_REG1_REG_RLOAD_SW_MASK;
}
- void RT1051LPM::SwitchToRegularModeLDO()
+ void RT1051LPMCommon::SwitchToRegularModeLDO()
{
// Enable regular 2P5 and wait it stable
PMU->REG_2P5_SET = PMU_REG_2P5_ENABLE_LINREG_MASK;
@@ 228,7 199,7 @@ namespace bsp
PMU->REG_1P1_CLR = PMU_REG_1P1_ENABLE_WEAK_LINREG_MASK;
}
- void RT1051LPM::SwitchToLowPowerModeLDO()
+ void RT1051LPMCommon::SwitchToLowPowerModeLDO()
{
// Enable weak 2P5 and turn off regular 2P5
PMU->REG_2P5 |= PMU_REG_2P5_ENABLE_WEAK_LINREG_MASK;
R module-bsp/board/rt1051/bsp/lpm/RT1051LPM.hpp => module-bsp/board/rt1051/bsp/lpm/RT1051LPMCommon.hpp +6 -13
@@ 1,8 1,7 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#ifndef PUREPHONE_RT1051LPM_HPP
-#define PUREPHONE_RT1051LPM_HPP
+#pragma once
#include "bsp/lpm/bsp_lpm.hpp"
#include "drivers/gpio/DriverGPIO.hpp"
@@ 10,21 9,18 @@
namespace bsp
{
- class RT1051LPM : public LowPowerMode
+ class RT1051LPMCommon : public LowPowerMode
{
public:
- RT1051LPM();
- int32_t PowerOff() override final;
- int32_t Reboot(RebootType reason) override final;
+ RT1051LPMCommon();
+ int32_t PowerOff() final;
+ int32_t Reboot(RebootType reason) final;
void SetCpuFrequency(CpuFrequencyMHz freq) final;
void SetHighestCoreVoltage() final;
[[nodiscard]] uint32_t GetCpuFrequency() const noexcept final;
void SwitchOscillatorSource(OscillatorSource source) final;
void SetBootSuccess() override;
- void EnableDcdcPowerSaveMode() final;
- void DisableDcdcPowerSaveMode() final;
-
void DisconnectInternalLoadResistor() final;
void ConnectInternalLoadResistor() final;
@@ 34,12 30,9 @@ namespace bsp
private:
CpuFrequencyMHz onChangeUp(CpuFrequencyMHz freq, CpuFrequencyMHz newFrequency);
void onChangeDown(bsp::CpuFrequencyMHz freq);
- std::shared_ptr<drivers::DriverGPIO> gpio_1;
- std::shared_ptr<drivers::DriverGPIO> gpio_2;
+
std::unique_ptr<bsp::CpuFreqLPM> CpuFreq;
std::shared_ptr<drivers::DriverSEMC> driverSEMC;
};
} // namespace bsp
-
-#endif // PUREPHONE_RT1051LPM_HPP
M module-bsp/board/rt1051/bsp/watchdog/watchdog.cpp => module-bsp/board/rt1051/bsp/watchdog/watchdog.cpp +2 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "bsp/watchdog/watchdog.hpp"
@@ 29,7 29,7 @@ namespace bsp::watchdog
config.workMode.enableDebug = false; // If true, RTWDOG will run when target is halted
config.testMode = kRTWDOG_TestModeDisabled;
config.enableUpdate = true;
- config.enableInterrupt = false;
+ config.enableInterrupt = true;
config.enableWindowMode = false;
config.windowValue = 0;
config.timeoutValue = static_cast<uint16_t>(timeoutValueTicks);
M module-bsp/board/rt1051/common/WorkerQueue.hpp => module-bsp/board/rt1051/common/WorkerQueue.hpp +9 -1
@@ 70,8 70,14 @@ WorkerQueue<Message>::WorkerQueue(const char *name, WorkerHandle workerHandle, c
template <typename Message> WorkerQueue<Message>::~WorkerQueue()
{
if (queueHandle && taskHandle) {
- InternalMessage killMsg{.kill = true};
+ const InternalMessage killMsg{.kill = true};
+ InternalMessage responseMsg;
xQueueSend(queueHandle, &killMsg, pdMS_TO_TICKS(100));
+ /// Wait 500ms for a response from the worker. If it does not arrive, kill it.
+ if (const auto result = xQueueReceive(queueHandle, &responseMsg, pdMS_TO_TICKS(500)); result != pdTRUE) {
+ vTaskDelete(taskHandle);
+ }
+ vQueueDelete(queueHandle);
}
}
template <typename Message> void WorkerQueue<Message>::worker()
@@ 81,6 87,8 @@ template <typename Message> void WorkerQueue<Message>::worker()
xQueueReceive(queueHandle, &msg, portMAX_DELAY);
if (msg.kill) {
+ InternalMessage killMsg{.kill = true};
+ xQueueSend(queueHandle, &killMsg, pdMS_TO_TICKS(100));
vTaskDelete(nullptr);
}
else {
M module-bsp/board/rt1051/common/board.cpp => module-bsp/board/rt1051/common/board.cpp +33 -52
@@ 1,4 1,5 @@
+#include "bsp.hpp"
#include "board.h"
#include "fsl_gpio.h"
#include <stdint.h>
@@ 14,7 15,6 @@ extern "C"
#include "fsl_lpuart.h"
#endif
}
-#include "audio.hpp"
#include "chip.hpp"
#include "board/irq_gpio.hpp"
#include "reboot_codes.hpp"
@@ 26,15 26,10 @@ extern std::uint32_t __sdram_cached_start[];
namespace bsp
{
-
- namespace {
- enum class rebootState : uintptr_t {
- none,
- poweroff,
- reboot
- };
- volatile rebootState rebootProgress {rebootState::none};
- }
+ namespace
+ {
+ volatile rebootState rebootProgress{rebootState::none};
+ } // namespace
/* MPU configuration. */
static void BOARD_ConfigMPU(void)
@@ 51,28 46,29 @@ namespace bsp
ARM_MPU_Disable();
/* MPU configure:
- * Use ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size)
- * API in core_cm7.h.
- * param DisableExec Instruction access (XN) disable bit,0=instruction fetches enabled, 1=instruction fetches disabled.
- * param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
- * Use MACROS defined in core_cm7.h: ARM_MPU_AP_NONE/ARM_MPU_AP_PRIV/ARM_MPU_AP_URO/ARM_MPU_AP_FULL/ARM_MPU_AP_PRO/ARM_MPU_AP_RO
+ * Use ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable,
+ * SubRegionDisable, Size) API in core_cm7.h. param DisableExec Instruction access (XN) disable
+ * bit,0=instruction fetches enabled, 1=instruction fetches disabled. param AccessPermission Data access
+ * permissions, allows you to configure read/write access for User and Privileged mode. Use MACROS defined in
+ * core_cm7.h: ARM_MPU_AP_NONE/ARM_MPU_AP_PRIV/ARM_MPU_AP_URO/ARM_MPU_AP_FULL/ARM_MPU_AP_PRO/ARM_MPU_AP_RO
* Combine TypeExtField/IsShareable/IsCacheable/IsBufferable to configure MPU memory access attributes.
* TypeExtField IsShareable IsCacheable IsBufferable Memory Attribtue Shareability Cache
* 0 x 0 0 Strongly Ordered shareable
* 0 x 0 1 Device shareable
- * 0 0 1 0 Normal not shareable Outer and inner write through no write allocate
- * 0 0 1 1 Normal not shareable Outer and inner write back no write allocate
- * 0 1 1 0 Normal shareable Outer and inner write through no write allocate
- * 0 1 1 1 Normal shareable Outer and inner write back no write allocate
- * 1 0 0 0 Normal not shareable outer and inner noncache
- * 1 1 0 0 Normal shareable outer and inner noncache
- * 1 0 1 1 Normal not shareable outer and inner write back write/read acllocate
- * 1 1 1 1 Normal shareable outer and inner write back write/read acllocate
- * 2 x 0 0 Device not shareable
- * Above are normal use settings, if your want to see more details or want to config different inner/outter cache policy.
- * please refer to Table 4-55 /4-56 in arm cortex-M7 generic user guide <dui0646b_cortex_m7_dgug.pdf>
- * param SubRegionDisable Sub-region disable field. 0=sub-region is enabled, 1=sub-region is disabled.
- * param Size Region size of the region to be configured. use ARM_MPU_REGION_SIZE_xxx MACRO in core_cm7.h.
+ * 0 0 1 0 Normal not shareable Outer and inner
+ * write through no write allocate 0 0 1 1 Normal not
+ * shareable Outer and inner write back no write allocate 0 1 1 0 Normal
+ * shareable Outer and inner write through no write allocate 0 1 1 1
+ * Normal shareable Outer and inner write back no write allocate 1 0 0
+ * 0 Normal not shareable outer and inner noncache 1 1 0 0
+ * Normal shareable outer and inner noncache 1 0 1 1 Normal
+ * not shareable outer and inner write back write/read acllocate 1 1 1 1
+ * Normal shareable outer and inner write back write/read acllocate 2 x 0 0 Device
+ * not shareable Above are normal use settings, if your want to see more details or want to config different
+ * inner/outter cache policy. please refer to Table 4-55 /4-56 in arm cortex-M7 generic user guide
+ * <dui0646b_cortex_m7_dgug.pdf> param SubRegionDisable Sub-region disable field. 0=sub-region is enabled,
+ * 1=sub-region is disabled. param Size Region size of the region to be configured. use
+ * ARM_MPU_REGION_SIZE_xxx MACRO in core_cm7.h.
*/
/* Region 0 setting: Memory with Device type, not shareable, non-cacheable. */
@@ 151,7 147,7 @@ namespace bsp
SCB_EnableICache();
}
- void BoardInit()
+ void board_init()
{
PINMUX_InitBootPins();
BOARD_InitBootClocks();
@@ 177,13 173,13 @@ namespace bsp
}
//! Board PowerOff function by cutdown power
- void BoardPowerOff()
+ void board_power_off()
{
rebootProgress = rebootState::poweroff;
}
//! Board reboot by the SVNC code
- void BoardReboot()
+ void board_restart()
{
rebootProgress = rebootState::reboot;
}
@@ 192,12 188,12 @@ namespace bsp
{
void (*func)();
};
- static unsigned short iObject = 0;
+ static unsigned short iObject = 0;
constexpr auto MAX_PLATFORM_EXIT_OBJECTS = 16u;
static PlatformExitObject objects[MAX_PLATFORM_EXIT_OBJECTS];
- int RegisterPlatformExitFunction(void (*func)())
+ int register_exit_functions(void (*func)())
{
if (iObject >= sizeof(objects))
return -1;
@@ 213,25 209,10 @@ namespace bsp
}
}
- extern "C" {
- void _platform_exit(void)
- {
- CallPlatformExitFunctions();
-
- static constexpr auto POWER_SWITCH_PIN = 7;
- static const auto POWER_SWITCH_PORT = GPIO2;
- switch(rebootProgress)
- {
- case rebootState::none:
- break;
- case rebootState::poweroff:
- GPIO_PinWrite(POWER_SWITCH_PORT, POWER_SWITCH_PIN, 0);
- break;
- case rebootState::reboot:
- NVIC_SystemReset();
- break;
- }
- }
+ extern "C" void _platform_exit(void)
+ {
+ CallPlatformExitFunctions();
+ bsp::board_exit(rebootProgress);
}
} // namespace bsp
M module-bsp/board/rt1051/common/startup_mimxrt1052.cpp => module-bsp/board/rt1051/common/startup_mimxrt1052.cpp +1 -6
@@ 754,12 754,7 @@ __attribute__((section(".after_vectors.reset"))) void ResetISR(void)
// call global destructors and functions registered using atexit
__call_exitprocs(0, 0);
_platform_exit();
- //
- // main() shouldn't return, but if it does, we'll just enter an infinite loop
- //
- while (1) {
- ;
- }
+ while (true) {}
}
//*****************************************************************************
M module-bsp/board/rt1051/puretx/CMakeLists.txt => module-bsp/board/rt1051/puretx/CMakeLists.txt +2 -0
@@ 17,12 17,14 @@ target_sources(
bsp/eink/eink_pin_config.cpp
bsp/keyboard/keyboard.cpp
bsp/lpm/PowerProfile.cpp
+ bsp/lpm/RT1051LPM.cpp
audio.cpp
pin_mux.c
clock_config.cpp
irq_gpio.cpp
debug_console.cpp
+ board.cpp
PUBLIC
eink-config.h
A module-bsp/board/rt1051/puretx/board.cpp => module-bsp/board/rt1051/puretx/board.cpp +44 -0
@@ 0,0 1,44 @@
+// Copyright (c) 2017-2022, 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_power_off()
+ {
+ /// 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_power_off();
+ break;
+ case rebootState::reboot:
+ board_reset();
+ break;
+ }
+
+ while (true) {}
+ }
+} // namespace bsp
A module-bsp/board/rt1051/puretx/bsp/lpm/RT1051LPM.cpp => module-bsp/board/rt1051/puretx/bsp/lpm/RT1051LPM.cpp +43 -0
@@ 0,0 1,43 @@
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "RT1051LPM.hpp"
+#include <board.h>
+#include <board/BoardDefinitions.hpp>
+
+namespace bsp
+{
+
+ using namespace drivers;
+
+ RT1051LPM::RT1051LPM()
+ {
+ gpio_1 = DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::POWER_SWITCH_HOLD_GPIO),
+ DriverGPIOParams{});
+ gpio_2 = DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::DCDC_INVERTER_MODE_GPIO),
+ DriverGPIOParams{});
+ gpio_1->ConfPin(DriverGPIOPinParams{.dir = DriverGPIOPinParams::Direction::Output,
+ .irqMode = DriverGPIOPinParams::InterruptMode::NoIntmode,
+ .defLogic = 1,
+ .pin = static_cast<uint32_t>(BoardDefinitions::POWER_SWITCH_HOLD_BUTTON)});
+
+ gpio_2->ConfPin(DriverGPIOPinParams{.dir = DriverGPIOPinParams::Direction::Output,
+ .irqMode = DriverGPIOPinParams::InterruptMode::NoIntmode,
+ .defLogic = 0,
+ .pin = static_cast<uint32_t>(BoardDefinitions::DCDC_INVERTER_MODE_PIN)});
+
+ gpio_1->WritePin(static_cast<uint32_t>(BoardDefinitions::POWER_SWITCH_HOLD_BUTTON), 1);
+ DisableDcdcPowerSaveMode();
+ }
+
+ void RT1051LPM::EnableDcdcPowerSaveMode()
+ {
+ gpio_2->WritePin(static_cast<uint32_t>(BoardDefinitions::DCDC_INVERTER_MODE_PIN), 0);
+ }
+
+ void RT1051LPM::DisableDcdcPowerSaveMode()
+ {
+ gpio_2->WritePin(static_cast<uint32_t>(BoardDefinitions::DCDC_INVERTER_MODE_PIN), 1);
+ }
+
+} // namespace bsp
A module-bsp/board/rt1051/puretx/bsp/lpm/RT1051LPM.hpp => module-bsp/board/rt1051/puretx/bsp/lpm/RT1051LPM.hpp +22 -0
@@ 0,0 1,22 @@
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <bsp/lpm/RT1051LPMCommon.hpp>
+
+namespace bsp
+{
+ class RT1051LPM : public RT1051LPMCommon
+ {
+ public:
+ RT1051LPM();
+ void EnableDcdcPowerSaveMode() final;
+ void DisableDcdcPowerSaveMode() final;
+
+ private:
+ std::shared_ptr<drivers::DriverGPIO> gpio_1;
+ std::shared_ptr<drivers::DriverGPIO> gpio_2;
+ };
+
+} // namespace bsp
M module-bsp/bsp/bsp.hpp => module-bsp/bsp/bsp.hpp +17 -13
@@ 1,21 1,25 @@
-#ifndef MODULE_BSP_BSP_HPP
-#define MODULE_BSP_BSP_HPP
+#pragma once
+
+#include <cstdint>
namespace bsp
{
- //! Board hardware init
- void BoardInit();
-
- // Board cuttoff power
- void BoardPowerOff();
+ enum class rebootState : uintptr_t
+ {
+ none,
+ poweroff,
+ reboot
+ };
- // Board system reset
- void BoardReboot();
+ void board_init();
- // Register platform exit functions
- int RegisterPlatformExitFunction(void (*func)());
-}
+ void board_power_off();
+ void board_restart();
+ /// Register platform exit functions
+ int register_exit_functions(void (*func)());
-#endif //MODULE_BSP_BSP_HPP
+ /// Board-specific exit/reset procedure. It is the main exit point from the system.
+ [[noreturn]] void board_exit(rebootState);
+} // namespace bsp
M module-bsp/bsp/lpm/bsp_lpm.cpp => module-bsp/bsp/lpm/bsp_lpm.cpp +1 -1
@@ 5,7 5,7 @@
#if defined(TARGET_RT1051)
-#include "board/rt1051/bsp/lpm/RT1051LPM.hpp"
+#include <bsp/lpm/RT1051LPM.hpp>
#elif defined(TARGET_Linux)
#include "board/linux/lpm/LinuxLPM.h"
#else
M module-platform/linux/src/LinuxPlatform.cpp => module-platform/linux/src/LinuxPlatform.cpp +2 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <platform/linux/LinuxPlatform.hpp>
@@ 16,7 16,7 @@ using platform::linux::LinuxPlatform;
LinuxPlatform::LinuxPlatform(std::string imageName) : imageName(std::move(imageName))
{
- bsp::BoardInit();
+ bsp::board_init();
}
LinuxPlatform::~LinuxPlatform()
M module-platform/rt1051/src/RT1051Platform.cpp => module-platform/rt1051/src/RT1051Platform.cpp +2 -2
@@ 15,8 15,8 @@ using platform::rt1051::RT1051Platform;
RT1051Platform::RT1051Platform()
{
- bsp::BoardInit();
- bsp::RegisterPlatformExitFunction(Log::Logger::destroyInstance);
+ bsp::board_init();
+ bsp::register_exit_functions(Log::Logger::destroyInstance);
}
void RT1051Platform::init()
M module-sys/SystemManager/SystemManagerCommon.cpp => module-sys/SystemManager/SystemManagerCommon.cpp +1 -1
@@ 180,7 180,7 @@ namespace sys
cpuStatistics.reset();
deviceManager.reset();
- // End of scheduler and back to the main and poweroff
+ // End of scheduler and back to the main and poweroff
EndScheduler();
}