Skip to content

Commit 1a66c2a

Browse files
authored
Merge branch 'AdaCore:master' into topic/stm32_flash
2 parents f88eefb + 0ace79c commit 1a66c2a

16 files changed

Lines changed: 1369 additions & 54 deletions

File tree

components/src/motion/lis3dsh/lis3dsh.adb

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
------------------------------------------------------------------------------
22
-- --
3-
-- Copyright (C) 2015-2016, AdaCore --
3+
-- Copyright (C) 2015-2026, AdaCore --
44
-- --
55
-- Redistribution and use in source and binary forms, with or without --
66
-- modification, are permitted provided that the following conditions are --
@@ -41,7 +41,6 @@
4141
------------------------------------------------------------------------------
4242

4343
with Ada.Unchecked_Conversion;
44-
with System;
4544
with Interfaces; use Interfaces;
4645

4746
package body LIS3DSH is
@@ -111,16 +110,12 @@ package body LIS3DSH is
111110
Axes : out Axes_Accelerations)
112111
is
113112

114-
Buffer : array (0 .. 5) of UInt8 with Alignment => 2, Size => 48;
115-
Scaled : Float;
113+
type Device_Data is array (0 .. 5) of UInt8 with Alignment => 2, Size => 48;
116114

117-
type Integer16_Pointer is access all Integer_16
118-
with Storage_Size => 0;
115+
Buffer : Device_Data;
119116

120-
function As_Pointer is new Ada.Unchecked_Conversion
121-
(Source => System.Address, Target => Integer16_Pointer);
122-
-- So that we can treat the address of a UInt8 as a pointer to a two-UInt8
123-
-- sequence representing a signed Integer_16 quantity
117+
function As_Axes_Accelerations is new Ada.Unchecked_Conversion
118+
(Source => Device_Data, Target => Axes_Accelerations);
124119

125120
begin
126121
This.Loc_IO_Read (Buffer (0), OUT_X_L);
@@ -130,26 +125,13 @@ package body LIS3DSH is
130125
This.Loc_IO_Read (Buffer (4), OUT_Z_L);
131126
This.Loc_IO_Read (Buffer (5), OUT_Z_H);
132127

