w25qxx icon indicating copy to clipboard operation
w25qxx copied to clipboard

Portability improvements

Open DzmitryStryzhevich opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

No response

Describe the idea you'd like

Hello! I think it would be useful to pass a customizable user handle like void* const hwHandle to all SPI interface functions declared in driver_w25qxx_interface.h. This pointer should be assigned by a setter in w25qxx_handle_t structure like that uint8_t w25qxx_set_hw_handle(w25qxx_handle_t *handle, void *hwHandle). A getter uint8_t w25qxx_get_hw_handle(w25qxx_handle_t *handle, void **hwHandle) may be useful, too. image

Rationale: modern MCUs may have several SPI/QSPI hardware interfaces. In this handle approach, we can assign the particular SPI interface to the device. We may simultaneously have several w25qxx devices on the same bus and/or on different buses. In my opinion, this approach can lead to the significant improvement of the device driver portability for different platforms, because all MCUs chip vendors have incompatible CSP

Describe alternatives you've considered

No response

Additional context

No response

DzmitryStryzhevich avatar Jan 19 '24 11:01 DzmitryStryzhevich

Thank you very much for using LibDriver and providing valuable feedback. Your idea is a good idea, and we believe that the addition of customized handles will greatly improve the flexibility of driver development. We will incorporate your idea in future updates. It should be noted that a very small number of drivers that include state machine management need to be controlled through different driver handles. For example, some drivers have registers that are only written and require the handle to store the current register configuration internally(https://github.com/libdriver/wm8978), while others require the driver handle to record the current driver's state(https://github.com/libdriver/ir_remote).

libdriver avatar Jan 22 '24 02:01 libdriver

Thanks a lot for lightning reaction. You are doing a great job. Today, there are not many high-quality platform-agnostic drivers for all kinds of peripherals ICs. Chip manufacturers very often do not provide them. This project is great.

DzmitryStryzhevich avatar Jan 22 '24 06:01 DzmitryStryzhevich

Thank you very much.

libdriver avatar Jan 22 '24 06:01 libdriver