Since AVR-Ada 1.2 there is a new and hopefully cleaner approach to text IO and numerical IO. It is applied via the serial line in the package AVR.Serial. The new approach intends to replace the existing packages AVR.UART and AVR.Int_Img. The general idea originates in Dmitry Kazakov's strings edit package. We also reused quite some of his code.
The new package AVR.Serial replaces the pure text IO part of the previous package AVR.UART. AVR.Serial provides the usual routines for sending and receiving Characters and Strings. Strings can be of various formats, notably
Input is read into
Put ("Hello");
Put ("World", Field => 10, Justify => Right, Fill => '.');
We have a generic package AVR.Generic_Text_IO. The package takes as generic parameters routines for sending and receiving single characters. The package AVR.UART_Basic_Polled provides these routines plus an 'Init' routine and some constants for the different baud rates.
The package AVR.Generic_Text_IO gets instantiated with the help of AVR.UART_Basic_Polled in the
The new package System.Int_Img provides an Ada interface to highly optimized assembler code for converting unsigned numbers to a textual (ASCII) representation. It can handle numbers in the range 0 .. 2^32 - 1 (4294967295) and any radix in the range 2 .. 36. The most direct way to access this routine is through Put_U32 in the package AVR.Strings.Edit.Generic_Integers.
-- Put the unsigned number 'Value' into the buffer 'Target'. 'Last' is
-- the index of the last valid character in 'Target'. A string of
-- length 10 can hold all numbers up to 2^32 base 10. So don't use
-- it for base 2!
procedure Put_U32 (Value : in Unsigned_32;
Base : in Number_Base := 10;
Target : in out AStr11;
Last : out Unsigned_8);