Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Appveyor continuous builder configuration

# Version format, we don't have version number for ADL yet
version: 0.0.{build}

# Setup python for build and test-suite scripts
environment:
PYTHON: C:\\Python27
TOOLS_DIR: C:\ADL_tools\
GNAT_NATIVE_INSTALLER: C:\ADL_tools\gnat-community-2018-x86_64-windows-bin.exe
GNAT_ARM_ELF_INSTALLER: C:\ADL_tools\gnat-community-2018-arm-elf-windows-bin.exe
INSTALL_DIR: C:\Install\
INSTALL_CONTROL_SCRIPT: C:\projects\ada-drivers-library\scripts\GNAT_CE_2018_install_control.qs

# Cache directories will be preseved from one build to the other
cache:
- C:\ADL_tools

on_failure:
- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

install:
# Show current dir and its content
- cmd: cd
- cmd: dir

# Create the tool dir if it doesn't exists
- ps: md -f $env:TOOLS_DIR
- ps: md -f $env:INSTALL_DIR

# Show content of tool dir
- cmd: dir %TOOLS_DIR%
- cmd: dir %INSTALL_DIR%

# Download compiler installer if not already in the tool dir
- ps: If (Test-Path $env:GNAT_NATIVE_INSTALLER){echo compiler already in cache}Else{(new-object net.webclient).DownloadFile('http://mirrors.cdn.adacore.com/art/5b30f4e6c7a4477116360355', $env:GNAT_NATIVE_INSTALLER)}
- ps: If (Test-Path $env:GNAT_ARM_ELF_INSTALLER){echo compiler already in cache}Else{(new-object net.webclient).DownloadFile('http://mirrors.cdn.adacore.com/art/5b0843e7a3f5d75c215f46b6', $env:GNAT_ARM_ELF_INSTALLER)}

# Show content of tool dir again so we can see if the download was ok
- cmd: dir %TOOLS_DIR%

- ps: Invoke-WebRequest https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_package.bat -OutFile install_package.bat
- ps: Invoke-WebRequest https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_script.qs -OutFile install_script.qs

# Install the compilers
- cmd: install_package.bat %GNAT_NATIVE_INSTALLER% C:\Install\native
- cmd: install_package.bat %GNAT_ARM_ELF_INSTALLER% C:\Install\arm-elf

# Show content of install dir so we can see if install was ok
- cmd: dir %INSTALL_DIR%
- cmd: dir C:\Install\

# Add compiler to the PATH
- ps: $env:Path += ";" + $env:INSTALL_DIR +"\native\bin"
- ps: $env:Path += ";" + $env:INSTALL_DIR +"\arm-elf\bin"

# Check that we can run the compiler (also display the version)
- ps: arm-eabi-gnatls -v

# Install optional dependencies
- cmd: python scripts/install_dependencies.py

# We don't need a build step
build: off

# Run the test scripts
test_script:
- cmd: python scripts/build_all_examples.py
- cmd: python testsuite/run.py
26 changes: 20 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ python:
env:
global:
- TOOLS_DIR=$HOME/build_tools
- GNAT_TAR_PATH=$TOOLS_DIR/gnat-gpl-2017-x86_64-linux-bin.tar.gz
- GNAT_BIN_PATH=$TOOLS_DIR/gnat-community-2018-x86_64-linux-bin
- GNAT_ARM_BIN_PATH=$TOOLS_DIR/gnat-community-2018-arm-elf-bin
- INSTALL_CONTROL_SCRIPT=$PWD/scripts/GNAT_CE_2018_install_control.qs

