02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3<br />

Creating a New <strong>BSP</strong><br />

might want to add additional hardware initialization code that is called before the<br />

kernel is started. In this case, you can add a hook right before the call to<br />

kernelInit( ). As an alternative to hooks, you can call routines from the debugger<br />

by using the GDB’s call procedure. For example:<br />

(gdb) call myHwInit2<br />

3<br />

The advantage of using hooks instead of the call mechanism is that:<br />

■<br />

Hooks let you avoid executing the original code.<br />

■<br />

Hooks are much faster.<br />

If your board has an “abort” button, consider connecting a debug routine to the<br />

abort interrupt. Then you can set a breakpoint on your interrupt handler from the<br />

debugger. This provides a way for you to gain control of the system if it appears to<br />

have died. In this case it is best to have the abort switch tied to a non-maskable<br />

interrupt (NMI).<br />

! WARNING: Only fatal interrupts such as “abort” can be connected to an NMI. If a<br />

device interrupt is connected to an NMI, the kernel will not work properly.<br />

3.4 Using a Minimal Kernel<br />

A minimal kernel involves adding just a few simple device drivers. Because these<br />

drivers involve connecting interrupt service routines, this section starts with some<br />

ISR guidelines.<br />

3.4.1 ISR <strong>Guide</strong>lines<br />

After the kernel is started, you can use the intConnect( ) routine and<br />

INUM_TO_IVEC macro to connect interrupt service routines (ISRs) to the interrupt<br />

vector table. For example:<br />

intConnect (INUM_TO_IVEC (intVec), proc, param);<br />

The intVec parameter is the interrupt vector, proc is the C routine to call in response<br />

to the interrupt, and param is a parameter to pass the proc routine. For more<br />

information, see the reference entry for intConnect( ).<br />

55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!