Software Detailed Design

Introduction

This module interfaces with the keyboard and debounces the POWER_BUTTON_KEY to provide a stable key press event.

Design Considerations

Specification: State Management SWDD_PB-100 ../../../_images/arrow-right-circle.svg
is tested by: TS_PB-001, TS_PB-003, TS_PB-004

The power button detection is implemented as a state machine with three states: INIT, PRESSED, and RELEASED.

Specification: Debouncing SWDD_PB-101 ../../../_images/arrow-right-circle.svg
is tested by: TS_PB-002, TS_PB-003, TS_PB-004

The key press and release events are debounced to prevent spurious signals. The debounce periods are configurable via POWER_BUTTON_PRESS_DEBOUNCE and POWER_BUTTON_RELEASE_DEBOUNCE. A key press or release is only registered after its state is consistently detected for the configured number of periodic calls.

Interfaces

Specification: Runnable SWDD_PB-200 ../../../_images/arrow-right-circle.svg
is tested by: TS_PB-003

The Power Button component shall be called periodically by its runnable powerButton().

Specification: Initialization SWDD_PB-201 ../../../_images/arrow-right-circle.svg
is tested by: TS_PB-001

The component shall be initialized by calling powerButtonInit().

Specification: Key Input SWDD_PB-202 ../../../_images/arrow-right-circle.svg
is tested by: TS_PB-003

The component uses the RTE interface RteIsKeyPressed(POWER_BUTTON_KEY) to get the current raw state of the power button.

Specification: Key Pressed Event Output SWDD_PB-203 ../../../_images/arrow-right-circle.svg
is tested by: TS_PB-001, TS_PB-002, TS_PB-003

The component uses the RTE interface RteSetPowerKeyPressedEvent() to signal a debounced key press event.

Internal Behavior

Specification: State Machine SWDD_PB-300 ../../../_images/arrow-right-circle.svg
is tested by: TS_PB-003, TS_PB-004

The internal state machine manages the debouncing logic. It transitions between states based on counters that track the duration of a consistent key state.

stateDiagram-v2 [*] --> INIT: Initial State INIT --> PRESSED: Button pressed long enough INIT --> RELEASED: Button released long enough PRESSED --> RELEASED: Button released long enough RELEASED --> PRESSED: Button pressed long enough