eic.h File Reference


Detailed Description

EIC driver for AVR32 UC3.

AVR32 External Interrupt Controller driver module.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file eic.h.

#include "compiler.h"

Go to the source code of this file.

Data Structures

struct  eic_options_t
 Configuration parameters of the EIC module. More...

Defines

Synch Mode Options
#define EIC_ASYNCH_MODE   AVR32_EIC_USE_ASYNC
#define EIC_SYNCH_MODE   AVR32_EIC_SYNC
Edge level Options
#define EIC_EDGE_FALLING_EDGE   AVR32_EIC_FALLING_EDGE
#define EIC_EDGE_RISING_EDGE   AVR32_EIC_RISING_EDGE
Filter Options
#define EIC_FILTER_DISABLED   AVR32_EIC_FILTER_OFF
#define EIC_FILTER_ENABLED   AVR32_EIC_FILTER_ON
Level Options
#define EIC_LEVEL_HIGH_LEVEL   AVR32_EIC_HIGH_LEVEL
#define EIC_LEVEL_LOW_LEVEL   AVR32_EIC_LOW_LEVEL
Mode Trigger Options
#define EIC_MODE_EDGE_TRIGGERED   AVR32_EIC_EDGE_IRQ
#define EIC_MODE_LEVEL_TRIGGERED   AVR32_EIC_LEVEL_IRQ
External Interrupt lines
#define EXT_INT0   AVR32_EIC_INT1
 Line 0.
#define EXT_INT1   AVR32_EIC_INT2
 Line 1.
#define EXT_INT2   AVR32_EIC_INT3
 Line 2.
#define EXT_INT3   AVR32_EIC_INT4
 Line 3.
#define EXT_INT4   AVR32_EIC_INT5
 Line 4.
#define EXT_INT5   AVR32_EIC_INT6
 Line 5.
#define EXT_INT6   AVR32_EIC_INT7
 Line 6.
#define EXT_INT7   AVR32_EIC_INT8
 Line 7.
#define EXT_NMI   AVR32_EIC_NMI
 Line 8.

Functions

void eic_disable_line (volatile avr32_eic_t *eic, unsigned int line_number)
 Disable the EIC driver.
void eic_disable_lines (volatile avr32_eic_t *eic, unsigned int mask_lines)
 Disable the EIC driver.
void eic_enable_line (volatile avr32_eic_t *eic, unsigned int line_number)
 Enable the EIC driver.
void eic_enable_lines (volatile avr32_eic_t *eic, unsigned int mask_lines)
 Enable the EIC driver.
void eic_init (volatile avr32_eic_t *eic, const eic_options_t *opt, unsigned int nb_lines)
 Init the EIC driver.
Bool eic_is_line_enabled (volatile avr32_eic_t *eic, unsigned int line_number)
 Tells whether an EIC line is enabled.
Interrupt Control Functions
void eic_clear_interrupt_line (volatile avr32_eic_t *eic, unsigned int line_number)
 Clear the interrupt flag. Call this function once you've handled the interrupt.
void eic_clear_interrupt_lines (volatile avr32_eic_t *eic, unsigned int mask_lines)
 Clear the interrupt flag. Call this function once you've handled the interrupt.
void eic_disable_interrupt_line (volatile avr32_eic_t *eic, unsigned int line_number)
 Disable the interrupt feature of the EIC.
void eic_disable_interrupt_lines (volatile avr32_eic_t *eic, unsigned int mask_lines)
 Disable the interrupt feature of the EIC.
void eic_disable_interrupt_scan (volatile avr32_eic_t *eic)
 Disable the interrupt scan feature of the EIC.
void eic_enable_interrupt_line (volatile avr32_eic_t *eic, unsigned int line_number)
 Enable the interrupt feature of the EIC.
void eic_enable_interrupt_lines (volatile avr32_eic_t *eic, unsigned int mask_lines)
 Enable the interrupt feature of the EIC.
void eic_enable_interrupt_scan (volatile avr32_eic_t *eic, unsigned int presc)
 Enable the interrupt scan feature of the EIC.
unsigned long eic_get_interrupt_pad_scan (volatile avr32_eic_t *eic)
 Return scan pad number that causes interrupt.
Bool eic_is_interrupt_line_enabled (volatile avr32_eic_t *eic, unsigned int line_number)
 Tells whether an EIC interrupt line is enabled.
Bool eic_is_interrupt_line_pending (volatile avr32_eic_t *eic, unsigned int line_number)
 Tells whether an EIC interrupt line is pending.


Define Documentation

#define EIC_ASYNCH_MODE   AVR32_EIC_USE_ASYNC

Definition at line 113 of file eic.h.

#define EIC_EDGE_FALLING_EDGE   AVR32_EIC_FALLING_EDGE

Definition at line 91 of file eic.h.

Referenced by main().

#define EIC_EDGE_RISING_EDGE   AVR32_EIC_RISING_EDGE

Definition at line 92 of file eic.h.

#define EIC_FILTER_DISABLED   AVR32_EIC_FILTER_OFF

Definition at line 106 of file eic.h.

#define EIC_FILTER_ENABLED   AVR32_EIC_FILTER_ON

Definition at line 105 of file eic.h.

#define EIC_LEVEL_HIGH_LEVEL   AVR32_EIC_HIGH_LEVEL

Definition at line 99 of file eic.h.

#define EIC_LEVEL_LOW_LEVEL   AVR32_EIC_LOW_LEVEL

Definition at line 98 of file eic.h.

#define EIC_MODE_EDGE_TRIGGERED   AVR32_EIC_EDGE_IRQ

Definition at line 84 of file eic.h.

Referenced by main().

#define EIC_MODE_LEVEL_TRIGGERED   AVR32_EIC_LEVEL_IRQ

Definition at line 85 of file eic.h.

#define EIC_SYNCH_MODE   AVR32_EIC_SYNC

Definition at line 112 of file eic.h.

Referenced by main().

#define EXT_INT0   AVR32_EIC_INT1

Line 0.

Definition at line 67 of file eic.h.

#define EXT_INT1   AVR32_EIC_INT2

Line 1.

Definition at line 68 of file eic.h.

#define EXT_INT2   AVR32_EIC_INT3

Line 2.

Definition at line 69 of file eic.h.

#define EXT_INT3   AVR32_EIC_INT4

Line 3.

Definition at line 70 of file eic.h.

#define EXT_INT4   AVR32_EIC_INT5

Line 4.

Definition at line 71 of file eic.h.

#define EXT_INT5   AVR32_EIC_INT6

Line 5.

Definition at line 72 of file eic.h.

#define EXT_INT6   AVR32_EIC_INT7

Line 6.

Definition at line 73 of file eic.h.

#define EXT_INT7   AVR32_EIC_INT8

Line 7.

Definition at line 74 of file eic.h.

#define EXT_NMI   AVR32_EIC_NMI

Line 8.

Definition at line 75 of file eic.h.


Function Documentation

void eic_clear_interrupt_line ( volatile avr32_eic_t *  eic,
unsigned int  line_number 
)

Clear the interrupt flag. Call this function once you've handled the interrupt.

Parameters:
eic Base address of the EIC (i.e. &AVR32_EIC).
line_number Line number to clear

Definition at line 147 of file eic.c.

Referenced by eic_int_handler1(), and eic_int_handler2().

00148 {
00149   Bool global_interrupt_enabled = Is_global_interrupt_enabled();
00150 
00151   // Clear line line_number
00152   if (global_interrupt_enabled) Disable_global_interrupt();
00153   eic->icr = 1 << line_number;
00154   eic->isr;
00155   if (global_interrupt_enabled) Enable_global_interrupt();
00156 }

void eic_clear_interrupt_lines ( volatile avr32_eic_t *  eic,
unsigned int  mask_lines 
)

Clear the interrupt flag. Call this function once you've handled the interrupt.

Parameters:
eic Base address of the EIC (i.e. &AVR32_EIC).
mask_lines Mask for current selected lines

Definition at line 137 of file eic.c.

00138 {
00139   Bool global_interrupt_enabled = Is_global_interrupt_enabled();
00140 
00141   if (global_interrupt_enabled) Disable_global_interrupt();
00142   eic->icr = mask_lines;
00143   eic->isr;
00144   if (global_interrupt_enabled) Enable_global_interrupt();
00145 }

