Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory size defines #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Nov 4, 2020

  1. Define correct size for RAM

    This was previously hardcoded to a single value, but is now derived from
    the STM32 chip-specific header files.
    matthijskooijman committed Nov 4, 2020
    Configuration menu
    Copy the full SHA
    65b6883 View commit details
    Browse the repository at this point in the history
  2. Define correct size for EEPROM

    This was previously hardcoded to 4k, which is intended for devices with
    6k of EEPROM reserving 2k for the LoRaWAN library. For devices like the
    L053, that only has 2k of EEPROM, this would result in an invalid EEPROM
    size.
    
    Now, this reserved value is more explicit and is configured on a
    per-board basis in variant.h using the new
    `STM32L0_CONFIG_EEPROM_RESERVED` macro. This is set to 2048 for all boards
    that have an embedded LoRaWAN transceiver and left undefined for the
    more generic boards.
    
    Then the full EEPROM size is autodetected using the STM32 CMSIS header
    files and exposed as `REAL_E2END`, and the reserved area is subtracted
    from that and exposed as `E2END` (and also through `EEPROM.length()`).
    
    This also changes `Arduino.h` to move the `avr/*.h` includes down to below
    the `variant.h` include (just moving `avr/io.h` would have been enough,
    but this is more consistent), so `variant.h` can be used in io.h.
    This also includes `Arduino.h` from `io.h`, in case `io.h` is included
    directly by a sketch.
    
    Note that the autodetection uses macros that include a typecast, so the
    resulting `E2END` macro cannot be examined by the preprocessor (e.g. an
    `#if` statement), which is why this uses a `static_assert` instead to
    check that `STM32L0_CONFIG_EEPROM_RESERVED` is not too big. The resulting
    expression is a valid constant expression in both C and C++ contexts,
    though.
    matthijskooijman committed Nov 4, 2020
    Configuration menu
    Copy the full SHA
    b98a094 View commit details
    Browse the repository at this point in the history