BERGSONNE

Platform Abstraction Layer

Tile drivers never talk to a Core’s bus directly. They’re written against the PAL — a small, uniform interface (tiles_pal_t) for bus I/O — so the same driver runs on any Core, over I²C or SPI, with no changes. You hand a driver a PAL handle; the PAL does the rest.

Overview

A tiles_pal_t is the contract between a tile driver and the Core it’s running on: read/write this register, transfer these bytes. A driver takes a tiles_pal_t * and an instance index — never a core_i2c_t * or core_spi_t * — so it knows nothing about which Core or bus it’s on. That’s what lets one driver binary serve the whole Core family.

Getting a handle

Wrap any Cores SDK bus handle with core_tiles_pal(). It accepts an I²C or SPI bus and returns the matching tiles_pal_t * — one per bus, cached, so you can call it freely:

#include "core.h"

tiles_pal_t *pal = core_tiles_pal(&core_i2c1);   // I²C bus
tiles_pal_t *spi = core_tiles_pal(&core_spi1);   // or an SPI bus

It’s a _Generic dispatch on the handle type, so the one call works for both bus kinds — no separate I²C / SPI entry points to remember.

Using it with a driver

Every driver’s init and find take the PAL plus an instance index (which device on the bus). After init you hold a tile_t handle and call the driver’s functions:

#include "core.h"
#include "tile_sense_bp.h"

tiles_pal_t *pal = core_tiles_pal(&core_i2c1);

if (tile_sense_bp_find(pal, 0)) {            // is instance 0 on the bus?
    tile_t bp;
    tile_sense_bp_init(pal, 0, &bp, NULL);   // driver gets the PAL, not the bus
    int32_t mhpa = tile_sense_bp_get_pressure_mhpa(&bp);
}
Instances = devices on a bus
The instance index selects which device the driver addresses (e.g. an I²C address variant). Several tiles of the same kind on one bus are instances 0, 1, …

Why it exists

The PAL is one small indirection that buys a lot:

  • Write once, run anywhere — a driver is authored against tiles_pal_t, not an STM32L0 or an STM32H5 bus, so it ships unchanged across every Core.
  • Bus-independent — the same driver works whether the tile is wired to I²C or SPI; only the handle you pass differs.
  • Portable to new architectures — bringing the SDK to a new MCU family (WCH, Nordic) means re-implementing the layers under the PAL, not rewriting drivers.

In short: core_tiles_pal(&bus) is the seam between the Core SDK and the tile drivers — the reason a driver’s page never mentions a specific Core.