Skip to content

Kernel (Device Model)

bflb_device_set_userdata(device, user_data)

Attach user data to a device handle

Parameters:

  • device:device handle
  • user_data:pointer to user data

Return value: None

bflb_device_get_by_name(name)

Get a device handle by name (the entry of every driver API)

Parameters:

  • name:device name

📎 Device name lookup: Supported Device Names (BL616)

Return value: device handle

Common Utilities

arch_strcmp(str1, str2)

Compare two strings (may use ROM API), returns the difference

Parameters:

  • str1:—
  • str2:—

Return value: int

arch_memcmp(s1, s2, n)

Compare memory bytes (may use ROM API), returns the difference

Parameters:

  • s1:—
  • s2:—
  • n:—

Return value: int

arch_delay_us(cnt)

Software microsecond delay (busy loop)

Parameters:

  • cnt:—

Return value: None

arch_delay_ms(cnt)

Software millisecond delay (busy loop)

Parameters:

  • cnt:—

Return value: None

bflb_soft_crc16(in, len)

Compute CRC16 checksum in software

Parameters:

  • in:—
  • len:—

Return value: [in] uint16_t

bflb_soft_crc32_ex(initial, in, len)

Compute CRC32 with a given initial value

Parameters:

  • initial:—
  • in:—
  • len:—

Return value: [in] uint32_t

bflb_soft_crc32(initial, in, len)

Compute CRC32 checksum in software

Parameters:

  • initial:—
  • in:—
  • len:—

Return value: [in] uint32_t

bflb_check_cache_addr(in, len)

Check whether an address is in the cacheable (XIP/PSRAM) region

Parameters:

  • in:—
  • len:—

Return value: [in] uint32_t

bflb_check_cache_addr_aligned(in, len)

Check whether an address is cache-line aligned

Parameters:

  • in:—
  • len:—

Return value: [in] uint32_t

bflb_get_app_version_from_efuse(version)

@}

Return value: see the SDK header

bflb_set_app_version_to_efuse(version)

@}

Return value: see the SDK header

bflb_get_boot2_version_from_efuse(version)

@}

Return value: see the SDK header

bflb_set_boot2_version_to_efuse(version)

@}

Return value: see the SDK header

bflb_get_boot2_info_from_flash(version)

@}

Return value: see the SDK header

bflb_get_chip_type(chip_type, chip_version)

@}

Return value: see the SDK header

volatile(ebreak)

@}

Return value: see the SDK header

arch_memcpy(dst, src, n)

Copy memory (may use ROM API)

Parameters:

  • dst:—
  • src:—
  • n:—

Return value: void*

arch_memset(s, c, n)

Fill memory (may use ROM API)

Parameters:

  • s:—
  • c:—
  • n:—

Return value: void*

arch_memcpy4(dst, src, n)

Copy memory in 4-byte units (may use ROM API)

Parameters:

  • dst:—
  • src:—
  • n:—

Return value: uint32_t*

arch_memcpy_fast(pdst, psrc, n)

Fast optimized memory copy (word copy when aligned)

Parameters:

  • pdst:—
  • psrc:—
  • n:—

Return value: void*

arch_memset4(dst, val, n)

Fill memory in 4-byte units (may use ROM API)

Parameters:

  • dst:—
  • val:—
  • n:—

Return value: uint32_t*

bflb_get_no_cache_addr(in, len)

Get the non-cacheable alias of a cacheable address

Parameters:

  • in:—
  • len:—

Return value: [in] uint32_t

printf(n, string, function, file, line)

Format and print to the serial port (standard library)

Return value: see the SDK header

Interrupts

bflb_irq_initialize()

Interrupt initialize.

Return value: None

bflb_irq_save()

Disable global irq and save the previous status.

Return value: last status

bflb_irq_restore(flags)

Enable global irq by the previous status.

Parameters:

  • flags:previous status by bflb_irq_save

Return value: None

bflb_irq_attach(irq, isr, arg)

Attach interrupt with callback.

Parameters:

  • irq:irq number
  • isr:interrupt callback
  • arg:user data

Return value: A negated errno value on failure.

bflb_irq_detach(irq)

Detach interrupt, reset interrupt callback.

Parameters:

  • irq:irq number

Return value: A negated errno value on failure.

bflb_irq_enable(irq)

Enable interrupt.

Parameters:

  • irq:irq number

Return value: None

bflb_irq_disable(irq)

Disable interrupt.

Parameters:

  • irq:irq number

Return value: None

bflb_irq_set_pending(irq)

Set interrupt with pending.

Parameters:

  • irq:irq number

Return value: None

bflb_irq_clear_pending(irq)

Clear interrupt pending status.

