Skip to content

Commit 36a3cb6

Browse files
Add support for the AdaFruit Feather STM32F405
1 parent 2f7f7dd commit 36a3cb6

File tree

14 files changed

+653
-1
lines changed

14 files changed

+653
-1
lines changed

boards/board_projects_generator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'STM32F746_Discovery': { 'rts_profiles': ['ravenscar-sfp', 'ravenscar-full']},
1717
'STM32F769_Discovery': { 'rts_profiles': ['ravenscar-sfp', 'ravenscar-full']},
1818
'NUCLEO_F446ZE': { 'rts_profiles': ['ravenscar-sfp', 'ravenscar-full']},
19+
'Feather_STM32F405': { 'rts_profiles': ['ravenscar-sfp', 'ravenscar-full']},
1920
}
2021

2122

@@ -30,7 +31,8 @@
3031
'STM32F469_Discovery': 'stm32f469_discovery',
3132
'STM32F746_Discovery': 'stm32f746_discovery',
3233
'STM32F769_Discovery': 'stm32f769_discovery',
33-
'NUCLEO_F446ZE': 'nucleo_f446ze'}
34+
'NUCLEO_F446ZE': 'nucleo_f446ze',
35+
'Feather_STM32F405': 'feather_stm32f405'}
3436

3537
USE_STARTUP_GEN = ['HiFive1', 'MicroBit']
3638

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
-- This project file was generated by the Ada_Drivers_Library project wizard script
2+
library project Feather_STM32F405_Full is
3+
4+
type Build_Type is ("Debug", "Production");
5+
Build : Build_Type := external ("ADL_BUILD", "Debug");
6+
7+
type Build_Checks_Type is ("Disabled", "Enabled");
8+
Build_Checks : Build_Checks_Type := external ("ADL_BUILD_CHECKS", "Disabled");
9+
10+
-- Target architecture
11+
Target := Project'Target;
12+
13+
-- Callgraph info is not available on all architectures
14+
Callgraph_Switch := ();
15+
case Target is
16+
when "riscv32-unknown-elf" => null;
17+
when others => Callgraph_Switch := ("-fcallgraph-info=su");
18+
end case;
19+
20+
Build_Checks_Switches := ();
21+
case Build_Checks is
22+
when "Disabled" => null;
23+
when others =>
24+
Build_Checks_Switches :=
25+
("-gnaty", "-gnatyM120", "-gnatyO", -- Style checks
26+
"-gnatwe"); -- Warnings as errors
27+
end case;
28+
29+
package Compiler is
30+
case Build is
31+
when "Production" =>
32+
for Default_Switches ("Ada") use
33+
("-O3", -- Optimization
34+
"-gnatp", -- Supress checks
35+
"-gnatn"); -- Enable inlining
36+
when "Debug" =>
37+
for Default_Switches ("Ada") use
38+
("-O0", -- No optimization
39+
"-gnata") -- Enable assertions
40+
& Callgraph_Switch;
41+
end case;
42+
43+
for Default_Switches ("ada") use Compiler'Default_Switches ("Ada") &
44+
Callgraph_Switch &
45+
Build_Checks_Switches &
46+
("-g", -- Debug info
47+
"-gnatwa", -- All warnings
48+
"-gnatw_A", -- Turn off warnings for anonymous allocators
49+
"-gnatQ", -- Don't quit. Generate ALI and tree files even if illegalities
50+
"-gnatw.X", -- Disable warnings for No_Exception_Propagation
51+
"-ffunction-sections", -- Create a linker section for each function
52+
"-fdata-sections"); -- Create a linker section for each data
53+
end Compiler;
54+
55+
56+
for Languages use ("Ada");
57+
for Create_Missing_Dirs use "True";
58+
for Object_Dir use "obj/full_" & Build;
59+
for Library_Dir use "obj/full_lib_" & Build;
60+
for Library_Kind use "static";
61+
for Library_Name use "ada_drivers_library";
62+
63+
Linker_Switches := ();
64+
for Target use "arm-eabi";
65+
for Runtime ("Ada") use "ravenscar-full-feather_stm32f405";
66+
67+
package Device_Configuration is
68+
for CPU_Name use "ARM Cortex-M4F";
69+
for Number_Of_Interrupts use "0";
70+
end Device_Configuration;
71+
72+
Vendor := "STMicro"; -- From board definition
73+
Max_Mount_Points := "2"; -- From default value
74+
Max_Mount_Name_Length := "128"; -- From default value
75+
Runtime_Profile := "ravenscar-full"; -- From command line
76+
Device_Name := "STM32F405RGTx"; -- From board definition
77+
Device_Family := "STM32F4"; -- From board definition
78+
Has_Ravenscar_SFP_Runtime := "True"; -- From board definition
79+
Runtime_Name := "ravenscar-full-feather_stm32f405"; -- From default value
80+
Has_Ravenscar_Full_Runtime := "True"; -- From board definition
81+
CPU_Core := "ARM Cortex-M4F"; -- From mcu definition
82+
Board := "Feather_STM32F405"; -- From command line
83+
Has_ZFP_Runtime := "False"; -- From board definition
84+
Number_Of_Interrupts := "0"; -- From default value
85+
High_Speed_External_Clock := "12000000"; -- From board definition
86+
Use_Startup_Gen := "False"; -- From command line
87+
Max_Path_Length := "1024"; -- From default value
88+
Runtime_Name_Suffix := "feather_stm32f405"; -- From board definition
89+
Architecture := "ARM"; -- From board definition
90+
91+
-- Project source directories
92+
Src_Dirs_Root := "../..";
93+
for Source_Dirs use (
94+
Src_Dirs_Root & "/hal/src/", -- From HAL config
95+
Src_Dirs_Root & "/boards/feather_stm32f405/src/", -- From board definition
96+
Src_Dirs_Root & "/arch/ARM/cortex_m/src", -- From arch definition
97+
Src_Dirs_Root & "/arch/ARM/cortex_m/src/cm4f", -- From arch definition
98+
Src_Dirs_Root & "/arch/ARM/cortex_m/src/fpu", -- From arch definition
99+
Src_Dirs_Root & "/arch/ARM/cortex_m/src/nocache", -- From arch definition
100+
Src_Dirs_Root & "/arch/ARM/cortex_m/src/nvic_cm4_cm7", -- From arch definition
101+
Src_Dirs_Root & "/arch/ARM/STM32/devices/stm32f40x/", -- From MCU definition
102+
Src_Dirs_Root & "/arch/ARM/STM32/svd/stm32f40x", -- From MCU definition
103+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/", -- From MCU definition
104+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/dma/", -- From MCU definition
105+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/dma_interrupts/", -- From MCU definition
106+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/crc_stm32f4/", -- From MCU definition
107+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/i2c_stm32f4", -- From MCU definition
108+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/power_control_stm32f4", -- From MCU definition
109+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/uart_stm32f4/", -- From MCU definition
110+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/sd/", -- From MCU definition
111+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/sd/sdio/", -- From MCU definition
112+
Src_Dirs_Root & "/middleware/src/filesystem", -- From middleware config
113+
Src_Dirs_Root & "/middleware/src/BLE", -- From middleware config
114+
Src_Dirs_Root & "/middleware/src/utils", -- From middleware config
115+
Src_Dirs_Root & "/middleware/src/audio", -- From middleware config
116+
Src_Dirs_Root & "/middleware/src/monitor", -- From middleware config
117+
Src_Dirs_Root & "/middleware/src/bitmap", -- From middleware config
118+
Src_Dirs_Root & "/middleware/src/command_line", -- From middleware config
119+
Src_Dirs_Root & "/middleware/src/sdmmc", -- From middleware config
120+
Src_Dirs_Root & "/middleware/src/neopixel", -- From middleware config
121+
Src_Dirs_Root & "/middleware/src/ravenscar-common", -- From middleware config
122+
Src_Dirs_Root & "/components/src/**", -- From components config
123+
"src/full/");
124+
end Feather_STM32F405_Full;
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
-- This project file was generated by the Ada_Drivers_Library project wizard script
2+
library project Feather_STM32F405_SFP is
3+
4+
type Build_Type is ("Debug", "Production");
5+
Build : Build_Type := external ("ADL_BUILD", "Debug");
6+
7+
type Build_Checks_Type is ("Disabled", "Enabled");
8+
Build_Checks : Build_Checks_Type := external ("ADL_BUILD_CHECKS", "Disabled");
9+
10+
-- Target architecture
11+
Target := Project'Target;
12+
13+
-- Callgraph info is not available on all architectures
14+
Callgraph_Switch := ();
15+
case Target is
16+
when "riscv32-unknown-elf" => null;
17+
when others => Callgraph_Switch := ("-fcallgraph-info=su");
18+
end case;
19+
20+
Build_Checks_Switches := ();
21+
case Build_Checks is
22+
when "Disabled" => null;
23+
when others =>
24+
Build_Checks_Switches :=
25+
("-gnaty", "-gnatyM120", "-gnatyO", -- Style checks
26+
"-gnatwe"); -- Warnings as errors
27+
end case;
28+
29+
package Compiler is
30+
case Build is
31+
when "Production" =>
32+
for Default_Switches ("Ada") use
33+
("-O3", -- Optimization
34+
"-gnatp", -- Supress checks
35+
"-gnatn"); -- Enable inlining
36+
when "Debug" =>
37+
for Default_Switches ("Ada") use
38+
("-O0", -- No optimization
39+
"-gnata") -- Enable assertions
40+
& Callgraph_Switch;
41+
end case;
42+
43+
for Default_Switches ("ada") use Compiler'Default_Switches ("Ada") &
44+
Callgraph_Switch &
45+
Build_Checks_Switches &
46+
("-g", -- Debug info
47+
"-gnatwa", -- All warnings
48+
"-gnatw_A", -- Turn off warnings for anonymous allocators
49+
"-gnatQ", -- Don't quit. Generate ALI and tree files even if illegalities
50+
"-gnatw.X", -- Disable warnings for No_Exception_Propagation
51+
"-ffunction-sections", -- Create a linker section for each function
52+
"-fdata-sections"); -- Create a linker section for each data
53+
end Compiler;
54+
55+
56+
for Languages use ("Ada");
57+
for Create_Missing_Dirs use "True";
58+
for Object_Dir use "obj/sfp_" & Build;
59+
for Library_Dir use "obj/sfp_lib_" & Build;
60+
for Library_Kind use "static";
61+
for Library_Name use "ada_drivers_library";
62+
63+
Linker_Switches := ();
64+
for Target use "arm-eabi";
65+
for Runtime ("Ada") use "ravenscar-sfp-feather_stm32f405";
66+
67+
package Device_Configuration is
68+
for CPU_Name use "ARM Cortex-M4F";
69+
for Number_Of_Interrupts use "0";
70+
end Device_Configuration;
71+
72+
Vendor := "STMicro"; -- From board definition
73+
Max_Mount_Points := "2"; -- From default value
74+
Max_Mount_Name_Length := "128"; -- From default value
75+
Runtime_Profile := "ravenscar-sfp"; -- From command line
76+
Device_Name := "STM32F405RGTx"; -- From board definition
77+
Device_Family := "STM32F4"; -- From board definition
78+
Has_Ravenscar_SFP_Runtime := "True"; -- From board definition
79+
Runtime_Name := "ravenscar-sfp-feather_stm32f405"; -- From default value
80+
Has_Ravenscar_Full_Runtime := "True"; -- From board definition
81+
CPU_Core := "ARM Cortex-M4F"; -- From mcu definition
82+
Board := "Feather_STM32F405"; -- From command line
83+
Has_ZFP_Runtime := "False"; -- From board definition
84+
Number_Of_Interrupts := "0"; -- From default value
85+
High_Speed_External_Clock := "12000000"; -- From board definition
86+
Use_Startup_Gen := "False"; -- From command line
87+
Max_Path_Length := "1024"; -- From default value
88+
Runtime_Name_Suffix := "feather_stm32f405"; -- From board definition
89+
Architecture := "ARM"; -- From board definition
90+
91+
-- Project source directories
92+
Src_Dirs_Root := "../..";
93+
for Source_Dirs use (
94+
Src_Dirs_Root & "/hal/src/", -- From HAL config
95+
Src_Dirs_Root & "/boards/feather_stm32f405/src/", -- From board definition
96+
Src_Dirs_Root & "/arch/ARM/cortex_m/src", -- From arch definition
97+
Src_Dirs_Root & "/arch/ARM/cortex_m/src/cm4f", -- From arch definition
98+
Src_Dirs_Root & "/arch/ARM/cortex_m/src/fpu", -- From arch definition
99+
Src_Dirs_Root & "/arch/ARM/cortex_m/src/nocache", -- From arch definition
100+
Src_Dirs_Root & "/arch/ARM/cortex_m/src/nvic_cm4_cm7", -- From arch definition
101+
Src_Dirs_Root & "/arch/ARM/STM32/devices/stm32f40x/", -- From MCU definition
102+
Src_Dirs_Root & "/arch/ARM/STM32/svd/stm32f40x", -- From MCU definition
103+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/", -- From MCU definition
104+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/dma/", -- From MCU definition
105+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/dma_interrupts/", -- From MCU definition
106+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/crc_stm32f4/", -- From MCU definition
107+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/i2c_stm32f4", -- From MCU definition
108+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/power_control_stm32f4", -- From MCU definition
109+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/uart_stm32f4/", -- From MCU definition
110+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/sd/", -- From MCU definition
111+
Src_Dirs_Root & "/arch/ARM/STM32/drivers/sd/sdio/", -- From MCU definition
112+
Src_Dirs_Root & "/middleware/src/filesystem", -- From middleware config
113+
Src_Dirs_Root & "/middleware/src/BLE", -- From middleware config
114+
Src_Dirs_Root & "/middleware/src/utils", -- From middleware config
115+
Src_Dirs_Root & "/middleware/src/audio", -- From middleware config
116+
Src_Dirs_Root & "/middleware/src/monitor", -- From middleware config
117+
Src_Dirs_Root & "/middleware/src/bitmap", -- From middleware config
118+
Src_Dirs_Root & "/middleware/src/command_line", -- From middleware config
119+
Src_Dirs_Root & "/middleware/src/sdmmc", -- From middleware config
120+
Src_Dirs_Root & "/middleware/src/neopixel", -- From middleware config
121+
Src_Dirs_Root & "/middleware/src/ravenscar-common", -- From middleware config
122+
Src_Dirs_Root & "/components/src/**", -- From components config
123+
"src/sfp/");
124+
end Feather_STM32F405_SFP;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
------------------------------------------------------------------------------
2+
-- --
3+
-- Copyright (C) 2019, AdaCore --
4+
-- --
5+
-- Redistribution and use in source and binary forms, with or without --
6+
-- modification, are permitted provided that the following conditions are --
7+
-- met: --
8+
-- 1. Redistributions of source code must retain the above copyright --
9+
-- notice, this list of conditions and the following disclaimer. --
10+
-- 2. Redistributions in binary form must reproduce the above copyright --
11+
-- notice, this list of conditions and the following disclaimer in --
12+
-- the documentation and/or other materials provided with the --
13+
-- distribution. --
14+
-- 3. Neither the name of the copyright holder nor the names of its --
15+
-- contributors may be used to endorse or promote products derived --
16+
-- from this software without specific prior written permission. --
17+
-- --
18+
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
19+
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
20+
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
21+
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
22+
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
23+
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
24+
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
25+
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
26+
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
27+
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
28+
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
29+
-- --
30+
------------------------------------------------------------------------------
31+
32+
with STM32.I2C; use STM32.I2C;
33+
with STM32.Setup;
34+
35+
package body Feather_STM32F405.I2C is
36+
37+
Init_Done : Boolean := False;
38+
Device : STM32.I2C.I2C_Port renames STM32.Device.I2C_1;
39+
40+
-----------------
41+
-- Initialized --
42+
-----------------
43+
44+
function Initialized return Boolean
45+
is (Init_Done);
46+
47+
----------------
48+
-- Initialize --
49+
----------------
50+
51+
procedure Initialize (Clock_Speed : HAL.UInt32) is
52+
begin
53+
STM32.Setup.Setup_I2C_Master
54+
(Port => Device,
55+
SDA => Feather_STM32F405.SDA,
56+
SCL => Feather_STM32F405.SCL,
57+
SDA_AF => STM32.Device.GPIO_AF_I2C1_4,
58+
SCL_AF => STM32.Device.GPIO_AF_I2C1_4,
59+
Clock_Speed => Clock_Speed);
60+
61+
Init_Done := True;
62+
end Initialize;
63+
64+
----------------
65+
-- Controller --
66+
----------------
67+
68+
function Controller return not null Any_I2C_Port
69+
is (Device'Access);
70+
71+
end Feather_STM32F405.I2C;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
------------------------------------------------------------------------------
2+
-- --
3+
-- Copyright (C) 2019, AdaCore --
4+
-- --
5+
-- Redistribution and use in source and binary forms, with or without --
6+
-- modification, are permitted provided that the following conditions are --
7+
-- met: --
8+
-- 1. Redistributions of source code must retain the above copyright --
9+
-- notice, this list of conditions and the following disclaimer. --
10+
-- 2. Redistributions in binary form must reproduce the above copyright --
11+
-- notice, this list of conditions and the following disclaimer in --
12+
-- the documentation and/or other materials provided with the --
13+
-- distribution. --
14+
-- 3. Neither the name of the copyright holder nor the names of its --
15+
-- contributors may be used to endorse or promote products derived --
16+
-- from this software without specific prior written permission. --
17+
-- --
18+
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
19+
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
20+
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
21+
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
22+
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
23+
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
24+
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
25+
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
26+
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
27+
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
28+
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
29+
-- --
30+
------------------------------------------------------------------------------
31+
32+
with HAL;
33+
with HAL.I2C; use HAL.I2C;
34+
35+
package Feather_STM32F405.I2C is
36+
37+
function Initialized return Boolean;
38+
-- Return True if the I2C controller is initialized and ready to use
39+
40+
procedure Initialize (Clock_Speed : HAL.UInt32)
41+
with Post => Initialized;
42+
-- Initialize the I2C controller at given speed
43+
44+
function Controller return not null Any_I2C_Port;
45+
-- Return the HAL.I2C controller implementation
46+
47+
end Feather_STM32F405.I2C;

0 commit comments

Comments
 (0)