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
241 stars 142 forks source link

STM32F7:SPI: 8bits communication #293

Closed LaetitiaEl closed 5 years ago

LaetitiaEl commented 5 years ago

Hi, By default the SPI communicates in 16bits mode in STM32F7xx devices. To be able to send/receive the 8bits data, I had to make some modifications in the stm32-spi.adb.

According to the reference manual, the SPI.DS register has to be set to 4bits mode, then the data needs to be parsed in a funny way to be able to transmit.

image

To be able to send the data, I had to made the following modifications in Receive_8bit_Mode / Send_8bit_Mode : his.Periph.DR.DR := UInt16 ((Outgoing (Index) and 16#0F#))256 + UInt16((Outgoing (Index) and 16#F0#))/16; To read the data: Tmp := This.Periph.DR.DR; K := UInt8 (Tmp and 16#000F#)16+ UInt8 ((Tmp and 16#0F00#)/256);

This way it works fine, the operations are clocked in 8bits. image

LaetitiaEl commented 5 years ago

Not worthy to fix.