void eic_disable_interrupt_line ( volatile avr32_eic_t *  eic,
unsigned int  line_number 
)

Disable the interrupt feature of the EIC.

Parameters:
eic Base address of the EIC (i.e. &AVR32_EIC).
line_number Line number to disable

Definition at line 121 of file eic.c.

00122 {
00123   Bool global_interrupt_enabled = Is_global_interrupt_enabled();
00124 
00125   // Disable line line_number
00126   if (global_interrupt_enabled) Disable_global_interrupt();
00127   eic->idr = 1 << line_number;
00128   eic->imr;
00129   if (global_interrupt_enabled) Enable_global_interrupt();
00130 }

void eic_disable_interrupt_lines ( volatile avr32_eic_t *  eic,
unsigned int  mask_lines 
)

Disable the interrupt feature of the EIC.

Parameters:
eic Base address of the EIC (i.e. &AVR32_EIC).
mask_lines Mask for current selected lines

Definition at line 111 of file eic.c.

00112 {
00113   Bool global_interrupt_enabled = Is_global_interrupt_enabled();
00114 
00115   if (global_interrupt_enabled) Disable_global_interrupt();
00116   eic->idr = mask_lines;
00117   eic->imr;
00118   if (global_interrupt_enabled) Enable_global_interrupt();
00119 }

void eic_disable_interrupt_scan ( volatile avr32_eic_t *  eic  ) 

Disable the interrupt scan feature of the EIC.

Parameters:
eic Base address of the EIC (i.e. &AVR32_EIC).

Definition at line 170 of file eic.c.

00171 {
00172   // Disable SCAN function
00173   eic->scan = 0 << AVR32_EIC_SCAN_EN_OFFSET;
00174 }

void eic_disable_line ( volatile avr32_eic_t *  eic,
unsigned int  line_number 
)

Disable the EIC driver.

Parameters:
eic Base address of the EIC module
line_number Line number to disable

Definition at line 89 of file eic.c.

00090 {
00091   // Disable line line_number
00092   eic->dis = 1 << line_number;
00093 }

void eic_disable_lines ( volatile avr32_eic_t *  eic,
unsigned int  mask_lines 
)

Disable the EIC driver.

Parameters:
eic Base address of the EIC module
mask_lines Mask for current selected lines

Definition at line 84 of file eic.c.

00085 {
00086   eic->dis = mask_lines;
00087 }

void eic_enable_interrupt_line ( volatile avr32_eic_t *  eic,
unsigned int  line_number 
)

Enable the interrupt feature of the EIC.

Parameters:
eic Base address of the EIC (i.e. &AVR32_EIC).
line_number Line number to enable

Definition at line 105 of file eic.c.

00106 {
00107   // Enable line line_number
00108   eic->ier = 1 << line_number;
00109 }

void eic_enable_interrupt_lines ( volatile avr32_eic_t *  eic,
unsigned int  mask_lines 
)

Enable the interrupt feature of the EIC.

Parameters:
eic Base address of the EIC (i.e. &AVR32_EIC).
mask_lines Mask for current selected lines

Definition at line 100 of file eic.c.

Referenced by main().

00101 {
00102   eic->ier = mask_lines;
00103 }

void eic_enable_interrupt_scan ( volatile avr32_eic_t *  eic,
unsigned int  presc 
)

Enable the interrupt scan feature of the EIC.

Parameters:
eic Base address of the EIC (i.e. &AVR32_EIC).
presc Prescale select for the keypad scan rate in the range [0,31].

Definition at line 164 of file eic.c.

Referenced by main().

00165 {
00166   // Enable SCAN function with PRESC value
00167   eic->scan |= (presc << AVR32_EIC_SCAN_PRESC_OFFSET) | (1 << AVR32_EIC_SCAN_EN_OFFSET);
00168 }

void eic_enable_line ( volatile avr32_eic_t *  eic,
unsigned int  line_number 
)

Enable the EIC driver.

Parameters:
eic Base address of the EIC module
line_number Line number to enable

