Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

API Structure

Austin Keener edited this page Jul 27, 2020 · 1 revision

This guide details how the mJackets API is structured, and how it incorporates with your project.

API

The API directory contains common public interface C++ functions. These functions interface with the HAL to provide a standardized and simplistic method of interfacing with hardware peripherals on STM32 MCUs.

API
|   CMakelists.txt
└───inc
|     └───mJackets.hpp
└───src    

The end-user can directly call any of the functions made available by the header files in the API/inc directory. A full API reference can be found in the DOCS directory. The mJackets.hpp header file includes all of the HAL and API functions into the project, and thus only this file needs to be included in the project main.cpp to provide user access to all API and HAL functions.

The CMakelists.txt file is responsible for configuring a build target for the API. It includes the appropriate HAL and CMSIS libraries into the API build, as well as the user-defined HAL configuration.

cmake

The cmake directory contains files used by CMake to configure the project for your specific STM32 chip, as well as set up build targets and specify toolchains.

HAL

The HAL directory contains all of the family and device-specific hardware drivers needed to interface with the microcontroller peripherals.

HAL
└───CMSIS
└───STM32<FAMILY>xx_HAL_Drivers  

The CMSIS directory contains the Cortex Microcontroller Software Interface Standard (CMSIS) standardized API for the Cortex-M processor core and peripherals. It includes intrinsic functions for Cortex-M4/M7/M33/M35P SIMD instructions.

The STM32<FAMILY>xx_HAL_Drivers directories contain the family-specific HAL drivers for STM32 peripherals. The appropriate family of drivers is automatically included by the API.

LIB

The LIB directory contains git submodules for external libraries such as FreeRTOS, LwIP, and FatFS. These libraries can be added to your project by linking them with the main.cpp file in your top-level CMakelist.txt file.

TEMPLATE

The template directory contains a project template for a mJackets API based project. This template comprises of the project's main.cpp file, board support files, and the top-level CMakelists.txt. The contents of this directory are intended to be copied over to your project directory to start a new project.

TEMPLATE
|   CMakelists.txt
|   main.cpp
└───bsp
|     └───inc
|     └───src
└───mjackets-api  

The bsp directory contains the board support files for your project. This directory needs to contain two files at a minimum. The first required file is PinDefs.hpp, which is a header file that defines the GPIO pin mappings for your board. Modify this file to suit your project. The second required file is stm32<family>xx_hal_config.h. This file specifies several hardware-specific parameters and includes all of the appropriate HAL drivers for your specific STM32 chip. Feel free to use/modify the default files in the bsp/inc directory, or you could also generate this file using the STM32CubeMX application from ST Microelectronics. You can additionally provide a device-specific startup assembly file (which can be generated by STM32CubeMX) in the bsp/src directory. This startup file is the first code that is executed upon startup/reset. If you do not provide this file, a default startup file will be used from the CMSIS libraries in the mJacket API.

The top-level CMakelists.txt configures the project build and links the main.cpp file with the mJackets API libraries and board support files.

The TEMPLATE directory also specifies the mJackets-api to be installed to the project folder as a git submodule.

TEST

The TEST directory contains unit tests for the API to be used with continuous integration (CI).

UTIL

The UTIL directory contains various scripts for automating development environment setup, device flashing, and debugging.

Clone this wiki locally