diff options
| author | jacqueline <me@jacqueline.id.au> | 2022-10-01 10:39:52 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2022-10-01 10:39:52 +1000 |
| commit | 23671453c01848d4d5591dbbfd31db16e7c6cf53 (patch) | |
| tree | 3152c11fa23436601d80ccd0640e5f53533e6e82 | |
| parent | 353df98ba1394de156923d00fc034badde8e4cc0 (diff) | |
| download | tangara-fw-23671453c01848d4d5591dbbfd31db16e7c6cf53.tar.gz | |
Implement gpio setting
| -rw-r--r-- | main/gpio-expander.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/main/gpio-expander.cpp b/main/gpio-expander.cpp index 9e905734..d17f9f07 100644 --- a/main/gpio-expander.cpp +++ b/main/gpio-expander.cpp @@ -54,8 +54,7 @@ bool GpioExpander::charge_power_ok(void) { } bool GpioExpander::headphone_detect(void) { - // Active-low. - return (input_b_ & (1 << 0)) == 0; // TODO. + return (input_b_ & (1 << 0)); } uint8_t GpioExpander::key_states(void) { @@ -63,15 +62,27 @@ uint8_t GpioExpander::key_states(void) { } void GpioExpander::set_sd_mux(SdMuxController controller) { - port_a_ &= (1 << 5); + if (controller == USB) { + port_a_ |= (1 << 5); + } else { + port_a_ &= ~(1 << 5); + } } void GpioExpander::set_sd_cs(bool high) { - port_a_ &= (1 << 6); + if (high) { + port_a_ |= (1 << 6); + } else { + port_a_ &= ~(1 << 6); + } } void GpioExpander::set_display_cs(bool high) { - port_a_ &= (1 << 7); + if (high) { + port_a_ |= (1 << 7); + } else { + port_a_ &= ~(1 << 7); + } } } // namespace gay_ipod |
