Examples / LCD_Demo now flashing screen through LTDC.

This commit is contained in:
Vovanium 2021-09-29 18:05:32 +03:00
parent bee5832796
commit 753e98c691
8 changed files with 48 additions and 9 deletions

View File

@ -184,19 +184,21 @@ package body Board.LCD.Controller is
RCC.APB2ENR (Index.LTDC) := True;
RCC.APB2RSTR (Index.LTDC) := True;
RCC.APB2RSTR (Index.LTDC) := False;
-- Configure Pixel clock
Initialize_Pixel_Clock;
-- Configure synchronous timings
-- Configure synchronous signals in the LTDC_GCR
Initialize_Timings;
-- Configure the background color
declare
R : Color_Register := LTDC.BCCR;
begin
R.R := 200;
R.G := 56;
R.B := 255;
R.R := 16#AA#;
R.G := 16#AA#;
R.B := 16#55#;
LTDC.BCCR := R;
end;
-- Configure the needed interrupts
@ -214,6 +216,19 @@ package body Board.LCD.Controller is
end;
-- All layer parameters may be modified...
end Initialize;
procedure Set_Background (R, G, B : Integer) is
begin
declare
C : Color_Register := LTDC.BCCR;
begin
C.R := R;
C.G := G;
C.B := B;
LTDC.BCCR := C;
end;
LTDC.SRCR := (IMR => True, others => <>);
end;
begin
Initialize;
end Board.LCD.Controller;

View File

@ -1,3 +1,4 @@
package Board.LCD.Controller is
procedure Initialize;
procedure Set_Background (R, G, B : Integer);
end Board.LCD.Controller;

View File

@ -29,11 +29,12 @@ package body Board.LCD.Generic_IO is
Now := Clock + Milliseconds (5);
delay until Now;
--Write_Command (ILI9341.Undocumented_CA, (16#C3#, 16#08#, 16#50#));
Write_Command (ILI9341.Power_Control_A, (16#39#, 16#2C#, 16#00#, 16#34#, 16#02#));
-- Vcore = 1.6, DDVDH = 5.6 (default)
Write_Command (ILI9341.Power_Control_B, (16#00#, 16#C1#, 16#30#));
-- PCEQ = 1, DRV_ena = 0, Power_Control = 0, DRV_vml = 0, DRV_vmh = 0, DC_ena = 1
--Command (ILI9341.Undocumented_EF, 16#03#, 16#80#, 16#02#);
--Write_Command (ILI9341.Undocumented_EF, (16#03#, 16#80#, 16#02#));
Write_Command (ILI9341.Driver_Timing_Control_A, (16#85#, 16#00#, 16#78#));
-- NOW = 1, EQ = 0, CR = 0, precharge = 2unit
Write_Command (ILI9341.Driver_Timing_Control_B, (16#00#, 16#00#));
@ -75,6 +76,14 @@ package body Board.LCD.Generic_IO is
Write_Command (ILI9341.DISPON);
end Initialize_Controller;
procedure Initialize_RGB_Interface is
begin
Write_Command (ILI9341.IFMODE, (16#C2#));
-- EPL = true, DPL = Falling, HSPL = low, VSPL = low, RCM = 10, bypass = memory
Write_Command (ILI9341.IFCTL, (16#01#, 16#00#, 16#06#));
-- WEMODE = 1, BGR_EOR = 0, MV_EOR = 0, MX_EOR = 0, MY_EOR = 0, MDT = 0, EPF = MSB, RIM = 18/16, RM = RGB, DM = RGB, ENDIAN = MSB first
end Initialize_RGB_Interface;
procedure Plot_24 (X, Y, R, G, B: Integer) is
-- Draw a pixel;
begin

View File

@ -6,5 +6,6 @@ generic
with procedure Write_Data (Data : Interfaces.Unsigned_8);
package Board.LCD.Generic_IO is
procedure Initialize_Controller;
procedure Initialize_RGB_Interface;
procedure Plot_24 (X, Y, R, G, B: Integer);
end Board.LCD.Generic_IO;

View File

@ -100,6 +100,7 @@ package body Board.LCD.SPI_IO is
package IO is new LCD.Generic_IO(Command, Data);
procedure Initialize_Controller renames IO.Initialize_Controller;
procedure Initialize_RGB_Interface renames IO.Initialize_RGB_Interface;
procedure Plot_24 (X, Y, R, G, B: Integer) renames IO.Plot_24;
begin
Initialize_SPI;

View File

@ -1,5 +1,6 @@
package Board.LCD.SPI_IO is
procedure Initialize_RGB_Interface;
procedure Plot_24 (X, Y, R, G, B: Integer);
end Board.LCD.SPI_IO;

View File

@ -3,7 +3,11 @@ with Board.LCD.Controller;
with Board.UART.IO;
with Board.Frequencies;
use Board.Frequencies;
with Ada.Real_Time;
use Ada.Real_Time;
procedure LCD_Demo is
Now : Time := Clock;
C : Integer := 0;
begin
Board.UART.IO.Transmit ("Frequencies" & ASCII.CR & ASCII.LF);
Board.UART.IO.Transmit ("VCO In " & Integer'Image (VCO_Input_Frequency) & ASCII.CR & ASCII.LF);
@ -20,9 +24,15 @@ begin
Board.UART.IO.Transmit ("SAI1B " & Integer'Image (SAI1B_Clock_Frequency) & ASCII.CR & ASCII.LF);
Board.UART.IO.Transmit ("LCD " & Integer'Image (LCD_Clock_Frequency) & ASCII.CR & ASCII.LF);
Board.LCD.Controller.Initialize;
--Board.LCD.Controller.Initialize;
Board.LCD.SPI_IO.Initialize_RGB_Interface;
Now := Clock;
loop
null;
Board.LCD.Controller.Set_Background(C, 255 - C, 255 - C);
C := (C + 1) mod 256;
Now := Now + Milliseconds (5);
delay until Now;
end loop;
end LCD_Demo;

View File

@ -125,9 +125,10 @@ package body STM32.RCC.Frequencies is
end;
function PLLI2S_N (Frequency : Natural) return Natural is
F : Natural := Frequency * RCC.PLLCFGR.M;
F : Product := Product (Frequency) * Product (RCC.PLLCFGR.M);
P : Product := Product (PLL_Input_Frequency);
begin
return (PLL_Input_Frequency + F / 2) / F;
return Natural ((F + P / 2) / P);
end;
function PLLSAI_N (Frequency : Natural) return Natural renames PLLI2S_N;