Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding peripheral handle to the filex::FX_MEDIA class #57

Open
nkrishit opened this issue Aug 16, 2024 · 1 comment
Open

Adding peripheral handle to the filex::FX_MEDIA class #57

nkrishit opened this issue Aug 16, 2024 · 1 comment

Comments

@nkrishit
Copy link

nkrishit commented Aug 16, 2024

Is your feature request related to a problem? Please describe.
When working with Filex and making custom driver, for instance, SD card using SPI, I need to extern the hspiX from the main.c to implement the driver. This approach ends up forcing me to have only one instance of this custom driver.

Describe the solution you'd like
By having the handle inside the FX_MEDIA class preferably as a (void *) type, I would be able to typecast it into my desired peripheral Handle, be it SDMMC, SPI, I2C or anything else and have multiple instances of the same driver to define different devices all connect via the same custom peripheral.

Describe alternatives you've considered
Alternatively expanding the available base options would be great. But the work involved might be non-trivial as opposed to the above change

Additional context
Add any other context or screenshots about the feature request here.

@nflandin
Copy link

nflandin commented Aug 26, 2024

I am not one of the contributors to this repo, but I have dealt with a similar situation, and would like to share my solution (in case it helps).

I dealt with it by creating a custom struct for that driver (which you can obviously apply to multiple drivers), which contains a pointer to the handle, along with a variety of other characteristics of the media. Another parameter might be an enum that described what type of peripheral you're using.

I initialize the struct, then pass a pointer to it into the fx_media_open, via the "VOID *driver_info_ptr" variable, which ends up as the "VOID *fx_media_driver_info;" parameter of the "FX_MEDIA" struct. You can then read the various parameters of your struct to determine how the driver should act.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants