HF-MAX22200 Driver 0.1.0-dev
HF-MAX22200 C++ Driver
Loading...
Searching...
No Matches
max22200_comprehensive_test.cpp File Reference

Comprehensive test suite for MAX22200 driver on ESP32. More...

#include <cinttypes>
#include <cmath>
#include <memory>
#include "esp32_max22200_bus.hpp"
#include "esp32_max22200_test_config.hpp"
#include "max22200.hpp"
#include "max22200_registers.hpp"
#include "max22200_types.hpp"
#include "TestFramework.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
Include dependency graph for max22200_comprehensive_test.cpp:

Functions

void app_main (void)
 ESP32 app entry point; runs MAX22200 test suite.
 

Detailed Description

Comprehensive test suite for MAX22200 driver on ESP32.

Tests the two-phase SPI protocol (per MAX22200 datasheet), register read/write, fault handling, and unit-based convenience APIs. All errors are caught and reported via DriverStatusToStr(); debug logging uses tagged prefixes ([init], [cfg], [unit_ma], etc.).

Test sections (controlled by ENABLE_* defines):

  • Basic: initialization, raw register dump, channel config write/readback, fault status, control pins (FAULT), trigger pins (TRIGA/TRIGB).
  • Unit APIs: BoardConfig (SetBoardConfig/GetBoardConfig, BoardConfig(rref, hfs)), current in mA and percent (SetHitCurrentMa, SetHoldCurrentPercent, etc.), duty in percent (SetHitDutyPercent, GetDutyLimits), HIT time in ms (SetHitTimeMs, GetHitTimeMs), ConfigureChannelCdr, ConfigureChannelVdr.
  • Error handling: invalid channel (8), GetHitCurrentMa with IFS=0; expects DriverStatus::INVALID_PARAMETER where appropriate.
Config
Board and channel-config test values (RREF, HFS, IFS, hit/hold setpoints) are defined in esp32_max22200_test_config.hpp: BoardTestConfig.
Build
From examples/esp32: ./scripts/build_app.sh max22200_comprehensive_test Debug
Author
HardFOC Development Team
Date
2025

Function Documentation

◆ app_main()

void app_main ( void )

ESP32 app entry point; runs MAX22200 test suite.

Initializes shared resources (SPI + driver), runs test tasks in sections: Basic (if ENABLE_BASIC_TESTS), Unit API (if ENABLE_UNIT_API_TESTS), Error handling (if ENABLE_ERROR_HANDLING_TESTS). Prints summary via print_test_summary() and cleans up resources.