GBDK 2020 Docs  4.3.0
API Documentation for GBDK 2020
isr.h File Reference
#include <stdint.h>
#include <types.h>

Go to the source code of this file.

Data Structures

struct  isr_vector_t
 
struct  isr_nested_vector_t
 

Macros

#define VECTOR_STAT   0x48
 
#define VECTOR_TIMER   0x50
 
#define VECTOR_SERIAL   0x58
 
#define VECTOR_JOYPAD   0x60
 
#define ISR_VECTOR(ADDR, FUNC)   static const isr_vector_t AT((ADDR)) __ISR_ ## ADDR = {0xc3, (void *)&(FUNC)};
 
#define ISR_NESTED_VECTOR(ADDR, FUNC)   static const isr_nested_vector_t AT((ADDR)) __ISR_ ## ADDR = {{0xfb, 0xc3}, (void *)&(FUNC)};
 

Typedefs

typedef struct isr_vector_t isr_vector_t
 
typedef struct isr_nested_vector_t isr_nested_vector_t
 

Detailed Description

Macros for creating raw interrupt service routines (ISRs) which do not use the default GBDK ISR dispatcher.

Handlers installed this way will have less overhead than ones which use the GBDK ISR dispatcher.

Macro Definition Documentation

◆ VECTOR_STAT

#define VECTOR_STAT   0x48

Address for the STAT interrupt vector

◆ VECTOR_TIMER

#define VECTOR_TIMER   0x50

Address for the TIMER interrupt vector

◆ VECTOR_SERIAL

#define VECTOR_SERIAL   0x58

Address for the SERIAL interrupt vector

◆ VECTOR_JOYPAD

#define VECTOR_JOYPAD   0x60

Address for the JOYPAD interrupt vector

◆ ISR_VECTOR

#define ISR_VECTOR (   ADDR,
  FUNC 
)    static const isr_vector_t AT((ADDR)) __ISR_ ## ADDR = {0xc3, (void *)&(FUNC)};

Creates an interrupt vector at the given address for a raw interrupt service routine (which does not use the GBDK ISR dispatcher)

Parameters
ADDRAddress of the interrupt vector, any of: VECTOR_STAT, VECTOR_TIMER, VECTOR_SERIAL, VECTOR_JOYPAD
FUNCISR function supplied by the user

This cannot be used with the VBLANK interrupt.

Do not use this in combination with interrupt installers that rely on the default GBDK ISR dispatcher such as add_TIM(), remove_TIM() (and the same for all other interrupts).

Example:

#include <gb/isr.h>
void TimerISR() __critical __interrupt {
// some ISR code here
}
#define ISR_VECTOR(ADDR, FUNC)
Definition: isr.h:52
#define VECTOR_TIMER
Definition: isr.h:17
See also
ISR_NESTED_VECTOR, set_interrupts

◆ ISR_NESTED_VECTOR

#define ISR_NESTED_VECTOR (   ADDR,
  FUNC 
)    static const isr_nested_vector_t AT((ADDR)) __ISR_ ## ADDR = {{0xfb, 0xc3}, (void *)&(FUNC)};

Creates an interrupt vector at the given address for a raw interrupt service routine allowing nested interrupts

Parameters
ADDRAddress of the interrupt vector, any of: VECTOR_STAT, VECTOR_TIMER, VECTOR_SERIAL, VECTOR_JOYPAD
FUNCISR function

This cannot be used with the VBLANK interrupt

The LCD STAT vector (VECTOR_STAT) cannot be used in the same program as stdio.h since they install an ISR vector to the same location.

See also
ISR_VECTOR

Typedef Documentation

◆ isr_vector_t

typedef struct isr_vector_t isr_vector_t

◆ isr_nested_vector_t