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.
GPIO and leaf procedures
-
- Site Admin
- Posts: 525
- Joined: Fri Dec 31, 2010 12:30 pm
- Contact:
Re: GPIO and leaf procedures
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.
If this had to be made much more efficient it could be written as a leaf procedure:
Although SYSTEM.PUT looks like a procedure, it, like most other SYSTEM functions, generate inline code so it can be used in leaf procedures.
Code: Select all
PROCEDURE Error();
BEGIN
GPIO.Put(LEDRed, HIGH);
WHILE TRUE DO END
END Error;
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;
Re: GPIO and leaf procedures
Thanks, using PUT and GET in leaf procedures for critical code can be fine.