|
libjoybus
Joybus implementation for 32-bit MCUs
|
API for implementing an N64 pak. More...
#include <n64_pak.h>
Data Fields | |
| int(* | read_block )(struct joybus_target_n64_pak *pak, uint16_t addr, uint8_t buf[JOYBUS_N64_PAK_BLOCK_SIZE]) |
| Called when a host requests to read a 32-byte block from the pak. | |
| int(* | write_block )(struct joybus_target_n64_pak *pak, uint16_t addr, const uint8_t buf[JOYBUS_N64_PAK_BLOCK_SIZE]) |
| Called when a host requests to write a 32-byte block to the pak. | |
API for implementing an N64 pak.
| int(* joybus_target_n64_pak_api::read_block) (struct joybus_target_n64_pak *pak, uint16_t addr, uint8_t buf[JOYBUS_N64_PAK_BLOCK_SIZE]) |
Called when a host requests to read a 32-byte block from the pak.
Runs in interrupt context, on the response critical path, so it must return quickly. Mark the implementation with JOYBUS_RAM_FUNC.
A pak that cannot serve the read yet returns -JOYBUS_ERR_BUSY. The controller then answers as it does for a missing pak, zeros with an inverted CRC, which the host treats as a transfer error and retries, while the pak stays reported as present. Any other negative return gets the same response, but it is a fault rather than a stall: the host will give up after its retries.
| pak | the pak being read from |
| addr | block-aligned address (low 5 bits are zero) |
| buf | destination buffer, exactly 32 bytes |
| int(* joybus_target_n64_pak_api::write_block) (struct joybus_target_n64_pak *pak, uint16_t addr, const uint8_t buf[JOYBUS_N64_PAK_BLOCK_SIZE]) |
Called when a host requests to write a 32-byte block to the pak.
Runs in interrupt context, on the response critical path, since the return value decides the CRC sent in reply. It must return quickly. Mark the implementation with JOYBUS_RAM_FUNC.
A pak that cannot accept the write yet returns -JOYBUS_ERR_BUSY. The controller then answers with the inverted payload CRC, as it does for a missing pak, which the host treats as a transfer error and retries, while the pak stays reported as present. The retry offers the whole block again, so a pak must not act on a block it declines. Any other negative return gets the same response, but it is a fault rather than a stall: the host will give up after its retries.
| pak | the pak being written to |
| addr | block-aligned address (low 5 bits are zero) |
| buf | source buffer, exactly 32 bytes |