// SPDX-License-Identifier: GPL-3.0-or-later #include #include "internal.h" // CMOC accepts volatile but does not implement its C semantics. Use one // explicit bus read per poll; a second read must never reuse the first value. asm unsigned char ssc_status(void) { asm { ldb $FF7E andb #$E0 } } asm unsigned char ssc_try_write(unsigned char value) { asm { tst $FF7E bpl @busy ldb 3,s ; low byte of first CMOC argument stb $FF7E ldb #1 bra @done @busy clrb @done } } asm void ssc_reset(void) { asm { ldb #1 stb $FF7D clrb stb $FF7D } } unsigned char ssc_write_bytes(const unsigned char *bytes, unsigned int count, unsigned int poll_limit) { while (count) { unsigned int remaining = poll_limit; while (remaining && !ssc_try_write(*bytes)) --remaining; if (!remaining) return SSC_TIMEOUT; ++bytes; --count; } return SSC_OK; }