As pointed out by bolishagnasty in DIscord, the red LED doesn't behave as documented.
I noticed in testing that red LED would act normally when an SD card wasn't used, but would stay on but more dimly when one is installed (suggesting that it's flashing quickly).
It turns out the the instructions that set and clear the red LED in spi_read_buffer is the same as in spi_send_buffer, but the register that the use have different values between the two functions. This led to data being written to Output Port Configuration Register instead of Set Output Port Bits Command and to Set Output Port Bits Command instead of Clear Output Port Bits Command.
This bug was changing the mode of OP3 to be a UART TX clock output instead of having the value set via the output port bits command registers, leading to the red LED being always-on when spi_read_buffer was called.
I don't know whether or not having the red LED still flash on SPI accesses is intended. It doesn't check the SDB system flags for whether the system is allowed to use the red LED, so the flashing should be removed or should check the flag, or the documentation should be updated. Either way, I've put this fix here to at least have what's there behave as intended.
As pointed out by bolishagnasty in DIscord, the red LED doesn't behave as documented.
I noticed in testing that red LED would act normally when an SD card wasn't used, but would stay on but more dimly when one is installed (suggesting that it's flashing quickly).
It turns out the the instructions that set and clear the red LED in
spi_read_buffer
is the same as inspi_send_buffer
, but the register that the use have different values between the two functions. This led to data being written toOutput Port Configuration Register
instead ofSet Output Port Bits Command
and toSet Output Port Bits Command
instead ofClear Output Port Bits Command
.This bug was changing the mode of OP3 to be a UART TX clock output instead of having the value set via the output port bits command registers, leading to the red LED being always-on when
spi_read_buffer
was called.I don't know whether or not having the red LED still flash on SPI accesses is intended. It doesn't check the SDB system flags for whether the system is allowed to use the red LED, so the flashing should be removed or should check the flag, or the documentation should be updated. Either way, I've put this fix here to at least have what's there behave as intended.