63typedef enum : uint32_t {
98 __asm__
volatile(
"wfi");
109typedef enum : uint32_t {
146 tmp[n++] = (uint8_t)
'0';
154 tmp[n++] = (uint8_t)
'-';
157 for (uint32_t i = 0U; i < n; ++i) {
158 out[i] = tmp[n - 1U - i];
214typedef enum : uint32_t {
225 for (uint32_t i = 0U; i < len; ++i) {
226 scratch[i + 1U] = buf[i];
247 uint32_t cpuclk0_hz = 0U;
290 uint32_t pclka_hz = 0U;
300 .pclka_hz = pclka_hz,
441 static const uint8_t k_label_prefix[] =
"lsm6dso: ax=";
442 static const uint8_t k_label_ay[] =
" ay=";
443 static const uint8_t k_label_az[] =
" az=";
444 static const uint8_t k_label_gx[] =
" gx=";
445 static const uint8_t k_label_gy[] =
" gy=";
446 static const uint8_t k_label_gz[] =
" gz=";
447 static const uint8_t k_label_temp[] =
" temp=";
448 static const uint8_t k_label_newline[] =
"\r\n";
467 imu_demo_emit_kv(k_label_temp, (uint32_t)(
sizeof(k_label_temp) - 1U), tcenti);
468 imu_demo_tx(k_label_newline, (uint32_t)(
sizeof(k_label_newline) - 1U));
void main(void)
Secure fallback main entry point.
static void imu_demo_clocks_or_halt(uint32_t *out_pclka_hz)
Bring CGC + SysTick + MSTP up; return PCLKA via out_pclka_hz.
static void imu_demo_sample_and_emit(ra8_lsm6dso_t *dev)
Read one cycle of accel + gyro + temperature and emit the log line.
static const uint8_t k_imu_demo_banner_nak[]
static void imu_demo_pfs_or_halt(void)
Route IIC channel-0 SCL/SDA via PFS.
static void imu_demo_setup_or_halt(void)
Bring CGC + SysTick + console + IIC_B up.
static void imu_demo_configure(ra8_lsm6dso_t *dev)
Apply the demo's fixed sensor configuration (+-2 g, +-250 dps, 104 Hz).
static void imu_demo_emit_kv(const uint8_t *label, uint32_t label_len, int32_t value)
Emit a labelled signed integer: "<label>=<n>".
static void imu_demo_tx(const uint8_t *bytes, uint32_t len)
Emit one line of bytes via the BSP UART console (SCI8).
static void imu_demo_panic_halt(void)
Park forever after a fatal error.
static const ra8_port_pin_t k_imu_demo_pin_scl
MikroBUS SDA/SCL routed through Arduino D14/D15 to SDA1/SCL1.
static void imu_demo_check_who_am_i(ra8_lsm6dso_t *dev)
Verify the LSM6DSO is alive and is the expected silicon.
static const ra8_port_pin_t k_imu_demo_pin_sda
static ra8_err_t imu_demo_iic_read(void *ctx, uint8_t reg, uint8_t *buf, uint32_t len)
Transport adapter: read N bytes starting at register reg.
static const uint8_t k_imu_demo_banner_err[]
imu_demo_iic_cap_t
Transport adapter: write N bytes starting at register reg.
@ k_imu_demo_iic_tx_cap
Imu demo iic TX cap.
static const uint8_t k_imu_demo_banner_ok[]
Banner line scraped by hil.conf.
static const uint8_t k_imu_demo_banner_bad[]
imu_demo_str_cap_t
Result buffer for one decimal int16_t (max "-32768" = 6 bytes plus the trailing NUL).
@ k_imu_demo_int_str_cap
Imu demo int str cap.
static ra8_err_t imu_demo_iic_write(void *ctx, uint8_t reg, const uint8_t *buf, uint32_t len)
static uint32_t imu_demo_i32_to_dec(int32_t value, uint8_t *out)
Convert a signed 16-bit int into a decimal ASCII string.
imu_demo_const_t
App-wide tunables.
@ k_imu_demo_baud
Imu demo baud.
@ k_imu_demo_bus_hz
Imu demo bus Hz.
@ k_imu_demo_period_ms
Imu demo period ms.
@ k_imu_demo_iic_channel
Imu demo iic channel.
@ k_imu_decimal_base
Radix for integer-to-ASCII.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
@ k_ra8_board_mikrobus_iic_b_channel
RA8 board mikrobus iic b channel.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
ra8_err_t ra8_board_led_init(ra8_board_led_id_t led)
Configure led as a digital output, initial level low (off).
ra8_err_t ra8_board_led_on(ra8_board_led_id_t led)
Drive led HIGH (light it).
@ k_ra8_board_mikrobus_i2c_scl
J22.5 SCL (SW4-5 OFF) -> P512 SCL1.
@ k_ra8_board_mikrobus_i2c_sda
J22.6 SDA (SW4-5 OFF) -> P511 SDA1.
@ k_ra8_board_led2
LED2, GREEN, P303 (jumper E26).
@ k_ra8_board_led1
LED1, BLUE, P600 (jumper E27).
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
@ k_ra8_clock_id_pclka
PCLKA.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
@ k_ra8_psel_iic
00111b: IIC / I3C controller-peripheral.
I3C Bus Interface driver – unified native-I3C + I2C-compat modes.
ra8_err_t ra8_i3c_transfer(uint8_t channel, uint8_t addr, const uint8_t *wr, uint32_t wr_len, uint8_t *rd, uint32_t rd_len)
Write-then-read with repeated-START framing (I2C mode).
@ k_ra8_i3c_mode_i2c
Legacy I2C-compatibility controller.
ra8_err_t ra8_i3c_write(uint8_t channel, uint8_t addr, const uint8_t *data, uint32_t len, bool restart)
Write len bytes to addr.
ra8_err_t ra8_i3c_init(uint8_t channel, const ra8_i3c_cfg_t *cfg)
Initialise an I3C channel in the configured mode.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
ST LSM6DSO 6-DoF IMU driver (accel + gyro + temperature).
ra8_err_t ra8_lsm6dso_set_odr(ra8_lsm6dso_t *dev, ra8_lsm6dso_odr_t odr)
Program the Output Data Rate for both the accelerometer and the gyroscope.
ra8_err_t ra8_lsm6dso_read_temp(ra8_lsm6dso_t *dev, int32_t *out_centi_c)
Read the on-die temperature in centi-degrees Celsius.
ra8_err_t ra8_lsm6dso_read_gyro(ra8_lsm6dso_t *dev, ra8_lsm6dso_xyz_t *out)
Read one gyroscope sample (raw 16-bit two's-complement).
ra8_err_t ra8_lsm6dso_init(ra8_lsm6dso_t *out_dev, const ra8_lsm6dso_bus_t *bus)
Bind a transport to a driver instance.
ra8_err_t ra8_lsm6dso_set_gyro_range(ra8_lsm6dso_t *dev, ra8_lsm6dso_g_fs_t fs)
Program the gyroscope full-scale range.
@ k_lsm6dso_i2c_addr_sa0_high
SDO/SA0 tied high.
@ k_lsm6dso_who_am_i_value
WHO_AM_I expected value (DS12140 sec 9.11).
@ k_lsm6dso_odr_104hz
104 Hz (normal mode).
ra8_err_t ra8_lsm6dso_read_accel(ra8_lsm6dso_t *dev, ra8_lsm6dso_xyz_t *out)
Read one accelerometer sample (raw 16-bit two's-complement).
ra8_err_t ra8_lsm6dso_who_am_i(ra8_lsm6dso_t *dev, uint8_t *out_id)
Read the WHO_AM_I register.
ra8_err_t ra8_lsm6dso_set_accel_range(ra8_lsm6dso_t *dev, ra8_lsm6dso_xl_fs_t fs)
Program the accelerometer full-scale range.
@ k_lsm6dso_g_fs_250dps
+-250 dps (default).
@ k_lsm6dso_xl_fs_2g
+-2 g, sens 0.061 mg/LSB (default).
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_pfs_route_peripheral(ra8_port_pin_t pin, ra8_psel_t psel, const char *owner)
Route a pin to a non-IRQ peripheral function via PFS.PSEL.
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
Adapter context: holds channel + 7-bit address.
uint8_t channel
IIC_B channel (0 on RA8D2).
uint8_t addr7
7-bit peripheral address.
Per-channel bring-up configuration for ra8_i3c_init.
Transport interface bound at ra8_lsm6dso_init time.
Per-instance driver state.
3-axis raw sample (X, Y, Z as 16-bit two's-complement counts).
int16_t y
Y-axis raw count.
int16_t z
Z-axis raw count.
int16_t x
X-axis raw count.