-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
shared-module/fourwire/FourWire.c: make the chip_select pin optional #9106
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look finished. There are a number of places in shared-module/fourwire/FourWire.c
where self.chip_select
is referenced and assumed not to be None
, e.g. line 83, and a bunch of others.
9b3bd02
to
2cf73b7
Compare
If there's only one device on the bus, the chip_select pin of the peripheral can be fixed in hardware, therefore lowering the number of pins required on the microcontroller side. This patch allows this by making the chip_select pin optional.
2cf73b7
to
659c385
Compare
I'm sorry @dhalbert, I am not familiar with the codebase and I should've spend more time on this. I added checks for the chip_select pin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. One more place to test if chip_select pin is set or not:
void common_hal_fourwire_fourwire_deinit(fourwire_fourwire_obj_t *self) {
if (self->bus == &self->inline_bus) {
common_hal_busio_spi_deinit(self->bus);
}
common_hal_reset_pin(self->command.pin);
common_hal_reset_pin(self->chip_select.pin); //// *************
common_hal_reset_pin(self->reset.pin);
}
Hi @dhalbert
Since the void common_hal_reset_pin(const mcu_pin_obj_t *pin) {
if (pin == NULL) {
return;
}
reset_pin_number(pin->port, pin->number);
} But maybe there is an oversight on the |
This depends on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
If there's only one device on the bus, the chip_select pin of the peripheral can be fixed in hardware, therefore lowering the number of pins required on the microcontroller side.
This patch allows this by making the chip_select pin optional.