GPIO and leaf procedures

General discussions about working with the Astrobe IDE and programming ARM Cortex-M3, M4 and M7 microcontrollers.

GPIO and leaf procedures

Postby steve64 » Wed Sep 05, 2018 9:53 am

I suppose GPIO.Put() and GPIO.Get() are not valid inside a leaf procedure, do you confirm?
If so, it would be helpful to allow that. I have a user case in fast bitbanging where
a protocol could be implemented by calling leaf procedures just operating on GPIOs.
steve64
 
Posts: 36
Joined: Mon Jul 09, 2018 8:56 am
Location: Italy

Re: GPIO and leaf procedures

Postby cfbsoftware » Wed Sep 05, 2018 12:06 pm

By definition leaf procedures cannot call procedures. However, you can call SYSTEM.PUT directly if you want to perform GPIO operations in a leaf procedure. e.g. the Error procedure in the DramTest example lights the red LED before going into an infinite loop.

Code: Select all
PROCEDURE Error();
BEGIN
  GPIO.Put(LEDRed, HIGH);
  WHILE TRUE DO END
END Error;

If this had to be made much more efficient it could be written as a leaf procedure:
Code: Select all
PROCEDURE* Error();
CONST
  GPIO_BSRR = 018H;
  LEDRedOn = {14};
BEGIN
  SYSTEM.PUT(MCU.GPIOBBase + GPIO_BSRR, LEDRedOn);
  WHILE TRUE DO END
END Error;

Although SYSTEM.PUT looks like a procedure, it, like most other SYSTEM functions, generate inline code so it can be used in leaf procedures.
cfbsoftware
Site Admin
 
Posts: 355
Joined: Fri Dec 31, 2010 12:30 pm

Re: GPIO and leaf procedures

Postby steve64 » Wed Sep 05, 2018 12:16 pm

Thanks, using PUT and GET in leaf procedures for critical code can be fine.
steve64
 
Posts: 36
Joined: Mon Jul 09, 2018 8:56 am
Location: Italy


Return to Astrobe for ARM Cortex-M3, M4 and M7

cron