Reduce stack usage a little by using static (global) buffer.
1 files changed, 9 insertions(+), 9 deletions(-)

M generic_pn532.adb
M generic_pn532.adb +9 -9
@@ 649,7 649,7 @@ package body Generic_PN532 is
    is
       Cmd : PN532_Buf (1..1) := (1 => PN532_TG_GET_DATA);
       Ok : Boolean;
-      Reply : PN532_Buf (1..48);
+      -- Reply : PN532_Buf (1..48);
       Reply_Len : Unsigned_8;
    begin
       Ok := PN532_Send_Command (Cmd, PN532_TIMEOUT_VALUE);

          
@@ 664,13 664,13 @@ package body Generic_PN532 is
          return;
       end if;
 
-      PN532_Read_Data (Reply, Reply_Len, Ok);
+      PN532_Read_Data (Data_Buffer, Reply_Len, Ok);
       if not Ok or Reply_Len = 0 then -- Some error
          Status := False;
          return;
       end if;
 
-      if Reply (2) /= 0 then
+      if Data_Buffer (2) /= 0 then
          -- AVR.UART.Put ("PN532 error code: ");
          -- AVR.UART.Put (Data => Reply (2), Base => 16);
          -- AVR.UART.CRLF;

          
@@ 680,7 680,7 @@ package body Generic_PN532 is
 
       Len := Reply_Len - 3;
 
-      Buf (1 .. Len) := Reply (3 .. 3 + Len);
+      Buf (1 .. Len) := Data_Buffer (3 .. 3 + Len);
       Status := True;
    end PN532_Get_Data;
 

          
@@ 715,17 715,17 @@ package body Generic_PN532 is
    function PN532_Init_As_Target return Boolean is
       use type System.Address;
 
-      Data  : PN532_Buf (1..40);
+      -- Data  : PN532_Buf (1..40);
       Len   : Unsigned_8;
       Ok    : Boolean;
    begin
       Len := AVR.Programspace.Get_Byte (Init_Cmd_PM'Address);
       for I in Unsigned_8 range 1..Len loop
-         Data (I) := AVR.Programspace.Get_Byte
+         Data_Buffer (I) := AVR.Programspace.Get_Byte
            (Init_Cmd_PM'Address + System.Address (I));
       end loop;
 
-      Ok := PN532_Send_Command (Data (1..Len), PN532_TIMEOUT_VALUE);
+      Ok := PN532_Send_Command (Data_Buffer (1..Len), PN532_TIMEOUT_VALUE);
 
       if not Ok then
          return False;

          
@@ 735,12 735,12 @@ package body Generic_PN532 is
          return False;
       end if;
 
-      PN532_Read_Data (Data, Len, Ok);
+      PN532_Read_Data (Data_Buffer, Len, Ok);
       if not Ok or Len = 0 then -- Some error
          return False;
       end if;
 
-      if Data (2) /= 16#08# then
+      if Data_Buffer (2) /= 16#08# then
          -- AVR.UART.Put ("Unsupported mode ");
          -- AVR.UART.Put (Data => Reply (2), Base => 16);
          -- AVR.UART.CRLF;