Doxygen: - Doxyfile: minimal config, HTML output to docs/, no LaTeX - @file/@brief on all source files, full @param/@return on public API - docs/ added to .gitignore clang-format (14, Linux brace style, 4-space, column 100): - .clang-format added - Applied to entire codebase; this commit is the canonical baseline - just format rewrites in-place; just format-check is the CI gate cppcheck (--enable=warning,style,performance,portability): - Linker-symbol pointer comparisons in startup.c suppressed with inline cppcheck-suppress (false positives, not real bugs) - just lint runs cppcheck; zero warnings required to pass Dockerfile gains clang-format, cppcheck, doxygen packages so all tools run inside the existing container -- host stays clean. Gitea Actions (.gitea/workflows/ci.yml): - Four parallel jobs: build, format, lint, docs - All jobs use the same Dockerfile-based image - Doxygen job fails on any warning line in output
40 lines
827 B
C
40 lines
827 B
C
/** @file power.c
|
|
* @brief Power management implementation.
|
|
*/
|
|
#include "power.h"
|
|
#include "regs.h"
|
|
#include <nrf52840.h>
|
|
#include <cmsis_gcc.h>
|
|
|
|
/* P0.02 on XIAO BLE - adjust to match your schematic */
|
|
#define BUTTON_PIN 2u
|
|
|
|
void power_init(void)
|
|
{
|
|
/* DC/DC converter has lower quiescent current than the LDO */
|
|
NRF_POWER->DCDCEN = 1u;
|
|
|
|
NRF_GPIOTE->CONFIG[0] = (gpiote_config_t){
|
|
.bit = {
|
|
.MODE = GPIOTE_MODE_EVENT,
|
|
.PSEL = BUTTON_PIN,
|
|
.PORT = 0u,
|
|
.POLARITY = GPIOTE_POL_LOTOHI,
|
|
}}.reg;
|
|
|
|
NRF_GPIOTE->INTENSET = (gpiote_inten_t){.bit.IN0 = 1u}.reg;
|
|
|
|
NVIC_EnableIRQ(GPIOTE_IRQn);
|
|
}
|
|
|
|
void power_sleep_until_button(void)
|
|
{
|
|
NRF_POWER->TASKS_LOWPWR = 1u;
|
|
__WFI();
|
|
}
|
|
|
|
void GPIOTE_IRQHandler(void)
|
|
{
|
|
NRF_GPIOTE->EVENTS_IN[0] = 0u;
|
|
}
|