Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5f73ed7
adding/revising WM8994 driver and Audio wrapper driver for it
Mar 27, 2024
36f227e
use new IO package for WM8994, with constants for register addresses
Mar 27, 2024
917a9c3
better name for procedure Play
Mar 28, 2024
a92a600
Move to signed 16-bit PCM samples, rather than unsigned
Mar 28, 2024
e6fd7b0
Add important comments re: mystery code and update copyright year
Mar 28, 2024
40964ff
Make the output device type use a static predicate to limit the options
Mar 28, 2024
dc150e3
Add support for dual channel conversion
pat-rogers Mar 21, 2026
7322436
Change type names to match WM8994 datasheet.
pat-rogers Mar 21, 2026
306feed
Fix potential display coherency problem when D-cache is enabled
pat-rogers Mar 21, 2026
f95f0a7
use new name for WM8994_Audio_Device
pat-rogers Mar 23, 2026
287e215
Add support for Ethernet RMII
pat-rogers Mar 23, 2026
e4c2351
change procedure name Start_Playing back to Play
pat-rogers Mar 23, 2026
8c1b25f
use a "private with" for Ravenscar_Time
pat-rogers Mar 24, 2026
72d2ce1
new general MPU config facility; also fixes LTDC slew
pat-rogers Mar 28, 2026
eb29424
Add new Device_Id package body for F7x, which uses a different address
pat-rogers May 5, 2026
d5e324b
Add asynchronous reload/update facilities to the LTDC facilities
pat-rogers May 6, 2026
6c27486
add device id source directory to F4ve gpr files
pat-rogers May 7, 2026
a612d1d
Move new MPU source files to dedicated directory specific to supporte…
pat-rogers May 8, 2026
557f158
Add device id source directory for additional F4 boards
pat-rogers May 8, 2026
230803b
Add missing procedures Disable_Clock and Reset for CRC_32.
pat-rogers May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions arch/ARM/STM32/devices/stm32f7x/stm32-device.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1099,4 +1099,25 @@ package body STM32.Device is
RCC_Periph.AHB1ENR.CRCEN := True;
end Enable_Clock;

-------------------
-- Disable_Clock --
-------------------

procedure Disable_Clock (This : in out CRC_32) is
pragma Unreferenced (This);
begin
RCC_Periph.AHB1ENR.CRCEN := False;
end Disable_Clock;

-----------
-- Reset --
-----------

procedure Reset (This : in out CRC_32) is
pragma Unreferenced (This);
begin
RCC_Periph.AHB1RSTR.CRCRST := True;
RCC_Periph.AHB1RSTR.CRCRST := False;
end Reset;

end STM32.Device;
4 changes: 4 additions & 0 deletions arch/ARM/STM32/devices/stm32f7x/stm32-device.ads
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ package STM32.Device is

procedure Enable_Clock (This : in out CRC_32);

procedure Disable_Clock (This : in out CRC_32);

procedure Reset (This : in out CRC_32);

-----------
-- SDMMC --
-----------
Expand Down
62 changes: 62 additions & 0 deletions arch/ARM/STM32/drivers/devid_stm32f7/stm32-device_id.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2026, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------

with System;

package body STM32.Device_Id is

ID_Address : constant System.Address := System'To_Address (16#1FF0_F420#);
-- per RM0385 for F74xxx and F75xxx, and RM0410 for F76xxx and F77xxx

---------------
-- Unique_Id --
---------------

function Unique_Id return Device_Id_Image is
Result : Device_Id_Image;
for Result'Address use ID_Address;
pragma Import (Ada, Result);
begin
return Result;
end Unique_Id;

---------------
-- Unique_Id --
---------------

function Unique_Id return Device_Id_Tuple is
Result : Device_Id_Tuple;
for Result'Address use ID_Address;
begin
return Result;
end Unique_Id;

end STM32.Device_Id;
18 changes: 18 additions & 0 deletions arch/ARM/STM32/drivers/ltdc/stm32-ltdc.adb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,24 @@ package body STM32.LTDC is
end if;
end Reload_Config;

-------------------------
-- Reload_Config_Async --
-------------------------

procedure Reload_Config_Async is
begin
Sync.Apply_On_VSync;
end Reload_Config_Async;

---------------------
-- Wait_For_Reload --
---------------------

procedure Wait_For_Reload is
begin
Sync.Wait;
end Wait_For_Reload;

------------------
-- To_LTDC_Mode --
------------------
Expand Down
29 changes: 29 additions & 0 deletions arch/ARM/STM32/drivers/ltdc/stm32-ltdc.ads
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,35 @@ package STM32.LTDC is

procedure Reload_Config (Immediate : Boolean := False);

procedure Reload_Config_Async;
-- Request a register reload at the next vertical blank and return
-- immediately, without waiting for the LTDC to apply it. The caller
-- can then do other useful work while the LTDC finishes scanning
-- the current frame and performs the reload at vertical blank,
-- rather than stalling on a hardware-paced wait whose length is
-- determined by display timing rather than by anything the caller
-- controls.
--
-- The now-hidden buffer remains live to the LTDC until the swap
-- takes effect, so the caller must leave that buffer untouched
-- until Wait_For_Reload returns.
--
-- Prefer the synchronous Reload_Config (Immediate => False) when
-- the next operation must read or write the now-hidden buffer
-- (for example a Copy_Back of the newly visible image into the
-- new hidden buffer): it blocks until the LTDC confirms the
-- reload, so the buffer the caller treats as hidden really is no
-- longer being scanned out. Use Reload_Config (Immediate => True)
-- only at setup or configuration time, when an unconditional
-- reload that is not aligned to vertical blank is acceptable.

procedure Wait_For_Reload;
-- Block until the LTDC has applied a reload previously requested by
-- Reload_Config_Async. Returns immediately if no reload is pending. Call
-- before any operation that needs the new buffer to be visible, or that
-- must write into the now-hidden buffer that the LTDC may still be
-- scanning.

function To_LTDC_Mode (HAL_Mode : HAL.Framebuffer.FB_Color_Mode)
return STM32.LTDC.Pixel_Format;
-- Convert HAL.Framebuffer color mode to LTDC color mode
Expand Down
89 changes: 67 additions & 22 deletions arch/ARM/STM32/drivers/stm32-dac.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- Copyright (C) 2015-2026, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
Expand Down Expand Up @@ -115,11 +115,9 @@ package body STM32.DAC is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
This.DHR12L1.DACC1DHR :=
UInt12 (Value and Max_12bit_Resolution);
This.DHR12L1.DACC1DHR := UInt12 (Value and Max_12bit_Resolution);
when Right_Aligned =>
This.DHR12R1.DACC1DHR :=
UInt12 (Value and Max_12bit_Resolution);
This.DHR12R1.DACC1DHR := UInt12 (Value and Max_12bit_Resolution);
end case;
when DAC_Resolution_8_Bits =>
This.DHR8R1.DACC1DHR := UInt8 (Value and Max_8bit_Resolution);
Expand All @@ -130,11 +128,9 @@ package body STM32.DAC is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
This.DHR12L2.DACC2DHR :=
UInt12 (Value and Max_12bit_Resolution);
This.DHR12L2.DACC2DHR := UInt12 (Value and Max_12bit_Resolution);
when Right_Aligned =>
This.DHR12R2.DACC2DHR :=
UInt12 (Value and Max_12bit_Resolution);
This.DHR12R2.DACC2DHR := UInt12 (Value and Max_12bit_Resolution);
end case;
when DAC_Resolution_8_Bits =>
This.DHR8R2.DACC2DHR := UInt8 (Value and Max_8bit_Resolution);
Expand All @@ -143,6 +139,35 @@ package body STM32.DAC is
end case;
end Set_Output;

-----------------------------
-- Set_Dual_Channel_Output --
-----------------------------

procedure Set_Dual_Channel_Output
(This : in out Digital_To_Analog_Converter;
Channel_2_Data : UInt16;
Channel_1_Data : UInt16;
Resolution : DAC_Resolution;
Alignment : Data_Alignment)
is
begin
-- See RM0385 Rev 8, sections 16.5.9 .. 16.5.11 for these registers
case Resolution is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
This.DHR12LD.DACC2DHR := UInt12 (Channel_2_Data and Max_12bit_Resolution);
This.DHR12LD.DACC1DHR := UInt12 (Channel_1_Data and Max_12bit_Resolution);
when Right_Aligned =>
This.DHR12RD.DACC2DHR := UInt12 (Channel_2_Data and Max_12bit_Resolution);
This.DHR12RD.DACC1DHR := UInt12 (Channel_1_Data and Max_12bit_Resolution);
end case;
when DAC_Resolution_8_Bits =>
This.DHR8RD.DACC2DHR := UInt8 (Channel_2_Data and Max_8bit_Resolution);
This.DHR8RD.DACC1DHR := UInt8 (Channel_1_Data and Max_8bit_Resolution);
end case;
end Set_Dual_Channel_Output;

