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

LSM303AGR driver implementation #380

Closed shakram02 closed 3 years ago

shakram02 commented 3 years ago

This is a work in progress to support the LSM303AGR accelerometer. Mainly needed for MicroBit v1.5 boards

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

Fabien-Chouteau commented 3 years ago

This looks pretty good @shakram02 :+1:

Fabien-Chouteau commented 3 years ago

Have a look at the build logs, you have some indention issues to fix:

lsm303agr.adb:32:05: (style) bad indentation
[...]
shakram02 commented 3 years ago

Adjusting the format took quite a while :sweat_smile:,

can you please point me towards how to integrate this driver into microbit-accelerometer.ads?

Is it okay to declare 2 Accelerometer variables then use the working one? I guess that I'll also have to extract the All_Axes_Data type.

Fabien-Chouteau commented 3 years ago

Thank you @shakram02 !

Is it okay to declare 2 Accelerometer variables then use the working one?

Yes, that's how I would do it. Then do a check in Initialize to see which one is available, and have a global variable to remember which one it is.

I guess that I'll also have to extract the All_Axes_Data type.

Since both data set have the same ranges, you can declare another All_Axes_Data in MicroBit.Accelerometer:

   type Axis_Data is range -2**9 .. 2**9 - 1 with Size => 10;

   type All_Axes_Data is record
      X, Y, Z : Axis_Data;
   end record;

and do an explicit cast for all fields from the drivers type to the MicroBit.Accelerometer type.

shakram02 commented 3 years ago

Okay then, I'll work on it on a new branch :ok_hand: