Microchip® Advanced Software Framework

sam/utils/cmsis/cm4_nvic_example/main.c File Reference

NVIC Example.

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

#include "asf.h"
#include "conf_board.h"
#include "stdio_serial.h"

Macros

#define INT_PRIOR_HIGH   4
 Define interrupt priority (0-15). More...
 
#define INT_PRIOR_LOW   6
 
#define STRING_EOL   "\r"
 
#define STRING_HEADER
 

Functions

static void configure_buttons (void)
 Configure the push buttons. More...
 
static void configure_console (void)
 Configure the Console UART. More...
 
static __INLINE void delay_ticks (uint32_t ul_dly_ticks)
 Delay number of tick Systicks (happens roughly every 1 ms). More...
 
static void display_menu (void)
 Display menu. More...
 
static void Int1Handler (uint32_t ul_id, uint32_t ul_mask)
 Handler for INT1, rising edge interrupt. More...
 
static void Int2Handler (uint32_t ul_id, uint32_t ul_mask)
 Handler for INT2, rising edge interrupt. More...
 
static __INLINE void led_config (void)
 Configure LED pins. More...
 
int main (void)
 Application entry point. More...
 
static void set_interrupt_priority (uint8_t int1Prior, uint8_t int2Prior)
 Set interrupt priority of INT1 and INT2. More...
 

Variables

volatile uint32_t g_ul_ms_ticks = 0
 

#define INT_PRIOR_HIGH   4

Define interrupt priority (0-15).

A higher level corresponds to a lower priority, so level 0 is the highest interrupt priority.

Referenced by main().

#define INT_PRIOR_LOW   6

Referenced by main().

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- Cortex-M4 NVIC Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define BOARD_NAME
Definition: inc/app_init.h:140
#define STRING_EOL
Definition: sam/utils/cmsis/cm4_nvic_example/main.c:144

Referenced by main().

static void configure_buttons ( void  )
static

Configure the push buttons.

Configure the PIOs as inputs and generate corresponding interrupt when the push buttons are pressed or released.

References Int1Handler(), Int2Handler(), pio_enable_interrupt(), and pio_set_debounce_filter().

Referenced by main().

static void configure_console ( void  )
static
static __INLINE void delay_ticks ( uint32_t  ul_dly_ticks)
static

Delay number of tick Systicks (happens roughly every 1 ms).

Note: As the systick has the lowest priority, lower than the PIO, the systick is not used here.

Referenced by Int1Handler(), and Int2Handler().

static void display_menu ( void  )
static

Display menu.

Referenced by main().

static void Int1Handler ( uint32_t  ul_id,
uint32_t  ul_mask 
)
static

Handler for INT1, rising edge interrupt.

In INT1, it will trigger INT2.

References delay_ticks(), gpio_set_pin_high, gpio_set_pin_low, pio_disable_interrupt(), and pio_enable_interrupt().

Referenced by configure_buttons().

static void Int2Handler ( uint32_t  ul_id,
uint32_t  ul_mask 
)
static

Handler for INT2, rising edge interrupt.

References delay_ticks(), gpio_set_pin_high, gpio_set_pin_low, pio_disable_interrupt(), and pio_enable_interrupt().

Referenced by configure_buttons().

static __INLINE void led_config ( void  )
static

Configure LED pins.

References gpio_set_pin_high.

Referenced by main().

static void set_interrupt_priority ( uint8_t  int1Prior,
uint8_t  int2Prior 
)
static

Set interrupt priority of INT1 and INT2.

Parameters
int1PriorPriority of interrupt 1.
int2PriorPriority of interrupt 2.

Steps to change the IRQ priority:

  1. Disable the interrupt service handler.
  2. Clear the pending interrupt service handler.
  3. Set the new priority.
  4. Enable the interrupt service handler.

Referenced by main().

volatile uint32_t g_ul_ms_ticks = 0