------------------------------------
-- Trigger_Conversion_By_Software --
------------------------------------
Expand Down Expand Up @@ -194,21 +219,15 @@ package body STM32.DAC is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
This.DHR12LD.DACC1DHR :=
UInt12 (Channel_1_Value and Max_12bit_Resolution);
This.DHR12LD.DACC2DHR :=
UInt12 (Channel_2_Value and Max_12bit_Resolution);
This.DHR12LD.DACC1DHR := UInt12 (Channel_1_Value and Max_12bit_Resolution);
This.DHR12LD.DACC2DHR := UInt12 (Channel_2_Value and Max_12bit_Resolution);
when Right_Aligned =>
This.DHR12RD.DACC1DHR :=
UInt12 (Channel_1_Value and Max_12bit_Resolution);
This.DHR12RD.DACC2DHR :=
UInt12 (Channel_2_Value and Max_12bit_Resolution);
This.DHR12RD.DACC1DHR := UInt12 (Channel_1_Value and Max_12bit_Resolution);
This.DHR12RD.DACC2DHR := UInt12 (Channel_2_Value and Max_12bit_Resolution);
end case;
when DAC_Resolution_8_Bits =>
This.DHR8RD.DACC1DHR :=
UInt8 (Channel_1_Value and Max_8bit_Resolution);
This.DHR8RD.DACC2DHR :=
UInt8 (Channel_2_Value and Max_8bit_Resolution);
This.DHR8RD.DACC1DHR := UInt8 (Channel_1_Value and Max_8bit_Resolution);
This.DHR8RD.DACC2DHR := UInt8 (Channel_2_Value and Max_8bit_Resolution);
end case;
end Set_Dual_Output_Voltages;

Expand Down Expand Up @@ -682,10 +701,36 @@ package body STM32.DAC is
when DAC_Resolution_8_Bits =>
Result := This.DHR8R2'Address;
end case;

end case;

return Result;
end Data_Address;

----------------------------------
-- Data_Address_Dual_Conversion --
----------------------------------

function Data_Address_Dual_Conversion
(This : Digital_To_Analog_Converter;
Resolution : DAC_Resolution;
Alignment : Data_Alignment)
return Address
is
Result : Address;
begin
case Resolution is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
Result := This.DHR12LD'Address;
when Right_Aligned =>
Result := This.DHR12RD'Address;
end case;
when DAC_Resolution_8_Bits =>
Result := This.DHR8RD'Address;
end case;

return Result;
end Data_Address_Dual_Conversion;

end STM32.DAC;
32 changes: 29 additions & 3 deletions arch/ARM/STM32/drivers/stm32-dac.ads
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- Copyright (C) 2015-2026, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
Expand Down Expand Up @@ -51,7 +51,9 @@ package STM32.DAC is

type DAC_Channel is (Channel_1, Channel_2);

-- Note that Channel 1 is tied to GPIO pin PA4, and Channel 2 to PA5
-- Note that Channel 1 is tied to GPIO pin PA4, and Channel 2 to PA5.
-- Note that Channel 1 is mapped to DMA1 Stream 5 channel 7.
-- Note that Channel 2 is mapped on DMA1 Stream 6 channel 7.

procedure Enable
(This : in out Digital_To_Analog_Converter;
Expand Down Expand Up @@ -88,6 +90,8 @@ package STM32.DAC is
Max_8bit_Resolution : constant := 16#00FF#;

type Data_Alignment is (Left_Aligned, Right_Aligned);
-- These only apply when using 12-bit resolution. For 8-bit resolution the
-- alignment is always right-aligned.

procedure Set_Output
(This : in out Digital_To_Analog_Converter;
Expand All @@ -102,6 +106,18 @@ package STM32.DAC is
-- the reference input voltage and the 'n' of Max_nbit_Counts is either 12
-- or 8.

procedure Set_Dual_Channel_Output
(This : in out Digital_To_Analog_Converter;
Channel_2_Data : UInt16;
Channel_1_Data : UInt16;
Resolution : DAC_Resolution;
Alignment : Data_Alignment);
-- This routine writes the 32-bit value, composed from the two 16-bit
-- values, with the necessary layout (8/12left-right alignment) to
-- the appropriate output register for conversion on both channels
-- simultaneously. DMA is the alternative to software calling this
-- procedure.

procedure Trigger_Conversion_By_Software
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
Expand Down Expand Up @@ -328,7 +344,17 @@ package STM32.DAC is
Alignment : Data_Alignment)
return Address;
-- Returns the address of the Data Holding register within This, for the
-- specified Channel, at the specified Resolution and Alignment.
-- specified Channel, given the specified Resolution and Alignment.
--
-- This function is stricly for use with DMA, all others use the API above.

function Data_Address_Dual_Conversion
(This : Digital_To_Analog_Converter;
Resolution : DAC_Resolution;
Alignment : Data_Alignment)
return Address;
-- Returns the address of the Data Holding register within This, for the
-- dual conversion case, given the specified Resolution and Alignment.
--
-- This function is stricly for use with DMA, all others use the API above.

Expand Down
Loading
Loading