Unit tests for BPM driver.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include <conf_test.h>
Unit test configuration | |
#define | EVENT_WAKEUP 1 |
Wakeup event, logged in ISR that wakes up the device. More... | |
#define | EVENT_RUN 2 |
Run event, logged in main loop after wakeup. More... | |
#define | IS_NB_EVENTS_OK() (2 == log_index) |
Is OK if 2 events detected. More... | |
#define | IS_EVENTS_OK() ((log_events[0]==EVENT_WAKEUP) && (log_events[1]==EVENT_RUN)) |
Is OK if first event is wakeup and second one is run. More... | |
static uint8_t | log_events [2] |
Logs for events detected. More... | |
static volatile uint8_t | log_index = 0 |
Current log index. More... | |
static volatile uint32_t | tick_1ms = 0 |
1ms Time Tick More... | |
static void | reset_log (void) |
Reset event log list. More... | |
static void | log_event (uint8_t event) |
Log a event. More... | |
static void | wait_test_assert_idle (void) |
Wait until test assert is done (no wave on assert port) More... | |
static void | ast_per_callback (void) |
AST interrupt handler. More... | |
void | BPM_Handler (void) |
BPM interrupt handler. More... | |
static void | run_backup_test (const struct test_case *test) |
Test entering and exiting backup mode. More... | |
static void | run_ps_test (const struct test_case *test) |
Test power scaling switch. More... | |
static void | run_ret_test (const struct test_case *test) |
Test entering and exiting retention mode. More... | |
static void | run_wait_test (const struct test_case *test) |
Test entering and exiting wait mode. More... | |
static void | run_sleep_3_test (const struct test_case *test) |
Test entering and exiting sleep 3 mode. More... | |
static void | run_sleep_2_test (const struct test_case *test) |
Test entering and exiting sleep 2 mode. More... | |
static void | run_sleep_1_test (const struct test_case *test) |
Test entering and exiting sleep 1 mode. More... | |
static void | run_sleep_0_test (const struct test_case *test) |
Test entering and exiting sleep 0 mode. More... | |
int | main (void) |
Run BPM driver unit tests. More... | |
#define EVENT_RUN 2 |
Run event, logged in main loop after wakeup.
Referenced by run_ret_test(), run_sleep_0_test(), run_sleep_1_test(), run_sleep_2_test(), run_sleep_3_test(), and run_wait_test().
#define EVENT_WAKEUP 1 |
Wakeup event, logged in ISR that wakes up the device.
Referenced by ast_per_callback(), and BPM_Handler().
#define IS_EVENTS_OK | ( | ) | ((log_events[0]==EVENT_WAKEUP) && (log_events[1]==EVENT_RUN)) |
Is OK if first event is wakeup and second one is run.
Referenced by run_ret_test(), run_sleep_0_test(), run_sleep_1_test(), run_sleep_2_test(), run_sleep_3_test(), and run_wait_test().
#define IS_NB_EVENTS_OK | ( | ) | (2 == log_index) |
Is OK if 2 events detected.
Referenced by run_ret_test(), run_sleep_0_test(), run_sleep_1_test(), run_sleep_2_test(), run_sleep_3_test(), and run_wait_test().
|
static |
AST interrupt handler.
References ast_clear_interrupt_flag(), AST_INTERRUPT_PER, EVENT_WAKEUP, and log_event().
Referenced by main().
void BPM_Handler | ( | void | ) |
BPM interrupt handler.
References bpm_clear_interrupt(), bpm_disable_interrupt(), bpm_get_interrupt_status(), EVENT_WAKEUP, and log_event().
|
inlinestatic |
Log a event.
References log_events, and log_index.
Referenced by ast_per_callback(), BPM_Handler(), run_ret_test(), run_sleep_0_test(), run_sleep_1_test(), run_sleep_2_test(), run_sleep_3_test(), and run_wait_test().
int main | ( | void | ) |
Run BPM driver unit tests.
Retain I/O lines after wakeup from backup. Disable to undo the previous retention state then enable.
References ast_clear_interrupt_flag(), AST_COUNTER_MODE, ast_disable(), ast_enable(), ast_enable_wakeup(), AST_INTERRUPT_PER, AST_OSC_32KHZ, ast_per_callback(), AST_PSEL_32KHZ_1HZ, ast_set_callback(), ast_set_config(), AST_WAKEUP_PER, ast_write_periodic0_value(), uart_rs232_options::baudrate, board_init(), bpm_disable_io_retention(), bpm_enable_fast_wakeup(), bpm_enable_io_retention(), bpm_enable_wakeup_source(), ast_config::counter, DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, ast_config::mode, NULL, osc_enable(), OSC_ID_OSC32, osc_is_ready(), ast_config::osc_type, osc_wait_ready(), ast_config::psel, run_backup_test(), run_ps_test(), run_ret_test(), run_sleep_0_test(), run_sleep_1_test(), run_sleep_2_test(), run_sleep_3_test(), run_wait_test(), stdio_serial_init(), sysclk_init(), test_suite_run(), and usart_serial_options.
|
inlinestatic |
Reset event log list.
References log_events, and log_index.
Referenced by run_ret_test(), run_sleep_0_test(), run_sleep_1_test(), run_sleep_2_test(), run_sleep_3_test(), and run_wait_test().
|
static |
Test entering and exiting backup mode.
test | Current test case. |
References bpm_get_backup_wakeup_cause(), bpm_sleep(), BPM_SM_BACKUP, delay_ms, and test_assert_true.
Referenced by main().
|
static |
Test power scaling switch.
test | Current test case. |
References bpm_power_scaling_cpu_failsafe(), BPM_PS_0, BPM_PS_1, sysclk_get_cpu_hz(), test_assert_true, and wait_test_assert_idle().
Referenced by main().
|
static |
Test entering and exiting retention mode.
test | Current test case. |
References bpm_sleep(), BPM_SM_RET, delay_ms, EVENT_RUN, IS_EVENTS_OK, IS_NB_EVENTS_OK, log_event(), reset_log(), test_assert_true, and wait_test_assert_idle().
Referenced by main().
|
static |
Test entering and exiting sleep 0 mode.
test | Current test case. |
References bpm_sleep(), BPM_SM_SLEEP_0, delay_ms, EVENT_RUN, IS_EVENTS_OK, IS_NB_EVENTS_OK, log_event(), reset_log(), test_assert_true, and wait_test_assert_idle().
Referenced by main().
|
static |
Test entering and exiting sleep 1 mode.
test | Current test case. |
References bpm_sleep(), BPM_SM_SLEEP_1, delay_ms, EVENT_RUN, IS_EVENTS_OK, IS_NB_EVENTS_OK, log_event(), reset_log(), test_assert_true, and wait_test_assert_idle().
Referenced by main().
|
static |
Test entering and exiting sleep 2 mode.
test | Current test case. |
References bpm_sleep(), BPM_SM_SLEEP_2, delay_ms, EVENT_RUN, IS_EVENTS_OK, IS_NB_EVENTS_OK, log_event(), reset_log(), test_assert_true, and wait_test_assert_idle().
Referenced by main().
|
static |
Test entering and exiting sleep 3 mode.
test | Current test case. |
References bpm_sleep(), BPM_SM_SLEEP_3, delay_ms, EVENT_RUN, IS_EVENTS_OK, IS_NB_EVENTS_OK, log_event(), reset_log(), test_assert_true, and wait_test_assert_idle().
Referenced by main().
|
static |
Test entering and exiting wait mode.
test | Current test case. |
References bpm_sleep(), BPM_SM_WAIT, delay_ms, EVENT_RUN, IS_EVENTS_OK, IS_NB_EVENTS_OK, log_event(), reset_log(), test_assert_true, and wait_test_assert_idle().
Referenced by main().
|
inlinestatic |
Wait until test assert is done (no wave on assert port)
References usart_is_tx_empty().
Referenced by run_ps_test(), run_ret_test(), run_sleep_0_test(), run_sleep_1_test(), run_sleep_2_test(), run_sleep_3_test(), and run_wait_test().
|
static |
Logs for events detected.
Referenced by log_event(), and reset_log().
|
static |
Current log index.
Referenced by log_event(), and reset_log().
|
static |
1ms Time Tick