libjoybus
Joybus implementation for 32-bit MCUs
Loading...
Searching...
No Matches
joybus_target_n64_pak_api Struct Reference

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.

Detailed Description

API for implementing an N64 pak.

Field Documentation

◆ read_block

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.

Parameters
pakthe pak being read from
addrblock-aligned address (low 5 bits are zero)
bufdestination buffer, exactly 32 bytes
Returns
0 on success, -JOYBUS_ERR_BUSY to decline the read for now, another negative joybus_error on failure

◆ write_block

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.

Parameters
pakthe pak being written to
addrblock-aligned address (low 5 bits are zero)
bufsource buffer, exactly 32 bytes
Returns
0 on success, -JOYBUS_ERR_BUSY to decline the write for now, another negative joybus_error on failure

The documentation for this struct was generated from the following file: