HF-Core Platform 0.1.0-dev
Hardware-Agnostic Handler Layer & RTOS Utilities for HardFOC
Loading...
Searching...
No Matches
as5047u_handler_comprehensive_test.cpp File Reference

Comprehensive test suite for As5047uHandler. More...

#include "TestFramework.h"
#include "esp32_bus_setup.hpp"
#include "esp32_test_config.hpp"
#include "handlers/as5047u/As5047uHandler.h"
#include <memory>
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Include dependency graph for as5047u_handler_comprehensive_test.cpp:

Functions

static bool create_handler () noexcept
 
static bool test_handler_construction () noexcept
 
static bool test_initialize () noexcept
 
static bool test_is_initialized () noexcept
 
static bool test_read_angle_raw () noexcept
 
static bool test_read_angle_degrees () noexcept
 
static bool test_read_angle_consistency () noexcept
 
static bool test_read_velocity () noexcept
 
static bool test_daec_enable_disable () noexcept
 
static bool test_set_zero_position () noexcept
 
static bool test_dump_diagnostics () noexcept
 
static bool test_get_sensor () noexcept
 
static bool test_operations_before_init () noexcept
 
static void concurrent_reader_task (void *param)
 
static bool test_concurrent_access () noexcept
 
void app_main (void)
 

Variables

static const char * TAG = "AS5047U_Handler_Test"
 
static TestResults g_test_results
 
static constexpr bool ENABLE_INITIALIZATION_TESTS = true
 
static constexpr bool ENABLE_ANGLE_TESTS = true
 
static constexpr bool ENABLE_VELOCITY_TESTS = true
 
static constexpr bool ENABLE_DAEC_TESTS = true
 
static constexpr bool ENABLE_ZERO_POSITION_TESTS = true
 
static constexpr bool ENABLE_DIAGNOSTICS_TESTS = true
 
static constexpr bool ENABLE_ERROR_HANDLING_TESTS = true
 
static constexpr bool ENABLE_THREAD_SAFETY_TESTS = true
 
static BaseSpi * g_spi_device = nullptr
 
static std::unique_ptr< As5047uHandlerg_handler
 
static volatile bool g_thread_test_pass = true
 

Detailed Description

Comprehensive test suite for As5047uHandler.

Tests the AS5047U magnetic rotary position sensor handler through its full public API, exercising the underlying CRTP SPI adapter and driver.

Test Categories:

  1. Initialization & lifecycle
  2. Angle reading (14-bit absolute, degrees)
  3. Velocity measurement (rpm, dps)
  4. DAEC configuration
  5. Zero position setting
  6. Interface configuration (ABI/UVW/PWM)
  7. Diagnostics & error flags
  8. Thread safety (mutex contention)
  9. Error handling & edge cases

Hardware Required:

  • AS5047U encoder on SPI bus (see esp32_test_config.hpp for pins)
  • Diametrically magnetized magnet within sensor range
Author
HardFOC Team
Date
2025-2026

Function Documentation

◆ app_main()

void app_main ( void )
Here is the call graph for this function:

◆ concurrent_reader_task()

static void concurrent_reader_task ( void * param)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_handler()

static bool create_handler ( )
staticnoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_concurrent_access()

static bool test_concurrent_access ( )
staticnoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_daec_enable_disable()

static bool test_daec_enable_disable ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_dump_diagnostics()

static bool test_dump_diagnostics ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_get_sensor()

static bool test_get_sensor ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_handler_construction()

static bool test_handler_construction ( )
staticnoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_initialize()

static bool test_initialize ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_is_initialized()

static bool test_is_initialized ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_operations_before_init()

static bool test_operations_before_init ( )
staticnoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_read_angle_consistency()

static bool test_read_angle_consistency ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_read_angle_degrees()

static bool test_read_angle_degrees ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_read_angle_raw()

static bool test_read_angle_raw ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_read_velocity()

static bool test_read_velocity ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_set_zero_position()

static bool test_set_zero_position ( )
staticnoexcept
Here is the caller graph for this function:

Variable Documentation

◆ ENABLE_ANGLE_TESTS

constexpr bool ENABLE_ANGLE_TESTS = true
staticconstexpr

◆ ENABLE_DAEC_TESTS

constexpr bool ENABLE_DAEC_TESTS = true
staticconstexpr

◆ ENABLE_DIAGNOSTICS_TESTS

constexpr bool ENABLE_DIAGNOSTICS_TESTS = true
staticconstexpr

◆ ENABLE_ERROR_HANDLING_TESTS

constexpr bool ENABLE_ERROR_HANDLING_TESTS = true
staticconstexpr

◆ ENABLE_INITIALIZATION_TESTS

constexpr bool ENABLE_INITIALIZATION_TESTS = true
staticconstexpr

◆ ENABLE_THREAD_SAFETY_TESTS

constexpr bool ENABLE_THREAD_SAFETY_TESTS = true
staticconstexpr

◆ ENABLE_VELOCITY_TESTS

constexpr bool ENABLE_VELOCITY_TESTS = true
staticconstexpr

◆ ENABLE_ZERO_POSITION_TESTS

constexpr bool ENABLE_ZERO_POSITION_TESTS = true
staticconstexpr

◆ g_handler

std::unique_ptr<As5047uHandler> g_handler
static

◆ g_spi_device

BaseSpi* g_spi_device = nullptr
static

◆ g_test_results

TestResults g_test_results
static

◆ g_thread_test_pass

volatile bool g_thread_test_pass = true
static

◆ TAG

const char* TAG = "AS5047U_Handler_Test"
static