Microchip® Advanced Software Framework

unit_tests.c File Reference

Unit tests for MegaRF Ext Interrupt driver.

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

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

Macros

#define CONF_OUT_PIN   IOPORT_CREATE_PIN(PORTE,1)
 
#define HIGH   0x01
 
#define LOW   0x00
 
#define PC_INT8_PIN_PORT_POS   0x00
 

Functions

static void ext_pc_int_callback (void)
 Interrupt callback for External PC interrupt Increments the trigger counter when the interrupt is triggered. More...
 
int main (void)
 Run Ext Interrupt unit tests. More...
 
static void run_interrupt_trigger_test (const struct test_case *test)
 Test External interrupt is getting triggered. More...
 
static void run_set_functions_test (const struct test_case *test)
 Test setting different parameters of the Ext_Int module. More...
 

Variables

static volatile uint8_t trigger_count =0
 

#define CONF_OUT_PIN   IOPORT_CREATE_PIN(PORTE,1)
#define HIGH   0x01
#define LOW   0x00
#define PC_INT8_PIN_PORT_POS   0x00

Referenced by run_set_functions_test().

static void ext_pc_int_callback ( void  )
static

Interrupt callback for External PC interrupt Increments the trigger counter when the interrupt is triggered.

Parameters
none

References trigger_count.

Referenced by run_interrupt_trigger_test().

int main ( void  )

Run Ext Interrupt unit tests.

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

References usart_rs232_options::baudrate, board_init(), CONF_TEST_BAUDRATE, CONF_TEST_CHARLENGTH, CONF_TEST_PARITY, CONF_TEST_STOPBITS, CONF_TEST_USART, DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, run_interrupt_trigger_test(), run_set_functions_test(), stdio_serial_init(), sysclk_init(), and test_suite_run().

static void run_interrupt_trigger_test ( const struct test_case test)
static

Test External interrupt is getting triggered.

This function enables the pin change interrupt(PE0) and changes the status of the pin by outputting high/low on GPIO pin (PE1) which in turn connected to PC interrupt pin

Parameters
testCurrent test case.

References CONF_OUT_PIN, CONF_PC_INT, cpu_irq_disable, cpu_irq_enable, ext_int_pcint_init(), ext_int_set_interrupt_callback(), ext_pc_int_callback(), HIGH, ioport_configure_pin(), IOPORT_DIR_OUTPUT, ioport_set_pin_level(), LOW, test_assert_true, and trigger_count.

Referenced by main().

static void run_set_functions_test ( const struct test_case test)
static

Test setting different parameters of the Ext_Int module.

This function calls the different set functions, and verifies that the correct values are being set.

Parameters
testCurrent test case.

References CONF_EXT_INT, CONF_PC_INT, ext_int_clear_flag(), ext_int_disable(), ext_int_enable(), ext_int_pcint_clear_flag(), ext_int_pcint_disable(), ext_int_pcint_enable(), EXT_INT_PORT_MASK, INT_PIN_MASK, PC_INT8_PIN_PORT_POS, and test_assert_true.

Referenced by main().

volatile uint8_t trigger_count =0
static