Microchip® Advanced Software Framework

common/services/sleepmgr/unit_tests/unit_tests.c File Reference

Unit tests for MegaRF Sleep Manager driver.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <conf_test.h>

Functions

static void adc_initialisation (void)
 
 ISR (ADC_vect)
 
 ISR (TIMER2_OVF_vect)
 
int main (void)
 Run Sleep Manager unit tests. More...
 
static void run_set_functions_test (const struct test_case *test)
 Test different parameters of the Sleep Manager module. More...
 
static void run_sleep_trigger_test (const struct test_case *test)
 Test interrupt is getting triggered in various Sleep mode. More...
 
static void timer2_initialisation (void)
 

Variables

static volatile uint8_t trigger_count = 0
 

ISR ( ADC_vect  )

References trigger_count.

ISR ( TIMER2_OVF_vect  )

References trigger_count.

int main ( void  )

Run Sleep Manager unit tests.

Main function.

Initializes the clock system, board and serial output, then sets up the Sleep Manager unit test suite and runs it.

The SAM3X_EK, SAM3X Arduino board and SAM4C_EK use two bytes length internal address EEPROM.

References usart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_set_functions_test(), run_sleep_trigger_test(), stdio_serial_init(), sysclk_init(), test_suite_run(), and usart_serial_options.

static void run_set_functions_test ( const struct test_case test)
static

Test different parameters of the Sleep Manager module.

This function locks & unlocks the different sleep modes, and verifies that the correct values are being set.

Parameters
testCurrent test case.

References sleepmgr_get_sleep_mode(), SLEEPMGR_IDLE, sleepmgr_init(), sleepmgr_lock_mode(), SLEEPMGR_NR_OF_MODES, SLEEPMGR_PDOWN, SLEEPMGR_PSAVE, sleepmgr_unlock_mode(), and test_assert_true.

Referenced by main().

static void run_sleep_trigger_test ( const struct test_case test)
static

Test interrupt is getting triggered in various Sleep mode.

This function put the device in Idle and Power Save sleep mode and check whether the ADC conversion complete interrupt is executed only in Idle sleep mode. The device will wakeup from power save mode when Timer/Counter2 overflow occur.

Parameters
testCurrent test case.

References adc_disable(), adc_initialisation(), adc_start_conversion(), cpu_irq_disable, cpu_irq_enable, sleepmgr_enter_sleep(), SLEEPMGR_IDLE, sleepmgr_init(), sleepmgr_lock_mode(), SLEEPMGR_PSAVE, sleepmgr_unlock_mode(), test_assert_true, timer2_initialisation(), and trigger_count.

Referenced by main().

static void timer2_initialisation ( void  )
static

volatile uint8_t trigger_count = 0
static

Referenced by ISR(), and run_sleep_trigger_test().