Timer unit test implementation for NAVHAL. More...
#include "core/cortex-m4/timer.h"#include "core/cortex-m4/timer_reg.h"#include "unity.h"#include <stdint.h>
Macros | |
| #define | TEST_TIMER TIM2 |
| Timer peripheral used for all tests (TIM2) | |
| #define | TEST_PSC 83 |
| Test prescaler value. | |
| #define | TEST_ARR 999 |
| Test auto-reload value. | |
| #define | TEST_CHANNEL 1 |
| Test channel number (Channel 1) | |
| #define | TEST_COMPARE_VALUE 500 |
| Test compare register value. | |
Functions | |
| void | test_timer_init_sets_prescaler_and_arr (void) |
| Test timer initialization. | |
| void | test_timer_start_sets_CEN_bit (void) |
| Test timer start functionality. | |
| void | test_timer_stop_clears_CEN_bit (void) |
| Test timer stop functionality. | |
| void | test_timer_reset_clears_count (void) |
| Test timer counter reset. | |
| void | test_timer_set_compare_and_get_compare (void) |
| Test compare register operations. | |
| void | test_timer_enable_and_disable_channel (void) |
| Test channel enable/disable. | |
| void | test_timer_enable_and_disable_interrupt (void) |
| Test interrupt enable. | |
| void | test_timer_clear_interrupt_flag_clears_UIF (void) |
| Test interrupt flag clearing. | |
| void | test_timer_get_arr_returns_arr_value (void) |
| Test auto-reload register access. | |
| void | test_timer_get_count_returns_count_value (void) |
| Test counter value access. | |
Timer unit test implementation for NAVHAL.
This file implements the test cases for verifying Timer peripheral functionality in the NAVHAL hardware abstraction layer. It performs register-level verification of all timer operations using TIM2 as the test timer.
Tests cover:
| #define TEST_ARR 999 |
Test auto-reload value.
| #define TEST_CHANNEL 1 |
Test channel number (Channel 1)
| #define TEST_COMPARE_VALUE 500 |
Test compare register value.
| #define TEST_PSC 83 |
Test prescaler value.
| #define TEST_TIMER TIM2 |
Timer peripheral used for all tests (TIM2)
| void test_timer_clear_interrupt_flag_clears_UIF | ( | void | ) |
Test interrupt flag clearing.
Verifies that timer_clear_interrupt_flag() clears the Update Interrupt Flag (UIF) in the SR register
| void test_timer_enable_and_disable_channel | ( | void | ) |
Test channel enable/disable.
Verifies:
| void test_timer_enable_and_disable_interrupt | ( | void | ) |
Test interrupt enable.
Test interrupt control.
Verifies that timer_enable_interrupt() sets the Update Interrupt Enable (UIE) bit in the DIER register
| void test_timer_get_arr_returns_arr_value | ( | void | ) |
Test auto-reload register access.
Verifies that timer_get_arr() correctly returns the value from the ARR register
| void test_timer_get_count_returns_count_value | ( | void | ) |
Test counter value access.
Verifies that timer_get_count() correctly returns the current counter value from the CNT register
| void test_timer_init_sets_prescaler_and_arr | ( | void | ) |
Test timer initialization.
Verifies that timer_init() correctly sets:
| void test_timer_reset_clears_count | ( | void | ) |
Test timer counter reset.
Verifies that timer_reset() clears the counter value to zero by checking the CNT register
| void test_timer_set_compare_and_get_compare | ( | void | ) |
Test compare register operations.
Verifies:
| void test_timer_start_sets_CEN_bit | ( | void | ) |
Test timer start functionality.
Verifies that timer_start() sets the Counter ENable (CEN) bit in the CR1 register
| void test_timer_stop_clears_CEN_bit | ( | void | ) |
Test timer stop functionality.
Verifies that timer_stop() clears the Counter ENable (CEN) bit in the CR1 register