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

Centralize application framework #323

Open
terrillmoore opened this issue Nov 21, 2021 · 0 comments
Open

Centralize application framework #323

terrillmoore opened this issue Nov 21, 2021 · 0 comments
Assignees

Comments

@terrillmoore
Copy link
Member

terrillmoore commented Nov 21, 2021

This is a roll-up ticket for centralizing the application framework material that is now scattered all over the place. This gives a ticket to reference for the development branch.

The application framework handles the following.

  • turning on the 3.3V boost regulator if needed (4612, 4618, 4630)
  • set up SPI flash interface (if SPI flash is available on this platform).
  • I2C initialization (ditto)
  • Serial port initialization at default speed (115200).
  • LED initialization (if available)
  • FRAM initialization (if available)
  • if there are operating flags, checks bit zero of the operating flags, and delays if zero and no serial port is attached.
  • Command-line interface via Serial, with standard commands
  • Command-line firmware download if the platform supports MCCI trusted boot loader and SPI flash.
  • Sensor initialization for the platform (e.g., put BME280 in standby)
  • LoRaWAN setup with LMIC if enabled by user
  • provides a consistent sleep API
  • on STM32L0, turning on the 32kHz clock and using it to discipline the ms/micros timebase
  • abstracting the built-in sensors (T, RH, optional P)
  • allows for one or more extensions (for FeatherWings) to provide setup, initialization, sleep, and recovery methods.
  • detecting first boot after update by comparing stashed hash (from FRAM) to live hash

In addition, we want to centralize some common things:

  • the makeVersion and version-comparison functions
  • the file base-name extraction constexpr.

You must do the following:

  • Create a standard application for your board. McciCatena::Catena gCatena;.
  • In setup(), add options: for example, gCatena.useLoRaWAN(); if using LoRaWAN, or gCatena.useSigfox(); if using Sigfox. Note that these imply useStandardFramework(). gCatena.useSerialBaudrate(n) sets the baudrate to n.
  • Then call gCatena.setup() to invoke the standard setup.

Then in loop(), call gCatena.loop().

We're going to need to add some slots on the various concrete Catenas. For convenience, we should consider adding a vanilla Catena that allows use of the command-line interface and some other things on any Arduino.

New classes

class Catena_SpiFlash: the abstract wrapper for the concrete flash drivers.

Methods

SPIClass *Catena::getExternalSpi() const;

Return pointer to the external SPI that's driving MOSI, MISO and SCK. By default, it's SPI, but on MCCI Catenas using the Murata module, it may be gSPI2.

Globals from the application framework

SPIClass gSPI2; for the second SPI bus, on MCCI Catenas -- this is because the primary SPI interface, SPI, is not brought to pins and is used with the LoRaWAN radio.

Catena_SpiFlash gFlash;
cDownload McciCatena::gDownload;
cBootloaderApi McciCatena::gBootloaderApi;
cSerial<decltype(Serial)> McciCatena::gSerial;
StatusLed McciCatena::gLed;
cLog McciCatena::gLog;

These are all set up (and exported) by Catena::setup(), which calls Catena::begin() for legacy use.

@terrillmoore terrillmoore self-assigned this Nov 21, 2021
terrillmoore added a commit that referenced this issue Nov 29, 2021
We don't want to have to tunnel the appVersion through all
the constructors, so McciCatena::Catena::Catena() calls new
protected McciCatena::Catena::setAppVersion(), exported by
CatenaBase, after all the other constructors are done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant