Giter VIP home page Giter VIP logo

stm32x's Introduction

STM32X

This is a HAL layer targeting my favourite STM32 series processors. Currently only the STM32L0's and STM32F0's are supported. Other series may be added in future, but I will prioritise the smaller processors.

Features

  • A clean API for all peripheral functions
  • 'Opt in' design philosophy. Modules only need to be considered when required.
  • Clock management and interrupts are internally handled within the modules.
  • Expected features like UART circular buffers are built-in
  • Much less bloat than a vanilla STM32Cube project. A project using many peripherals including USB-CDC can easily compile to under 16KB.
  • Still compatible with the Cube if additional functionality needed (I still use some of it too)
  • There is very little abstraction between the STM32X api and the hardware. This promotes efficiency and predictibilty.
  • Low power is a key use case for this project: Low power modes are supported, and peripheral init/deinit is under user control.

Creating a STM32X based project

  1. Create a new project using the STM32CubeIDE. STM32Cube should be the targeted project type.
  2. Ensure the complete STM32Cube Drivers are added to the project. This can be done by enabling all peripherals in the IOC editer. Alternately download them from ST.
  3. Remove junk source from the Core directory. Only system_stm32*xx.c, and startup_stm32*.s should remain.
  4. Checkout the STM32X repo into your project. I recommend adding it as a git sub-module. Add ../STM32X/Lib to your include paths. Change the resource configurations for the STM32X/Lib folder, so that it not excluded from the build.
  5. Copy in the replacement stm32*xx_hal_conf.h, main.c, and Board.h file from the STM32X/Templates folder into your Core/ folder.
  6. Edit Board.h to configure your peripherals. Ensure the correct processor is defined at the top.
  7. Build to confirm that the environment is set up correctly.

Modules

Documentation for each module can be found in Docs

The CORE module provides a lot of basic functionality, and should be your starting point. Next, GPIO and UART make for good examples of what to expect from this project.

Basic:

Connectivity:

Analog:

Timing:

Storage:

Misc:

stm32x's People

Contributors

lambosaurus avatar timlamborn avatar

Stargazers

 avatar

Watchers

 avatar

stm32x's Issues

When selecting a prescalar lower than 125K, the wrong prescalar will be selected.

STM32X/Lib/SPI.c

Lines 125 to 141 in 66dd61e

static uint32_t SPI_SelectPrescalar(SPI_t * spi, uint32_t target)
{
// Div clock by 2, because the prescalars start at 2
uint32_t clk = CLK_GetPCLKFreq() >> 1;
uint32_t actual;
uint32_t k;
for (k = 0; k <= 0x7; k++)
{
actual = clk >> k;
if (actual <= target)
{
break;
}
}
spi->bitrate = actual;
return k << SPI_CR1_BR_Pos;
}

Because this loops to k = 8, which is an invalid prescalar.

Implement HSE, PLL and SYSCLK options

The current clocking regime is HSI with PLL up to 32MHz. This should be configurable in Board.h, and include options for HSE. This should also be managed outside of the HAL to minimize garbage code. The OSC & PLL configuration is responsible for ~4K of code space.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.