Microchip® Advanced Software Framework

drivers/extint/unit_test/unit_test.c File Reference

SAM External Interrupt Unit test.

Copyright (c) 2013-2020 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <stdio_serial.h>
#include <string.h>
#include "conf_test.h"

Functions

static void cdc_uart_init (void)
 Initialize the USART for unit test. More...
 
static void cleanup_extint_callback_mode_test (const struct test_case *test)
 Cleanup function for callback mode test. More...
 
static void cleanup_extint_polled_mode_test (const struct test_case *test)
 Cleanup function for polled mode test. More...
 
static void extint_user_callback (void)
 External interrupt callback function. More...
 
int main (void)
 Run External Interrupt unit tests. More...
 
static void run_extint_callback_mode_test (const struct test_case *test)
 Test for external interrupt detection using callback. More...
 
static void run_extint_polled_mode_test (const struct test_case *test)
 Test for external interrupt detection by polling. More...
 
static void setup_extint_callback_mode_test (const struct test_case *test)
 Setup function for callback mode test. More...
 
static void setup_extint_polled_mode_test (const struct test_case *test)
 Setup function for polled mode test. More...
 

Variables

struct usart_module cdc_uart_module
 
struct extint_chan_conf eic_conf
 
volatile bool interrupt_flag = false
 
struct port_config pin_conf
 
volatile bool result = false
 

static void cdc_uart_init ( void  )
static
static void cleanup_extint_callback_mode_test ( const struct test_case test)
static

Cleanup function for callback mode test.

This function disables the callback & external interrupt channel.

Parameters
testCurrent test case.

References extint_chan_conf::detection_criteria, eic_conf, EXTINT_CALLBACK_TYPE_DETECT, extint_chan_disable_callback(), extint_chan_set_config(), EXTINT_DETECT_NONE, extint_unregister_callback(), and extint_user_callback().

Referenced by main().

static void cleanup_extint_polled_mode_test ( const struct test_case test)
static

Cleanup function for polled mode test.

This function disables the external interrupt channel.

Parameters
testCurrent test case.

References extint_chan_conf::detection_criteria, eic_conf, extint_chan_set_config(), and EXTINT_DETECT_NONE.

Referenced by main().

static void extint_user_callback ( void  )
static

External interrupt callback function.

Called by external interrupt driver on interrupt detection.

References interrupt_flag.

Referenced by cleanup_extint_callback_mode_test(), and setup_extint_callback_mode_test().

int main ( void  )
static void run_extint_callback_mode_test ( const struct test_case test)
static

Test for external interrupt detection using callback.

This test changes the logic level of PB05 from high to low so that the external interrupt channel detects the edge and calls the callback function.

Detection is tested for both rising and falling edges.

Parameters
testCurrent test case.

References extint_chan_conf::detection_criteria, eic_conf, extint_chan_set_config(), EXTINT_DETECT_RISING, interrupt_flag, port_pin_set_output_level(), and test_assert_true.

Referenced by main().

static void run_extint_polled_mode_test ( const struct test_case test)
static

Test for external interrupt detection by polling.

This test changes the logic level of PB05 from high to low so that the external interrupt channel detects the edge.

Detection is tested for both rising and falling edges.

Parameters
testCurrent test case.

References delay_ms, extint_chan_conf::detection_criteria, eic_conf, extint_chan_clear_detected(), extint_chan_is_detected(), extint_chan_set_config(), EXTINT_DETECT_RISING, port_pin_set_output_level(), result, and test_assert_true.

Referenced by main().

static void setup_extint_polled_mode_test ( const struct test_case test)
static

struct usart_module cdc_uart_module
volatile bool interrupt_flag = false