1
0
mirror of synced 2024-11-27 15:00:49 +01:00
bananatools/board/najv4.h

37 lines
892 B
C
Raw Permalink Normal View History

2023-01-03 05:35:53 +01:00
#pragma once
#include <stdint.h>
#include "jvs/jvs-bus.h"
struct najv4_switch_state {
/* Note: this struct is host-endian. The NAJV4 emulator handles the conversion
to protocol-endian. */
uint8_t system;
uint16_t p1;
uint16_t p2;
};
struct najv4_ops {
void (*reset)(void *ctx);
void (*write_gpio)(void *ctx, uint32_t state);
void (*read_switches)(void *ctx, struct najv4_switch_state *out);
void (*read_analogs)(void *ctx, uint16_t *analogs, uint8_t nanalogs);
void (*read_coin_counter)(void *ctx, uint8_t slot_no, uint16_t *out);
};
struct najv4 {
struct jvs_node jvs;
uint8_t addr;
const struct najv4_ops *ops;
void *ops_ctx;
};
void najv4_init(
struct najv4 *najv4,
struct jvs_node *next,
const struct najv4_ops *ops,
void *ops_ctx);
struct jvs_node *najv4_to_jvs_node(struct najv4 *najv4);