Suggestions For New Embedded Functions

Suggestions For New Embedded Functions For The Arduino:

1. toggleOutputPin(pin) Toggle output pin number if pin mode is output ---> 1=0 or 0=1 - do nothing if input.

2. noop(void) ---> no operation - delay is @ clock frequency cycle time.

3. pinModeStatus(pin) ---> returns 1 if output mode or 0 is returned otherwise (input mode)

4. pinIsPulledUp(pin) ---> returns 1 if input is internally pulled up & 0 = no internal pullup - valid for inputs only.

5. pinDefault(void) ---> resets all I/O pins to their power-up default state - all inputs.

6. restartCPU(void) ---> resets all I/O pins, registers and restarts program execution.

7. setPinModeState(pin,mode,state) ---> set pin# mode as Input/Output. Input, state 1 = pullup or state Output 1 or 0.

Of course some of the above functions could be easily created in a sketch but it would be very convenient to install them in an updated revision. :) :) :)

I think that restartCPU(void) would be the hardest nut to crack. It’s been asked about and discussed a lot on this board.

Using the Watchdog timer has been often suggested, but it carries risk of not working with the existing bootloaders and locking up the chip. Now that the Aduino IDE supports quite a range of AVR chips, simulating in software a reset by direct access to all the unique registers and pin maps is not a simple task.

Of course dedicating a digital outpin triggering an external hardware on-shot would make a programmable reset trivial, but that of course requires those external components.