No description provided.
https://github.com/scottc11/ok-STM32F4/blob/d94320112c449a8369a6cfa2a5fe33a228b8fc84/drivers/CD4051/CD4051.cpp#L24-L30 In AVR I typically write directly to registers. In the case of the mux addressing, I'd just write the 3 bit address to the output register with necessary bit masks to preserve the state of the other bits. something like this: ``` GPIO_REGISTER &= bit_mask; GPIO_REGISTER |= mux_address; ``` This is easy to do when you've got 3 consecutive bits - you just bit shift up or down as needed and you've created the address for the mux. If I'd noticed it, I would've suggested that the mux address pins be consecutive bits in a register, but they are instead pins 2, 4, and 7. Your switch case statement to extract the mux address from the channel index is a bit unwieldy. I started to figure out the bit masks and bit shifting required to write directly to the gpio register, but then just asked chat gpt, and this is better and less complicated than anything I would've come up with: ``` pinA.write((channel & 0x01) ? 1 : 0); pinB.write((channel & 0x02) ? 1 : 0); pinC.write((channel & 0x04) ? 1 : 0); ``` & the channel (0-7) with each bit place to set or clear the 3 pin address! Tested and working.
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by minisystem and has received 0 comments.