rosco-m68k / rosco_m68k

Design, documentation and software for the Really Old School Computer (M68K)
https://rosco-m68k.com
Other
157 stars 32 forks source link

Make LED respect SYSFLAGS and don't write to OPCR on DUART SPI read #420

Closed 0xTJ closed 5 months ago

0xTJ commented 5 months ago

This PR includes the changes in #419 (see that PR for details on those changes) as well as additional ones to prevent the GPIOs from being incorrectly changed when the LEDs are controlled and SYSFLAGS sets them as not available to the firmware.

It adds checks to spi_send_buffer and spi_read_buffer in dua_spi_asm.asm to only set/clear the red LED if the corresponding SYSFLAGS bit is set.

There were also cases where the SYSFLAGS were and-ed with the value to set in the MFP GPDR, which seemingly would clear those bits, instead of leaving them untouched. I've changed this here to use RMW instructions with an already-masked value to directly only update the bits that are allowed by the SYSFLAGS.

I have only tested the behaviour on r2 boards with DUART, not on the r1.x with MFP. EDIT: I have now also tested that the system still works with these changes on a HUGEROM r1.23 with MFP, but haven't thoroughly tested how the LEDs behave.