Fx2lib  0.2
Defines | Enumerations
include/fx2ints.h File Reference

Go to the source code of this file.

Defines

#define INTERRUPT_HIGH_PRIO   1
 Interrupt high priority.
#define INTERRUPT_LOW_PRIO   0
 Interrupt low priority.
#define ENABLE_TIMER0()   ET0=1
 Enable the timer 0 interrupt.
#define CLEAR_TIMER0()
 Clear timer 0 interrupt.
#define ENABLE_TIMER1()   ET1=1
 Enable timer 1 interrupt.
#define CLEAR_TIMER1()
 Clear timer 1 interrupt.
#define ENABLE_TIMER2()   ET2=1
 Enable timer 2 interrupt.
#define CLEAR_TIMER2()   TF2=0;EXF2=0;
 Clear timer 2 interrupt.
#define ENABLE_RESUME()   ERESI = 1
 Enable the Resume Interrupt. Requires EA=1 separately.
#define CLEAR_RESUME()   RESI=0
 Clear the resume interrupt. Use within the resume interrupt handler.
#define ENABLE_INT5()   EIEX5=1
 Enable external interrupt for INT5#.
#define CLEAR_INT5()   EXIF &= ~bmIE5
 Clear INT5# interrupt.
#define SET_USART0_ISR_PRIORITY(p)   PS0 = p
 Set the USART 0 interrupt priority.
#define ENABLE_USART0()   ES0 = 1;
 Enable the USART 0 interrupt.
#define CLEAR_USART0_RX()   RI = 0;
 Clear USART 0 RX bit.
#define CLEAR_USART0_TX()   TI = 0;
 Clear USART 0 TX bit.
#define CLEAR_USART0()
 Clear USART 0 both TX & RX bit.
#define SET_USART1_ISR_PRIORITY(p)   PS1 = p
 Set the USART 1 interrupt priority.
#define ENABLE_USART1()   ES1 = 1;
 Enable the USART 1 interrupt.
#define CLEAR_USART1_RX()   RI1 = 0;
 Clear USART 1 receive (RI1) bit.
#define CLEAR_USART1_TX()   TI1 = 0;
 Clear USART 1 transmit (TI1) bit.
#define CLEAR_USART1()
 Clear USART 1 both TX & RX bits.
#define SET_I2C_ISR_PRIORITY(p)   PI2C = p
 Set the I2C interrupt priority.
#define ENABLE_I2C()   EI2C = 1;
 Enable the I2C interrupt.
#define CLEAR_I2C()   EXIF &= ~bmI2CINT;
 Clear I2C interrupt.

Enumerations

enum  FX2_ISR {
  IE0_ISR = 0, TF0_ISR, IE1_ISR, TF1_ISR,
  TI_0_ISR, TF2_ISR, RESUME_ISR, TI_1_ISR,
  USBINT_ISR, I2CINT_ISR, IE4_ISR, IE5_ISR,
  IE6_ISR, USART0_ISR = TI_0_ISR, USART1_ISR = TI_1_ISR
}
 Interrupt numbers for standard FX2 interrupts. More...

Detailed Description

Define the standard FX2 interrupts. For INT2 and INT4 autovector interrupts see autovector.h

To enable an interrupt, simply define an interrupt handler function and use the appropriate ENABLE_* macro. Interrupt enable macros do not enable interrupts globally. Use EA=1 to enable interrupts.

      void main() {
          ENABLE_RESUME();
          EA=1;
          ...
      }

      void handle_resume() interrupt RESUME_ISR {
          CLEAR_RESUME();
      }

Definition in file fx2ints.h.


Define Documentation

#define CLEAR_I2C ( )    EXIF &= ~bmI2CINT;

Clear I2C interrupt.

Definition at line 277 of file fx2ints.h.

#define CLEAR_INT5 ( )    EXIF &= ~bmIE5

Clear INT5# interrupt.

Definition at line 162 of file fx2ints.h.

#define CLEAR_RESUME ( )    RESI=0

Clear the resume interrupt. Use within the resume interrupt handler.

Examples:
fw.c.

Definition at line 142 of file fx2ints.h.

#define CLEAR_TIMER0 ( )

Clear timer 0 interrupt.

CLEAR_TIMER0() is a NOP because the timer interrupt flag is automatically cleared when the ISR is called.

Definition at line 89 of file fx2ints.h.

#define CLEAR_TIMER1 ( )

Clear timer 1 interrupt.

CLEAR_TIMER1() is a NOP because the timer interrupt flag is automatically cleared when the ISR is called.

Definition at line 108 of file fx2ints.h.

#define CLEAR_TIMER2 ( )    TF2=0;EXF2=0;

Clear timer 2 interrupt.

Clears both the TF2 AND EXF2 flag

Definition at line 125 of file fx2ints.h.

#define CLEAR_USART0 ( )
Value:
CLEAR_USART0_RX(); \
        CLEAR_USART0_TX();

Clear USART 0 both TX & RX bit.

Definition at line 203 of file fx2ints.h.

#define CLEAR_USART0_RX ( )    RI = 0;

Clear USART 0 RX bit.

Definition at line 193 of file fx2ints.h.

#define CLEAR_USART0_TX ( )    TI = 0;

Clear USART 0 TX bit.

