From 8e4fceec7e4b74b25cd214a2fa5d21b3e3cc225e Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Santos Souza de Miranda Date: Wed, 3 Jun 2026 12:23:00 -0300 Subject: [PATCH] Create the FakeGPIO.hpp to be used as Mock for testing and Update the timing for the delays and also create the Write method on the HAL to choreograph the writing process in the YMF262 --- Lib/YMF262-HAL/Inc/FakeGPIO.hpp | 19 ------------------- Lib/YMF262-HAL/Inc/YMF262-HAL.h | 20 ++++++++++++++++++++ Tests/FakeGPIO.hpp | 22 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 19 deletions(-) delete mode 100644 Lib/YMF262-HAL/Inc/FakeGPIO.hpp create mode 100644 Lib/YMF262-HAL/Inc/YMF262-HAL.h create mode 100644 Tests/FakeGPIO.hpp diff --git a/Lib/YMF262-HAL/Inc/FakeGPIO.hpp b/Lib/YMF262-HAL/Inc/FakeGPIO.hpp deleted file mode 100644 index a117976..0000000 --- a/Lib/YMF262-HAL/Inc/FakeGPIO.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef FAKE_GPIO_HPP -#define FAKE_GPIO_HPP - - -#include -#include "GPIO.hpp" - -struct FakeGpio { - void set_data_bus(uint8_t val){} - void set_a0(Port port){} - void set_a1(Bank address_bank){} - void set_cs(State state){} - void set_wr(State state){} - void set_ic(State state){} - void set_rd(State state){} - void delay_ticks(uint32_t n){} -}; - -#endif \ No newline at end of file diff --git a/Lib/YMF262-HAL/Inc/YMF262-HAL.h b/Lib/YMF262-HAL/Inc/YMF262-HAL.h new file mode 100644 index 0000000..4bd6d14 --- /dev/null +++ b/Lib/YMF262-HAL/Inc/YMF262-HAL.h @@ -0,0 +1,20 @@ +#ifndef YMF262_HAL_H +#define YMF262_HAL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct YMF262_HAL_Handle YMF262_HAL_Handle; + +YMF262_HAL_Handle* YMF262_HAL_Create(uint32_t opl_clock, uint32_t cpu_clock); +void YMF262_HAL_Destroy(YMF262_HAL_Handle* handle); + + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/Tests/FakeGPIO.hpp b/Tests/FakeGPIO.hpp new file mode 100644 index 0000000..77d1871 --- /dev/null +++ b/Tests/FakeGPIO.hpp @@ -0,0 +1,22 @@ +#ifndef FAKE_GPIO_HPP +#define FAKE_GPIO_HPP + +#include +#include +#include +#include "GPIO.hpp" + +struct FakeGpio { + std::vector log; + + void set_data_bus(uint8_t val) { log.push_back("data " + std::to_string(val)); } + void set_a0(Port port) { log.push_back(port == Port::ADDRESS ? "a0 ADDR" : "a0 DATA"); } + void set_a1(Bank bank) { log.push_back(bank == Bank::BANK_0 ? "a1 B0" : "a1 B1"); } + void set_cs(State s) { log.push_back(s == State::ACTIVE ? "cs ON" : "cs OFF"); } + void set_wr(State s) { log.push_back(s == State::ACTIVE ? "wr ON" : "wr OFF"); } + void set_ic(State s) { log.push_back(s == State::ACTIVE ? "ic ON" : "ic OFF"); } + void set_rd(State s) { log.push_back(s == State::ACTIVE ? "rd ON" : "rd OFF"); } + void delay_ticks(uint32_t n) { log.push_back("delay " + std::to_string(n)); } +}; + +#endif \ No newline at end of file