Kernel (Device Model)
bflb_device_set_userdata(device, user_data)
Attach user data to a device handle
Parameters:
device:device handleuser_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 numberisr:interrupt callbackarg: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 numberpreemptprio:preempt prioritysubprio:sub priority
Return value: None
bl618dg_level2_irq_handler(irq, preemptprio, subprio)
Set interrupt priority.
Parameters:
irq:irq numberpreemptprio:preempt prioritysubprio:sub priority
Return value: None
Clocks
bflb_peripheral_clock_control(peri, enable)
enable/disable peri clock
Parameters:
peri:: BFLB_PERIPHERAL_xxxenable:: 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 typeidx: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 itn: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 insertedl: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 handleoffset:—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 handleoffset:—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 handlename:—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 handlename:—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 name | Peripheral | Supported modules | Reference |
|---|---|---|---|
adc | ADC | Ai-M61 / Ai-M62 | ADC |
dac | DAC | Ai-M61 / Ai-M62 | DAC |
ef_ctrl | eFuse Controller | Ai-M61 / Ai-M62 / Ai-M64 | EFUSE |
gpio | GPIO | Ai-M61 / Ai-M62 / Ai-M64 | GPIO Output (LED) |
uart0 | UART | Ai-M61 / Ai-M62 / Ai-M64 | UART (Serial) |
uart1 | UART | Ai-M61 / Ai-M62 / Ai-M64 | UART (Serial) |
spi0 | SPI | Ai-M61 / Ai-M62 / Ai-M64 | SPI Protocol |
pwm_v2_0 | PWM v2 | Ai-M61 / Ai-M62 / Ai-M64 | PWM |
dma0_ch0 | DMA | Ai-M61 / Ai-M62 / Ai-M64 | DMA Transfer |
dma0_ch1 | DMA | Ai-M61 / Ai-M62 / Ai-M64 | DMA Transfer |
dma0_ch2 | DMA | Ai-M61 / Ai-M62 / Ai-M64 | DMA Transfer |
dma0_ch3 | DMA | Ai-M61 / Ai-M62 / Ai-M64 | DMA Transfer |
i2c0 | I2C | Ai-M61 / Ai-M62 / Ai-M64 | I2C Protocol |
i2c1 | I2C | Ai-M61 / Ai-M62 / Ai-M64 | I2C Protocol |
i2s0 | I2S Audio | Ai-M61 / Ai-M62 / Ai-M64 | I2S Audio |
timer0 | Timer | Ai-M61 / Ai-M62 / Ai-M64 | TIMER |
timer1 | Timer | Ai-M61 / Ai-M62 / Ai-M64 | TIMER |
rtc | RTC | Ai-M61 / Ai-M62 / Ai-M64 | RTC |
sec_aes | AES | Ai-M61 / Ai-M62 / Ai-M64 | SEC_ENG (AES) |
sec_sha | SHA | Ai-M61 / Ai-M62 / Ai-M64 | |
sec_trng | TRNG | Ai-M61 / Ai-M62 / Ai-M64 | |
sec_pka | PKA | Ai-M61 / Ai-M62 / Ai-M64 | |
sec_gmac | GMAC Auth | Ai-M61 / Ai-M62 / Ai-M64 | |
emac0 | Ethernet EMAC | Ai-M61 / Ai-M62 / Ai-M64 | EMAC Ethernet |
watchdog0 | Watchdog | Ai-M61 / Ai-M62 / Ai-M64 | TIMER |
cks | CKS | Ai-M61 / Ai-M62 / Ai-M64 | CKS Checksum |
mjpeg | MJPEG | Ai-M61 / Ai-M62 / Ai-M64 | MJPEG Video Capture |
irrx | IR | Ai-M61 / Ai-M62 | IR (NEC Protocol) |
cam0 | Camera | Ai-M61 / Ai-M62 / Ai-M64 | CAM (DVP) |
cam1 | Camera | Ai-M61 / Ai-M62 / Ai-M64 | CAM (DVP) |
auadc | Audio ADC | Ai-M61 / Ai-M62 / Ai-M64 | Audio Capture & Playback |
audac | Audio DAC | Ai-M61 / Ai-M62 / Ai-M64 | Audio Capture & Playback |
sdio2 | SDIO | Ai-M61 / Ai-M62 / Ai-M64 | SDIO |
sdh | SD Host | Ai-M61 / Ai-M62 / Ai-M64 | |
dbi | DBI Display | Ai-M61 / Ai-M62 / Ai-M64 | DBI Display |
wo | WO | Ai-M61 / Ai-M62 / Ai-M64 | WO (WS2812) |
usb_v2 | USB | Ai-M61 / Ai-M62 / Ai-M64 | |
adc_v2_0 | ADC v2 | Ai-M64 only | |
uart2 | UART | Ai-M64 only | |
spi1 | SPI | Ai-M64 only | |
dma0_ch4 | DMA | Ai-M64 only | |
dma0_ch5 | DMA | Ai-M64 only | |
dma0_ch6 | DMA | Ai-M64 only | |
dma0_ch7 | DMA | Ai-M64 only | |
timer0_capture | TIMER Capture | Ai-M64 only | |
gmac0 | Gigabit Ethernet GMAC | Ai-M64 only | |
mjdec | JPEG Decoder | Ai-M64 only | |
pec_sm0 | PEC v2 | Ai-M64 only | |
pec_sm1 | PEC v2 | Ai-M64 only | |
touch_v2 | touch v2 | Ai-M64 only |
Have questions?
For any other questions, visit the unified Q&A and discussion board: Ai-Thinker Discussions