Parameters:

  • irq:irq number

Return value: None

bflb_irq_set_nlbits(nlbits)

Set interrupt group.

Parameters:

  • nlbits:—

Return value: None

bflb_irq_set_priority(irq, preemptprio, subprio)

Set interrupt priority.

Parameters:

  • irq:irq number
  • preemptprio:preempt priority
  • subprio:sub priority

Return value: None

bl618dg_level2_irq_handler(irq, preemptprio, subprio)

Set interrupt priority.

Parameters:

  • irq:irq number
  • preemptprio:preempt priority
  • subprio:sub priority

Return value: None

Clocks

bflb_peripheral_clock_control(peri, enable)

enable/disable peri clock

Parameters:

  • peri:: BFLB_PERIPHERAL_xxx
  • enable:: Boolean value to enable or disable the clock

Return value: int

bflb_peripheral_clock_get(peri)

get peri clock value

Parameters:

  • peri:: BFLB_PERIPHERAL_xxx

Return value: int

bflb_peripheral_clock_status_get(peri)

get peri clock status

Parameters:

  • peri:: BFLB_PERIPHERAL_xxx

Return value: int

bflb_clk_get_system_clock(type)

Get system clock frequence

Parameters:

  • type:system clock type

Return value: frequence

bflb_clk_get_peripheral_clock(type, idx)

Get peripheral clock frequence

Parameters:

  • type:peripheral type
  • idx:peripheral index

Return value: frequence

Reset

bflb_peripheral_reset(peri)

reset peri

Parameters:

  • peri:: BFLB_PERIPHERAL_xxx

Return value: int

Device Names

Linked List

bflb_dlist_remove(n)

Remove a node from a doubly-linked list

Parameters:

  • n:the node to remove from the list.

Return value: see the SDK header

bflb_dlist_insert_after(l, n)

Insert a node after a given node

Parameters:

  • l:list to insert it
  • n:new node to be inserted

Return value: see the SDK header

bflb_dlist_insert_before(n, l)

Insert a node before a given node

Parameters:

  • n:new node to be inserted
  • l:list to insert it

Return value: see the SDK header

eFuse Controller

bflb_ef_ctrl_get_common_trim_list(trim_list)

Get efuse control common trim list.

Parameters:

  • trim_list:pointer to save trim list

Return value: trim list length

bflb_ef_ctrl_autoload_done(dev)

Check whether eFuse auto-load is done

Parameters:

  • dev:device handle

📎 Device name lookup: Supported Device Names (BL616)

Return value: int

bflb_ef_ctrl_set_para(para)

Configure eFuse read/write timing parameters

Parameters:

  • para:parameter for efuse program or read

Return value: int

bflb_ef_ctrl_write_direct(dev, offset, pword, count, program)

Program eFuse directly at an offset (optionally burn now)

Parameters:

  • dev:device handle
  • offset:—
  • pword:—
  • count:—
  • program:—

📎 Device name lookup: Supported Device Names (BL616)

Return value: None

bflb_ef_ctrl_read_direct(dev, offset, pword, count, reload)

Read eFuse directly at an offset (optionally reload)

Parameters:

  • dev:device handle
  • offset:—
  • pword:—
  • count:—
  • reload:—

📎 Device name lookup: Supported Device Names (BL616)

Return value: None

bflb_ef_ctrl_read_common_trim(dev, name, trim, reload)

Read a common eFuse calibration parameter by name

Parameters:

  • dev:device handle
  • name:—
  • trim:—
  • reload:—

📎 Device name lookup: Supported Device Names (BL616)

Return value: None

bflb_ef_ctrl_write_common_trim(dev, name, value, program)

Write a common eFuse calibration parameter by name (with parity)

Parameters:

  • dev:device handle
  • name:—
  • value:—
  • program:—

📎 Device name lookup: Supported Device Names (BL616)

Return value: None

bflb_ef_ctrl_is_all_bits_zero(val, start, len)

Check whether a bit field of a value is all zeros

Parameters:

  • val:—
  • start:—
  • len:—

Return value: uint8_t

bflb_ef_ctrl_get_byte_zero_cnt(val)

Count zero bits in a byte

Parameters:

  • val:—

Return value: uint32_t

bflb_ef_ctrl_get_trim_parity(val, len)

Compute the parity bit of a given bit length

Parameters:

  • val:—
  • len:—

Return value: uint8_t

bflb_ef_ctrl_busy(dev)

Check efuse busy status

Parameters:

  • dev:ef control device pointer

📎 Device name lookup: Supported Device Names (BL616)

Return value: 1 for busy 0 for not

bflb_ef_ctrl_busy_r1(dev)

