-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
As stated in README.md, hardware_* are Hardware Abstraction Layer (HAL), while pico_* provide higher level functionality.
I have noticed that some code in pico_* accesses memory-mapped I/O (MMIO) without going through HAL or drivers. This type of access may have several drawbacks, including poor portability and maintainability.
I would like to open this issue to investigate why some MMIO access does not follow the conventional path through HAL or drivers. Are there specific scenarios where non-conventional MMIO access is preferred? Is it possible to fix the code by accessing MMIO conventionally (i.e. through HAL/drivers)?
Code snippets with MMIO access that does not go through HAL or drivers:
rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18); uint32_t chip_id = *((io_ro_32*)(SYSINFO_BASE + SYSINFO_CHIP_ID_OFFSET)); return !!((*(io_ro_32 *)TBMAN_BASE) & TBMAN_PLATFORM_FPGA_BITS); return *(uint8_t*)0x13; pico-sdk/src/rp2_common/pico_runtime/runtime.c
Lines 117 to 118 in f396d05
hw_clear_alias(padsbank0_hw)->io[26] = hw_clear_alias(padsbank0_hw)->io[27] = hw_clear_alias(padsbank0_hw)->io[28] = hw_clear_alias(padsbank0_hw)->io[29] = PADS_BANK0_GPIO0_IE_BITS; if (mpu_hw->ctrl) {