Definition at line 198 of file fx2ints.h.

#define CLEAR_USART1 ( )
Value:
CLEAR_USART1_RX(); \
        CLEAR_USART1_TX();

Clear USART 1 both TX & RX bits.

Definition at line 245 of file fx2ints.h.

#define CLEAR_USART1_RX ( )    RI1 = 0;

Clear USART 1 receive (RI1) bit.

Definition at line 235 of file fx2ints.h.

#define CLEAR_USART1_TX ( )    TI1 = 0;

Clear USART 1 transmit (TI1) bit.

Definition at line 240 of file fx2ints.h.

#define ENABLE_I2C ( )    EI2C = 1;

Enable the I2C interrupt.

Requires enabling global interrupts (EA=1) separately.

The USART interrupt fires for both *receive* (RX) and *transmit* (TX) completing, the interrupt must clear *both*.

Definition at line 272 of file fx2ints.h.

#define ENABLE_INT5 ( )    EIEX5=1

Enable external interrupt for INT5#.

Definition at line 156 of file fx2ints.h.

#define ENABLE_RESUME ( )    ERESI = 1

Enable the Resume Interrupt. Requires EA=1 separately.

Examples:
fw.c.

Definition at line 136 of file fx2ints.h.

#define ENABLE_TIMER0 ( )    ET0=1

Enable the timer 0 interrupt.

CLEAR_TIMER0() is a NOP because the timer interrupt flag is automatically cleared when the ISR is called.

Definition at line 81 of file fx2ints.h.

#define ENABLE_TIMER1 ( )    ET1=1

Enable timer 1 interrupt.

CLEAR_TIMER1() is a NOP because the timer interrupt flag is automatically cleared when the ISR is called.

Definition at line 100 of file fx2ints.h.

#define ENABLE_TIMER2 ( )    ET2=1

Enable timer 2 interrupt.

This is the same interrupt whether timer 2 overflowed or for the external EXF2 flag.

Definition at line 119 of file fx2ints.h.

#define ENABLE_USART0 ( )    ES0 = 1;

Enable the USART 0 interrupt.

Requires enabling global interrupts (EA=1) separately.

The USART interrupt fires for both *receive* (RX) and *transmit* (TX) completing, the interrupt must clear *both*.

Definition at line 188 of file fx2ints.h.

#define ENABLE_USART1 ( )    ES1 = 1;

Enable the USART 1 interrupt.

Requires enabling global interrupts (EA=1) separately.

The USART interrupt fires for both *receive* (RX) and *transmit* (TX) completing, the interrupt must clear *both*.

Definition at line 230 of file fx2ints.h.

#define INTERRUPT_HIGH_PRIO   1

Interrupt high priority.

Definition at line 65 of file fx2ints.h.

#define INTERRUPT_LOW_PRIO   0

Interrupt low priority.

Definition at line 69 of file fx2ints.h.

#define SET_I2C_ISR_PRIORITY (   p)    PI2C = p

Set the I2C interrupt priority.

Does *not* enable the interrupt.

  SET_I2C_ISR_PRIO(INTERRUPT_HIGH_PRIO) // Set I2C to high priority
  SET_I2C_ISR_PRIO(INTERRUPT_LOW_PRIO)  // Set I2C to low priority

Definition at line 262 of file fx2ints.h.

#define SET_USART0_ISR_PRIORITY (   p)    PS0 = p

Set the USART 0 interrupt priority.

Does *not* enable the interrupt.

  SET_USART0_ISR_PRIO(INTERRUPT_HIGH_PRIO); // Set USART0 to high priority
  SET_USART0_ISR_PRIO(INTERRUPT_LOW_PRIO);  // Set USART0 to low priority

Definition at line 178 of file fx2ints.h.

#define SET_USART1_ISR_PRIORITY (   p)    PS1 = p

Set the USART 1 interrupt priority.

Does *not* enable the interrupt.

 SET_USART1_ISR_PRIO(INTERRUPT_HIGH_PRIO); // Set USART1 to high priority
 SET_USART1_ISR_PRIO(INTERRUPT_LOW_PRIO);  // Set USART1 to low priority

Definition at line 220 of file fx2ints.h.


Enumeration Type Documentation

enum FX2_ISR

Interrupt numbers for standard FX2 interrupts.

Enumerator:
IE0_ISR 

External interrupt 0.

TF0_ISR 

Timer 0 interrupt.

IE1_ISR 

External interrupt 1.

TF1_ISR 

Timer 1 interrupt.

TI_0_ISR 

Serial port 0 transmit or receive interrupt.

TF2_ISR 

Timer 2 interrupt.

RESUME_ISR 

Resume interrupt.

TI_1_ISR 

Serial port 1 transmit or receive interrupt.

USBINT_ISR 

USB Interrupt. An interrupt handler for this should only be used if not using auto vectored interrupts with INT2.

I2CINT_ISR 

I2C Bus interrupt.

IE4_ISR 

External interrupt 4. An interrupt handler for this should only be used if not using auto vectored interrupts with INT4.

IE5_ISR 

External interrupt 5.

IE6_ISR 

External interrupt 6.

USART0_ISR 

Better name for USART0 interrupt.

USART1_ISR 

Better name for USART1 interrupt.

Definition at line 43 of file fx2ints.h.