Sapphire SoC DS Sapphire SoC UG Sapphire HP SoC DS Sapphire HP SoC UG RISC-V Embedded IDE UG Board Support Package
Loading...
Searching...
No Matches
Overview

Welcome to the Board Support Package (BSP) for the Efinix Sapphire SoC. This BSP allows software running on the RISC-V processor to interact with on-chip peripherals such as SPI, I2C, GPIO, and Timers.

The drivers are designed to be bare-metal compliant, lightweight, and capable of running with or without an operating system (RTOS).

Driver Implementation Model

The BSP follows an Instance-Based driver model. Each peripheral driver consists of two main data structures:

  • Hardware Register Map (*_hwreg_t): A structure that maps directly to the physical memory address of the peripheral. This is typically used internally by the driver to read/write hardware registers.
  • Software Instance (*_instance_t): A high-level structure that holds the Configuration State (Shadow Registers) and a pointer to the hardware base address. @ Unlike traditional drivers that write to hardware immediately, this BSP uses a "Configure-then-Apply" pattern to ensure atomic updates:
  1. Modify: Update the settings in the instance structure (e.g., spi.cpol = HIGH).
  2. Apply: Call the applyConfig() function to flush these settings to the hardware.

Initialization Sequence

To use a specific driver, the application must follow this initialization flow:

  1. Instantiate: Declare the driver instance structure.
  2. Link: Assign the hardware base address (defined in soc.h).
  3. Configure: Set the desired parameters (Prescalers, Modes, Interrupts).
  4. Apply: Call *_applyConfig() to initialize the hardware.
  5. Enable: (Optional) Register the interrupt handler via the PLIC.

Note: This is an example showing how to instantiate I2C with i2c_instance_t and i2c_hwreg_t.

#include i2c/i2c.h
#define I2C_FREQ 100000
#define I2C_ADDR 0x67<<1 // Slave device address
#define I2C_CTRL_HZ SYSTEM_CLINT_HZ
#define I2C_CTRL (i2c_hwreg_t *)SYSTEM_I2C_1_IO_CTRL
i2c_instance_t I2C_inst = {
.hwreg = I2C_CTRL,
.slaveAddress = I2C_ADDR,
.samplingClockDivider = 3,
.timeout = I2C_CTRL_HZ/1000,
.tsuDat = I2C_CTRL_HZ/(I2C_FREQ*5),
.tLow = I2C_CTRL_HZ/(I2C_FREQ*2),
.tHigh = I2C_CTRL_HZ/(I2C_FREQ*2),
.tBuf = I2C_CTRL_HZ/(I2C_FREQ),
};
I2C instance. Holds the software registers and hardware pointer.
Definition i2c.h:259

Revision History

Version Date Author Description of Changes
1.0.1 2026-02-25 Efinix Critical Update: Added spi_instance_t.
1.0.0 2026-02-01 Efinix Initial BSP release. Includes drivers for I2C Driver, SPI Driver, UART Driver, and GPIO Driver.

View License and Legal Information