Migrate to busDevice infrastructure. Phase 1#2275
Conversation
…S# pins are pulled high before device initialization
|
Further changes will gradually move to bus-independent device drivers. |
| } i2c; | ||
| } busDevice_t; | ||
|
|
||
| #ifdef __APPLE__ |
There was a problem hiding this comment.
Why is this needed? __APPLE__ should only be defined when compiling for macOS and iOS and I guess we're not supporting any of those targets anytime soon :-)
There was a problem hiding this comment.
True, but it's better to keep the source compilable 😄
There was a problem hiding this comment.
No problem with that being left in the PR. It just grabbed my attention cause I wasn't really expecting a test for Apple's platform on code running on MCUs!
Now that I think about it, ßF added support for running on a simulator and we eventually should do that too. Not sure how that simulator works but it might need that special handling on macOS.
There was a problem hiding this comment.
Actually, I was mostly concerned with chip-select lines left floating for not (yet) initialized SPI devices. Might be the cause of #2074.
Idea behind this PR is better driver abstraction from hardware. Descriptors for devices are stored in flash and ultimately will be defined in the target files, not in device driver files. Device driver itself should be unaware of underlying bus (SPI or I2C) and device definition.
Bus init code will also ensure that hardware state is consistent. For SPI devices this mean that all CS# lines are pulled high before initializing the devices.
Fixes: #2074