Check efuse region1 busy status

Parameters:

  • dev:ef control device pointer

📎 Device name lookup: Supported Device Names (BL616)

Return value: 1 for busy 0 for not

Supported Device Names (BL616)

The following names can be passed to bflb_device_get_by_name(name) to get a device handle. The tables come from drivers/lhal/config/<chip>/device_table.c: names in both the BL616 and BL616CL tables are supported on Ai-M61 / Ai-M62 / Ai-M64; names only in the BL616 table are Ai-M61 / Ai-M62; names only in the BL616CL table are Ai-M64 exclusive.

Device namePeripheralSupported modulesReference
adcADCAi-M61 / Ai-M62ADC
dacDACAi-M61 / Ai-M62DAC
ef_ctrleFuse ControllerAi-M61 / Ai-M62 / Ai-M64EFUSE
gpioGPIOAi-M61 / Ai-M62 / Ai-M64GPIO Output (LED)
uart0UARTAi-M61 / Ai-M62 / Ai-M64UART (Serial)
uart1UARTAi-M61 / Ai-M62 / Ai-M64UART (Serial)
spi0SPIAi-M61 / Ai-M62 / Ai-M64SPI Protocol
pwm_v2_0PWM v2Ai-M61 / Ai-M62 / Ai-M64PWM
dma0_ch0DMAAi-M61 / Ai-M62 / Ai-M64DMA Transfer
dma0_ch1DMAAi-M61 / Ai-M62 / Ai-M64DMA Transfer
dma0_ch2DMAAi-M61 / Ai-M62 / Ai-M64DMA Transfer
dma0_ch3DMAAi-M61 / Ai-M62 / Ai-M64DMA Transfer
i2c0I2CAi-M61 / Ai-M62 / Ai-M64I2C Protocol
i2c1I2CAi-M61 / Ai-M62 / Ai-M64I2C Protocol
i2s0I2S AudioAi-M61 / Ai-M62 / Ai-M64I2S Audio
timer0TimerAi-M61 / Ai-M62 / Ai-M64TIMER
timer1TimerAi-M61 / Ai-M62 / Ai-M64TIMER
rtcRTCAi-M61 / Ai-M62 / Ai-M64RTC
sec_aesAESAi-M61 / Ai-M62 / Ai-M64SEC_ENG (AES)
sec_shaSHAAi-M61 / Ai-M62 / Ai-M64
sec_trngTRNGAi-M61 / Ai-M62 / Ai-M64
sec_pkaPKAAi-M61 / Ai-M62 / Ai-M64
sec_gmacGMAC AuthAi-M61 / Ai-M62 / Ai-M64
emac0Ethernet EMACAi-M61 / Ai-M62 / Ai-M64EMAC Ethernet
watchdog0WatchdogAi-M61 / Ai-M62 / Ai-M64TIMER
cksCKSAi-M61 / Ai-M62 / Ai-M64CKS Checksum
mjpegMJPEGAi-M61 / Ai-M62 / Ai-M64MJPEG Video Capture
irrxIRAi-M61 / Ai-M62IR (NEC Protocol)
cam0CameraAi-M61 / Ai-M62 / Ai-M64CAM (DVP)
cam1CameraAi-M61 / Ai-M62 / Ai-M64CAM (DVP)
auadcAudio ADCAi-M61 / Ai-M62 / Ai-M64Audio Capture & Playback
audacAudio DACAi-M61 / Ai-M62 / Ai-M64Audio Capture & Playback
sdio2SDIOAi-M61 / Ai-M62 / Ai-M64SDIO
sdhSD HostAi-M61 / Ai-M62 / Ai-M64
dbiDBI DisplayAi-M61 / Ai-M62 / Ai-M64DBI Display
woWOAi-M61 / Ai-M62 / Ai-M64WO (WS2812)
usb_v2USBAi-M61 / Ai-M62 / Ai-M64
adc_v2_0ADC v2Ai-M64 only
uart2UARTAi-M64 only
spi1SPIAi-M64 only
dma0_ch4DMAAi-M64 only
dma0_ch5DMAAi-M64 only
dma0_ch6DMAAi-M64 only
dma0_ch7DMAAi-M64 only
timer0_captureTIMER CaptureAi-M64 only
gmac0Gigabit Ethernet GMACAi-M64 only
mjdecJPEG DecoderAi-M64 only
pec_sm0PEC v2Ai-M64 only
pec_sm1PEC v2Ai-M64 only
touch_v2touch v2Ai-M64 only

Have questions?

For any other questions, visit the unified Q&A and discussion board: Ai-Thinker Discussions

Released under the MIT License. Build Time 2026-09-11 14:52:23