Definition in file thirdparty_app.c.
#include <avr32/io.h>
#include "board.h"
#include "intc.h"
#include "cycle_counter.h"
#include "gpio.h"
#include "flashvault.h"
Go to the source code of this file.
Defines | |
#define | NB_CLOCK_CYCLE_DELAY_SHORT 1000 |
Functions | |
static void | compare_irq_handler (void) |
static void | delay (int d) |
int | main (void) |
Variables | |
static volatile unsigned char | bFirstInterrupt = FALSE |
static volatile int | dummy |
static volatile unsigned int | u32NbCompareIrqTrigger = 0 |
#define NB_CLOCK_CYCLE_DELAY_SHORT 1000 |
static void compare_irq_handler | ( | void | ) | [static] |
Definition at line 149 of file thirdparty_app.c.
References bFirstInterrupt, and NB_CLOCK_CYCLE_DELAY_SHORT.
Referenced by main().
00150 { 00151 bFirstInterrupt = TRUE; 00152 // Count the number of times this IRQ handler is called. 00153 u32NbCompareIrqTrigger++; 00154 00155 dummy++; 00156 00157 // Toggle LED0. 00158 gpio_tgl_gpio_pin(LED0_GPIO); 00159 00160 // Clear the pending interrupt(writing a value to the COMPARE register clears 00161 // any pending compare interrupt requests). Schedule the COUNT&COMPARE match 00162 // interrupt to happen every NB_CLOCK_CYCLE_DELAY_SHORT cycles. 00163 Set_sys_compare(NB_CLOCK_CYCLE_DELAY_SHORT); 00164 }
static void delay | ( | int | d | ) | [static] |
int main | ( | void | ) |
Definition at line 178 of file thirdparty_app.c.
References bFirstInterrupt, compare_irq_handler(), delay(), FLASHVAULT_API_TGL_LED1, INST_SSCALL, and NB_CLOCK_CYCLE_DELAY_SHORT.
00179 { 00180 U32 u32CompareVal; 00181 U32 u32CountVal; 00182 00183 00184 // Disable all interrupts. 00185 Disable_global_interrupt(); 00186 00187 INTC_init_interrupts(); 00188 00189 // Register the compare interrupt handler to the interrupt controller. 00190 // compare_irq_handler is the interrupt handler to register. 00191 // AVR32_CORE_COMPARE_IRQ is the IRQ of the interrupt handler to register. 00192 // AVR32_INTC_INT0 is the interrupt priority level to assign to the group of this IRQ. 00193 // void INTC_register_interrupt(__int_handler handler, unsigned int irq, unsigned int int_level); 00194 INTC_register_interrupt(&compare_irq_handler, AVR32_CORE_COMPARE_IRQ, AVR32_INTC_INT0); 00195 00196 // Enable all interrupts. 00197 Enable_global_interrupt(); 00198 00199 // Schedule the COUNT&COMPARE match interrupt in NB_CLOCK_CYCLE_DELAY_SHORT 00200 // clock cycles from now. 00201 u32CountVal = Get_sys_count(); 00202 00203 u32CompareVal = u32CountVal + NB_CLOCK_CYCLE_DELAY_SHORT; // WARNING: MUST FIT IN 32bits. 00204 // If u32CompareVal ends up to be 0, make it 1 so that the COMPARE and exception 00205 // generation feature does not get disabled. 00206 if(0 == u32CompareVal) 00207 { 00208 u32CompareVal++; 00209 } 00210 00211 Set_sys_compare(u32CompareVal); // GO 00212 00213 // Wait for the first COUNT/COMPARE match interrupt to trigger. 00214 while(bFirstInterrupt == FALSE); 00215 00216 while(1) 00217 { 00218 // Toggle led1. According to the FlashVault API, we must fill R8 with the 00219 // target function id before calling SSCALL. 00220 __asm__ __volatile__ ( \ 00221 /* Fill the api vector id. */ \ 00222 "mov r8, %[TGL_LED1]\n\t" \ 00223 \ 00224 /* Call the secure world. */ \ 00225 ".int %[SSCALL]" \ 00226 : \ 00227 : [SSCALL] "i" (INST_SSCALL), \ 00228 [TGL_LED1] "i" (FLASHVAULT_API_TGL_LED1) \ 00229 ); 00230 00231 // Insert a delay 00232 delay(5000); 00233 } 00234 return 0; // Never reached 00235 }
volatile unsigned char bFirstInterrupt = FALSE [static] |
volatile int dummy [static] |
Definition at line 144 of file thirdparty_app.c.
volatile unsigned int u32NbCompareIrqTrigger = 0 [static] |
Definition at line 141 of file thirdparty_app.c.