Creating a microcontroller startup file
Jens Bauer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Apr 8 09:10:52 PDT 2015
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote:
> On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote:
>
> enum weak = gcc.attribute.attribute("weak");
> enum isrDefault = gcc.attribute.attribute("alias",
> "defaultHandler");
>
> extern @weak @isrDefault void NMI_Handler();
> extern @weak @isrDefault void HardFault_Handler();
This is indeed helpful. I've now reduced each of the
approximately 100 lines declaring exception vectors to something
like these:
@weak @ar void Reset_Handler();
@weak @ae void NMI_Handler();
-It would be neat, if @attribute("weak") and
@attribute("alias","function") could be combined into one, but I
haven't found a way to do that - I've done that in C earlier,
though:
void __attribute__((weak, alias(defaultExceptionHandler)))
NMI_Handler(void);
> I use this idiom briefly in my code here:
> https://github.com/JinShil/stm32f42_discovery_demo/blob/master/source/start.d
Yes. I actually came across it and didn't notice it. But now that
you've explained it, it absolutely makes sense. :)
-I actually added @attribute("naked") to my defaultResetHandler
yesterday, as I wanted to get rid of the prologue; so I
completely agree; the startup code should have this attribute.
I've now changed that to use the enum, to be more consistent. ;)
More information about the Digitalmars-d-learn
mailing list