Skip to content

Commit

Permalink
Add TX/RX indicators to LCD
Browse files Browse the repository at this point in the history
  • Loading branch information
masonticehurst committed Mar 1, 2024
1 parent 9ed9c51 commit 79bffbe
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 5 deletions.
43 changes: 40 additions & 3 deletions eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.adb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ package body Net.Interfaces.STM32 is
(System.Address, Rx_Ring_Array_Type_Access);

Tx_Ring_Instance : aliased Tx_Ring_Array_Type;

function Next_Tx (Value : in Tx_Position) return Tx_Position;
function Next_Rx (Value : in Rx_Position) return Rx_Position;

Expand Down Expand Up @@ -94,7 +94,7 @@ package body Net.Interfaces.STM32 is

-- Check if the transmit queue is initialized.
function Is_Ready return Boolean;

function Get_Cur_TX return Tx_Position;
private
-- Transmit queue management.
Tx_Space : Uint32 := 0;
Expand All @@ -118,7 +118,7 @@ package body Net.Interfaces.STM32 is

-- Check if the receive queue is initialized.
function Is_Ready return Boolean;

function Get_Cur_RX return Rx_Position;
private

-- Receive queue management.
Expand Down Expand Up @@ -298,6 +298,11 @@ package body Net.Interfaces.STM32 is
return Tx_Ring /= null;
end Is_Ready;

function Get_Cur_TX return Tx_Position is
begin
return Cur_Tx;
end Get_Cur_TX;

end Transmit_Queue;

protected body Receive_Queue is
Expand All @@ -319,6 +324,11 @@ package body Net.Interfaces.STM32 is
Ethernet_MAC_Periph.MACCR.RE := True;
end Wait_Packet;

function Get_Cur_RX return Rx_Position is
begin
return Cur_Rx;
end Get_Cur_RX;

procedure Receive_Interrupt is
Rx : Rx_Ring_Access;
begin
Expand Down Expand Up @@ -425,4 +435,31 @@ package body Net.Interfaces.STM32 is

end Receive_Queue;

task RX_TX_Monitor;

task body RX_TX_Monitor is
RX_Pos : Rx_Position := Receive_Queue.Get_Cur_RX;
TX_Pos : Tx_Position := Transmit_Queue.Get_Cur_TX;
begin
loop
if Receive_Queue.Get_Cur_RX /= RX_Pos then
RX_Active := True;
RX_Pos := Receive_Queue.Get_Cur_RX;
delay 0.1;
else
RX_Active := False;
end if;

if Transmit_Queue.Get_Cur_TX /= TX_Pos then
TX_Active := True;
TX_Pos := Transmit_Queue.Get_Cur_TX;
delay 0.1;
else
TX_Active := False;
end if;

delay 0.01;
end loop;
end RX_TX_Monitor;

end Net.Interfaces.STM32;
4 changes: 4 additions & 0 deletions eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.ads
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ package Net.Interfaces.STM32 is
-- Size of the receive ring.
RX_RING_SIZE : constant Uint32 := 500;

-- TX/RX activity statuses
RX_Active : Boolean := False;
TX_Active : Boolean := False;

-- The STM32F Ethernet driver.
type STM32_Ifnet is limited new Net.Interfaces.Ifnet_Type with null record;

Expand Down
10 changes: 10 additions & 0 deletions eRINA_STM32F7/src/rina/demo.adb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,20 @@ begin
((5, 105), (GUI.Board_Resolution.Width - 8, 160), HAL.Bitmap.Black, 2,
1);

GUI.Draw_Rounded_Rectangle ((277, 2), (200, 60), HAL.Bitmap.Black, 2, 1);
GUI.Print ("CPU U: xx.xx%", (280, 12));
GUI.Print ("RAM U: xx.xx%", (280, 24));
GUI.Print (" Mac: 00:81:E1:05:05:01", (280, 36));
GUI.Print ("Board: STM32F746-DISCO", (280, 48));

GUI.Draw_Rounded_Rectangle ((277, 65), (200, 20), HAL.Bitmap.Black, 2, 1);

GUI.Fill_Rounded_Rectangle ((330, 70), (25, 10), GUI.Get_RX_Status_Color, 1);
GUI.Print ("RX", (300, 71));

GUI.Fill_Rounded_Rectangle ((420, 70), (25, 10), GUI.Get_TX_Status_Color, 1);
GUI.Print ("TX", (390, 71));

-- GUI.Print ("Status: ", (80, 45));
-- GUI.Print ("Waiting for enrollment request", (145, 45));

Expand Down
13 changes: 12 additions & 1 deletion eRINA_STM32F7/src/rina/gui.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
with Bitmapped_Drawing;
with STM32.Board;
with STM32.RNG.Interrupts;
with STM32.RNG.Interrupts; use STM32.RNG.Interrupts;
with Net.Interfaces.STM32;

package body GUI is

Expand All @@ -25,6 +26,16 @@ package body GUI is
STM32.Board.Display.Update_Layer (1);
end Update;

function Get_TX_Status_Color return Bitmap_Color is
begin
return (if Net.Interfaces.STM32.TX_Active then GUI.TX_Active else GUI.TX_Inactive);
end Get_TX_Status_Color;

function Get_RX_Status_Color return Bitmap_Color is
begin
return (if Net.Interfaces.STM32.RX_Active then GUI.RX_Active else GUI.RX_Inactive);
end Get_RX_Status_Color;

procedure Draw_Rectangle (P : Point; S : Size; C : Bitmap_Color) is
begin
Set_Source (Buffer => Screen_Buffer.all, ARGB => C);
Expand Down
8 changes: 7 additions & 1 deletion eRINA_STM32F7/src/rina/gui.ads
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ package GUI is
Foreground : Bitmap_Color := Black;
Background : Bitmap_Color := White;
Button_Color : Bitmap_Color := (255, 242, 243, 245);
TX_Active : Bitmap_Color := (255, 111, 255, 109);
TX_Inactive : Bitmap_Color := (255, 56, 128, 55);
RX_Active : Bitmap_Color := (255, 255, 109, 109);
RX_Inactive : Bitmap_Color := (255, 128, 55, 55);
Build_Verson : String := "0.0.1";

type Size is record
Expand All @@ -26,7 +30,7 @@ package GUI is
end record;

Board_Resolution : Size := (480, 272);
Frame_Rate : Natural := 60;
Frame_Rate : Natural := 120;
Max_Buttons : Natural := 16;

package Button_Vectors is new Ada.Containers.Vectors
Expand All @@ -36,6 +40,8 @@ package GUI is

procedure Initialize;
procedure Update;
function Get_TX_Status_Color return Bitmap_Color;
function Get_RX_Status_Color return Bitmap_Color;
procedure Print (Msg : in String; Pos : in Point);
procedure Print_Large (Msg : in String; Pos : in Point);
function Screen_Buffer return Any_Bitmap_Buffer;
Expand Down

0 comments on commit 79bffbe

Please sign in to comment.