Why have cortex_handlers.c?

This file, cortex_handlers.c, implements these dummy interrupt handler.

void NMI_Handler( void );
void HardFault_Handler( void );
void MemManage_Handler( void );
void BusFault_Handler( void );
void UsageFault_Handler( void );
void SVC_Handler( void );
void DebugMon_Handler( void );
void PendSV_Handler( void );

Currently these handlers don't get loaded, so you can override the weak dummy handler define by the Atmel file. The Atmel weak handlers are also a forever loop.

Why not continue to let the user override these handlers?

Why not continue to let the user override these handlers?

Is that not the case with the Arduino setup?

They are only prototypes aren't they, can't you still define your own functions?


Rob

They are not prototypes. I listed the protoypes but here is a typical handler in this file

void SVC_Handler( void )
{
  for ( ;; ) ;
}

This file is in the cores/arduino folder and doesn't currently get linked to replace the weak symbols.

I believe the intent is to link these handlers. I base this on a message from cmaglie.

I see.

So that file is superfluous at present and worse could stop you from defining your own functions if it is ever linked in.


Rob

can somebody open an issue on github? cristian will get rid of the file in the next release

m

Uhm, I should have fixed this some times ago:

there are other places where its left defined?

Something to think before get rid of cortex_handler.c and other ARM related files :

The Cortex-M3 processor introduces new powerful features (if compare with prior art). This make the Cortex-M3 processor attractive to existing ARM processor users as well as many new Arduino users considering use of 32-bit micro controllers in their products. Let's consider only NMI_Handler, a non maskarable interrupt for safety-critical tasks. NMI_Handler is the highest priority exception other than reset followed by the HardFault_Handler. It is permanently enabled and has a fixed priority of -2. It's already defined in sam3x8e.h and startup_sam3xa.c. I believe, whoever from Atmel or Arduino added this file to the library, surely was thinking in future developments related to NMI.
A practical application? NMI could be connected to a watchdog timer or a voltage-monitoring block and generates panic requests that warns the processor to take actions if the WDT hangs or when the voltage drops below a certain level. Arduino Due could turn on or toggle a LED through sam_gpio.h. I would even go as far as to write an example. In other words, the fact that is not useful now, doesn't mean that we should cut it out of Arduino library. Remember, we are pulling Due from the ARM underworld to Arduino arenas. I am far to be an ARM connoisseur but just a different point of view.

Yup, but we are not talking about removing handlers, but about cleaning-up some handlers that was defined as a non-weak functions that does nothing! see the example posted by fat16lib:

void SVC_Handler( void )
{
  for ( ;; ) ;
}

this was due to some testing code coming from the beta-testing period and not cleaned up. But I'm pretty sure I've already fixed upstream.