133-
Get_X : declare
134-
Raw : Integer_16 renames As_Pointer (Buffer (0)'Address).all;
128+
Scale_Them : declare
129+
Raw : Axes_Accelerations renames As_Axes_Accelerations (Buffer);
135130
begin
136-
Scaled := Float (Raw) * This.Sensitivity;
137-
Axes.X := Axis_Acceleration (Scaled);
138-
end Get_X;
139-
140-
Get_Y : declare
141-
Raw : Integer_16 renames As_Pointer (Buffer (2)'Address).all;
142-
begin
143-
Scaled := Float (Raw) * This.Sensitivity;
144-
Axes.Y := Axis_Acceleration (Scaled);
145-
end Get_Y;
146-
147-
Get_Z : declare
148-
Raw : Integer_16 renames As_Pointer (Buffer (4)'Address).all;
149-
begin
150-
Scaled := Float (Raw) * This.Sensitivity;
151-
Axes.Z := Axis_Acceleration (Scaled);
152-
end Get_Z;
131+
Axes.X := Axis_Acceleration (Float (Raw.X) * This.Sensitivity);
132+
Axes.Y := Axis_Acceleration (Float (Raw.Y) * This.Sensitivity);
133+
Axes.Z := Axis_Acceleration (Float (Raw.Z) * This.Sensitivity);
134+
end Scale_Them;
153135
end Get_Accelerations;
154136

155137
---------------

components/src/radio/si4432/si4432.adb

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -570,24 +570,16 @@ package body Si4432 is
570570
(This : Si4432_Driver;
571571
Value : UInt9)
572572
is
573-
Data : constant Unsigned_16 := Unsigned_16 (Value);
573+
Data : HAL.SPI.SPI_Data_8b (1 .. 2);
574+
Reg : Modulation_Mode_Control_2_Register with Import,
575+
Address => Data (1)'Address;
576+
574577
begin
575-
Write_Register
576-
(This,
577-
Frequency_Deviation_Name,
578-
Register (Data and 16#FF#));
579-
580-
if (Data and 2#1_0000_0000#) /= 0 then
581-
declare
582-
R : Register := Read_Register
583-
(This, Modulation_Mode_Control_2_Name);
584-
Reg : Modulation_Mode_Control_2_Register with Import,
585-
Address => R'Address;
586-
begin
587-
Reg.fd := 1;
588-
Write_Register (This, Modulation_Mode_Control_2_Name, R);
589-
end;
590-
end if;
578+
Data (1) := UInt8 (Read_Register (This, Modulation_Mode_Control_2_Name));
579+
Reg.fd :=
580+
(if (Unsigned_16 (Value) and 2#1_0000_0000#) > 0 then 1 else 0);
581+
Data (2) := UInt8 (Unsigned_16 (Value) and 16#FF#);
582+
Write_Register (This, Modulation_Mode_Control_2_Name, Data);
591583
end Set_Frequency_Deviation;
592584

593585
-----------------------------
@@ -1435,7 +1427,8 @@ package body Si4432 is
14351427

14361428
begin
14371429
Data (1) := UInt8 (Read_Register (This, Header_Control_2_Name));
1438-
Reg.prealen := Bit (Unsigned_16 (Value) and 2#1_0000_0000#);
1430+
Reg.prealen :=
1431+
(if (Unsigned_16 (Value) and 2#1_0000_0000#) > 0 then 1 else 0);
14391432
Data (2) := UInt8 (Local and 16#FF#);
14401433

14411434
Write_Register (This, Header_Control_2_Name, Data);
@@ -2774,10 +2767,21 @@ package body Si4432 is
27742767
Data : SPI_Data_8b) is
27752768
begin
27762769
Set_Packet_Length (This, Data'Length);
2777-
Write_Register (This, FIFO_Access_Name, Data);
2770+
Write_FIFO (This, Data);
27782771
Set_State (This, TX);
27792772
end Send;
27802773

2774+
----------------
2775+
-- Write_FIFO --
2776+
----------------
2777+
2778+
procedure Write_FIFO
2779+
(This : Si4432_Driver;
2780+
Data : SPI_Data_8b) is
2781+
begin
2782+
Write_Register (This, FIFO_Access_Name, Data);
2783+
end Write_FIFO;
2784+
27812785
------------------
27822786
-- Get_Received --
27832787
------------------
@@ -2790,14 +2794,24 @@ package body Si4432 is
27902794
(Get_Received_Packet_Length (This));
27912795
Length : constant Natural := Natural'Min (Received, Data'Length);
27922796
begin
2793-
Read_Register
2794-
(This, FIFO_Access_Name, Data (Data'First .. Data'First + Length - 1));
2797+
Read_FIFO (This, Data (Data'First .. Data'First + Length - 1));
27952798

27962799
if Received <= Data'Length then
27972800
Clear_RX_FIFO (This);
27982801
end if;
27992802
end Get_Received;
28002803

2804+
---------------
2805+
-- Read_FIFO --
2806+
---------------
2807+
2808+
procedure Read_FIFO
2809+
(This : Si4432_Driver;
2810+
Data : out SPI_Data_8b) is
2811+
begin
2812+
Read_Register (This, FIFO_Access_Name, Data);
2813+
end Read_FIFO;
2814+
28012815
-------------------
28022816
-- Clear_RX_FIFO --
28032817
-------------------

components/src/radio/si4432/si4432.ads

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,16 @@ package Si4432 is
19211921
(This : Si4432_Driver)
19221922
return FIFO_Threshold;
19231923

1924+
procedure Write_FIFO
1925+
(This : Si4432_Driver;
1926+
Data : SPI_Data_8b);
1927+
-- Write data to the FIFO
1928+
1929+
procedure Read_FIFO
1930+
(This : Si4432_Driver;
1931+
Data : out SPI_Data_8b);
1932+
-- Read data from the FIFO
1933+
19241934
private
19251935

19261936
type Register_Address is range 16#00# .. 16#7F# with Size => UInt7'Size;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
See components/src/sensors/combined/BMP280
2+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The BMP280 is an absolute barometric pressure sensor especially designed for mobile applications.
2+
3+
Pressure resolution 0.16 Pa
4+
5+
Temperature resolution 0.01°C
6+

0 commit comments

Comments
 (0)