Definition at line 78 of file eic.c.

00079 {
00080   // Enable line line_number
00081   eic->en = 1 << line_number;
00082 }

void eic_enable_lines ( volatile avr32_eic_t *  eic,
unsigned int  mask_lines 
)

Enable the EIC driver.

Parameters:
eic Base address of the EIC module
mask_lines Mask for current selected lines

Definition at line 73 of file eic.c.

Referenced by main().

00074 {
00075   eic->en = mask_lines;
00076 }

unsigned long eic_get_interrupt_pad_scan ( volatile avr32_eic_t *  eic  ) 

Return scan pad number that causes interrupt.

Parameters:
eic Base address of the EIC (i.e. &AVR32_EIC).

Definition at line 176 of file eic.c.

Referenced by eic_int_handler1(), and eic_int_handler2().

00177 {
00178   // Return pad number that causes interrupt
00179   return(eic->scan>>AVR32_EIC_SCAN_PIN_OFFSET);
00180 }

void eic_init ( volatile avr32_eic_t *  eic,
const eic_options_t opt,
unsigned int  nb_lines 
)

Init the EIC driver.

Parameters:
eic Base address of the EIC module
opt Configuration parameters of the EIC module (see eic_options_t)
nb_lines Number of lines to consider, equal to size of opt buffer

Definition at line 55 of file eic.c.

References eic_options_t::eic_async, eic_options_t::eic_edge, eic_options_t::eic_filter, eic_options_t::eic_level, eic_options_t::eic_line, and eic_options_t::eic_mode.

Referenced by main().

00056 {
00057   int i;
00058   for (i = 0; i < nb_lines; i++)
00059   {
00060     // Set up mode level
00061     eic->mode = (opt[i].eic_mode == 1) ? (eic->mode | (1 << opt[i].eic_line)) : (eic->mode & ~(1 << opt[i].eic_line));
00062     // Set up edge type
00063     eic->edge = (opt[i].eic_edge == 1) ? (eic->edge | (1 << opt[i].eic_line)) : (eic->edge & ~(1 << opt[i].eic_line));
00064     // Set up level
00065     eic->level = (opt[i].eic_level == 1) ? (eic->level | (1 << opt[i].eic_line)) : (eic->level & ~(1 << opt[i].eic_line));
00066     // Set up if filter is used
00067     eic->filter = (opt[i].eic_filter == 1) ? (eic->filter | (1 << opt[i].eic_line)) : (eic->filter & ~(1 << opt[i].eic_line));
00068     // Set up which mode is used : asynchronous mode/ synchronous mode
00069     eic->async = (opt[i].eic_async == 1) ? (eic->async | (1 << opt[i].eic_line)) : (eic->async & ~(1 << opt[i].eic_line));
00070   }
00071 }

Bool eic_is_interrupt_line_enabled ( volatile avr32_eic_t *  eic,
unsigned int  line_number 
)

Tells whether an EIC interrupt line is enabled.

Parameters:
eic Base address of the EIC module
line_number Line number to test
Returns:
Whether an EIC interrupt line is enabled.

Definition at line 132 of file eic.c.

00133 {
00134   return (eic->imr & (1 << line_number)) != 0;
00135 }

Bool eic_is_interrupt_line_pending ( volatile avr32_eic_t *  eic,
unsigned int  line_number 
)

Tells whether an EIC interrupt line is pending.

Parameters:
eic Base address of the EIC module
line_number Line number to test
Returns:
Whether an EIC interrupt line is pending.

Definition at line 158 of file eic.c.

00159 {
00160   return (eic->isr & (1 << line_number)) != 0;
00161 }

Bool eic_is_line_enabled ( volatile avr32_eic_t *  eic,
unsigned int  line_number 
)

Tells whether an EIC line is enabled.

Parameters:
eic Base address of the EIC module
line_number Line number to test
Returns:
Whether an EIC line is enabled.

Definition at line 95 of file eic.c.

00096 {
00097   return (eic->ctrl & (1 << line_number)) != 0;
00098 }


Generated on Fri Feb 19 02:24:42 2010 for AVR32 UC3 - EIC Driver Example 3 by  doxygen 1.5.5