AdaCore / Ada_Drivers_Library

Ada source code and complete sample GNAT projects for selected bare-board platforms supported by GNAT.
BSD 3-Clause "New" or "Revised" License
236 stars 141 forks source link

Using STM32.SPI #339

Closed simonjwright closed 4 years ago

simonjwright commented 4 years ago

STM32.SPI starts with

package STM32.SPI is

   type Internal_SPI_Port is private;

   type SPI_Port (Periph : not null access Internal_SPI_Port) is
      limited new HAL.SPI.SPI_Port with private;

and I’m puzzled about how this is to be used given that we know nothing about Internal_SPI_Port.

I’ve got as far as

   Peripheral : aliased STM32.SPI.Internal_SPI_Port;
   SPI_Port : STM32.SPI.SPI_Port (Peripheral'Access);

which doesn’t seem to be much use.

Somehow I need to use the full declaration

   type Internal_SPI_Port is new STM32_SVD.SPI.SPI_Peripheral;

so that maybe I could say

   SPI_Port : STM32.SPI.SPI_Port (STM32_SVD.SPI.SPI1_Periph'Access);
Fabien-Chouteau commented 4 years ago

Hi @simonjwright,

Peripherals instances are already declared for you in STM32.Device. With the correct address and number of instances in the device.

You can see an example of SPI initialization here.