├── 2048
├── src
│ ├── tasking.ads
│ ├── framebuffer_helper.ads
│ ├── solver.ads
│ ├── ltdc
│ │ └── framebuffer_helper.adb
│ ├── dsi
│ │ └── framebuffer_helper.adb
│ ├── status.ads
│ ├── malloc.ads
│ ├── game.ads
│ ├── grid.ads
│ ├── malloc.adb
│ └── demo_2048.adb
├── demo_2048_stm32f469disco.gpr
├── demo_2048_stm32f746disco.gpr
└── demo_2048_stm32f769disco.gpr
├── wolf
├── obj
│ ├── rpi2
│ │ └── .gitignore
│ ├── rpi3
│ │ └── .gitignore
│ ├── stm32f429disco
│ │ └── .gitignore
│ ├── stm32f469disco
│ │ └── .gitignore
│ └── stm32f746disco
│ │ └── .gitignore
├── gen
│ ├── ada.png
│ ├── spark.png
│ ├── lady_ada.png
│ ├── pics
│ │ ├── barrel.png
│ │ ├── column.png
│ │ ├── light.png
│ │ ├── plant.png
│ │ ├── redada.png
│ │ ├── table.png
│ │ ├── wood.png
│ │ ├── colorada.png
│ │ ├── greyada.png
│ │ ├── redbrick.png
│ │ ├── woodada.png
│ │ ├── colorstone.png
│ │ ├── greystone.png
│ │ ├── redada_dark.png
│ │ ├── wood_dark.png
│ │ ├── colorada_dark.png
│ │ ├── greyada_dark.png
│ │ ├── redbrick_dark.png
│ │ ├── woodada_dark.png
│ │ ├── colorstone_dark.png
│ │ └── greystone_dark.png
│ ├── gencos.py
│ └── pngtoada.py
├── src
│ ├── playground.adb
│ ├── renderer.ads
│ ├── textures.ads
│ ├── rpi
│ │ ├── bitmap.ads
│ │ ├── wolf_demo.adb
│ │ ├── display.adb
│ │ ├── display.ads
│ │ ├── notasking
│ │ │ └── renderer-tasks.adb
│ │ └── tasking
│ │ │ └── renderer-tasks.adb
│ ├── stm32
│ │ ├── bitmap.ads
│ │ ├── wolf_demo.adb
│ │ ├── display.adb
│ │ ├── display.ads
│ │ └── renderer-tasks.adb
│ ├── math.ads
│ └── raycaster.ads
├── wolf_stm32f429disco.gpr
├── wolf_stm32f746disco.gpr
├── wolf_stm32f769disco.gpr
├── wolf_stm32f469disco.gpr
├── wolf_rpi2.gpr
├── wolf_rpi3.gpr
└── wolf_common.gpr
├── sdcard
├── obj
│ ├── stm32f469disco
│ │ └── .gitignore
│ ├── stm32f746disco
│ │ └── .gitignore
│ └── stm32f769disco
│ │ └── .gitignore
├── src
│ └── test_support.ads
├── sdcard_stm32f746disco.gpr
├── sdcard_stm32f469disco.gpr
└── sdcard_stm32f769disco.gpr
├── .gitmodules
├── conway
├── obj
│ ├── stm32f429disco
│ │ └── .gitignore
│ ├── stm32f469disco
│ │ └── .gitignore
│ └── stm32f746disco
│ │ └── .gitignore
├── conway_stm32f746disco.gpr
├── conway_stm32f769disco.gpr
├── conway_stm32f469disco.gpr
├── conway_stm32f429disco.gpr
└── src
│ ├── conway_driver.ads
│ └── conway_demo.adb
├── fractals
├── obj
│ ├── stm32f429disco
│ │ └── .gitignore
│ ├── stm32f469disco
│ │ └── .gitignore
│ └── stm32f746disco
│ │ └── .gitignore
├── src
│ ├── single
│ │ └── float_support.ads
│ ├── double
│ │ └── float_support.ads
│ ├── fractals.ads
│ └── fractals.adb
├── fractals_stm32f429disco.gpr
├── fractals_stm32f746disco.gpr
├── fractals_stm32f769disco.gpr
└── fractals_stm32f469disco.gpr
├── .gitignore
├── common
├── utils
│ ├── images_aux.ads
│ ├── images_gen.ads
│ ├── images_gen.adb
│ └── hex_images.ads
├── common.gpr
└── gui
│ ├── gestures.ads
│ ├── hershey_fonts.ads
│ ├── bmp_fonts.ads
│ ├── lcd_std_out.ads
│ └── bitmapped_drawing.ads
├── rpi2-mmc
├── src
│ └── sdcard_buf.ads
├── sdcard_rpi3.gpr
└── sdcard_rpi2.gpr
├── balls
├── balls_stm32f429disco.gpr
├── balls_stm32f746disco.gpr
├── balls_stm32f769disco.gpr
└── balls_stm32f469disco.gpr
├── zynq-eth
├── src
│ └── eth_demo.adb
└── eth_zynq.gpr
├── wav_player
├── wav_stm32f769disco.gpr
├── wav_stm32f746disco.gpr
├── wav_stm32f469disco.gpr
└── src
│ ├── gui.ads
│ ├── wav_player.ads
│ ├── player.adb
│ ├── wav_reader.ads
│ └── wav_db.ads
├── rpi3-bluetooth
└── bt.gpr
├── raspberrypi_demos.gpr
├── stm32f429_demos.gpr
├── Makefile
├── stm32f469_demos.gpr
├── stm32f746_demos.gpr
├── stm32f769_demos.gpr
├── services
├── README.md
├── filesystem
│ ├── filesystem.adb
│ ├── VFS
│ │ └── filesystem-vfs.ads
│ ├── FAT
│ │ ├── filesystem-fat-files.ads
│ │ └── filesystem-fat-directories.ads
│ └── MBR
│ │ ├── filesystem-mbr.ads
│ │ └── filesystem-mbr.adb
└── COPYING.RUNTIME
├── README.md
└── all_demos.gpr
/wolf/obj/rpi2/.gitignore:
--------------------------------------------------------------------------------
1 | *
--------------------------------------------------------------------------------
/wolf/obj/rpi3/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 |
--------------------------------------------------------------------------------
/sdcard/obj/stm32f469disco/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 |
--------------------------------------------------------------------------------
/sdcard/obj/stm32f746disco/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 |
--------------------------------------------------------------------------------
/sdcard/obj/stm32f769disco/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 |
--------------------------------------------------------------------------------
/wolf/gen/ada.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/ada.png
--------------------------------------------------------------------------------
/wolf/gen/spark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/spark.png
--------------------------------------------------------------------------------
/wolf/gen/lady_ada.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/lady_ada.png
--------------------------------------------------------------------------------
/wolf/gen/pics/barrel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/barrel.png
--------------------------------------------------------------------------------
/wolf/gen/pics/column.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/column.png
--------------------------------------------------------------------------------
/wolf/gen/pics/light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/light.png
--------------------------------------------------------------------------------
/wolf/gen/pics/plant.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/plant.png
--------------------------------------------------------------------------------
/wolf/gen/pics/redada.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/redada.png
--------------------------------------------------------------------------------
/wolf/gen/pics/table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/table.png
--------------------------------------------------------------------------------
/wolf/gen/pics/wood.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/wood.png
--------------------------------------------------------------------------------
/wolf/src/playground.adb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/src/playground.adb
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "drivers"]
2 | path = drivers
3 | url = git@github.com:lambourg/Ada_Drivers_Library.git
4 |
--------------------------------------------------------------------------------
/wolf/gen/pics/colorada.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/colorada.png
--------------------------------------------------------------------------------
/wolf/gen/pics/greyada.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/greyada.png
--------------------------------------------------------------------------------
/wolf/gen/pics/redbrick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/redbrick.png
--------------------------------------------------------------------------------
/wolf/gen/pics/woodada.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/woodada.png
--------------------------------------------------------------------------------
/conway/obj/stm32f429disco/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file
4 | !.gitignore
5 |
--------------------------------------------------------------------------------
/conway/obj/stm32f469disco/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file
4 | !.gitignore
5 |
--------------------------------------------------------------------------------
/conway/obj/stm32f746disco/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file
4 | !.gitignore
5 |
--------------------------------------------------------------------------------
/wolf/gen/pics/colorstone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/colorstone.png
--------------------------------------------------------------------------------
/wolf/gen/pics/greystone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/greystone.png
--------------------------------------------------------------------------------
/wolf/gen/pics/redada_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/redada_dark.png
--------------------------------------------------------------------------------
/wolf/gen/pics/wood_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/wood_dark.png
--------------------------------------------------------------------------------
/wolf/obj/stm32f429disco/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file
4 | !.gitignore
5 |
--------------------------------------------------------------------------------
/wolf/obj/stm32f469disco/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file
4 | !.gitignore
5 |
--------------------------------------------------------------------------------
/wolf/obj/stm32f746disco/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file
4 | !.gitignore
5 |
--------------------------------------------------------------------------------
/fractals/obj/stm32f429disco/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file
4 | !.gitignore
5 |
--------------------------------------------------------------------------------
/fractals/obj/stm32f469disco/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file
4 | !.gitignore
5 |
--------------------------------------------------------------------------------
/fractals/obj/stm32f746disco/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file
4 | !.gitignore
5 |
--------------------------------------------------------------------------------
/wolf/gen/pics/colorada_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/colorada_dark.png
--------------------------------------------------------------------------------
/wolf/gen/pics/greyada_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/greyada_dark.png
--------------------------------------------------------------------------------
/wolf/gen/pics/redbrick_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/redbrick_dark.png
--------------------------------------------------------------------------------
/wolf/gen/pics/woodada_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/woodada_dark.png
--------------------------------------------------------------------------------
/wolf/gen/pics/colorstone_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/colorstone_dark.png
--------------------------------------------------------------------------------
/wolf/gen/pics/greystone_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lambourg/Ada_Bare_Metal_Demos/HEAD/wolf/gen/pics/greystone_dark.png
--------------------------------------------------------------------------------
/fractals/src/single/float_support.ads:
--------------------------------------------------------------------------------
1 | package Float_Support is
2 |
3 | subtype Base_Float is Float;
4 |
5 | end Float_Support;
6 |
--------------------------------------------------------------------------------
/fractals/src/double/float_support.ads:
--------------------------------------------------------------------------------
1 | package Float_Support is
2 |
3 | subtype Base_Float is Long_Float;
4 |
5 | end Float_Support;
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.db
2 | *.ali
3 | *.o
4 | *.a
5 | *.xml
6 | *.cgpr
7 | *.bexch
8 | *.lexch
9 | *.a
10 | *.ci
11 | *.cswi
12 | .DS_Store
13 | *~
14 |
--------------------------------------------------------------------------------
/sdcard/src/test_support.ads:
--------------------------------------------------------------------------------
1 | with HAL.Block_Drivers;
2 |
3 | package Test_Support is
4 |
5 | Test_Block : HAL.Block_Drivers.Block (0 .. 16#FFFF#);
6 |
7 | end Test_Support;
8 |
--------------------------------------------------------------------------------
/common/utils/images_aux.ads:
--------------------------------------------------------------------------------
1 | -- Auxilliary package to avoid duplicating constants.
2 | package Images_Aux is
3 | Hex_Digits : constant array (0 .. 15) of Character := "0123456789abcdef";
4 | end Images_Aux;
5 |
--------------------------------------------------------------------------------
/rpi2-mmc/src/sdcard_buf.ads:
--------------------------------------------------------------------------------
1 | with HAL.Block_Drivers;
2 |
3 | package SDCard_Buf is
4 | -- Buffer for speed test. Too large to be on the stack.
5 | Data : HAL.Block_Drivers.Block (0 .. 256 * 512 - 1);
6 | end SDCard_Buf;
7 |
--------------------------------------------------------------------------------
/wolf/gen/gencos.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | from math import radians, sin
3 |
4 | def gen_sin(x):
5 | val = sin(radians(x / 10.0))
6 | print ' %d => %.10f,' % (x, val)
7 |
8 | for d in range(0, 900):
9 | gen_sin(d)
10 |
--------------------------------------------------------------------------------
/balls/balls_stm32f429disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f429disco.gpr";
2 |
3 | project Balls_STM32F429Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F429Disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f429disco";
7 |
8 | for Main use ("balls_demo.adb");
9 | for Source_Dirs use ("src");
10 |
11 | end Balls_STM32F429Disco;
12 |
--------------------------------------------------------------------------------
/balls/balls_stm32f746disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f746disco.gpr";
2 |
3 | project Balls_STM32F746Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F746Disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f746disco";
7 |
8 | for Main use ("balls_demo.adb");
9 | for Source_Dirs use ("src");
10 |
11 | end Balls_STM32F746Disco;
12 |
--------------------------------------------------------------------------------
/balls/balls_stm32f769disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f769disco.gpr";
2 |
3 | project Balls_STM32F769Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F769Disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f769disco";
7 |
8 | for Main use ("balls_demo.adb");
9 | for Source_Dirs use ("src");
10 |
11 | end Balls_STM32F769Disco;
12 |
--------------------------------------------------------------------------------
/common/utils/images_gen.ads:
--------------------------------------------------------------------------------
1 | -- Function that returns a fixed string (to avoid the use of the secondary
2 | -- stack) representing the image in hexadecimal of the parameter.
3 | generic
4 | Width : Positive;
5 | type T is mod <>;
6 | package Images_Gen is
7 | subtype Fixed_String is String (1 .. Width);
8 | function Hex (V : T) return Fixed_String;
9 | end Images_Gen;
10 |
--------------------------------------------------------------------------------
/common/utils/images_gen.adb:
--------------------------------------------------------------------------------
1 | with Images_Aux; use Images_Aux;
2 |
3 | package body Images_Gen is
4 | function Hex (V : T) return Fixed_String is
5 | Res : Fixed_String;
6 | begin
7 | for I in Res'Range loop
8 | Res (I) := Hex_Digits
9 | (Natural ((V / 2 ** (4 * (Width - I))) and 15));
10 | end loop;
11 | return Res;
12 | end Hex;
13 | end Images_Gen;
14 |
--------------------------------------------------------------------------------
/zynq-eth/src/eth_demo.adb:
--------------------------------------------------------------------------------
1 | with Ada.Text_IO; use Ada.Text_IO;
2 | with System.Text_IO; use System.Text_IO;
3 | with Eth;
4 |
5 | procedure Eth_Demo is
6 | begin
7 | Put_Line ("Hello ethernet");
8 | Eth.Init;
9 | Put ("Press q to reset");
10 | loop
11 | Eth.Wait_Packet;
12 |
13 | if Is_Rx_Ready then
14 | exit when Get = 'q';
15 | end if;
16 | end loop;
17 | end Eth_Demo;
18 |
--------------------------------------------------------------------------------
/conway/conway_stm32f746disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f746disco.gpr";
2 |
3 | project Conway_STM32F746Disco extends "../common/common.gpr" is
4 |
5 | for Target use STM32F746Disco'Target;
6 | for Runtime ("Ada") use STM32F746Disco'Runtime("Ada");
7 | for Object_Dir use "obj/stm32f746disco";
8 |
9 | for Main use ("conway_demo.adb");
10 | for Source_Dirs use ("src");
11 |
12 | end Conway_STM32F746Disco;
13 |
--------------------------------------------------------------------------------
/balls/balls_stm32f469disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f469disco_sfp.gpr";
2 |
3 | project Balls_STM32F469Disco extends "../common/common.gpr" is
4 |
5 | for Target use STM32F469Disco_SFP'Target;
6 | for Runtime ("Ada") use STM32F469Disco_SFP'Runtime("Ada");
7 | for Object_Dir use "obj/stm32f469disco";
8 |
9 | for Main use ("balls_demo.adb");
10 | for Source_Dirs use ("src");
11 |
12 | end Balls_STM32F469Disco;
13 |
--------------------------------------------------------------------------------
/conway/conway_stm32f769disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f769disco.gpr";
2 |
3 | project Conway_STM32F769Disco extends "../common/common.gpr" is
4 |
5 | for Target use STM32F769Disco'Target;
6 | for Runtime ("Ada") use STM32F769Disco'Runtime("Ada");
7 |
8 | for Object_Dir use "obj/stm32f769disco";
9 |
10 | for Main use ("conway_demo.adb");
11 | for Source_Dirs use ("src");
12 |
13 | end Conway_STM32F769Disco;
14 |
--------------------------------------------------------------------------------
/conway/conway_stm32f469disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f469disco_sfp.gpr";
2 |
3 | project Conway_STM32F469Disco extends "../common/common.gpr" is
4 |
5 | for Target use STM32F469Disco_SFP'Target;
6 | for Runtime ("Ada") use STM32F469Disco_SFP'Runtime("Ada");
7 |
8 | for Object_Dir use "obj/stm32f469disco";
9 |
10 | for Main use ("conway_demo.adb");
11 | for Source_Dirs use ("src");
12 |
13 | end Conway_STM32F469Disco;
14 |
--------------------------------------------------------------------------------
/wolf/wolf_stm32f429disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f429disco.gpr";
2 |
3 | project Wolf_STM32F429Disco extends "wolf_common.gpr" is
4 |
5 | for Target use STM32F429Disco'Target;
6 | for Runtime ("Ada") use STM32F429Disco'Runtime("Ada");
7 | for Source_Dirs use
8 | Project'Source_Dirs & ("src/stm32");
9 | for Object_Dir use "obj/stm32f429disco";
10 |
11 | for Main use ("wolf_demo.adb");
12 |
13 | end Wolf_STM32F429Disco;
14 |
--------------------------------------------------------------------------------
/wolf/wolf_stm32f746disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f746disco.gpr";
2 |
3 | project Wolf_STM32F746Disco extends "wolf_common" is
4 |
5 | for Target use STM32F746Disco'Target;
6 | for Runtime ("Ada") use STM32F746Disco'Runtime("Ada");
7 | for Source_Dirs use
8 | Project'Source_Dirs &
9 | ("src/stm32");
10 | for Object_Dir use "obj/stm32f746disco";
11 |
12 | for Main use ("wolf_demo.adb");
13 |
14 | end Wolf_STM32F746Disco;
15 |
--------------------------------------------------------------------------------
/wolf/wolf_stm32f769disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f769disco.gpr";
2 |
3 | project Wolf_STM32F769Disco extends "wolf_common.gpr" is
4 |
5 | for Target use STM32F769Disco'Target;
6 | for Runtime ("Ada") use STM32F769Disco'Runtime("Ada");
7 | for Source_Dirs use
8 | Project'Source_Dirs &
9 | ("src/stm32");
10 | for Object_Dir use "obj/stm32f769disco";
11 |
12 | for Main use ("wolf_demo.adb");
13 |
14 | end Wolf_STM32F769Disco;
15 |
--------------------------------------------------------------------------------
/wolf/wolf_stm32f469disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f469disco_sfp.gpr";
2 |
3 | project Wolf_STM32F469Disco extends "wolf_common.gpr" is
4 |
5 | for Target use STM32F469Disco_SFP'Target;
6 | for Runtime ("Ada") use STM32F469Disco_SFP'Runtime("Ada");
7 | for Source_Dirs use
8 | Project'Source_Dirs &
9 | ("src/stm32");
10 | for Object_Dir use "obj/stm32f469disco";
11 |
12 | for Main use ("wolf_demo.adb");
13 |
14 | end Wolf_STM32F469Disco;
15 |
--------------------------------------------------------------------------------
/conway/conway_stm32f429disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f429disco.gpr";
2 |
3 | project Conway_STM32F429Disco extends "../common/common.gpr" is
4 |
5 | for Target use STM32F429Disco'Target;
6 | for Runtime ("Ada") use STM32F429Disco'Runtime("Ada");
7 |
8 | for Object_Dir use "obj/stm32f429disco";
9 | for Exec_Dir use project'Object_Dir;
10 |
11 | for Main use ("conway_demo.adb");
12 | for Source_Dirs use ("src");
13 |
14 | end Conway_STM32F429Disco;
15 |
--------------------------------------------------------------------------------
/rpi2-mmc/sdcard_rpi3.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/rpi3";
2 |
3 | project SDCard_RPI3 is
4 |
5 | for Target use "aarch64-elf";
6 | for Runtime ("Ada") use "ravenscar-sfp-rpi3";
7 |
8 | for Object_Dir use "obj/rpi3";
9 |
10 | for Main use ("sdcard_demo.adb");
11 | for Source_Dirs use ("src",
12 | "../common/utils",
13 | "../services/filesystem/**");
14 |
15 | package Compiler renames Common.Compiler;
16 |
17 | end SDCard_RPI3;
18 |
--------------------------------------------------------------------------------
/2048/src/tasking.ads:
--------------------------------------------------------------------------------
1 | with System;
2 | with Gestures;
3 |
4 | package Tasking is
5 |
6 | procedure Solver_Toggled;
7 |
8 | procedure Handle_Gesture (Value : Gestures.Gesture_Data);
9 |
10 | task Slider is
11 | pragma Priority (System.Priority'Last);
12 | pragma Storage_Size (4 * 1024);
13 | end Slider;
14 |
15 | task Controller is
16 | pragma Priority (System.Priority'Last - 1);
17 | pragma Storage_Size (32 * 1024);
18 | end Controller;
19 |
20 | end Tasking;
21 |
--------------------------------------------------------------------------------
/rpi2-mmc/sdcard_rpi2.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/rpi2";
2 | with "../drivers/hal/common";
3 |
4 | project SDCard_RPI2 is
5 |
6 | for Target use "arm-eabi";
7 | for Runtime ("Ada") use "ravenscar-sfp-rpi2";
8 |
9 | for Object_Dir use "obj/rpi2";
10 |
11 | for Main use ("sdcard_demo.adb");
12 | for Source_Dirs use ("src",
13 | "../common/utils",
14 | "../services/filesystem/**");
15 |
16 | package Compiler renames Common.Compiler;
17 |
18 | end SDCard_RPI2;
19 |
--------------------------------------------------------------------------------
/2048/demo_2048_stm32f469disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f469disco_full.gpr";
2 |
3 | project Demo_2048_STM32F469Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F469Disco_Full'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f469disco";
7 |
8 | for Main use ("demo_2048.adb");
9 | for Source_Dirs use ("src", "src/dsi");
10 |
11 | package Linker is
12 | for Default_Switches ("Ada") use
13 | ("-Wl,--defsym=__stack_size=32768",
14 | "-Wl,--gc-sections");
15 | end Linker;
16 |
17 | end Demo_2048_STM32F469Disco;
18 |
--------------------------------------------------------------------------------
/2048/demo_2048_stm32f746disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f746disco_full.gpr";
2 |
3 | project Demo_2048_STM32F746Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F746Disco_Full'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f746disco";
7 |
8 | for Main use ("demo_2048.adb");
9 | for Source_Dirs use ("src", "src/ltdc");
10 |
11 | package Linker is
12 | for Default_Switches ("Ada") use
13 | ("-Wl,--defsym=__stack_size=65536",
14 | "-Wl,--gc-sections");
15 | end Linker;
16 |
17 | end Demo_2048_STM32F746Disco;
18 |
--------------------------------------------------------------------------------
/2048/demo_2048_stm32f769disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f769disco_full.gpr";
2 |
3 | project Demo_2048_STM32F769Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F769Disco_Full'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f769disco";
7 |
8 | for Main use ("demo_2048.adb");
9 | for Source_Dirs use ("src", "src/dsi");
10 |
11 | package Linker is
12 | for Default_Switches ("Ada") use
13 | ("-Wl,--defsym=__stack_size=32768",
14 | "-Wl,--gc-sections");
15 | end Linker;
16 |
17 | end Demo_2048_STM32F769Disco;
18 |
--------------------------------------------------------------------------------
/fractals/fractals_stm32f429disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f429disco.gpr";
2 |
3 | project Fractals_STM32F429Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F429Disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f429disco";
7 |
8 | for Main use ("fractals_demo.adb");
9 | for Source_Dirs use ("src", "src/single");
10 |
11 | package Linker is
12 | for Default_Switches ("Ada") use
13 | ("-Wl,--defsym=__stack_size=16384",
14 | "-Wl,--gc-sections");
15 | end Linker;
16 |
17 | end Fractals_STM32F429Disco;
18 |
--------------------------------------------------------------------------------
/fractals/fractals_stm32f746disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f746disco.gpr";
2 |
3 | project Fractals_STM32F746Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F746Disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f746disco";
7 |
8 | for Main use ("fractals_demo.adb");
9 | for Source_Dirs use ("src", "src/single");
10 |
11 | package Linker is
12 | for Default_Switches ("Ada") use
13 | ("-Wl,--defsym=__stack_size=16384",
14 | "-Wl,--gc-sections");
15 | end Linker;
16 |
17 | end Fractals_STM32F746Disco;
18 |
--------------------------------------------------------------------------------
/fractals/fractals_stm32f769disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f769disco.gpr";
2 |
3 | project Fractals_STM32F769Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F769Disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f769disco";
7 |
8 | for Main use ("fractals_demo.adb");
9 | for Source_Dirs use ("src", "src/double");
10 |
11 | package Linker is
12 | for Default_Switches ("Ada") use
13 | ("-Wl,--defsym=__stack_size=16384",
14 | "-Wl,--gc-sections");
15 | end Linker;
16 |
17 | end Fractals_STM32F769Disco;
18 |
--------------------------------------------------------------------------------
/sdcard/sdcard_stm32f746disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f746disco.gpr";
2 |
3 | project SDCard_STM32F746Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F746Disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f746disco";
7 |
8 | for Main use ("sdcard_demo.adb");
9 | for Source_Dirs use ("src",
10 | "../services/filesystem/**");
11 |
12 | package Linker is
13 | for Default_Switches ("Ada") use
14 | ("-Wl,--defsym=__stack_size=32768",
15 | "-Wl,--gc-sections");
16 | end Linker;
17 |
18 | end SDCard_STM32F746Disco;
19 |
--------------------------------------------------------------------------------
/fractals/fractals_stm32f469disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f469disco_sfp.gpr";
2 |
3 | project Fractals_STM32F469Disco extends "../common/common.gpr" is
4 |
5 | for Target use STM32F469Disco_SFP'Target;
6 | for Runtime ("Ada") use STM32F469Disco_SFP'Runtime("Ada");
7 | for Object_Dir use "obj/stm32f469disco";
8 |
9 | for Main use ("fractals_demo.adb");
10 | for Source_Dirs use ("src", "src/single");
11 |
12 | package Linker is
13 | for Default_Switches ("Ada") use
14 | ("-Wl,--defsym=__stack_size=16384",
15 | "-Wl,--gc-sections");
16 | end Linker;
17 |
18 | end Fractals_STM32F469Disco;
19 |
--------------------------------------------------------------------------------
/wolf/wolf_rpi2.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/rpi2";
2 |
3 | project Wolf_RPi2 extends "wolf_common.gpr" is
4 |
5 | for Target use RPi2'Target;
6 | for Runtime ("Ada") use RPi2'Runtime ("Ada");
7 |
8 | for Source_Dirs use Project'Source_Dirs & ("src/rpi");
9 | for Object_Dir use "obj/rpi2";
10 |
11 | for Main use ("wolf_demo.adb");
12 |
13 | package Builder is
14 | for Switches ("Ada") use ("-s");
15 | end Builder;
16 |
17 | package Linker is
18 | for Default_Switches ("Ada") use
19 | Linker'Default_Switches ("Ada") &
20 | ("-Wl,--defsym=__stack_size=32768");
21 | end Linker;
22 |
23 | end Wolf_RPi2;
24 |
--------------------------------------------------------------------------------
/sdcard/sdcard_stm32f469disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f469disco_sfp.gpr";
2 |
3 | project SDCard_STM32F469Disco extends "../common/common.gpr" is
4 |
5 | for Target use STM32F469Disco_SFP'Target;
6 | for Runtime ("Ada") use STM32F469Disco_SFP'Runtime("Ada");
7 | for Object_Dir use "obj/stm32f469disco";
8 |
9 | for Main use ("sdcard_demo.adb");
10 | for Source_Dirs use
11 | ("src",
12 | "../services/filesystem/**");
13 |
14 | package Linker is
15 | for Default_Switches ("Ada") use
16 | ("-Wl,--defsym=__stack_size=32768",
17 | "-Wl,--gc-sections");
18 | end Linker;
19 |
20 | end SDCard_STM32F469Disco;
21 |
--------------------------------------------------------------------------------
/zynq-eth/eth_zynq.gpr:
--------------------------------------------------------------------------------
1 | project ETH_Zynq is
2 |
3 | type Boards is ("RPI2", "ZYNQ");
4 | Board : Boards := external ("BOARD", "RPI2");
5 |
6 | for Object_Dir use "obj";
7 |
8 | for Main use ("eth_demo.adb");
9 | for Source_Dirs use ("src",
10 | "../drivers/hal/src",
11 | "../common/utils",
12 | "../services/filesystem/",
13 | "../services/filesystem/mbr",
14 | "../services/filesystem/VFS",
15 | "../services/filesystem/FAT");
16 |
17 | package Compiler is
18 | for Default_Switches ("Ada") use ("-O", "-gnatyg-s");
19 | end Compiler;
20 |
21 | end ETH_Zynq;
22 |
--------------------------------------------------------------------------------
/sdcard/sdcard_stm32f769disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f769disco.gpr";
2 |
3 | project SDCard_STM32F769Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F769disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f769disco";
7 |
8 | for Main use ("sdcard_demo.adb");
9 | for Source_Dirs use
10 | ("src",
11 | "../services/filesystem/**");
12 |
13 | package Builder is
14 | for Switches ("Ada") use ("-s");
15 | end Builder;
16 |
17 | package Linker is
18 | for Default_Switches ("Ada") use
19 | ("-Wl,--defsym=__stack_size=32768",
20 | "-Wl,--gc-sections");
21 | end Linker;
22 |
23 | end SDCard_STM32F769Disco;
24 |
--------------------------------------------------------------------------------
/wav_player/wav_stm32f769disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f769disco.gpr";
2 |
3 | project WAV_STM32F769Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F769Disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f769disco";
7 |
8 | for Main use ("player.adb");
9 | for Source_Dirs use
10 | ("src",
11 | "../services/filesystem/**");
12 |
13 | package Binder is
14 | for Default_Switches ("Ada") use ("-D4096");
15 | end Binder;
16 |
17 | package Linker is
18 | for Default_Switches ("Ada") use
19 | ("-Wl,--defsym=__stack_size=32768",
20 | "-Wl,--gc-sections");
21 | end Linker;
22 |
23 | end WAV_STM32F769Disco;
24 |
--------------------------------------------------------------------------------
/wav_player/wav_stm32f746disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f746disco.gpr";
2 |
3 | project WAV_STM32F746Disco extends "../common/common.gpr" is
4 |
5 | for Runtime ("Ada") use STM32F746Disco'Runtime("Ada");
6 | for Object_Dir use "obj/stm32f746disco";
7 |
8 | for Main use ("player.adb");
9 | for Source_Dirs use
10 | ("src",
11 | "../services/filesystem/**");
12 |
13 | package Binder is
14 | for Default_Switches ("Ada") use
15 | ("-D8k");
16 | end Binder;
17 |
18 | package Linker is
19 | for Default_Switches ("Ada") use
20 | ("-Wl,--defsym=__stack_size=32768",
21 | "-Wl,--gc-sections");
22 | end Linker;
23 |
24 | end WAV_STM32F746Disco;
25 |
--------------------------------------------------------------------------------
/wolf/wolf_rpi3.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/rpi3";
2 |
3 | project Wolf_RPi3 extends "wolf_common.gpr" is
4 |
5 | type Yes_No_Type is ("yes", "no");
6 | Use_Tasking : Yes_No_Type := external ("Use_Tasking", "yes");
7 |
8 | for Target use RPi3'Target;
9 | for Runtime ("Ada") use RPi3'Runtime ("Ada");
10 |
11 | for Source_Dirs use Project'Source_Dirs & ("src/rpi");
12 | case Use_Tasking is
13 | when "yes" =>
14 | for Source_Dirs use project'Source_Dirs & ("src/rpi/tasking");
15 | when "no" =>
16 | for Source_Dirs use project'Source_Dirs & ("src/rpi/notasking");
17 | end case;
18 |
19 | for Object_Dir use "obj/rpi3";
20 |
21 | for Main use ("wolf_demo.adb");
22 |
23 | end Wolf_RPi3;
24 |
--------------------------------------------------------------------------------
/wav_player/wav_stm32f469disco.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/stm32f469disco_sfp.gpr";
2 |
3 | project WAV_STM32F469Disco extends "../common/common.gpr" is
4 |
5 | for Target use STM32F469Disco_SFP'Target;
6 | for Runtime ("Ada") use STM32F469Disco_SFP'Runtime("Ada");
7 | for Object_Dir use "obj/stm32f469disco";
8 |
9 | for Main use ("player.adb");
10 | for Source_Dirs use
11 | ("src",
12 | "../services/filesystem/**");
13 |
14 | package Binder is
15 | for Default_Switches ("Ada") use ("-D8k");
16 | end Binder;
17 |
18 | package Linker is
19 | for Default_Switches ("Ada") use
20 | ("-Wl,--defsym=__stack_size=65536",
21 | "-Wl,--gc-sections");
22 | end Linker;
23 |
24 | end WAV_STM32F469Disco;
25 |
--------------------------------------------------------------------------------
/rpi3-bluetooth/bt.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/boards/rpi3";
2 |
3 | project BT is
4 |
5 | for Target use RPi3'Target;
6 | for Runtime ("Ada") use RPi3'Runtime ("Ada");
7 |
8 | for Languages use ("Ada");
9 |
10 | for Source_Dirs use ("src");
11 | for Object_Dir use "obj/rpi3";
12 | for Exec_Dir use ".";
13 |
14 | for Main use ("bt.adb");
15 |
16 | package Builder is
17 | for Executable ("wolf_demo.adb") use "wolf_demo_rpi3";
18 | end Builder;
19 |
20 | package Compiler is
21 | for Switches ("Ada") use ("-O3", "-gnatyg-s", "-gnatwa.X");
22 | end Compiler;
23 |
24 | package Linker is
25 | for Default_Switches ("Ada") use
26 | ("-Wl,--defsym=__stack_size=32768",
27 | "-Wl,--gc-sections",
28 | "-Wl,--print-memory-usage");
29 | end Linker;
30 |
31 | end BT;
32 |
--------------------------------------------------------------------------------
/common/utils/hex_images.ads:
--------------------------------------------------------------------------------
1 | with HAL; use HAL;
2 | with Images_Gen;
3 |
4 | package Hex_Images is
5 | -- Hex2
6 |
7 | package Byte_Image_Pkg is new Images_Gen (2, UInt8);
8 |
9 | function Hex2 (V : UInt8) return Byte_Image_Pkg.Fixed_String
10 | renames Byte_Image_Pkg.Hex;
11 |
12 | -- Hex4
13 |
14 | package UInt16_Image_Pkg is new Images_Gen (4, UInt16);
15 |
16 | function Hex4 (V : UInt16) return UInt16_Image_Pkg.Fixed_String
17 | renames UInt16_Image_Pkg.Hex;
18 |
19 | -- Hex8
20 |
21 | package UInt32_Image_Pkg is new Images_Gen (8, UInt32);
22 |
23 | function Hex8 (V : UInt32) return UInt32_Image_Pkg.Fixed_String
24 | renames UInt32_Image_Pkg.Hex;
25 |
26 | -- Hex16
27 |
28 | package UInt64_Image_Pkg is new Images_Gen (16, UInt64);
29 |
30 | function Hex16 (V : UInt64) return UInt64_Image_Pkg.Fixed_String
31 | renames UInt64_Image_Pkg.Hex;
32 | end Hex_Images;
33 |
--------------------------------------------------------------------------------
/raspberrypi_demos.gpr:
--------------------------------------------------------------------------------
1 | aggregate project RaspberryPi_Demos is
2 |
3 | type Board_Type is
4 | ("rpi2",
5 | "rpi3"};
6 | Board : Board_Type := external ("Board", "rpi2");
7 |
8 | type RTS_Profile_Type is ("ravenscar-sfp", "ravenscar-full");
9 | RTS_Profile : RTS_Profile_Type := external ("RTS", "ravenscar-sfp");
10 |
11 | type BUILD_TYPE is ("Debug", "Production");
12 | Build : BUILD_Type := external ("PLATFORM_BUILD", "Debug");
13 |
14 | case Board is
15 | when "rpi2" =>
16 | for Target use "arm-eabi";
17 | when "rpi3" =>
18 | for Target use "aarch64-elf";
19 | end case;
20 |
21 | for Runtime ("Ada") use RTS_Profile & "-" & Board;
22 |
23 | for External ("RTS_Profile") use RTS_Profile;
24 | for External ("PLATFORM_BUILD") use Build;
25 |
26 | for Project_Files use
27 | ("wolf/wolf_" & Board & ".gpr",
28 | "rpi2-mmc/sdcard_" & Board & ".gpr");
29 |
30 | end RaspberryPi_Demos;
31 |
--------------------------------------------------------------------------------
/stm32f429_demos.gpr:
--------------------------------------------------------------------------------
1 | aggregate project STM32F429_Demos is
2 |
3 | type RTS_Profile_Type is ("ravenscar-sfp", "ravenscar-full");
4 | RTS_Profile : RTS_Profile_Type := external ("RTS", "ravenscar-sfp");
5 |
6 | type BUILD_TYPE is ("Debug", "Production");
7 | Build : BUILD_Type := external ("PLATFORM_BUILD", "Debug");
8 |
9 | for Target use "arm-eabi";
10 | for Runtime ("Ada") use RTS_Profile & "-stm32f429disco";
11 |
12 | for External ("RTS") use RTS_Profile;
13 | for External ("PLATFORM_BUILD") use Build;
14 |
15 | for Project_Files use
16 | ("balls/balls_stm32f429disco.gpr",
17 | "conway/conway_stm32f429disco.gpr",
18 | "fractals/fractals_stm32f429disco.gpr",
19 | "wolf/wolf_stm32f429disco.gpr");
20 |
21 | package Ide is
22 | for Program_Host use "localhost:4242";
23 | for Communication_Protocol use "remote";
24 | for Connection_Tool use "st-util";
25 | end Ide;
26 |
27 | end STM32F429_Demos;
28 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | SFP_DEMOS=balls conway fractals sdcard wav_player wolf rpi2-mmc
2 | FULL_DEMOS=2048 $(SFP_DEMOS)
3 |
4 | BUILD=Debug
5 |
6 | GPRBUILD=gprbuild -XBUILD=$(BUILD)
7 |
8 | all: sfp full
9 |
10 | sfp:
11 | for f in $(SFP_DEMOS); do \
12 | for p in $$f/*.gpr; do \
13 | echo $$p | grep common > /dev/null; \
14 | if [ $$? = 1 ]; then \
15 | echo $$p; \
16 | $(GPRBUILD) -XRTS=ravenscar-sfp -P $$p -p -q -j0; \
17 | fi; \
18 | done; \
19 | done
20 |
21 | full:
22 | for f in $(FULL_DEMOS); do \
23 | for p in $$f/*.gpr; do \
24 | echo $$p; \
25 | $(GPRBUILD) -XRTS=ravenscar-full -P $$p -p -q -j0; \
26 | done; \
27 | done
28 |
29 | clean:
30 | for f in $(FULL_DEMOS); do \
31 | for p in $$f/*.gpr; do \
32 | echo $$p; \
33 | gprclean -XRTS=ravenscar-full -P $$p -q -r; \
34 | done; \
35 | done
36 | for f in $(SFP_DEMOS); do \
37 | for p in $$f/*.gpr; do \
38 | echo $$p; \
39 | gprclean -XRTS=ravenscar-sfp -P $$p -q -r; \
40 | done; \
41 | done
42 |
--------------------------------------------------------------------------------
/common/common.gpr:
--------------------------------------------------------------------------------
1 | with "../drivers/hal/config";
2 |
3 | project Common is
4 |
5 | type Build_Type is ("Debug", "Production");
6 | Build : Build_Type := external ("PLATFORM_BUILD", "Debug");
7 |
8 | for Languages use ("Ada");
9 | for Source_Dirs use ("gui");
10 |
11 | package Compiler is
12 | case Build is
13 | when "Production" =>
14 | for Default_Switches ("Ada") use
15 | ("-g", "-O2", "-gnatp", "-gnatn");
16 | when "Debug" =>
17 | for Default_Switches ("Ada") use
18 | ("-g", "-O0", "-gnata", "-gnatwae");
19 | end case;
20 | for Default_Switches ("ada") use Compiler'Default_Switches ("Ada") &
21 | ("-gnaty", "-ffunction-sections", "-fdata-sections",
22 | "-fcallgraph-info=su");
23 | end Compiler;
24 |
25 | package Linker is
26 | for Default_Switches ("Ada") use
27 | ("-Wl,--gc-sections");
28 | end Linker;
29 |
30 | package Ide is
31 | for Program_Host use "10.211.55.13:4242";
32 | for Communication_Protocol use "remote";
33 | for Connection_Tool use "st-util"; -- ??? Not true anymore.
34 | end Ide;
35 |
36 | end Common;
37 |
--------------------------------------------------------------------------------
/stm32f469_demos.gpr:
--------------------------------------------------------------------------------
1 | aggregate project STM32F469_Demos is
2 |
3 | type RTS_Profile_Type is ("ravenscar-sfp", "ravenscar-full");
4 | RTS_Profile : RTS_Profile_Type := external ("RTS", "ravenscar-sfp");
5 |
6 | type BUILD_TYPE is ("Debug", "Production");
7 | Build : BUILD_Type := external ("PLATFORM_BUILD", "Debug");
8 |
9 | for Target use "arm-eabi";
10 | for Runtime ("Ada") use RTS_Profile & "-stm32f469disco";
11 |
12 | for External ("RTS") use RTS_Profile;
13 | for External ("PLATFORM_BUILD") use Build;
14 |
15 | for Project_Files use
16 | ("balls/balls_stm32f469disco.gpr",
17 | "conway/conway_stm32f469disco.gpr",
18 | "fractals/fractals_stm32f469disco.gpr",
19 | "sdcard/sdcard_stm32f469disco.gpr",
20 | "wav_player/wav_stm32f469disco.gpr",
21 | "wolf/wolf_stm32f469disco.gpr");
22 |
23 | case RTS_Profile is
24 | when "ravenscar-full" =>
25 | for Project_Files use Project'Project_Files &
26 | ("2048/demo_2048_stm32f469disco.gpr");
27 | when others =>
28 | end case;
29 |
30 | package Ide is
31 | for Program_Host use "localhost:4242";
32 | for Communication_Protocol use "remote";
33 | for Connection_Tool use "st-util";
34 | end Ide;
35 |
36 | end STM32F469_Demos;
37 |
--------------------------------------------------------------------------------
/stm32f746_demos.gpr:
--------------------------------------------------------------------------------
1 | aggregate project STM32F746_Demos is
2 |
3 | type RTS_Profile_Type is ("ravenscar-sfp", "ravenscar-full");
4 | RTS_Profile : RTS_Profile_Type := external ("RTS", "ravenscar-sfp");
5 |
6 | type BUILD_TYPE is ("Debug", "Production");
7 | Build : BUILD_Type := external ("PLATFORM_BUILD", "Debug");
8 |
9 | for Target use "arm-eabi";
10 | for Runtime ("Ada") use RTS_Profile & "-stm32f746disco";
11 |
12 | for External ("RTS") use RTS_Profile;
13 | for External ("PLATFORM_BUILD") use Build;
14 |
15 | for Project_Files use
16 | ("balls/balls_stm32f746disco.gpr",
17 | "conway/conway_stm32f746disco.gpr",
18 | "fractals/fractals_stm32f746disco.gpr",
19 | "sdcard/sdcard_stm32f746disco.gpr",
20 | "wav_player/wav_stm32f746disco.gpr",
21 | "wolf/wolf_stm32f746disco.gpr");
22 |
23 | case RTS_Profile is
24 | when "ravenscar-full" =>
25 | for Project_Files use Project'Project_Files &
26 | ("2048/demo_2048_stm32f746disco.gpr");
27 | when others =>
28 | end case;
29 |
30 | package Ide is
31 | for Program_Host use "localhost:4242";
32 | for Communication_Protocol use "remote";
33 | for Connection_Tool use "st-util";
34 | end Ide;
35 |
36 | end STM32F746_Demos;
37 |
--------------------------------------------------------------------------------
/stm32f769_demos.gpr:
--------------------------------------------------------------------------------
1 | aggregate project STM32F769_Demos is
2 |
3 | type RTS_Profile_Type is ("ravenscar-sfp", "ravenscar-full");
4 | RTS_Profile : RTS_Profile_Type := external ("RTS", "ravenscar-sfp");
5 |
6 | type BUILD_TYPE is ("Debug", "Production");
7 | Build : BUILD_Type := external ("PLATFORM_BUILD", "Debug");
8 |
9 | for Target use "arm-eabi";
10 | for Runtime ("Ada") use RTS_Profile & "-stm32f769disco";
11 |
12 | for External ("RTS") use RTS_Profile;
13 | for External ("PLATFORM_BUILD") use Build;
14 |
15 | for Project_Files use
16 | ("balls/balls_stm32f769disco.gpr",
17 | "conway/conway_stm32f769disco.gpr",
18 | "fractals/fractals_stm32f769disco.gpr",
19 | "sdcard/sdcard_stm32f769disco.gpr",
20 | "wav_player/wav_stm32f769disco.gpr",
21 | "wolf/wolf_stm32f769disco.gpr");
22 |
23 | case RTS_Profile is
24 | when "ravenscar-full" =>
25 | for Project_Files use Project'Project_Files &
26 | ("2048/demo_2048_stm32f769disco.gpr");
27 | when others =>
28 | end case;
29 |
30 | package Ide is
31 | for Program_Host use "localhost:4242";
32 | for Communication_Protocol use "remote";
33 | for Connection_Tool use "st-util";
34 | end Ide;
35 |
36 | end STM32F769_Demos;
37 |
--------------------------------------------------------------------------------
/fractals/src/fractals.ads:
--------------------------------------------------------------------------------
1 | with Float_Support; use Float_Support;
2 |
3 | package Fractals is
4 |
5 | type Coordinate is record
6 | X : Base_Float;
7 | Y : Base_Float;
8 | end record;
9 |
10 | type Screen is record
11 | X0, Y0, Width, Height : Base_Float;
12 | end record;
13 |
14 | type Fractal is abstract tagged null record;
15 | type Fractal_Ref is access all Fractal'Class;
16 |
17 | function Default_Screen (F : Fractal) return Screen is abstract;
18 | function Compute
19 | (F : Fractal;
20 | Z0 : Coordinate;
21 | Max_Depth : Natural) return Natural
22 | is abstract;
23 |
24 | type Fractal_Mandelbrot is new Fractal with null record;
25 |
26 | overriding function Default_Screen (F : Fractal_Mandelbrot) return Screen
27 | is (-2.5, -1.0, 3.5, 2.0);
28 |
29 | overriding function Compute
30 | (F : Fractal_Mandelbrot;
31 | Z0 : Coordinate;
32 | Max_Depth : Natural) return Natural;
33 |
34 | type Fractal_Julia is new Fractal with null record;
35 |
36 | overriding function Default_Screen (F : Fractal_Julia) return Screen
37 | is (-1.5, -1.0, 3.0, 2.0);
38 |
39 | overriding function Compute
40 | (F : Fractal_Julia;
41 | Z0 : Coordinate;
42 | Max_Depth : Natural) return Natural;
43 |
44 | Mandelbrot : aliased Fractal_Mandelbrot;
45 | Julia : aliased Fractal_Julia;
46 |
47 | end Fractals;
48 |
--------------------------------------------------------------------------------
/services/README.md:
--------------------------------------------------------------------------------
1 | Overview
2 | --------
3 |
4 | This folder contains a prototype version of Filesystem support library
5 | written in Ada. This is not strictly speaking part of this demo repository
6 | and is meant to be moved to a standalone repository at some point.
7 |
8 | The reason of its presence here is to allow filesystem access within some
9 | of the demos (sdcard and wav_reader demos).
10 |
11 | Features
12 | --------
13 |
14 | This library is composed of several components:
15 | * filesystem: an interface definition for filesystem support
16 | * filesystem.MBR: support for Master Boot Record partitions
17 | * filesystem.VFS: support for virtual mount points
18 | * filesystem.FAT: support for FAT16/FAT32
19 |
20 | Status
21 | ------
22 |
23 | MBR and VFS should work OK, they're very simple packages.
24 |
25 | FAT support for FAT32 should not destroy completely your data, however:
26 | * it is strongly advised to use the library on a support where no important
27 | data is present
28 | * in particular, the write mode should be ok most of the time, but is still
29 | very experimental
30 | * FAT16 support is still work in progress.
31 |
32 | Roadmap
33 | -------
34 |
35 | * provide a common handle memory pool, to allow the usage of a static pool
36 | of generic handles
37 | * add support for GUID partitions
38 | * strengthen and add more testing of the write functionality
39 | * add support for creating a MBR from scratch, and formatting a new partition.
40 |
41 | License
42 | -------
43 |
44 | The license of this library is GPL+Runtime exception.
45 |
--------------------------------------------------------------------------------
/fractals/src/fractals.adb:
--------------------------------------------------------------------------------
1 | package body Fractals is
2 |
3 | function Square (C : Coordinate) return Coordinate
4 | is ((C.X ** 2 - C.Y ** 2, 2.0 * C.X * C.Y))
5 | with Inline_Always;
6 |
7 | function Square (C : Coordinate) return Base_Float
8 | is (C.X ** 2 + C.Y ** 2)
9 | with Inline_Always;
10 |
11 | function "+" (C1, C2 : Coordinate) return Coordinate
12 | is ((C1.X + C2.X, C1.Y + C2.Y))
13 | with Inline_Always;
14 |
15 | -------------
16 | -- Compute --
17 | -------------
18 |
19 | overriding function Compute
20 | (F : Fractal_Mandelbrot;
21 | Z0 : Coordinate;
22 | Max_Depth : Natural) return Natural
23 | is
24 | pragma Unreferenced (F);
25 | Z : Coordinate := (0.0, 0.0);
26 | Iter : Natural := 0;
27 | begin
28 | while Square (Z) <= 4.0 and then Iter < Max_Depth loop
29 | Z := Square (Z) + Z0;
30 | Iter := Iter + 1;
31 | end loop;
32 |
33 | return Iter;
34 | end Compute;
35 |
36 | -------------
37 | -- Compute --
38 | -------------
39 |
40 | overriding function Compute
41 | (F : Fractal_Julia;
42 | Z0 : Coordinate;
43 | Max_Depth : Natural) return Natural
44 | is
45 | pragma Unreferenced (F);
46 | C : constant Coordinate := (-0.7, 0.27015);
47 | Z : Coordinate := Z0;
48 | Iter : Natural := 0;
49 | begin
50 | while Square (Z) <= 4.0 and then Iter < Max_Depth loop
51 | Z := Square (Z) + C;
52 | Iter := Iter + 1;
53 | end loop;
54 |
55 | return Iter;
56 | end Compute;
57 |
58 | end Fractals;
59 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Bare Metal demos written in Ada
2 | ===============================
3 |
4 | Important notice
5 | ----------------
6 |
7 | This repository uses submodules. To clone it, you need to use the --recursive git option:
8 |
9 | $ git clone --recursive https://github.com/lambourg/Ada_Bare_Metal_Demos.git
10 |
11 | You will also need run-time support for your board. More instruction can be
12 | found in the Ada Drivers Library submodule (the drivers folder). You can also
13 | see directly the installation instructions at https://github.com/AdaCore/embedded-runtimes.git
14 |
15 | In order to build and flash those demos on your specific target, you will need
16 | an Ada run-time supporting your board. You can also see directly
17 | https://github.com/AdaCore/embedded-runtimes.git to build and install various
18 | run-times targeting ARM boards.
19 |
20 | Content:
21 | --------
22 |
23 | The following demos/examples are available:
24 |
25 | * **2048**: A demo of the famous game, with automatic solver, for STM32 discovery boards
26 | * **balls**: Simple bouncing balls, for STM32 discovery boards
27 | * **conway**: A version of the "Game of Life", for STM32 discovery boards
28 | * **fractals**: Mandelbrot/Julia fractals calculator, with zooming capability using the touch screen, for STM32 discovery boards
29 | * **rpi2-mmc**: SD/MMC card demo for the Raspberry Pi2/Pi3
30 | * **sdcard**: SDCard demo for the STM32 discovery boards
31 | * **wav_player**: A simple WAV player to play songs from sdcards. For the STM32Disco boards with display and audio support.
32 | * **wolf**: A raycaster demo "a la" Castle Wolfenstein. For STM32disco and
33 | raspberry pi2/3 boards.
34 | * **zynq-eth**: Ethernet experimentations for the Zynq7k.
35 |
36 | This repository also contains a FAT FS Library that is used by some of the
37 | demos. This library is present in the 'services' folder.
38 |
--------------------------------------------------------------------------------
/wolf/src/renderer.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | package Renderer is
25 |
26 | procedure Initialize;
27 |
28 | procedure Draw_Frame;
29 |
30 | end Renderer;
31 |
--------------------------------------------------------------------------------
/2048/src/framebuffer_helper.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | package Framebuffer_Helper is
25 |
26 | procedure Update_All_Layers;
27 |
28 | end Framebuffer_Helper;
29 |
--------------------------------------------------------------------------------
/conway/src/conway_driver.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with System;
25 |
26 | package Conway_Driver is
27 |
28 | task Driver is
29 | pragma Storage_Size (16 * 1024);
30 | pragma Priority (System.Default_Priority);
31 | end Driver;
32 |
33 | end Conway_Driver;
34 |
--------------------------------------------------------------------------------
/2048/src/solver.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Grid;
25 |
26 | package Solver is
27 |
28 | type Move_Type is (Up, Down, Left, Right, None);
29 | subtype Valid_Move_Type is Move_Type range Up .. Right;
30 |
31 | procedure Init_Solver;
32 |
33 | function Next_Move (The_Grid : Grid.CGrid) return Move_Type;
34 |
35 | end Solver;
36 |
--------------------------------------------------------------------------------
/2048/src/ltdc/framebuffer_helper.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with STM32.Board; use STM32.Board;
25 |
26 | package body Framebuffer_Helper is
27 |
28 | procedure Update_All_Layers is
29 | begin
30 | Display.Update_Layers (Copy_Layer1 => True,
31 | Copy_Layer2 => True);
32 | end Update_All_Layers;
33 |
34 | end Framebuffer_Helper;
35 |
--------------------------------------------------------------------------------
/2048/src/dsi/framebuffer_helper.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with STM32.Board; use STM32.Board;
25 |
26 | package body Framebuffer_Helper is
27 |
28 | procedure Update_All_Layers
29 | is
30 | begin
31 | -- With the DSIHost, there's no need to "copy back" data as there's
32 | -- only one frame buffer per layer, the driver pushing it upon request
33 | -- to the display.
34 | Display.Update_Layers;
35 | end Update_All_Layers;
36 |
37 | end Framebuffer_Helper;
38 |
--------------------------------------------------------------------------------
/all_demos.gpr:
--------------------------------------------------------------------------------
1 | aggregate project All_Demos is
2 |
3 | type Board_Type is
4 | ("stm32f429disco",
5 | "stm32f469disco",
6 | "stm32f746disco",
7 | "stm32f769disco",
8 | "rpi2",
9 | "rpi3"};
10 | Board : Board_Type := external ("Board", "stm32f429disco");
11 |
12 | type RTS_Profile_Type is ("ravenscar-sfp", "ravenscar-full");
13 | RTS_Profile : RTS_Profile_Type := external ("RTS", "ravenscar-sfp");
14 |
15 | type BUILD_TYPE is ("Debug", "Production");
16 | Build : BUILD_Type := external ("PLATFORM_BUILD", "Debug");
17 |
18 | case Board is
19 | when "rpi3" =>
20 | for Target use "aarch64-elf";
21 | when others =>
22 | for Target use "arm-eabi";
23 | end case;
24 |
25 | for Runtime ("Ada") use RTS_Profile & "-" & Board;
26 |
27 | for External ("RTS_Profile") use RTS_Profile;
28 | for External ("PLATFORM_BUILD") use Build;
29 |
30 | case Board is
31 | when "stm32f429disco" =>
32 | for Project_Files use
33 | ("balls/balls_stm32f429disco.gpr",
34 | "conway/conway_stm32f429disco.gpr",
35 | "fractals/fractals_stm32f429disco.gpr",
36 | "wolf/wolf_stm32f429disco.gpr");
37 | when "stm32f469disco" | "stm32f746disco" | "stm32f769disco" =>
38 | for Project_Files use
39 | ("balls/balls_" & Board & ".gpr",
40 | "conway/conway_" & Board & ".gpr",
41 | "fractals/fractals_" & Board & ".gpr",
42 | "sdcard/sdcard_" & Board & ".gpr",
43 | "wav_player/wav_" & Board & ".gpr",
44 | "wolf/wolf_" & Board & ".gpr");
45 |
46 | case RTS_Profile is
47 | when "ravenscar-full" =>
48 | for Project_Files use Project'Project_Files &
49 | ("2048/demo_2048_stm32f769disco.gpr");
50 | when others =>
51 | end case;
52 | when "rpi2" | "rpi3" =>
53 | for Project_Files use
54 | ("wolf/wolf_" & Board & ".gpr",
55 | "rpi2-mmc/sdcard_" & Board & ".gpr");
56 | end case;
57 |
58 |
59 | package Ide is
60 | for Program_Host use "localhost:4242";
61 | for Communication_Protocol use "remote";
62 | for Connection_Tool use "st-util";
63 | end Ide;
64 |
65 | end All_Demos;
66 |
--------------------------------------------------------------------------------
/wolf/src/textures.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with HAL; use HAL;
25 |
26 | package Textures is
27 |
28 | Texture_Size : constant := 128;
29 |
30 | type Texture_Column is array (0 .. Texture_Size - 1) of UInt16
31 | with Component_Size => 16;
32 |
33 | type Texture is array (0 .. Texture_Size - 1) of aliased Texture_Column
34 | with Pack;
35 |
36 | type Texture_Column_Access is access constant Texture_Column;
37 |
38 | type Texture_Access is access constant Texture;
39 |
40 | end Textures;
41 |
--------------------------------------------------------------------------------
/wolf/src/rpi/bitmap.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with System;
25 |
26 | with HAL;
27 | with HAL.Bitmap;
28 | with RPi.Bitmap;
29 |
30 | package Bitmap is
31 |
32 | subtype Bitmap_Buffer is RPi.Bitmap.RPi_Bitmap_Buffer;
33 |
34 | Null_Buffer : constant Bitmap_Buffer :=
35 | (Addr => System.Null_Address,
36 | Width => 0,
37 | Height => 0,
38 | Color_Mode => HAL.Bitmap.L_8,
39 | Swapped => False);
40 |
41 | end Bitmap;
42 |
--------------------------------------------------------------------------------
/wav_player/src/gui.ads:
--------------------------------------------------------------------------------
1 | -----------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2016, J. Lambourg --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Gestures;
25 | with Wav_Player;
26 |
27 | package GUI is
28 |
29 | procedure Initialize;
30 |
31 | procedure Display_Error (Msg : String);
32 | procedure Display_Message (Msg : String);
33 |
34 | procedure DB_Updated (Card_Present : Boolean);
35 | -- To call when a SDCard is inserted
36 |
37 | procedure On_Audio_Event (Event : Wav_Player.Audio_State);
38 | procedure On_Gesture_Event (Event : Gestures.Gesture_Data);
39 |
40 | procedure Main_Loop;
41 |
42 | end GUI;
43 |
--------------------------------------------------------------------------------
/2048/src/status.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with HAL.Bitmap; use HAL.Bitmap;
25 | with Bitmapped_Drawing; use Bitmapped_Drawing;
26 |
27 | package Status is
28 |
29 | procedure Init_Area (Buffer : HAL.Bitmap.Bitmap_Buffer'Class);
30 |
31 | procedure Set_Score
32 | (Score : Natural);
33 |
34 | function Has_Buttons return Boolean;
35 |
36 | procedure Set_Autoplay_Enabled (State : Boolean);
37 |
38 | procedure Set_Autoplay (State : Boolean);
39 |
40 | function Get_Autoplay_Btn_Area return Rect;
41 |
42 | end Status;
43 |
--------------------------------------------------------------------------------
/wolf/src/stm32/bitmap.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with System;
25 |
26 | with HAL;
27 | with HAL.Bitmap;
28 |
29 | with STM32.DMA2D_Bitmap;
30 |
31 | package Bitmap is
32 |
33 | subtype Bitmap_Buffer is STM32.DMA2D_Bitmap.DMA2D_Bitmap_Buffer;
34 |
35 | Null_Buffer : constant Bitmap_Buffer :=
36 | (Addr => System.Null_Address,
37 | Width => 0,
38 | Height => 0,
39 | Color_Mode => HAL.Bitmap.L_8,
40 | Swapped => False);
41 |
42 | end Bitmap;
43 |
--------------------------------------------------------------------------------
/wolf/src/math.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | package Math is
25 | pragma Elaborate_Body;
26 |
27 | type Degree is mod 3600;
28 |
29 | function Cos (Angle : Degree) return Float with Inline_Always;
30 |
31 | function Sin (Angle : Degree) return Float with Inline_Always;
32 |
33 | function Tan (Angle : Degree) return Float with Inline_Always;
34 |
35 | function Arctan (F : Float) return Degree with Inline_Always;
36 |
37 | function Sqrt (X : Float) return Float
38 | with Import,
39 | Convention => Intrinsic,
40 | External_Name => "__builtin_sqrtf";
41 |
42 | end Math;
43 |
--------------------------------------------------------------------------------
/services/filesystem/filesystem.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Ada Filesystem Library --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | package body Filesystem is
25 |
26 | ------------------
27 | -- Generic_Read --
28 | ------------------
29 |
30 | function Generic_Read
31 | (File : File_Handle;
32 | Value : out T) return Status_Code
33 | is
34 | L : File_Size := T'Size / 8;
35 | begin
36 | return File.Read (Value'Address, L);
37 | end Generic_Read;
38 |
39 | -------------------
40 | -- Generic_Write --
41 | -------------------
42 |
43 | function Generic_Write
44 | (File : File_Handle;
45 | Value : T) return Status_Code
46 | is
47 | begin
48 | return File.Write (Value'Address, T'Size / 8);
49 | end Generic_Write;
50 |
51 | end Filesystem;
52 |
--------------------------------------------------------------------------------
/wolf/src/stm32/wolf_demo.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Last_Chance_Handler;
25 | pragma Unreferenced (Last_Chance_Handler);
26 |
27 |
28 | with STM32.Board; use STM32.Board;
29 | with STM32.SDRAM;
30 | with HAL.Bitmap;
31 | with HAL.Framebuffer; use HAL.Framebuffer;
32 |
33 | with Playground; use Playground;
34 |
35 | -- A simple raycasting demo
36 | procedure Wolf_Demo
37 | is
38 | begin
39 | STM32.SDRAM.Initialize;
40 | Display.Initialize (HAL.Framebuffer.Landscape, HAL.Framebuffer.Interrupt);
41 | Display.Initialize_Layer
42 | (Layer => 1,
43 | Mode => Playground.Color_Mode);
44 | Display.Initialize_Layer
45 | (Layer => 2,
46 | Mode => HAL.Bitmap.ARGB_1555,
47 | X => 5,
48 | Y => 5,
49 | Width => 25 * 12, -- 25 characters
50 | Height => 5 * 12); -- 5 lines
51 |
52 | Playground.Play;
53 | end Wolf_Demo;
54 |
--------------------------------------------------------------------------------
/2048/src/malloc.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | -- A simple implementation of storage allocation (malloc etc) for ZFP use
25 |
26 | pragma Restrictions (No_Elaboration_Code);
27 |
28 | with HAL; use HAL;
29 | with System; use System;
30 | with Interfaces.C; use Interfaces.C;
31 |
32 | package Malloc is
33 | pragma Elaborate_Body;
34 |
35 | function Alloc (Size : size_t) return Address;
36 | pragma Export (C, Alloc, "malloc");
37 |
38 | procedure Free (Ptr : Address);
39 | pragma Export (C, Free, "free");
40 |
41 | function Realloc (Ptr : Address; Size : size_t) return Address;
42 | pragma Export (C, Realloc, "realloc");
43 |
44 | procedure Start_Fast_Malloc (Byte_Size : UInt32);
45 |
46 | function Allocated return UInt32;
47 | -- Total allocated memory
48 |
49 | function Is_Full return Boolean;
50 | -- In 'fast malloc' mode, tells if we've allocated the full buffer
51 |
52 | end Malloc;
53 |
--------------------------------------------------------------------------------
/conway/src/conway_demo.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | -- The file declares the main procedure for the demonstration.
25 |
26 | with Conway_Driver; pragma Unreferenced (Conway_Driver);
27 | -- The Conway_Driver package contains the task that actually controls the app.
28 | -- Although it is not referenced directly in the main procedure, we need it
29 | -- in the closure of the context clauses so that it will be included in the
30 | -- executable.
31 |
32 | with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
33 | -- The "last chance handler" is the user-defined routine that is called when
34 | -- an exception is propagated. We need it in the executable, therefore it
35 | -- must be somewhere in the closure of the context clauses.
36 |
37 | with Ada.Real_Time;
38 | with System;
39 |
40 | procedure Conway_Demo is
41 | pragma Priority (System.Priority'First);
42 | begin
43 | delay until Ada.Real_Time.Time_Last;
44 | end Conway_Demo;
45 |
--------------------------------------------------------------------------------
/wolf/src/rpi/wolf_demo.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | -- with Ada.Exceptions;
25 | with Ada.Text_IO; use Ada.Text_IO;
26 |
27 | with RPi.Framebuffer; use RPi.Framebuffer;
28 |
29 | with Playground;
30 | with Rpi_Board; use Rpi_Board;
31 |
32 | -- A simple raycasting demo
33 | -- Below, we're using the follwing conventions:
34 | --
35 | -- Coordinates:
36 | -- +---> X
37 | -- |
38 | -- |
39 | -- v y
40 | --
41 | -- with angles in tenth of degrees, anticlockwise.
42 |
43 | procedure Wolf_Demo
44 | is
45 |
46 | begin
47 | Put_Line ("Setup display");
48 | Initialize (Display, Display_Width, Display_Height, 2);
49 | Put_Line ("Display initialized");
50 |
51 | Put_Line ("Now starting ...");
52 |
53 | Playground.Play;
54 |
55 | -- exception
56 | -- when E : others =>
57 | -- Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E));
58 | -- loop
59 | -- null;
60 | -- end loop;
61 | end Wolf_Demo;
62 |
--------------------------------------------------------------------------------
/wav_player/src/wav_player.ads:
--------------------------------------------------------------------------------
1 | -----------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2016, J. Lambourg --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with HAL.Audio;
25 |
26 | with Wav_DB;
27 |
28 | package Wav_Player is
29 |
30 | type Audio_State is
31 | (Playing,
32 | Paused,
33 | Stopped);
34 |
35 | type Volume_Level is record
36 | L : Float;
37 | R : Float;
38 | end record;
39 |
40 | type State_Changed_CB is access procedure (New_State : Audio_State);
41 |
42 | procedure Initialize
43 | (Volume : HAL.Audio.Audio_Volume;
44 | State_CB : not null State_Changed_CB);
45 | -- Initializes the Audio device and internal structures.
46 |
47 | procedure Play
48 | (Track : Wav_DB.Track_Id);
49 | -- Plays the track.
50 |
51 | function Current_Volume return Volume_Level;
52 | -- Current Volume of the playing Buffer. This is calculated from an RMS
53 | -- (Root-Sqare of Mean Squares) of the currently playing buffer.
54 |
55 | procedure Pause;
56 |
57 | procedure Resume;
58 |
59 | procedure Stop;
60 |
61 | end Wav_Player;
62 |
--------------------------------------------------------------------------------
/wolf/gen/pngtoada.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | try:
4 | import png
5 | except:
6 | raise Exception ('pypng is missing.')
7 | import os
8 |
9 |
10 | def gen_ada(filename, pkg, dest):
11 | content = []
12 |
13 | argb_mode = False
14 |
15 | with open(filename, "rb") as finput:
16 | r = png.Reader(file=finput)
17 | (width, height, pixels, properties) = r.asRGBA()
18 | for line in pixels:
19 | cols = []
20 | for j in range(width):
21 | a = line[4 * j + 3]
22 | if a < 128:
23 | argb_mode = True
24 | cols.append([0, 0, 0, 0])
25 | else:
26 | r = line[4 * j]
27 | g = line[4 * j + 1]
28 | b = line[4 * j + 2]
29 | cols.append([255, r, g, b])
30 | content.append (cols)
31 |
32 | if argb_mode:
33 | print "ARGB_1555 mode"
34 | else:
35 | print "RGB_565 mode"
36 |
37 | with open(dest, 'w') as fout:
38 | n_line = 1
39 | fout.write("package %s is\n\n" % pkg)
40 | fout.write(" Bmp : aliased constant Texture :=\n")
41 | for y in range(height):
42 | cols = []
43 | for x in range(width):
44 | values = content[x][y]
45 | if argb_mode:
46 | a = values[0] >> 7
47 | r = values[1] >> 3
48 | g = values[2] >> 3
49 | b = values[3] >> 3
50 | val = (a << 15) | (r << 10) | (g << 5) | b
51 | else:
52 | r = values[1] >> 3
53 | g = values[2] >> 2
54 | b = values[3] >> 3
55 | val = (r << 11) | (g << 5) | b
56 | cols.append('16#%x#' % val)
57 | if n_line == 1:
58 | fout.write(" (")
59 | else:
60 | fout.write(" ")
61 | fout.write("(%s)" % ", ".join(cols))
62 | if n_line == height:
63 | fout.write(");\n")
64 | else:
65 | fout.write(",\n")
66 | n_line += 1
67 | fout.write("\nend %s;\n" % pkg)
68 |
69 |
70 | def is_png(pics, fname):
71 | base, ext = os.path.splitext(fname)
72 | return os.path.isfile(os.path.join(pics, fname)) and ext == '.png'
73 |
74 |
75 | pics = os.path.abspath("./pics")
76 | files = [f for f in os.listdir(pics) if is_png(pics, f)]
77 | for f in files:
78 | pkg, _ = os.path.splitext(os.path.basename(f))
79 | src = os.path.join('..', 'pics', 'textures-%s.ads' % pkg)
80 | pkg = "Textures.%s" % pkg.title()
81 | print src
82 | gen_ada(os.path.join(pics, f), pkg, src)
83 |
--------------------------------------------------------------------------------
/common/gui/gestures.ads:
--------------------------------------------------------------------------------
1 | -----------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2016, J. Lambourg --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | package Gestures is
25 |
26 | type Gesture_Id is
27 | (No_Gesture,
28 | V_Scroll,
29 | H_Scroll,
30 | Tap,
31 | Long_Tap);
32 | subtype Scroll_Id is Gesture_Id range V_Scroll .. H_Scroll;
33 |
34 | type Coordinate is record
35 | X : Natural;
36 | Y : Natural;
37 | end record;
38 |
39 | type Touch_Point is record
40 | Point : Coordinate;
41 | Active : Boolean;
42 | end record;
43 |
44 | Inactive_Point : constant Touch_Point := ((0, 0), False);
45 |
46 | type Touch_Points is array (1 .. 2) of Touch_Point;
47 |
48 | type Gesture_Data is record
49 | Id : Gesture_Id := No_Gesture;
50 | Distance : Integer := 0;
51 | Cumulated : Integer := 0;
52 | Speed : Float := 0.0;
53 | Origin : Coordinate := (0, 0);
54 | end record;
55 |
56 | No_Gesture_Data : constant Gesture_Data := (others => <>);
57 |
58 | type Gesture_CB is access procedure (New_Gesture : Gesture_Data);
59 |
60 | procedure Initialize (CB : not null Gesture_CB);
61 |
62 | end Gestures;
63 |
--------------------------------------------------------------------------------
/wolf/wolf_common.gpr:
--------------------------------------------------------------------------------
1 | project Wolf_Common extends "../common/common.gpr" is
2 |
3 | for Source_Dirs use ("src", "pics");
4 |
5 | package Compiler is
6 | for Default_Switches ("Ada") use Common.Compiler'Default_Switches ("Ada");
7 | for Switches ("textures-colorada.ads") use
8 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
9 | for Switches ("textures-colorada_dark.ads") use
10 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
11 | for Switches ("textures-colorstone.ads") use
12 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
13 | for Switches ("textures-colorstone_dark.ads") use
14 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
15 | for Switches ("textures-greyada.ads") use
16 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
17 | for Switches ("textures-greyada_dark.ads") use
18 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
19 | for Switches ("textures-greystone.ads") use
20 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
21 | for Switches ("textures-greystone_dark.ads") use
22 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
23 | for Switches ("textures-redada.ads") use
24 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
25 | for Switches ("textures-redada_dark.ads") use
26 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
27 | for Switches ("textures-redbrick.ads") use
28 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
29 | for Switches ("textures-redbrick_dark.ads") use
30 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
31 | for Switches ("textures-wood.ads") use
32 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
33 | for Switches ("textures-wood_dark.ads") use
34 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
35 | for Switches ("textures-woodada.ads") use
36 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
37 | for Switches ("textures-woodada_dark.ads") use
38 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
39 | for Switches ("textures-barrel.ads") use
40 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
41 | for Switches ("textures-column.ads") use
42 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
43 | for Switches ("textures-light.ads") use
44 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
45 | for Switches ("textures-plant.ads") use
46 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
47 | for Switches ("textures-table.ads") use
48 | Compiler'Default_Switches ("Ada") & ("-gnatyM9999");
49 | end Compiler;
50 |
51 | package Linker is
52 | for Default_Switches ("Ada") use
53 | ("-Wl,--defsym=__stack_size=16384",
54 | "-Wl,--gc-sections");
55 | end Linker;
56 |
57 | end Wolf_Common;
58 |
--------------------------------------------------------------------------------
/wolf/src/rpi/display.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with System.Storage_Elements; use System.Storage_Elements;
25 |
26 | pragma Warnings (Off);
27 | with Interfaces.Cache;
28 | pragma Warnings (On);
29 |
30 | package body Display is
31 |
32 | ------------------
33 | -- Update_Layer --
34 | ------------------
35 |
36 | procedure Update_Layer (Layer : Positive)
37 | is
38 | pragma Unreferenced (Layer);
39 | begin
40 | RPi.Framebuffer.Flip (Rpi_Board.Display);
41 | end Update_Layer;
42 |
43 | -----------------
44 | -- Flush_Cache --
45 | -----------------
46 |
47 | procedure Flush_Cache (Buffer : Bitmap.Bitmap_Buffer'Class)
48 | is
49 | begin
50 | Interfaces.Cache.Dcache_Flush_By_Range
51 | (Buffer.Addr, Storage_Offset (Buffer.Buffer_Size));
52 | end Flush_Cache;
53 |
54 | -----------------------
55 | -- Get_Hidden_Buffer --
56 | -----------------------
57 |
58 | function Get_Hidden_Buffer
59 | (Layer : Positive) return RPi.Bitmap.RPi_Bitmap_Buffer
60 | is
61 | pragma Unreferenced (Layer);
62 | begin
63 | return RPi.Framebuffer.Hidden_Framebuffer (Rpi_Board.Display);
64 | end Get_Hidden_Buffer;
65 |
66 | end Display;
67 |
--------------------------------------------------------------------------------
/wav_player/src/player.adb:
--------------------------------------------------------------------------------
1 | -----------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2016, J. Lambourg --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Ada.Unchecked_Conversion;
25 |
26 | with GUI;
27 | with Gestures;
28 | with Wav_Player;
29 |
30 | with HAL.Bitmap; use HAL.Bitmap;
31 | with HAL.Framebuffer; use HAL.Framebuffer;
32 |
33 | -- with Cortex_M.Cache;
34 | with STM32.Board; use STM32.Board;
35 | with STM32.SDRAM;
36 |
37 | with Filesystem;
38 |
39 | procedure Player is
40 |
41 | begin
42 | -- It looks like the FATFS library is not totally immune to data-cache
43 | -- issues currently, so disable cache for now...
44 | -- Cortex_M.Cache.Disable_D_Cache;
45 | STM32.SDRAM.Initialize;
46 |
47 | SDCard_Device.Initialize;
48 |
49 | Display.Initialize (Landscape, Interrupt);
50 | Display.Initialize_Layer (1, ARGB_1555);
51 | Display.Initialize_Layer (2, ARGB_1555);
52 | GUI.Initialize;
53 |
54 | Wav_Player.Initialize
55 | (Volume => 80,
56 | State_CB => GUI.On_Audio_Event'Access);
57 |
58 | Touch_Panel.Initialize
59 | (Orientation => Landscape,
60 | Calibrate => False,
61 | Enable_Interrupts => False);
62 | Gestures.Initialize (GUI.On_Gesture_Event'Access);
63 |
64 | GUI.Main_Loop;
65 | end Player;
66 |
--------------------------------------------------------------------------------
/wolf/src/stm32/display.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Cortex_M.Cache;
25 | with STM32.DMA2D;
26 | with STM32.DMA2D_Bitmap;
27 |
28 | package body Display is
29 |
30 | function Get_Hidden_Buffer
31 | (Layer : Positive) return Bitmap.Bitmap_Buffer'Class
32 | is
33 | begin
34 | return STM32.DMA2D_Bitmap.DMA2D_Bitmap_Buffer'Class
35 | (STM32.Board.Display.Get_Hidden_Buffer (Layer));
36 | end Get_Hidden_Buffer;
37 |
38 | ------------------
39 | -- Update_Layer --
40 | ------------------
41 |
42 | procedure Update_Layer
43 | (Layer : Positive)
44 | is
45 | begin
46 | STM32.Board.Display.Update_Layer (Layer);
47 | end Update_Layer;
48 |
49 | -------------------
50 | -- Update_Layers --
51 | -------------------
52 |
53 | procedure Update_Layers
54 | is
55 | begin
56 | STM32.Board.Display.Update_Layers;
57 | end Update_Layers;
58 |
59 | -----------------
60 | -- Flush_Cache --
61 | -----------------
62 |
63 | procedure Flush_Cache (Buffer : Bitmap.Bitmap_Buffer'Class)
64 | is
65 | begin
66 | Cortex_M.Cache.Clean_DCache (Buffer.Addr, Buffer.Buffer_Size);
67 | end Flush_Cache;
68 |
69 | -------------------
70 | -- Wait_Transfer --
71 | -------------------
72 |
73 | procedure Wait_Transfer
74 | is
75 | begin
76 | STM32.DMA2D.DMA2D_Wait_Transfer;
77 | end Wait_Transfer;
78 |
79 | end Display;
80 |
--------------------------------------------------------------------------------
/wolf/src/rpi/display.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with HAL.Framebuffer;
25 |
26 | with Bitmap;
27 | with Rpi_Board;
28 | with RPi.Bitmap;
29 | with RPi.Framebuffer;
30 |
31 | package Display is
32 |
33 | LCD_W : constant Natural := Rpi_Board.Display_Width;
34 | LCD_H : constant Natural := Rpi_Board.Display_Height;
35 |
36 | Use_Column_Cache : constant Boolean := False;
37 | -- When copying from the cached data to the string, we need this copy to
38 | -- be synchronous, so that the column can later on be duplicated safely if
39 | -- needed.
40 |
41 | function Get_Color_Mode
42 | (Layer : Positive) return HAL.Framebuffer.FB_Color_Mode
43 | with Inline_Always;
44 |
45 | function Is_Swapped return Boolean
46 | with Inline_Always;
47 |
48 | function Get_Hidden_Buffer
49 | (Layer : Positive) return Bitmap.Bitmap_Buffer
50 | with Inline_Always;
51 |
52 | procedure Update_Layer (Layer : Positive)
53 | with Inline_Always;
54 |
55 | procedure Flush_Cache (Buffer : Bitmap.Bitmap_Buffer'Class);
56 |
57 | -- procedure Wait_Transfer is null;
58 | procedure Wait_Transfer renames RPi.Bitmap.Wait_Transfer;
59 |
60 | private
61 |
62 | function Get_Color_Mode
63 | (Layer : Positive) return HAL.Framebuffer.FB_Color_Mode
64 | is (RPi.Framebuffer.Color_Mode (Rpi_Board.Display));
65 |
66 | function Is_Swapped return Boolean
67 | is (False);
68 |
69 | end Display;
70 |
--------------------------------------------------------------------------------
/wolf/src/raycaster.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Display; use Display;
25 | with Math; use Math;
26 | with Playground;
27 |
28 | package Raycaster is
29 |
30 | subtype LCD_Column is Natural range 0 .. LCD_W - 1;
31 |
32 | Height_Multiplier : constant Float :=
33 | Float (LCD_H) / 2.0;
34 |
35 | -- 1 pixel = 1/10 degree
36 | FOV_Vect : array (0 .. LCD_W - 1) of Degree;
37 |
38 | FOV : constant Math.Degree :=
39 | 2 * Arctan
40 | (Float (LCD_W) / (2.0 * Height_Multiplier));
41 |
42 |
43 | type Trace_Point is record
44 | Col : LCD_Column;
45 | Dist : Float;
46 | Tile : Playground.Cell;
47 | Offset : Float;
48 | Vertical_Hit : Boolean := False;
49 | Visible_Tile : Boolean := False;
50 | end record;
51 |
52 | type Trace_Points is array (LCD_Column) of Trace_Point;
53 |
54 | type Visible_Elements is
55 | array (Playground.Compressed'Range, 0 .. Playground.Compressed (1)'Length)
56 | of Boolean;
57 |
58 | procedure Initialize_Tables;
59 |
60 | procedure Trace
61 | (Col : LCD_Column;
62 | Visible_Tiles : in out Visible_Elements;
63 | Ray : out Trace_Point);
64 |
65 | procedure Trace_Rays
66 | (Visible_Tiles : out Visible_Elements;
67 | Tracers : out Trace_Points);
68 |
69 | end Raycaster;
70 |
--------------------------------------------------------------------------------
/wolf/src/stm32/display.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with HAL.Framebuffer;
25 |
26 | with Bitmap;
27 |
28 | with STM32.Board; use STM32.Board;
29 |
30 | -- Wrapper around the board's display definition, to accomodate both STM32
31 | -- and raspberry pi implementations.
32 | package Display is
33 |
34 | LCD_W : constant Natural :=
35 | (if LCD_Natural_Width > LCD_Natural_Height
36 | then LCD_Natural_Width
37 | else LCD_Natural_Height);
38 |
39 | LCD_H : constant Natural :=
40 | (if LCD_Natural_Width > LCD_Natural_Height
41 | then LCD_Natural_Height
42 | else LCD_Natural_Width);
43 |
44 | Use_Column_Cache : constant Boolean := True;
45 | -- Accelerated Copy_Rect available with the DMA2D
46 |
47 | function Get_Color_Mode
48 | (Layer : Positive) return HAL.Framebuffer.FB_Color_Mode
49 | with Inline_Always;
50 |
51 | function Is_Swapped return Boolean
52 | with Inline_Always;
53 |
54 | function Get_Hidden_Buffer
55 | (Layer : Positive) return Bitmap.Bitmap_Buffer'Class
56 | with Inline_Always;
57 |
58 | procedure Update_Layer
59 | (Layer : Positive)
60 | with Inline_Always;
61 |
62 | procedure Update_Layers with Inline_Always;
63 |
64 | procedure Flush_Cache (Buffer : Bitmap.Bitmap_Buffer'Class);
65 |
66 | procedure Wait_Transfer with Inline_Always;
67 |
68 | private
69 |
70 | function Get_Color_Mode
71 | (Layer : Positive) return HAL.Framebuffer.FB_Color_Mode
72 | is (STM32.Board.Display.Get_Color_Mode (Layer));
73 |
74 | function Is_Swapped return Boolean
75 | is (STM32.Board.Display.Is_Swapped);
76 |
77 | end Display;
78 |
--------------------------------------------------------------------------------
/services/COPYING.RUNTIME:
--------------------------------------------------------------------------------
1 | GCC RUNTIME LIBRARY EXCEPTION
2 |
3 | Version 3.1, 31 March 2009
4 |
5 | Copyright (C) 2009 Free Software Foundation, Inc.
6 |
7 | Everyone is permitted to copy and distribute verbatim copies of this
8 | license document, but changing it is not allowed.
9 |
10 | This GCC Runtime Library Exception ("Exception") is an additional
11 | permission under section 7 of the GNU General Public License, version
12 | 3 ("GPLv3"). It applies to a given file (the "Runtime Library") that
13 | bears a notice placed by the copyright holder of the file stating that
14 | the file is governed by GPLv3 along with this Exception.
15 |
16 | When you use GCC to compile a program, GCC may combine portions of
17 | certain GCC header files and runtime libraries with the compiled
18 | program. The purpose of this Exception is to allow compilation of
19 | non-GPL (including proprietary) programs to use, in this way, the
20 | header files and runtime libraries covered by this Exception.
21 |
22 | 0. Definitions.
23 |
24 | A file is an "Independent Module" if it either requires the Runtime
25 | Library for execution after a Compilation Process, or makes use of an
26 | interface provided by the Runtime Library, but is not otherwise based
27 | on the Runtime Library.
28 |
29 | "GCC" means a version of the GNU Compiler Collection, with or without
30 | modifications, governed by version 3 (or a specified later version) of
31 | the GNU General Public License (GPL) with the option of using any
32 | subsequent versions published by the FSF.
33 |
34 | "GPL-compatible Software" is software whose conditions of propagation,
35 | modification and use would permit combination with GCC in accord with
36 | the license of GCC.
37 |
38 | "Target Code" refers to output from any compiler for a real or virtual
39 | target processor architecture, in executable form or suitable for
40 | input to an assembler, loader, linker and/or execution
41 | phase. Notwithstanding that, Target Code does not include data in any
42 | format that is used as a compiler intermediate representation, or used
43 | for producing a compiler intermediate representation.
44 |
45 | The "Compilation Process" transforms code entirely represented in
46 | non-intermediate languages designed for human-written code, and/or in
47 | Java Virtual Machine byte code, into Target Code. Thus, for example,
48 | use of source code generators and preprocessors need not be considered
49 | part of the Compilation Process, since the Compilation Process can be
50 | understood as starting with the output of the generators or
51 | preprocessors.
52 |
53 | A Compilation Process is "Eligible" if it is done using GCC, alone or
54 | with other GPL-compatible software, or if it is done without using any
55 | work based on GCC. For example, using non-GPL-compatible Software to
56 | optimize any GCC intermediate representations would not qualify as an
57 | Eligible Compilation Process.
58 |
59 | 1. Grant of Additional Permission.
60 |
61 | You have permission to propagate a work of Target Code formed by
62 | combining the Runtime Library with Independent Modules, even if such
63 | propagation would otherwise violate the terms of GPLv3, provided that
64 | all Target Code was generated by Eligible Compilation Processes. You
65 | may then convey such a combination under terms of your choice,
66 | consistent with the licensing of the Independent Modules.
67 |
68 | 2. No Weakening of GCC Copyleft.
69 |
70 | The availability of this Exception does not imply any general
71 | presumption that third-party software is unaffected by the copyleft
72 | requirements of the license of GCC.
73 |
74 |
--------------------------------------------------------------------------------
/wav_player/src/wav_reader.ads:
--------------------------------------------------------------------------------
1 | -----------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2016, J. Lambourg --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Interfaces; use Interfaces;
25 |
26 | with Filesystem;
27 |
28 | package Wav_Reader is
29 |
30 | type WAV_Status_Code is
31 | (OK,
32 | Not_A_WAV_File,
33 | Internal_Error,
34 | Wrong_WAV_Format,
35 | Unexpected_Section,
36 | Cannot_Read);
37 |
38 | type Header_Block is record
39 | ID : String (1 .. 4);
40 | Size : Unsigned_32;
41 | end record with Pack;
42 |
43 | type RIFF_Block is record
44 | Format_ID : String (1 .. 4);
45 | end record with Pack;
46 |
47 | type Audio_Format is
48 | (Unknown,
49 | PCM) with Size => 16;
50 |
51 | type Audio_Description_Block is record
52 | Format : Audio_Format;
53 | Channels : Unsigned_16;
54 | Frequency : Unsigned_32;
55 | Byte_Per_Sec : Unsigned_32;
56 | Byte_Per_Block : Unsigned_16;
57 | Bits_Per_Sample : Unsigned_16;
58 | end record with Pack;
59 |
60 | type Metadata_Info is record
61 | Artist : String (1 .. 48) := (others => ' ');
62 | Title : String (1 .. 96) := (others => ' ');
63 | Album : String (1 .. 64) := (others => ' ');
64 | Track_Num : Natural := 0;
65 | Year : Natural := 0;
66 | Genre : String (1 .. 32) := (others => ' ');
67 | end record;
68 |
69 | type WAV_Info is record
70 | Audio_Description : Audio_Description_Block;
71 | Metadata : Metadata_Info;
72 | Data_Size : Unsigned_32;
73 | Data_Offset : Filesystem.File_Size;
74 | end record;
75 |
76 | function Read_Header
77 | (F : Filesystem.File_Handle;
78 | Info : out WAV_Info) return WAV_Status_Code;
79 | -- Decodes the WAV file's header and fills the INFO structure with it.
80 |
81 | end Wav_Reader;
82 |
--------------------------------------------------------------------------------
/common/gui/hershey_fonts.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | -- This package handles the Hershey font format.
25 |
26 | with Interfaces; use Interfaces;
27 |
28 | package Hershey_Fonts is
29 |
30 | type Font_Desc is access constant String;
31 |
32 | type Hershey_Font is private;
33 |
34 | type Glyph_Index is private;
35 |
36 | function Valid_Glyph (Val : Natural) return Boolean;
37 |
38 | function Read (Fnt : Font_Desc) return Hershey_Font;
39 | procedure Read (Fnt : Font_Desc;
40 | Ret : out Hershey_Font);
41 |
42 | function Strlen (S : String;
43 | Fnt : Hershey_Font;
44 | Height : Natural) return Natural;
45 |
46 | generic
47 | with procedure Draw_Line
48 | (X0, Y0, X1, Y1 : Natural;
49 | Width : Positive);
50 | procedure Draw_Glyph
51 | (Fnt : Hershey_Font;
52 | C : Character;
53 | X : in out Natural;
54 | Y : Natural;
55 | Height : Natural;
56 | Bold : Boolean);
57 |
58 | private
59 |
60 | type Coord is record
61 | X : Interfaces.Integer_8;
62 | Y : Interfaces.Integer_8;
63 | end record with Size => 16;
64 |
65 | Raise_Pen : constant Coord := (others => Integer_8'First);
66 |
67 | type Coord_Array is array (Positive range <>) of Coord
68 | with Component_Size => 16;
69 |
70 | type Glyph is record
71 | Vertices : Natural;
72 | Width : Unsigned_8;
73 | Height : Unsigned_8;
74 | Coords : Coord_Array (1 .. 120);
75 | end record with Pack;
76 |
77 | type Glyph_Index is new Positive range 1 .. 96;
78 |
79 | function Valid_Glyph (Val : Natural) return Boolean
80 | is (Val in 1 .. 96);
81 |
82 | type Glyph_Array is array (Glyph_Index) of Glyph;
83 |
84 | type Hershey_Font is record
85 | Number_Of_Glyphs : Glyph_Index;
86 | Glyphs : Glyph_Array;
87 | Font_Height : Unsigned_8;
88 | Baseline : Unsigned_8;
89 | end record;
90 |
91 | end Hershey_Fonts;
92 |
--------------------------------------------------------------------------------
/2048/src/game.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with HAL.Bitmap; use HAL.Bitmap;
25 |
26 | with Bitmapped_Drawing; use Bitmapped_Drawing;
27 | with Hershey_Fonts.FuturaL; use Hershey_Fonts;
28 |
29 | with Grid; use Grid;
30 | with Ada.Real_Time; use Ada.Real_Time;
31 | with Gestures;
32 |
33 | package Game is
34 |
35 | Times : constant Hershey_Font := Read (FuturaL.Font);
36 |
37 | Grid : CGrid := (Grid => (others => (others => 0)),
38 | Score => 0);
39 | procedure Init;
40 | procedure Init_Background_Buffer;
41 |
42 | function Get_Score return Natural;
43 | function Get_Status_Area return Rect;
44 |
45 | procedure Init_Cells_Buffer;
46 | procedure Draw (Dst : Bitmap_Buffer'Class);
47 | procedure Init_Slide (Old_Grid : CGrid; Trace : Trace_Grid_T);
48 | function Slide (Dst : Bitmap_Buffer'Class) return Boolean;
49 | procedure Start;
50 | procedure Add_Value;
51 | function Can_Move (Direction : Direction_E) return Boolean;
52 | -- procedure Move (Direction : Direction_E);
53 | procedure Move (Direction : Direction_E);
54 | function Is_Sliding return Boolean;
55 | procedure Treat_Touch (G : Gestures.Gesture_Data);
56 |
57 | private
58 |
59 | type Point is record
60 | X, Y : Integer;
61 | end record;
62 |
63 | type Speed is record
64 | X : Integer;
65 | Y : Integer;
66 | end record;
67 |
68 | type Moving_Cell_T is record
69 | Src : Point;
70 | Dst : Point;
71 | Src_Value : Integer;
72 | Dst_Value : Integer;
73 | V : Speed;
74 | Max_Length : Integer;
75 | Moving : Boolean := False;
76 | end record;
77 | type Moving_Cells_Index_T is new Integer
78 | range 0 .. Integer (Size'Range_Length * Size'Range_Length - 1);
79 | type Moving_Cells_A is array (Moving_Cells_Index_T) of Moving_Cell_T;
80 |
81 | Moving_Cells : Moving_Cells_A;
82 |
83 | Sliding : Boolean := False;
84 | Slide_Start_Time : Time;
85 |
86 | end Game;
87 |
--------------------------------------------------------------------------------
/services/filesystem/VFS/filesystem-vfs.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Ada Filesystem Library --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | -- Simple virtual file system allowing to mount actual fs into a virtual
25 | -- fs environment composed of 1 level of virtual directories.
26 |
27 | package Filesystem.VFS is
28 |
29 | MAX_MOUNT_POINTS : constant := 2;
30 | MAX_MOUNT_NAME_LENGTH : constant := 128;
31 |
32 | subtype Mount_Path is String
33 | with Dynamic_Predicate => Mount_Path'Length <= MAX_MOUNT_NAME_LENGTH;
34 |
35 | function Mount_Volume
36 | (Mount_Point : Mount_Path;
37 | FS : Filesystem_Access) return Status_Code;
38 |
39 | function Mount_Drive
40 | (Mount_Point : Mount_Path;
41 | Device : HAL.Block_Drivers.Any_Block_Driver) return Status_Code;
42 |
43 | function Unmount (Mount_Point : Mount_Path) return Status_Code;
44 |
45 | function Open
46 | (Path : String;
47 | Status : out Status_Code)
48 | return Directory_Handle;
49 |
50 | function Open
51 | (Path : String;
52 | Mode : File_Mode;
53 | Status : out Status_Code)
54 | return File_Handle;
55 |
56 | private
57 |
58 | type Mount_Record is record
59 | Is_Free : Boolean := True;
60 | Name : String (1 .. MAX_MOUNT_NAME_LENGTH);
61 | Name_Len : Positive;
62 | FS : Filesystem_Access;
63 | end record;
64 |
65 | subtype Mount_Index is Integer range 0 .. MAX_MOUNT_POINTS;
66 | subtype Valid_Mount_Index is Mount_Index range 1 .. MAX_MOUNT_POINTS;
67 | type Mount_Array is array (Valid_Mount_Index) of Mount_Record;
68 |
69 | type VFS_Directory_Handle is new Directory_Handle_Object with record
70 | Is_Free : Boolean := True;
71 | Mount_Id : Mount_Index;
72 | end record;
73 |
74 | overriding function Get_FS
75 | (Dir : access VFS_Directory_Handle) return Filesystem_Access;
76 | -- Return the filesystem the handle belongs to.
77 |
78 | overriding function Read
79 | (Dir : access VFS_Directory_Handle;
80 | Status : out Status_Code) return Node_Access;
81 | -- Reads the next directory entry. If no such entry is there, an error
82 | -- code is returned in Status.
83 |
84 | overriding procedure Reset (Dir : access VFS_Directory_Handle);
85 | -- Resets the handle to the first node
86 |
87 | overriding procedure Close (Dir : access VFS_Directory_Handle);
88 | -- Closes the handle, and free the associated resources.
89 |
90 | end Filesystem.VFS;
91 |
--------------------------------------------------------------------------------
/2048/src/grid.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | package Grid is
25 | type Size is new Integer range 0 .. 3;
26 |
27 | type Grid_T is array (Size, Size) of Integer;
28 |
29 | type Direction_E is (Left, Up, Right, Down);
30 |
31 | type CGrid is tagged record
32 | Grid : Grid_T;
33 | Score : Natural;
34 | end record;
35 |
36 |
37 | type Cell_Position_T is record
38 | X : Size;
39 | Y : Size;
40 | end record;
41 | type Moving_Tile_T is record
42 | Current : Cell_Position_T;
43 | Previous : Cell_Position_T;
44 | end record;
45 | type Trace_Grid_T is array (Size, Size) of Cell_Position_T;
46 |
47 | procedure Init (G : in out CGrid);
48 |
49 | function Get
50 | (G : in CGrid;
51 | X : Size;
52 | Y : Size) return Integer with Inline;
53 |
54 | procedure Set
55 | (G : in out CGrid;
56 | X : Size;
57 | Y : Size;
58 | Value : Integer) with Inline;
59 |
60 | procedure Move
61 | (G : in out CGrid;
62 | Direction : Direction_E);
63 |
64 | function Move
65 | (G : in out CGrid;
66 | Direction : Direction_E) return Trace_Grid_T;
67 |
68 | function Can_Move
69 | (G : in out CGrid;
70 | Direction : Direction_E) return Boolean;
71 |
72 | private
73 | type Row_T is array (Size) of Integer;
74 | type Row_Trace_T is array (Size) of Size;
75 |
76 | type Rows_T is array (Size) of Row_T;
77 |
78 | type Rows_Traces_T is array (Size) of Row_Trace_T;
79 |
80 | procedure Compact_Row (Row : in out Row_T;
81 | Score : in out Natural);
82 |
83 | function Compact_Row (Row : in out Row_T;
84 | Score : in out Natural) return Row_Trace_T;
85 |
86 | procedure Compact_Rows (Rows : in out Rows_T;
87 | Score : in out Natural);
88 |
89 | function Compact_Rows (Rows : in out Rows_T;
90 | Score : in out Natural) return Rows_Traces_T;
91 |
92 | function Grid_To_Rows
93 | (G : in CGrid;
94 | Direction : Direction_E) return Rows_T;
95 |
96 | procedure Rows_To_Grid
97 | (G : in out CGrid;
98 | Rows : Rows_T;
99 | Direction : Direction_E);
100 |
101 | function Traces_To_Move_Grid
102 | (Traces : Rows_Traces_T;
103 | Direction : Direction_E) return Trace_Grid_T;
104 |
105 | end Grid;
106 |
--------------------------------------------------------------------------------
/services/filesystem/FAT/filesystem-fat-files.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Ada Filesystem Library --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | -- Initial contribution by:
25 | --
26 | -- Institution: Technische Universitaet Muenchen
27 | -- Department: Real-Time Computer Systems (RCS)
28 | -- Project: StratoX
29 | -- Authors: Martin Becker (becker@rcs.ei.tum.de)
30 | --
31 | -- XXX! Nothing here is proven thread-safe!
32 |
33 | with System;
34 |
35 | -- @summary File handling for FAT FS
36 | private package Filesystem.FAT.Files is
37 |
38 | type File_Data is array (FAT_File_Size range <>) of Interfaces.Unsigned_8;
39 |
40 | function Open
41 | (Parent : FAT_Node;
42 | Name : FAT_Name;
43 | Mode : File_Mode;
44 | File : access FAT_File_Handle) return Status_Code;
45 | -- open the file given by the directory entry and return
46 | -- handle.
47 | -- if Mode is Read_Mode, then the file is returned with read-only access
48 | -- if Mode is Write_Mode, then if the file is created: if a file already
49 | -- exists it's content is wiped out
50 | -- if Mode is Read_Write_Mode, then the file is created if not exist, else
51 | -- its content is preserved but can be overwritten by calls to File_Write.
52 |
53 | -- function Size (File : access FAT_File_Handle) return FAT_File_Size;
54 | --
55 | -- function Mode (File : access FAT_File_Handle) return File_Mode;
56 |
57 | function Read
58 | (File : access FAT_File_Handle;
59 | Addr : System.Address;
60 | Length : in out FAT_File_Size) return Status_Code
61 | with Pre => Mode (File) /= Write_Mode;
62 | -- read data from file.
63 | -- @return number of bytes read (at most Data'Length), or -1 on error.
64 |
65 | -- function Offset
66 | -- (File : access FAT_File_Handle) return FAT_File_Size;
67 | -- -- Current index within the file
68 | --
69 | function Write
70 | (File : access FAT_File_Handle;
71 | Addr : System.Address;
72 | Length : FAT_File_Size) return Status_Code
73 | with
74 | Pre => Mode (File) = Write_Mode or else Mode (File) = Read_Write_Mode;
75 | -- write to file
76 | -- @return number of bytes written (at most Data'Length), or -1 on error.
77 |
78 | function Flush
79 | (File : access FAT_File_Handle) return Status_Code;
80 | -- force writing file to disk at this very moment (slow!)
81 |
82 | function Seek
83 | (File : access FAT_File_Handle;
84 | Amount : in out FAT_File_Size;
85 | Origin : Seek_Mode) return Status_Code;
86 | -- Moves the current file position from "Origin" of "Amount" bytes.
87 |
88 | procedure Close (File : access FAT_File_Handle);
89 | -- invalidates the handle, and ensures that
90 | -- everything is flushed to the disk
91 |
92 | end Filesystem.FAT.Files;
93 |
--------------------------------------------------------------------------------
/wolf/src/rpi/notasking/renderer-tasks.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Ada.Real_Time; use Ada.Real_Time;
25 |
26 | with GNAT.IO;
27 |
28 | separate (Renderer)
29 | package body Tasks is
30 |
31 | Tracers : Raycaster.Trace_Points;
32 |
33 | FPS : Natural := 0;
34 | Last : Time := Clock;
35 |
36 | ----------------
37 | -- Initialize --
38 | ----------------
39 |
40 | procedure Initialize is
41 | begin
42 | null;
43 | end Initialize;
44 |
45 | -------------------------
46 | -- Copy_Sprites_Buffer --
47 | -------------------------
48 |
49 | procedure Copy_Sprites_Buffer
50 | (Cache : Column_Info;
51 | Buf : in out HAL.Bitmap.Bitmap_Buffer'Class;
52 | X : Natural;
53 | Y : Natural;
54 | Height : Natural)
55 | is
56 | function To_RGB (Col : UInt16) return UInt16;
57 |
58 | ------------
59 | -- To_RGB --
60 | ------------
61 |
62 | function To_RGB (Col : UInt16) return UInt16
63 | is
64 | begin
65 | return Shift_Left (Col and 2#0_11111_11111_00000#, 1)
66 | or (Col and 2#0_00000_00000_11111#);
67 | end To_RGB;
68 |
69 | Col : UInt16;
70 |
71 | begin
72 | for Row in 0 .. Height - 1 loop
73 | Col := Cache.Column (Row);
74 | if Col /= 0 then
75 | Buf.Set_Pixel ((X, Y + Row), UInt32 (To_RGB (Col)));
76 | end if;
77 | end loop;
78 | end Copy_Sprites_Buffer;
79 |
80 | ----------
81 | -- Draw --
82 | ----------
83 |
84 | procedure Draw
85 | is
86 | Visible : Visible_Elements := (others => (others => False));
87 | Buf : Bitmap.Bitmap_Buffer :=
88 | Display.Get_Hidden_Buffer (1);
89 | Tmp : aliased Column_Info;
90 | begin
91 | -- Trace the rays in the env task
92 | Trace_Rays (Visible, Tracers);
93 | Sort_Sprites (Visible);
94 |
95 | Tmp.Col_Buffer :=
96 | (Addr => Tmp.Column'Address,
97 | Width => 1,
98 | Height => LCD_H,
99 | Color_Mode => Playground.Color_Mode,
100 | Swapped => False);
101 |
102 | Tmp.Prev_Height := LCD_H;
103 | Tmp.Prev_Top := 0;
104 |
105 | for X in 0 .. LCD_W - 1 loop
106 | Draw_Wall (Tracers (X), Buf, Tmp);
107 | end loop;
108 |
109 | Display.Wait_Transfer;
110 | Draw_Sprites (Buf, Tracers);
111 |
112 | FPS := FPS + 1;
113 |
114 | if Clock - Last > Milliseconds (500) then
115 | GNAT.IO.Put (FPS);
116 | GNAT.IO.Put_Line (" fps");
117 | FPS := 0;
118 | Last := Clock;
119 | end if;
120 |
121 | Display.Update_Layer (1);
122 | end Draw;
123 |
124 | end Tasks;
125 |
--------------------------------------------------------------------------------
/common/gui/bmp_fonts.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- --
3 | -- Copyright (C) 2015, 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 STMicroelectronics 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 | -- This file is based on: --
32 | -- --
33 | -- @file fonts.h --
34 | -- @author MCD Application Team --
35 | -- @version V1.1.0 --
36 | -- @date 19-June-2014 --
37 | -- @brief Header for fonts.c file. --
38 | -- --
39 | -- COPYRIGHT(c) 2014 STMicroelectronics --
40 | ------------------------------------------------------------------------------
41 |
42 | with HAL; use HAL;
43 |
44 | package BMP_Fonts is
45 |
46 | type BMP_Font is (Font8x8, Font12x12, Font16x24);
47 |
48 | function Data
49 | (Font : BMP_Font;
50 | C : Character;
51 | Height_Offset : Natural)
52 | return UInt16 with Inline;
53 | -- Provides the numeric data values representing individual characters. For
54 | -- the given font and character within that font, returns the numeric value
55 | -- representing the bits at the Height_Offset within the representation.
56 |
57 | function Mask (Font : BMP_Font; Width_Offset : Natural) return UInt16
58 | with Inline;
59 | -- Provides the mask value used to test individual bits in the data
60 | -- values representing individual characters. For example, to see if bit W
61 | -- within the bits representing Char at height H is set, you would do the
62 | -- following:
63 | --
64 | -- if (Data (Font, Char, H) and Mask (Font, W)) /= 0 then
65 |
66 | function Char_Height (Font : BMP_Font) return Natural with Inline;
67 | -- Returns the height of any individual character in the specified font, in
68 | -- terms of pixels .
69 |
70 | function Char_Width (Font : BMP_Font) return Natural with Inline;
71 | -- Returns the width of any individual character in the specified font, in
72 | -- terms of pixels .
73 |
74 | end BMP_Fonts;
75 |
--------------------------------------------------------------------------------
/services/filesystem/FAT/filesystem-fat-directories.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Ada Filesystem Library --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | private package Filesystem.FAT.Directories is
25 |
26 | function Find
27 | (FS : access FAT_Filesystem;
28 | Path : String;
29 | DEntry : out FAT_Node) return Status_Code;
30 |
31 | function Find
32 | (Parent : FAT_Node;
33 | Filename : FAT_Name;
34 | DEntry : out FAT_Node) return Status_Code
35 | with Pre => Is_Subdirectory (Parent);
36 |
37 | function Root_Entry (FS : not null access FAT_Filesystem) return FAT_Node;
38 |
39 | function Read
40 | (Dir : access FAT_Directory_Handle;
41 | DEntry : out FAT_Node) return Status_Code;
42 |
43 | function Next_Entry
44 | (FS : access FAT_Filesystem;
45 | Current_Cluster : in out Cluster_Type;
46 | Current_Block : in out Block_Offset;
47 | Current_Index : in out Entry_Index;
48 | DEntry : out FAT_Directory_Entry) return Status_Code;
49 |
50 | function Next_Entry
51 | (FS : access FAT_Filesystem;
52 | Current_Cluster : in out Cluster_Type;
53 | Current_Block : in out Block_Offset;
54 | Current_Index : in out Entry_Index;
55 | DEntry : out FAT_Node) return Status_Code;
56 |
57 | -------------------------------------
58 | -- Operations on directory entries --
59 | -------------------------------------
60 |
61 | function Create_Subdir
62 | (Dir : FAT_Node;
63 | Name : FAT_Name;
64 | New_Dir : out FAT_Node) return Status_Code;
65 |
66 | function Create_File_Node
67 | (Dir : FAT_Node;
68 | Name : FAT_Name;
69 | New_File : out FAT_Node) return Status_Code;
70 |
71 | function Delete_Subdir
72 | (Dir : FAT_Node;
73 | Recursive : Boolean) return Status_Code;
74 |
75 | function Delete_Entry
76 | (Dir : FAT_Node;
77 | Ent : FAT_Node) return Status_Code;
78 | -- Mark the clusters related to Ent as free
79 |
80 | function Adjust_Clusters
81 | (Ent : FAT_Node) return Status_Code;
82 | -- Adjust the number of clusters depending on Ent size
83 |
84 | -------------------------
85 | -- FAT_Node properties --
86 | -------------------------
87 |
88 | procedure Set_Size
89 | (E : in out FAT_Node;
90 | Size : FAT_File_Size);
91 |
92 | function Update_Entry
93 | (Parent : FAT_Node;
94 | Value : in out FAT_Node) return Status_Code;
95 |
96 | ---------------------------
97 | -- Low_Level subprograms --
98 | ---------------------------
99 |
100 | function Allocate_Entry
101 | (Parent : access FAT_Directory_Handle;
102 | Name : FAT_Name;
103 | Attributes : FAT_Directory_Entry_Attribute;
104 | E : out FAT_Node) return Status_Code;
105 |
106 | end Filesystem.FAT.Directories;
107 |
--------------------------------------------------------------------------------
/wav_player/src/wav_db.ads:
--------------------------------------------------------------------------------
1 | -----------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2016, J. Lambourg --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Filesystem;
25 | with Wav_Reader;
26 |
27 | package Wav_DB is
28 |
29 | MAX_FILES : constant := 500;
30 |
31 | procedure Read_Dir (Path : String;
32 | Status : out Filesystem.Status_Code);
33 | procedure Add_File (Path : String);
34 |
35 | procedure Reset_DB;
36 | -- Clears values from the database
37 |
38 | type Selection is private;
39 | type Id_Type is new Integer range -1 .. MAX_FILES;
40 | subtype Valid_Id is Id_Type range 1 .. Id_Type'Last;
41 |
42 | All_Id : constant Id_Type := 0;
43 | No_Id : constant Id_Type := -1;
44 |
45 | subtype Artist_Id is Id_Type;
46 | subtype Album_Id is Id_Type;
47 | subtype Track_Id is Id_Type;
48 |
49 | function Artist (Id : Artist_Id) return String;
50 | function Album (Id : Album_Id) return String;
51 | function Track (Id : Album_Id) return String;
52 | function Track_Path (Id : Track_Id) return String;
53 | function Track_Info
54 | (Id : Track_Id) return Wav_Reader.Metadata_Info;
55 |
56 | function Is_Empty (S : Selection) return Boolean;
57 |
58 | function Num_Artists (S : Selection) return Natural;
59 | function First_Artist (S : Selection) return Artist_Id;
60 | function Next_Artist
61 | (S : Selection;
62 | Id : in out Artist_Id) return Boolean;
63 | procedure Set_Artist
64 | (S : in out Selection;
65 | Id : Artist_Id);
66 | -- If set to All_Id, resets the filter on the artist selection
67 | function Selected_Artist (S : Selection) return Artist_Id;
68 |
69 | function Num_Albums (S : Selection) return Natural;
70 | function First_Album (S : Selection) return Album_Id;
71 | function Next_Album
72 | (S : Selection;
73 | Id : in out Album_Id) return Boolean;
74 | procedure Set_Album
75 | (S : in out Selection;
76 | Id : Album_Id);
77 | function Selected_Album (S : Selection) return Album_Id;
78 | function Has_Album
79 | (S : Selection;
80 | Id : Album_Id) return Boolean;
81 |
82 | function Num_Tracks (S : Selection) return Natural;
83 | function First_Track (S : Selection) return Track_Id;
84 | function Last_Track (S : Selection) return Track_Id;
85 | function Has_Next_Track
86 | (S : Selection;
87 | Id : Track_Id) return Boolean;
88 | function Next_Track
89 | (S : Selection;
90 | Id : in out Track_Id) return Boolean;
91 | function Has_Previous_Track
92 | (S : Selection;
93 | Id : Track_Id) return Boolean;
94 | function Previous_Track
95 | (S : Selection;
96 | Id : in out Track_Id) return Boolean;
97 | function Has_Track
98 | (S : Selection;
99 | Id : Track_Id) return Boolean;
100 |
101 | private
102 |
103 | type Selection is record
104 | Artist_Filter : Artist_Id := All_Id;
105 | Album_Filter : Album_Id := All_Id;
106 | end record;
107 |
108 | end Wav_DB;
109 |
--------------------------------------------------------------------------------
/2048/src/malloc.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2020, Jerome Lambourg --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- You should have received a copy of the GNU General Public License and --
14 | -- a copy of the GCC Runtime Library Exception along with this program; --
15 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
16 | -- . --
17 | -- --
18 | ------------------------------------------------------------------------------
19 |
20 | with Interfaces; use Interfaces;
21 | with System.Storage_Elements; use System.Storage_Elements;
22 | with Ada.Unchecked_Conversion;
23 |
24 | with STM32.Board;
25 | with STM32.SDRAM;
26 |
27 | package body Malloc is
28 |
29 | Heap_Start : Character;
30 | for Heap_Start'Alignment use Standard'Maximum_Alignment;
31 | for Heap_Start'Address use System'To_Address (STM32.Board.SDRAM_Base);
32 | -- The address of the variable is the start of the heap
33 |
34 | Heap_End : Character;
35 | for Heap_End'Address use System'To_Address
36 | (STM32.Board.SDRAM_Base + STM32.Board.SDRAM_Size);
37 | -- The address of the variable is the end of the heap
38 |
39 | G_Preallocated : System.Address := System.Null_Address;
40 | G_Prealloc_Size : Storage_Offset := 0;
41 | G_Fast_Mode : Boolean := False;
42 | G_Current : System.Address := System.Null_Address;
43 |
44 | -----------------------
45 | -- Start_Fast_Malloc --
46 | -----------------------
47 |
48 | procedure Start_Fast_Malloc (Byte_Size : UInt32) is
49 | begin
50 | if not G_Fast_Mode then
51 | G_Prealloc_Size := Storage_Offset (Byte_Size);
52 | G_Fast_Mode := True;
53 | G_Preallocated := STM32.SDRAM.Reserve (Byte_Size);
54 | end if;
55 |
56 | -- We reset the allocation buffer
57 | G_Current := G_Preallocated;
58 | end Start_Fast_Malloc;
59 |
60 | -----------
61 | -- Alloc --
62 | -----------
63 |
64 | function Alloc (Size : size_t) return Address is
65 | Rounded_Size : size_t;
66 | Ret : Address;
67 |
68 | begin
69 | -- Return null address for zero length request
70 |
71 | if Size = 0 then
72 | return Null_Address;
73 | end if;
74 |
75 | STM32.SDRAM.Initialize;
76 |
77 | -- Round size up
78 |
79 | if G_Fast_Mode then
80 | Rounded_Size := (Size + Standard'Maximum_Alignment);
81 | Rounded_Size :=
82 | Rounded_Size - Rounded_Size rem Standard'Maximum_Alignment;
83 |
84 | Ret := G_Current;
85 | G_Current := G_Current + Storage_Offset (Rounded_Size);
86 |
87 | if G_Current > (G_Preallocated + G_Prealloc_Size) then
88 | raise Constraint_Error with "Not enough memory";
89 | end if;
90 |
91 | return Ret;
92 | else
93 | return STM32.SDRAM.Reserve (UInt32 (Size));
94 | end if;
95 | end Alloc;
96 |
97 | ----------
98 | -- Free --
99 | ----------
100 |
101 | procedure Free (Ptr : Address) is
102 | pragma Unreferenced (Ptr);
103 | begin
104 | return;
105 | end Free;
106 |
107 | -------------
108 | -- Realloc --
109 | -------------
110 |
111 | function Realloc (Ptr : Address; Size : size_t) return Address is
112 | begin
113 | raise Program_Error with "Not implemented";
114 | return Null_Address;
115 | end Realloc;
116 |
117 | ---------------
118 | -- Allocated --
119 | ---------------
120 |
121 | function Allocated return UInt32
122 | is
123 | begin
124 | if G_Fast_Mode then
125 | return UInt32 (G_Prealloc_Size) +
126 | UInt32 (G_Current - G_Preallocated);
127 | else
128 | return 0;
129 | end if;
130 | end Allocated;
131 |
132 | -------------
133 | -- Is_Full --
134 | -------------
135 |
136 | function Is_Full return Boolean is
137 | begin
138 | if not G_Fast_Mode then
139 | return False;
140 | end if;
141 |
142 | return (G_Current - G_Preallocated) >= G_Prealloc_Size;
143 | end Is_Full;
144 |
145 | end Malloc;
146 |
--------------------------------------------------------------------------------
/2048/src/demo_2048.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | -- The file declares the main procedure for the demonstration.
25 |
26 | with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
27 | -- The "last chance handler" is the user-defined routine that is called when
28 | -- an exception is propagated. We need it in the executable, therefore it
29 | -- must be somewhere in the closure of the context clauses.
30 |
31 | with Ada.Real_Time; use Ada.Real_Time;
32 | with Ada.Text_IO;
33 |
34 | with STM32.Board; use STM32.Board;
35 | with STM32.DMA2D_Bitmap; use STM32.DMA2D_Bitmap;
36 | with STM32.SDRAM;
37 |
38 | with HAL.Bitmap; use HAL.Bitmap;
39 | with HAL.Framebuffer;
40 |
41 | with Bitmapped_Drawing; use Bitmapped_Drawing;
42 | with Framebuffer_Helper; use Framebuffer_Helper;
43 |
44 | with Gestures;
45 | with Tasking;
46 |
47 | with Game;
48 | with Solver;
49 | with Status;
50 |
51 | procedure Demo_2048
52 | is
53 | procedure On_Autoplay_Clicked;
54 | procedure On_Slide (New_Gesture : Gestures.Gesture_Data);
55 |
56 | -------------------------
57 | -- On_Autoplay_Clicked --
58 | -------------------------
59 |
60 | procedure On_Autoplay_Clicked
61 | is
62 | begin
63 | Tasking.Solver_Toggled;
64 | end On_Autoplay_Clicked;
65 |
66 | --------------
67 | -- On_Slide --
68 | --------------
69 |
70 | procedure On_Slide (New_Gesture : Gestures.Gesture_Data)
71 | is
72 | use Gestures;
73 | Area : constant Rect := Status.Get_Autoplay_Btn_Area;
74 | G : Gestures.Gesture_Data renames New_Gesture;
75 |
76 | begin
77 | if G.Id = Gestures.Tap
78 | and then G.Origin.X >= Area.X
79 | and then G.Origin.Y >= Area.Y
80 | and then G.Origin.X <= Area.X + Area.Width
81 | and then G.Origin.Y <= Area.Y + Area.Height
82 | then
83 | On_Autoplay_Clicked;
84 | elsif not Game.Is_Sliding then
85 | Tasking.Handle_Gesture (New_Gesture);
86 | end if;
87 | end On_Slide;
88 |
89 | Status_Layer_Area : constant Rect := Game.Get_Status_Area;
90 | Buffer : DMA2D_Bitmap_Buffer;
91 |
92 | begin
93 | Ada.Text_IO.Put_Line ("Ready");
94 | Initialize_LEDs;
95 | STM32.SDRAM.Initialize;
96 | Display.Initialize (Mode => HAL.Framebuffer.Polling);
97 | Display.Initialize_Layer (1, ARGB_1555);
98 | Display.Initialize_Layer (2, ARGB_1555,
99 | Status_Layer_Area.X,
100 | Status_Layer_Area.Y,
101 | Status_Layer_Area.Width,
102 | Status_Layer_Area.Height);
103 | Touch_Panel.Initialize (Enable_Interrupts => True);
104 |
105 | Display.Set_Background (240, 240, 240);
106 |
107 | -- STM32.User_Button.Initialize;
108 |
109 | Game.Init;
110 | Game.Start;
111 |
112 | Buffer := DMA2D_Bitmap_Buffer (Display.Get_Hidden_Buffer (1));
113 | Game.Draw (Buffer);
114 | Status.Init_Area (Buffer);
115 |
116 | Status.Set_Score (0);
117 |
118 | Status.Set_Autoplay_Enabled (False);
119 |
120 | Update_All_Layers;
121 |
122 | Gestures.Initialize (On_Slide'Unrestricted_Access);
123 |
124 | Solver.Init_Solver;
125 |
126 | Status.Set_Autoplay_Enabled (True);
127 |
128 | Update_All_Layers;
129 |
130 | STM32.Board.Turn_Off (STM32.Board.Green);
131 |
132 | loop
133 | delay until Time_Last;
134 | end loop;
135 | end Demo_2048;
136 |
--------------------------------------------------------------------------------
/services/filesystem/MBR/filesystem-mbr.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Ada Filesystem Library --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Interfaces;
25 | with HAL.Block_Drivers;
26 |
27 | package Filesystem.MBR is
28 |
29 | type Master_Boot_Record is private;
30 | type Extended_Boot_Record is private;
31 |
32 | type Partition_Number is range 1 .. 4;
33 |
34 | type Partition_Type is new Interfaces.Unsigned_8;
35 |
36 | function Read
37 | (Controller : HAL.Block_Drivers.Any_Block_Driver;
38 | MBR : out Master_Boot_Record) return Status_Code;
39 |
40 | function Active (MBR : Master_Boot_Record;
41 | P : Partition_Number) return Boolean;
42 | function Valid (MBR : Master_Boot_Record;
43 | P : Partition_Number) return Boolean;
44 | function Get_Type (MBR : Master_Boot_Record;
45 | P : Partition_Number) return Partition_Type;
46 | function LBA (MBR : Master_Boot_Record;
47 | P : Partition_Number) return Block_Number;
48 | function Sectors (MBR : Master_Boot_Record;
49 | P : Partition_Number) return Interfaces.Unsigned_32;
50 |
51 | function Is_Extended
52 | (MBR : Master_Boot_Record;
53 | P : Partition_Number) return Boolean;
54 |
55 | function Read_Extended
56 | (Controller : HAL.Block_Drivers.Any_Block_Driver;
57 | MBR : Master_Boot_Record;
58 | P : Partition_Number;
59 | EBR : out Extended_Boot_Record) return Status_Code;
60 |
61 | function Get_Type (EBR : Extended_Boot_Record) return Partition_Type;
62 | function LBA (EBR : Extended_Boot_Record) return Block_Number;
63 | function Sectors (EBR : Extended_Boot_Record) return Interfaces.Unsigned_32;
64 |
65 | function Has_Next (EBR : Extended_Boot_Record) return Boolean;
66 |
67 | function Read_Next
68 | (Controller : HAL.Block_Drivers.Any_Block_Driver;
69 | EBR : in out Extended_Boot_Record) return Status_Code;
70 |
71 | private
72 |
73 | type CHS_Address is record
74 | Head : Interfaces.Unsigned_8;
75 | Sector : Interfaces.Unsigned_8;
76 | Cylinder : Interfaces.Unsigned_8;
77 | end record with Size => 24;
78 |
79 | for CHS_Address use record
80 | Head at 0 range 0 .. 7;
81 | Sector at 1 range 0 .. 7;
82 | Cylinder at 2 range 0 .. 7;
83 | end record;
84 |
85 | type Partition_Entry is record
86 | Status : Interfaces.Unsigned_8;
87 | First_Sector : CHS_Address;
88 | P_Type : Partition_Type;
89 | Last_Sector : CHS_Address;
90 | LBA : Interfaces.Unsigned_32;
91 | Num_Sectors : Interfaces.Unsigned_32;
92 | end record with Size => 16 * 8;
93 |
94 | for Partition_Entry use record
95 | Status at 0 range 0 .. 7;
96 | First_Sector at 1 range 0 .. 23;
97 | P_Type at 4 range 0 .. 7;
98 | Last_Sector at 5 range 0 .. 23;
99 | LBA at 8 range 0 .. 31;
100 | Num_Sectors at 12 range 0 .. 31;
101 | end record;
102 |
103 | Zeroed_Entry : constant Partition_Entry :=
104 | (Status => 0,
105 | First_Sector => (0, 0, 0),
106 | P_Type => 0,
107 | Last_Sector => (0, 0, 0),
108 | LBA => 0,
109 | Num_Sectors => 0);
110 |
111 | type Partition_Array is array (Partition_Number) of Partition_Entry;
112 |
113 | type Master_Boot_Record is record
114 | P_Entries : Partition_Array;
115 | Signature : Interfaces.Unsigned_16;
116 | end record with Size => 512 * 8;
117 |
118 | for Master_Boot_Record use record
119 | P_Entries at 16#1BE# range 0 .. 4 * 16 * 8 - 1;
120 | Signature at 16#1FE# range 0 .. 15;
121 | end record;
122 |
123 | type Extended_Boot_Record is new Master_Boot_Record;
124 |
125 | function Is_Extended
126 | (MBR : Master_Boot_Record;
127 | P : Partition_Number) return Boolean
128 | is (Get_Type (MBR, P) = 16#0F#);
129 |
130 | end Filesystem.MBR;
131 |
--------------------------------------------------------------------------------
/common/gui/lcd_std_out.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | -- This package provides a set of convenience routines for putting characters
25 | -- and strings out to the LCD.
26 |
27 | with STM32.Device; use STM32.Device;
28 | with BMP_Fonts; use BMP_Fonts;
29 |
30 | with HAL.Bitmap;
31 | with HAL.Framebuffer;
32 |
33 | package LCD_Std_Out is
34 |
35 | Black : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Black;
36 | Blue : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Blue;
37 | Light_Blue : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Light_Blue;
38 | Green : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Green;
39 | Cyan : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Cyan;
40 | Gray : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Gray;
41 | Magenta : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Magenta;
42 | Light_Green : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Light_Green;
43 | Brown : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Brown;
44 | Red : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Red;
45 | Orange : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Orange;
46 | Yellow : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Yellow;
47 | White : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.White;
48 |
49 | Default_Text_Color : constant HAL.Bitmap.Bitmap_Color := White;
50 | Default_Background_Color : constant HAL.Bitmap.Bitmap_Color := Black;
51 | Default_Font : constant BMP_Font := Font16x24;
52 | -- Default_Orientation : constant LCD.Orientations := LCD.Portrait_2;
53 |
54 | -- Changes to these current values will appear on subsequent calls to the
55 | -- output routines.
56 | Current_Text_Color : HAL.Bitmap.Bitmap_Color := Default_Text_Color;
57 | Current_Background_Color : HAL.Bitmap.Bitmap_Color := Default_Background_Color;
58 |
59 | procedure Set_Font (To : BMP_Font);
60 | -- Changes the current font setting so that subsequent output is in the
61 | -- specified font.
62 |
63 | procedure Set_Orientation (To : HAL.Framebuffer.Display_Orientation);
64 | -- Configures the screen orientation and fills the screen with the current
65 | -- background color. All previously displayed content is lost.
66 |
67 | procedure Clear_Screen;
68 |
69 | ----------------------------------------------------------------------------
70 |
71 | -- These routines maintain a logical line and column, such that text will
72 | -- wrap around to the next "line" when necessary, as determined by the
73 | -- current orientation of the screen.
74 |
75 | procedure Put_Line (Msg : String);
76 | -- Note: wraps around to the next line if necessary.
77 | -- Always calls procedure New_Line automatically after printing the string.
78 |
79 | procedure Put (Msg : String);
80 | -- Note: wraps around to the next line if necessary.
81 |
82 | procedure Put (Msg : Character);
83 |
84 | procedure New_Line;
85 | -- A subsequent call to Put or Put_Line will start printing characters at
86 | -- the beginning of the next line, wrapping around to the top of the LCD
87 | -- screen if necessary.
88 |
89 | ----------------------------------------------------------------------------
90 |
91 | -- These routines are provided for convenience, as an alternative to
92 | -- using both this package and an instance of Bitmnapped_Drawing directly,
93 | -- when wanting both the wrap-around semantics and direct X/Y coordinate
94 | -- control. You can combine calls to these routines with the ones above but
95 | -- these do not update the logical line/column state, so more likely you
96 | -- will use one set or the other. If you only need X/Y coordinate control,
97 | -- consider directly using an instance of HAL.Bitmap.
98 |
99 | procedure Put (X, Y : Natural; Msg : Character);
100 | -- Prints the character at the specified location. Has no other effect
101 | -- whatsoever, especially none on the state of the current logical line
102 | -- or logical column.
103 |
104 | procedure Put (X, Y : Natural; Msg : String);
105 | -- Prints the string, starting at the specified location. Has no other
106 | -- effect whatsoever, especially none on the state of the current logical
107 | -- line or logical column. Does not wrap around.
108 |
109 | end LCD_Std_Out;
110 |
--------------------------------------------------------------------------------
/common/gui/bitmapped_drawing.ads:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- --
3 | -- Copyright (C) 2015-2016, 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 | -- This package provides routines for drawing shapes, characters, and strings
33 | -- on a bit-mapped device or graphical buffer.
34 |
35 | with Interfaces; use Interfaces;
36 | with BMP_Fonts; use BMP_Fonts;
37 | with Hershey_Fonts; use Hershey_Fonts;
38 | with HAL.Bitmap; use HAL.Bitmap;
39 |
40 | package Bitmapped_Drawing is
41 |
42 | type Point is record
43 | X : Natural;
44 | Y : Natural;
45 | end record;
46 |
47 | function "+" (P1, P2 : Point) return Point
48 | is ((P1.X + P2.X, P1.Y + P2.Y));
49 |
50 | function "-" (P1, P2 : Point) return Point
51 | is ((P1.X - P2.X, P1.Y - P2.Y));
52 |
53 | type Rect is record
54 | X : Natural;
55 | Y : Natural;
56 | Width : Natural;
57 | Height : Natural;
58 | end record;
59 |
60 | procedure Draw_Line
61 | (Buffer : Bitmap_Buffer'Class;
62 | Start, Stop : Point;
63 | Hue : Unsigned_32;
64 | Thickness : Natural := 1;
65 | Fast : Boolean := True);
66 | procedure Draw_Line
67 | (Buffer : Bitmap_Buffer'Class;
68 | Start, Stop : Point;
69 | Hue : Bitmap_Color;
70 | Thickness : Natural := 1;
71 | Fast : Boolean := True);
72 | -- If fast is set, then the line thickness uses squares to draw, while
73 | -- if not set, then the line will be composed of circles, much slower to
74 | -- draw but providing nicer line cap.
75 |
76 | procedure Draw_Rectangle
77 | (Buffer : Bitmap_Buffer'Class;
78 | Area : Rect;
79 | Hue : Bitmap_Color;
80 | Thickness : Natural := 1);
81 |
82 | procedure Draw_Rounded_Rectangle
83 | (Buffer : Bitmap_Buffer'Class;
84 | Area : Rect;
85 | Radius : Natural;
86 | Hue : Bitmap_Color;
87 | Thickness : Natural := 1);
88 |
89 | procedure Fill_Rounded_Rectangle
90 | (Buffer : Bitmap_Buffer'Class;
91 | X : Natural;
92 | Y : Natural;
93 | Width : Positive;
94 | Height : Positive;
95 | Radius : Natural;
96 | Hue : Bitmap_Color);
97 |
98 | procedure Cubic_Bezier
99 | (Buffer : Bitmap_Buffer'Class;
100 | P1, P2, P3, P4 : Point;
101 | Hue : Bitmap_Color;
102 | N : Positive := 20;
103 | Thickness : Natural := 1);
104 |
105 | procedure Draw_Circle
106 | (Buffer : Bitmap_Buffer'Class;
107 | Center : Point;
108 | Radius : Natural;
109 | Hue : Unsigned_32);
110 | procedure Draw_Circle
111 | (Buffer : Bitmap_Buffer'Class;
112 | Center : Point;
113 | Radius : Natural;
114 | Hue : Bitmap_Color);
115 |
116 | procedure Fill_Circle
117 | (Buffer : Bitmap_Buffer'Class;
118 | Center : Point;
119 | Radius : Natural;
120 | Hue : Unsigned_32);
121 | procedure Fill_Circle
122 | (Buffer : Bitmap_Buffer'Class;
123 | Center : Point;
124 | Radius : Natural;
125 | Hue : Bitmap_Color);
126 |
127 | procedure Draw_Char
128 | (Buffer : Bitmap_Buffer'Class;
129 | Start : Point;
130 | Char : Character;
131 | Font : BMP_Font;
132 | Foreground : Unsigned_32;
133 | Background : Unsigned_32);
134 |
135 | procedure Draw_String
136 | (Buffer : Bitmap_Buffer'Class;
137 | Start : Point;
138 | Msg : String;
139 | Font : BMP_Font;
140 | Foreground : Bitmap_Color;
141 | Background : Bitmap_Color);
142 |
143 | procedure Draw_String
144 | (Buffer : Bitmap_Buffer'Class;
145 | Start : Point;
146 | Msg : String;
147 | Font : Hershey_Font;
148 | Height : Natural;
149 | Bold : Boolean;
150 | Foreground : Bitmap_Color;
151 | Fast : Boolean := True);
152 |
153 | procedure Draw_String
154 | (Buffer : Bitmap_Buffer'Class;
155 | Area : Rect;
156 | Msg : String;
157 | Font : Hershey_Font;
158 | Bold : Boolean;
159 | Outline : Boolean;
160 | Foreground : Bitmap_Color;
161 | Fast : Boolean := True);
162 |
163 | end Bitmapped_Drawing;
164 |
--------------------------------------------------------------------------------
/services/filesystem/MBR/filesystem-mbr.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Ada Filesystem Library --
3 | -- --
4 | -- Copyright (C) 2015-2016, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Interfaces; use Interfaces;
25 |
26 | package body Filesystem.MBR is
27 |
28 | ----------
29 | -- Read --
30 | ----------
31 |
32 | function Read
33 | (Controller : HAL.Block_Drivers.Any_Block_Driver;
34 | MBR : out Master_Boot_Record) return Status_Code
35 | is
36 | Tmp : aliased Master_Boot_Record;
37 | Data : aliased HAL.Block_Drivers.Block (1 .. 512)
38 | with Address => Tmp'Address;
39 | begin
40 | -- Let's read the MBR: located in the first block
41 | if not Controller.Read (0, Data) then
42 | return Disk_Error;
43 | end if;
44 |
45 | MBR := Tmp;
46 |
47 | if MBR.Signature /= 16#AA55# then
48 | return No_MBR_Found;
49 | end if;
50 |
51 | return OK;
52 | end Read;
53 |
54 | -------------------
55 | -- Read_Extended --
56 | -------------------
57 |
58 | function Read_Extended
59 | (Controller : HAL.Block_Drivers.Any_Block_Driver;
60 | MBR : Master_Boot_Record;
61 | P : Partition_Number;
62 | EBR : out Extended_Boot_Record) return Status_Code
63 | is
64 | BA : constant Block_Number := LBA (MBR, P);
65 | Tmp : aliased Extended_Boot_Record;
66 | Data : aliased HAL.Block_Drivers.Block (1 .. 512)
67 | with Address => Tmp'Address;
68 | begin
69 | -- Let's read the MBR: located in the first block
70 | if not Controller.Read (HAL.UInt64 (BA), Data) then
71 | return Disk_Error;
72 | end if;
73 |
74 | EBR := Tmp;
75 |
76 | if EBR.Signature /= 16#AA55# then
77 | return No_MBR_Found;
78 | end if;
79 |
80 | return OK;
81 | end Read_Extended;
82 |
83 | ------------
84 | -- Active --
85 | ------------
86 |
87 | function Active (MBR : Master_Boot_Record;
88 | P : Partition_Number) return Boolean
89 | is (MBR.P_Entries (P).Status = 16#80#);
90 |
91 | -----------
92 | -- Valid --
93 | -----------
94 |
95 | function Valid (MBR : Master_Boot_Record;
96 | P : Partition_Number) return Boolean
97 | is ((MBR.P_Entries (P).Status and not 16#80#) = 0);
98 |
99 | --------------
100 | -- Get_Type --
101 | --------------
102 |
103 | function Get_Type (MBR : Master_Boot_Record;
104 | P : Partition_Number) return Partition_Type
105 | is (MBR.P_Entries (P).P_Type);
106 |
107 | ---------
108 | -- LBA --
109 | ---------
110 |
111 | function LBA (MBR : Master_Boot_Record;
112 | P : Partition_Number) return Block_Number
113 | is (
114 | -- MBR only supports 32-bit LBA. But as we want a generic FS interface
115 | -- here, LBA is defined as a 64-bit number, hence the explicit cast
116 | -- below.
117 | Block_Number (MBR.P_Entries (P).LBA));
118 |
119 | -------------
120 | -- Sectors --
121 | -------------
122 |
123 | function Sectors (MBR : Master_Boot_Record;
124 | P : Partition_Number) return Interfaces.Unsigned_32
125 | is (MBR.P_Entries (P).Num_Sectors);
126 |
127 | --------------
128 | -- Get_Type --
129 | --------------
130 |
131 | function Get_Type (EBR : Extended_Boot_Record) return Partition_Type
132 | is
133 | begin
134 | return EBR.P_Entries (1).P_Type;
135 | end Get_Type;
136 |
137 | ---------
138 | -- LBA --
139 | ---------
140 |
141 | function LBA (EBR : Extended_Boot_Record) return Block_Number
142 | is
143 | begin
144 | return Block_Number (EBR.P_Entries (1).LBA);
145 | end LBA;
146 |
147 | -------------
148 | -- Sectors --
149 | -------------
150 |
151 | function Sectors (EBR : Extended_Boot_Record) return Interfaces.Unsigned_32
152 | is
153 | begin
154 | return EBR.P_Entries (1).Num_Sectors;
155 | end Sectors;
156 |
157 | --------------
158 | -- Has_Next --
159 | --------------
160 |
161 | function Has_Next (EBR : Extended_Boot_Record) return Boolean
162 | is
163 | begin
164 | return EBR.P_Entries (2) /= Zeroed_Entry;
165 | end Has_Next;
166 |
167 | ---------------
168 | -- Read_Next --
169 | ---------------
170 |
171 | function Read_Next
172 | (Controller : HAL.Block_Drivers.Any_Block_Driver;
173 | EBR : in out Extended_Boot_Record) return Status_Code
174 | is
175 | BA : constant Block_Number := Block_Number (EBR.P_Entries (2).LBA);
176 | Tmp : aliased Extended_Boot_Record;
177 | Data : aliased HAL.Block_Drivers.Block (1 .. 512)
178 | with Address => Tmp'Address;
179 | begin
180 | -- Let's read the MBR: located in the first block
181 | if not Controller.Read (HAL.UInt64 (BA), Data) then
182 | return Disk_Error;
183 | end if;
184 |
185 | EBR := Tmp;
186 |
187 | if EBR.Signature /= 16#AA55# then
188 | return No_MBR_Found;
189 | end if;
190 |
191 | return OK;
192 | end Read_Next;
193 |
194 | end Filesystem.MBR;
195 |
--------------------------------------------------------------------------------
/wolf/src/stm32/renderer-tasks.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with Ada.Real_Time; use Ada.Real_Time;
25 |
26 | with Cortex_M.Cache;
27 | -- with STM32.SDRAM; use STM32.SDRAM;
28 |
29 | with Bitmapped_Drawing;
30 | with BMP_Fonts;
31 |
32 | separate (Renderer)
33 | package body Tasks is
34 |
35 | FPS : Natural := 0;
36 | Last : Time := Clock;
37 |
38 | -- Timers used to measure the time spent in the various steps of building
39 | -- a frame
40 | Trace_Time : Time_Span := Milliseconds (0);
41 | Wall_Time : Time_Span := Milliseconds (0);
42 | Sprite_Time : Time_Span := Milliseconds (0);
43 | Total_Time : Time_Span := Milliseconds (0);
44 |
45 | Tracers : Raycaster.Trace_Points;
46 |
47 | ----------------
48 | -- Initialize --
49 | ----------------
50 |
51 | procedure Initialize is
52 | begin
53 | null;
54 | end Initialize;
55 |
56 | -------------------------
57 | -- Copy_Sprites_Buffer --
58 | -------------------------
59 |
60 | procedure Copy_Sprites_Buffer
61 | (Cache : Column_Info;
62 | Buf : HAL.Bitmap.Bitmap_Buffer'Class;
63 | X : Natural;
64 | Y : Natural;
65 | Height : Natural)
66 | is
67 | begin
68 | Copy_Rect_Blend
69 | (Src_Buffer => HAL.Bitmap.Bitmap_Buffer'Class (Cache.Col_Buffer),
70 | X_Src => 0,
71 | Y_Src => 0,
72 | Dst_Buffer => Buf,
73 | X_Dst => X,
74 | Y_Dst => Y,
75 | Width => 1,
76 | Height => Height,
77 | Synchronous => False,
78 | Clean_Cache => False);
79 | end Copy_Sprites_Buffer;
80 |
81 | ----------
82 | -- Draw --
83 | ----------
84 |
85 | procedure Draw
86 | is
87 | Visible : Visible_Elements := (others => (others => False));
88 | Tmp : constant Time := Clock;
89 | Buf_1 : Bitmap.Bitmap_Buffer'Class renames
90 | Display.Get_Hidden_Buffer (1);
91 | Buf_2 : Bitmap.Bitmap_Buffer'Class renames
92 | Display.Get_Hidden_Buffer (2);
93 |
94 | begin
95 | Trace_Rays (Visible, Tracers);
96 | Sort_Sprites (Visible);
97 |
98 | Trace_Time := Trace_Time + (Clock - Tmp);
99 |
100 | declare
101 | Info : Column_Info;
102 | Now : constant Time := Clock;
103 | begin
104 | Info.Col_Buffer :=
105 | (Addr => Info.Column'Address,
106 | Width => 1,
107 | Height => LCD_H,
108 | Color_Mode => Playground.Color_Mode,
109 | Swapped => Display.Is_Swapped);
110 | Info.Prev_Height := LCD_H;
111 | Info.Prev_Top := 0;
112 |
113 | for X in Tracers'Range loop
114 | Draw_Wall (Tracers (X), Buf_1, Info);
115 | end loop;
116 |
117 | Wall_Time := Wall_Time + Clock - Now;
118 | end;
119 |
120 | declare
121 | Now : constant Time := Clock;
122 | begin
123 | Draw_Sprites (Buf_1, Tracers);
124 | Sprite_Time := Sprite_Time + Clock - Now;
125 | end;
126 |
127 | Total_Time := Total_Time + (Clock - Tmp);
128 |
129 | FPS := FPS + 1;
130 |
131 | if Clock - Last > Seconds (1) then
132 | declare
133 | Trace : constant Natural := Trace_Time / Milliseconds (1) / FPS;
134 | Wall : constant Natural := Wall_Time / Milliseconds (1) / FPS;
135 | Sprites : constant Natural := Sprite_Time / Milliseconds (1) / FPS;
136 | Total : constant Natural := Total_Time / Milliseconds (1) / FPS;
137 |
138 | begin
139 | -- Reset the timers
140 | Trace_Time := Milliseconds (0);
141 | Wall_Time := Milliseconds (0);
142 | Sprite_Time := Milliseconds (0);
143 | Total_Time := Milliseconds (0);
144 |
145 | Buf_2.Fill (HAL.Bitmap.Transparent);
146 | Cortex_M.Cache.Invalidate_DCache
147 | (Buf_2.Addr,
148 | Buf_2.Buffer_Size);
149 | Bitmapped_Drawing.Draw_String
150 | (Buffer => Buf_2,
151 | Start => (0, 0),
152 | Msg => " fps: " & Natural'Image (FPS),
153 | Font => BMP_Fonts.Font12x12,
154 | Foreground => HAL.Bitmap.White,
155 | Background => HAL.Bitmap.Transparent);
156 | Bitmapped_Drawing.Draw_String
157 | (Buffer => Buf_2,
158 | Start => (0, 12),
159 | Msg => " trace: " & Natural'Image (Trace) & " ms/f",
160 | Font => BMP_Fonts.Font12x12,
161 | Foreground => HAL.Bitmap.White,
162 | Background => HAL.Bitmap.Transparent);
163 | Bitmapped_Drawing.Draw_String
164 | (Buffer => Buf_2,
165 | Start => (0, 24),
166 | Msg => " wall: " & Natural'Image (Wall) & " ms/f",
167 | Font => BMP_Fonts.Font12x12,
168 | Foreground => HAL.Bitmap.White,
169 | Background => HAL.Bitmap.Transparent);
170 | Bitmapped_Drawing.Draw_String
171 | (Buffer => Buf_2,
172 | Start => (0, 36),
173 | Msg => " sprite:" & Natural'Image (Sprites) & " ms/f",
174 | Font => BMP_Fonts.Font12x12,
175 | Foreground => HAL.Bitmap.White,
176 | Background => HAL.Bitmap.Transparent);
177 | Bitmapped_Drawing.Draw_String
178 | (Buffer => Buf_2,
179 | Start => (0, 48),
180 | Msg => " TOTAL: " & Natural'Image (Total) & " ms/f",
181 | Font => BMP_Fonts.Font12x12,
182 | Foreground => HAL.Bitmap.White,
183 | Background => HAL.Bitmap.Transparent);
184 | end;
185 |
186 | FPS := 0;
187 | Last := Clock;
188 |
189 | Display.Update_Layers;
190 |
191 | else
192 | Display.Update_Layer (1);
193 | end if;
194 | end Draw;
195 |
196 | end Tasks;
197 |
--------------------------------------------------------------------------------
/wolf/src/rpi/tasking/renderer-tasks.adb:
--------------------------------------------------------------------------------
1 | ------------------------------------------------------------------------------
2 | -- Bareboard drivers examples --
3 | -- --
4 | -- Copyright (C) 2015-2017, AdaCore --
5 | -- --
6 | -- This library is free software; you can redistribute it and/or modify it --
7 | -- under terms of the GNU General Public License as published by the Free --
8 | -- Software Foundation; either version 3, or (at your option) any later --
9 | -- version. This library is distributed in the hope that it will be useful, --
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11 | -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
12 | -- --
13 | -- As a special exception under Section 7 of GPL version 3, you are granted --
14 | -- additional permissions described in the GCC Runtime Library Exception, --
15 | -- version 3.1, as published by the Free Software Foundation. --
16 | -- --
17 | -- You should have received a copy of the GNU General Public License and --
18 | -- a copy of the GCC Runtime Library Exception along with this program; --
19 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
20 | -- . --
21 | -- --
22 | ------------------------------------------------------------------------------
23 |
24 | with System;
25 | with System.Multiprocessors; use System.Multiprocessors;
26 |
27 | with Ada.Real_Time; use Ada.Real_Time;
28 | with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control;
29 |
30 | with GNAT.IO;
31 |
32 | separate (Renderer)
33 | package body Tasks is
34 |
35 | type Suspension_Array is array (CPU) of
36 | Ada.Synchronous_Task_Control.Suspension_Object;
37 |
38 | Tracers : Raycaster.Trace_Points;
39 | Starts : Suspension_Array;
40 |
41 | ---------------
42 | -- Draw_Task --
43 | ---------------
44 |
45 | task type Draw_Task (Id : CPU) is
46 | pragma Cpu (Id);
47 | pragma Priority (System.Default_Priority - 1);
48 | pragma Storage_Size (256 * 1024);
49 | end Draw_Task;
50 |
51 | ---------------
52 | -- Draw_Prot --
53 | ---------------
54 |
55 | protected Draw_Prot
56 | is
57 | procedure Set_Done (Id : CPU);
58 | entry Wait with Max_Queue_Length => 1;
59 |
60 | private
61 | Done1 : Boolean := False;
62 | Done2 : Boolean := False;
63 | Done3 : Boolean := False;
64 | Done4 : Boolean := False;
65 | Done : Boolean := False;
66 | end Draw_Prot;
67 |
68 | Drawer_1 : Draw_Task (1);
69 | Drawer_2 : Draw_Task (2);
70 | Drawer_3 : Draw_Task (3);
71 | Drawer_4 : Draw_Task (4);
72 |
73 | ---------------
74 | -- Draw_Task --
75 | ---------------
76 |
77 | task body Draw_Task
78 | is
79 | Tmp : aliased Column_Info;
80 | X0 : constant Natural := (case Id is
81 | when 1 => 0,
82 | when 2 => LCD_W / 4,
83 | when 3 => LCD_W / 2,
84 | when 4 => 3 * LCD_W / 4);
85 | X1 : constant Natural := (case Id is
86 | when 1 => LCD_W / 4 - 1,
87 | when 2 => LCD_W / 2 - 1,
88 | when 3 => 3 * LCD_W / 4 - 1,
89 | when 4 => LCD_W - 1);
90 | begin
91 | Tmp.Col_Buffer :=
92 | (Addr => Tmp.Column'Address,
93 | Width => 1,
94 | Height => LCD_H,
95 | Color_Mode => Playground.Color_Mode,
96 | Swapped => False);
97 |
98 | loop
99 | Tmp.Prev_Height := LCD_H;
100 | Tmp.Prev_Top := 0;
101 |
102 | Suspend_Until_True (Starts (Id));
103 |
104 | declare
105 | Buf : Bitmap.Bitmap_Buffer :=
106 | Display.Get_Hidden_Buffer (1);
107 | begin
108 | for X in X0 .. X1 loop
109 | Draw_Wall (Tracers (X), Buf, Tmp);
110 | end loop;
111 | end;
112 |
113 | Draw_Prot.Set_Done (Id);
114 | end loop;
115 | end Draw_Task;
116 |
117 | ---------------
118 | -- Draw_Prot --
119 | ---------------
120 |
121 | protected body Draw_Prot is
122 |
123 | --------------
124 | -- Set_Done --
125 | --------------
126 |
127 | procedure Set_Done (Id : CPU)
128 | is
129 | begin
130 | if Id = 1 then
131 | Done1 := True;
132 | elsif Id = 2 then
133 | Done2 := True;
134 | elsif Id = 3 then
135 | Done3 := True;
136 | elsif Id = 4 then
137 | Done4 := True;
138 | end if;
139 |
140 | Done := Done1 and then Done2 and then Done3 and then Done4;
141 | end Set_Done;
142 |
143 | ----------
144 | -- Wait --
145 | ----------
146 |
147 | entry Wait when Done is
148 | begin
149 | Done := False;
150 | Done1 := False;
151 | Done2 := False;
152 | Done3 := False;
153 | Done4 := False;
154 | end Wait;
155 | end Draw_Prot;
156 |
157 | FPS : Natural := 0;
158 | Last : Time := Clock;
159 |
160 | ----------------
161 | -- Initialize --
162 | ----------------
163 |
164 | procedure Initialize is
165 | begin
166 | null;
167 | end Initialize;
168 |
169 | -------------------------
170 | -- Copy_Sprites_Buffer --
171 | -------------------------
172 |
173 | procedure Copy_Sprites_Buffer
174 | (Cache : Column_Info;
175 | Buf : in out HAL.Bitmap.Bitmap_Buffer'Class;
176 | X : Natural;
177 | Y : Natural;
178 | Height : Natural)
179 | is
180 | function To_RGB (Col : UInt16) return UInt16;
181 |
182 | ------------
183 | -- To_RGB --
184 | ------------
185 |
186 | function To_RGB (Col : UInt16) return UInt16
187 | is
188 | begin
189 | return Shift_Left (Col and 2#0_11111_11111_00000#, 1)
190 | or (Col and 2#0_00000_00000_11111#);
191 | end To_RGB;
192 |
193 | Col : UInt16;
194 |
195 | begin
196 | for Row in 0 .. Height - 1 loop
197 | Col := Cache.Column (Row);
198 | if Col /= 0 then
199 | Buf.Set_Pixel ((X, Y + Row), UInt32 (To_RGB (Col)));
200 | end if;
201 | end loop;
202 | end Copy_Sprites_Buffer;
203 |
204 | ----------
205 | -- Draw --
206 | ----------
207 |
208 | procedure Draw
209 | is
210 | Visible : Visible_Elements := (others => (others => False));
211 | Buf : Bitmap.Bitmap_Buffer :=
212 | Display.Get_Hidden_Buffer (1);
213 | begin
214 | -- Trace the rays in the env task
215 | Trace_Rays (Visible, Tracers);
216 | Sort_Sprites (Visible);
217 |
218 | for J in Starts'Range loop
219 | -- Unlock all tasks: when work is completed, it will unlock the
220 | -- protected object.
221 | Set_True (Starts (J));
222 | end loop;
223 |
224 | -- Wait for the tasks to finish
225 | Draw_Prot.Wait;
226 |
227 | Display.Wait_Transfer;
228 | Draw_Sprites (Buf, Tracers);
229 |
230 | FPS := FPS + 1;
231 |
232 | if Clock - Last > Milliseconds (500) then
233 | GNAT.IO.Put (FPS);
234 | GNAT.IO.Put_Line (" fps");
235 | FPS := 0;
236 | Last := Clock;
237 | end if;
238 |
239 | Display.Update_Layer (1);
240 | end Draw;
241 |
242 | end Tasks;
243 |
--------------------------------------------------------------------------------