os:
- linux
Expand All @@ -21,17 +23,29 @@ cache:
install:
# Check if the GNAT package is already available in the cache directory. If
# not, download it.
- test -f $GNAT_TAR_PATH ||( mkdir -p $TOOLS_DIR && wget http://mirrors.cdn.adacore.com/art/591c6d80c7a447af2deed1d7 -O $GNAT_TAR_PATH)
- test -f $GNAT_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget http://mirrors.cdn.adacore.com/art/5b0d7bffa3f5d709751e3e04 -O $GNAT_BIN_PATH)
- test -f $GNAT_ARM_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget http://mirrors.cdn.adacore.com/art/5b0c1227a3f5d7097625478d -O $GNAT_ARM_BIN_PATH)

# Extract GNAT from its package
- tar -xf $GNAT_TAR_PATH
- wget https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_package.sh
- wget https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_script.qs

- sh install_package.sh $GNAT_BIN_PATH $TOOLS_DIR/native/
- sh install_package.sh $GNAT_ARM_BIN_PATH $TOOLS_DIR/arm-elf/

# Add GNAT to $PATH
- export PATH=$PATH:$PWD/gnat-gpl-2017-x86_64-linux-bin/bin/
- export PATH=$PATH:$TOOLS_DIR/native/bin/
- export PATH=$PATH:$TOOLS_DIR/arm-elf/bin/

script:
# Show GNAT version for the record
- $PWD/gnat-gpl-2017-x86_64-linux-bin/bin/gprbuild --version
- $TOOLS_DIR/native/bin/gprbuild --version
- $TOOLS_DIR/arm-elf/bin/gprbuild --version

# Install extra run-times
- python $PWD/scripts/install_dependencies.py

# Build all examples
- python $PWD/scripts/build_all_examples.py

# Start the testsuite
- python $PWD/testsuite/run.py
56 changes: 21 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,33 @@

# 1. Introduction

This repository contains Ada source code and complete sample GNAT projects for
selected bare-board platforms supported by GNAT. Initially the repository
contains software for ARM platforms from a specific vendor, but we intend this
to be a location for both AdaCore and the community in general to contribute
support for additional processors, platforms, and vendors.
This repository contains drivers and sample projects to program
micro-controllers with the Ada and SPARK languages. The library also provides
some middleware services and drivers for external devices such as sensors. We
intend this to be a location for both AdaCore and the community in general to
contribute support for additional processors, platforms, and vendors.

# 2. Getting started
# 3. Supported hardware

To start using the Ada_Drivers_Library, please go to the [examples directory](examples/)
where you will find instructions to run your first project.
Ada_Drivers_Library provides support for various devices in the ARM Cortex-M
and RISC-V architectures. Some devices are only partially supported. Go to the
[boards directory](boards/) for a list of supported hardware.

# 3. License
# 3. Getting started

To start using the Ada_Drivers_Library, please go to the [examples
directory](examples/) where you will find instructions to run your first
project.

# 4. License

All files are provided under a 3-clause Berkeley Software Distribution (BSD)
license. As such, and within the conditions required by the license, the files
are available both for proprietary ("commercial") and non-proprietary use.

For details, see the `LICENSE` file in the root directory.

# 4. Requirements
# 5. Requirements

The software is written in Ada 2012 and uses, for example, preconditions,
postconditions, and the high-level iterator form of for-loops.
Expand All @@ -35,31 +42,9 @@ wishing to submit additions to the library should see the GNAT Reference Manual
for details.

Therefore, building with the sources requires a compiler supporting both Ada
2012 and the GNAT-defined pragma `Volatile_Full_Access`. The "GNAT GPL 2017"
compiler for ARM ELF is one such compiler [(Download it
here)](http://libre.adacore.com/download/configurations). A recent GNAT Pro
compiler for that target will also suffice.

# 5. Content

Initial provision is for the hardware in the STM32F4 family of 32-bit MCUs, as
defined in the "RM0090 Reference Manual" (Doc ID 018909 Rev 6, Feb 2014) by
STMicroelectronics and made available on the "STM32F4 Discovery" and the
"STM32F429 Discovery" kit boards.

Specifically, there are low-level device drivers, higher-level component drivers,
small demonstration programs for the drivers, and larger example applications.
"Component" drivers are those that are implemented using the lower-level device
drivers (e.g., SPI or GPIO), such as the gyroscope and accelerometer on the
Discovery boards.

The small driver demonstration programs and the larger applications programs are
provided as full projects, including GNAT project files, and are ready to build
either within GPS or on the command-line.

Not all devices defined by the Reference Manual are supported, and not all those
supported are complete. We encourage contributions of corrections, enhancements,
and new drivers.
2012 and the GNAT-defined pragma `Volatile_Full_Access`. For instance a recent
GNAT Pro compiler or GNAT Community 2018 for ARM ELF or RISC-V ELF [(Download
here)](http://adacore.com/download).

# 6. Roadmap

Expand Down Expand Up @@ -91,3 +76,4 @@ https://github.com/AdaCore/Lunar_Lander_Rotation_Demo)
* [Bare metal sudoku solver](https://github.com/stangassinger/sudoku)

(Add yours to the list!)

56 changes: 0 additions & 56 deletions appveyor.yml

This file was deleted.

41 changes: 40 additions & 1 deletion arch/ARM/Nordic/drivers/nrf51-interrupts.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- Copyright (C) 2016-2018, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
Expand Down Expand Up @@ -30,9 +30,16 @@
------------------------------------------------------------------------------

with Cortex_M.NVIC;
with System.Machine_Code; use System.Machine_Code;

package body nRF51.Interrupts is

Handlers : array (nRF51.Interrupts.Interrupt_Name) of Handler
:= (others => null);

procedure GNAT_IRQ_Handler;
pragma Export (Asm, GNAT_IRQ_Handler, "__gnat_irq_trap");

------------------
-- Set_Priority --
------------------
Expand Down Expand Up @@ -69,4 +76,36 @@ package body nRF51.Interrupts is
return Cortex_M.NVIC.Pending (Int'Enum_Rep);
end Pending;

--------------
-- Register --
--------------

procedure Register (Id : nRF51.Interrupts.Interrupt_Name;
Hdl : Handler)
is
begin
Handlers (Id) := Hdl;
end Register;

----------------------
-- GNAT_IRQ_Handler --
----------------------

procedure GNAT_IRQ_Handler is
Id : nRF51.Interrupts.Interrupt_Name;
IPSR : UInt32;
begin
Asm ("mrs %0, ipsr",
UInt32'Asm_Output ("=r", IPSR),
Volatile => True);

IPSR := IPSR and 16#FF#;

Id := nRF51.Interrupts.Interrupt_Name'Val (IPSR - 16);

if Handlers (Id) /= null then
Handlers (Id).all;
end if;
end GNAT_IRQ_Handler;

end nRF51.Interrupts;
7 changes: 7 additions & 0 deletions arch/ARM/Nordic/drivers/nrf51-interrupts.ads
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ package nRF51.Interrupts is
procedure Disable (Int : Interrupt_Name);
function Pending (Int : Interrupt_Name) return Boolean;

type Handler is access procedure;

procedure Register (Id : nRF51.Interrupts.Interrupt_Name;
Hdl : Handler);
-- Register a handler for the given interrupt. There can be only one handler
-- for each interrupt so the previous one, if any, will be removed.

private
for Interrupt_Name use
(POWER_CLOCK_Interrupt => 0,
Expand Down
16 changes: 16 additions & 0 deletions arch/ARM/cortex_m/src/semihosting-filesystem.adb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,22 @@ package body Semihosting.Filesystem is
return Operation_Not_Permitted;
end Open;

---------------
-- Root_Node --
---------------

overriding
function Root_Node
(This : in out SHFS;
As : String;
Handle : out Any_Node_Handle)
return Status_Code
is
pragma Unreferenced (As, Handle, This);
begin
return Operation_Not_Permitted;
end Root_Node;

---------------------
-- Get_File_Handle --
---------------------
Expand Down
3 changes: 1 addition & 2 deletions arch/ARM/cortex_m/src/semihosting-filesystem.ads
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ package Semihosting.Filesystem is
(This : in out SHFS;
As : String;
Handle : out Any_Node_Handle)
return Status_Code
is (Operation_Not_Permitted);
return Status_Code;

overriding
procedure Close (This : in out SHFS);
Expand Down
6 changes: 3 additions & 3 deletions boards/MicroBit/microbit_zfp.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ library project MicroBit_ZFP is
for Library_Kind use "static";
for Library_Name use "ada_drivers_library";
for Target use "arm-eabi";
for Runtime ("Ada") use "zfp-nrf51";
for Runtime ("Ada") use "zfp-microbit";

Vendor := "Nordic"; -- From board definition
Max_Mount_Points := "2"; -- From default value
Max_Mount_Name_Length := "128"; -- From default value
Runtime_Profile := "zfp"; -- From command line
Device_Name := "nRF51822xxAA"; -- From board definition
Device_Family := "nRF51"; -- From board definition
Runtime_Name := "zfp-nrf51"; -- From default value
Runtime_Name := "zfp-microbit"; -- From default value
Has_Ravenscar_Full_Runtime := "False"; -- From board definition
CPU_Core := "ARM Cortex-M0"; -- From mcu definition
Board := "MicroBit"; -- From command line
Has_ZFP_Runtime := "True"; -- From board definition
Has_Ravenscar_SFP_Runtime := "False"; -- From board definition
Max_Path_Length := "1024"; -- From default value
Runtime_Name_Suffix := "nrf51"; -- From board definition
Runtime_Name_Suffix := "microbit"; -- From board definition
Architecture := "ARM"; -- From board definition

-- Project source directories
Expand Down
Loading