From f6a7f3b2e614f110f07bbe6091ff5e8643bc2376 Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Thu, 15 Aug 2024 10:25:27 -0300 Subject: [PATCH] Updating README and fixing mobile stuff --- README.md | 6 ++++-- examples/LinkMobile_demo/src/main.cpp | 22 ++++------------------ lib/LinkMobile.hpp | 24 ++++++++++++------------ 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index beb274e..684e33c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,9 @@ A set of Game Boy Advance (GBA) C++ libraries to interact with the Serial Port. * The examples can be tested on real GBAs or using emulators. * For `LinkCable`/`LinkWireless`/`LinkUniversal`, there are stress tests that you can use to tweak your configuration. -To learn implementation details, you might also want to check out the [docs](docs) folder, which contains important documentation. +> The example ROMs were compiled using [devkitPro](https://devkitpro.org) with GCC `14.1.0`. + +> To learn implementation details, you might also want to check out the [docs](docs) folder, which contains important documentation. ### Makefile actions (for all examples) @@ -461,4 +463,4 @@ Name | Return type | Description |DATA --> SO | |VCC ---> VCC| |GND ---> GND| -``` \ No newline at end of file +``` diff --git a/examples/LinkMobile_demo/src/main.cpp b/examples/LinkMobile_demo/src/main.cpp index c00f8c4..c0214c6 100644 --- a/examples/LinkMobile_demo/src/main.cpp +++ b/examples/LinkMobile_demo/src/main.cpp @@ -16,7 +16,6 @@ void waitFor(u16 key); void wait(u32 verticalLines); void hang(); -LinkMobile::Error lastError; LinkMobile* linkMobile = NULL; void init() { @@ -31,14 +30,9 @@ int main() { start: // Options - log("LinkMobile_demo (v6.7.0)\n\n\n\n" + log("LinkMobile_demo (v7.0.0)\n\n" "Press A to start"); waitFor(KEY_A); - // u16 initialKeys = ~REG_KEYS & KEY_ANY; - // forwarding = !(initialKeys & KEY_LEFT); - // retransmission = !(initialKeys & KEY_UP); - // maxPlayers = (initialKeys & KEY_B) ? 2 : LINK_MOBILE_MAX_PLAYERS; - // asyncACK = initialKeys & KEY_START; // (1) Create a LinkMobile instance linkMobile = new LinkMobile(); @@ -59,16 +53,16 @@ start: // (3) Initialize the library linkMobile->activate(); - bool activating = false; bool reading = false; while (true) { u16 keys = ~REG_KEYS & KEY_ANY; // Menu - log(std::string("") + + log(std::string("") + "State = " + std::to_string(linkMobile->getState()) + + "\n\n" + "L = Read Configuration\n\n (DOWN = ok)\n " - "(SELECT = cancel)\n (START = reactivate)"); + "(SELECT = stop)"); // SELECT = back if (keys & KEY_SELECT) { @@ -78,14 +72,6 @@ start: goto start; } - // START = Activate - if ((keys & KEY_START) && !activating) { - activating = true; - activate(); - } - if (activating && !(keys & KEY_START)) - activating = false; - // L = Read Configuration if ((keys & KEY_L) && !reading) { reading = true; diff --git a/lib/LinkMobile.hpp b/lib/LinkMobile.hpp index f0f04ec..1500121 100644 --- a/lib/LinkMobile.hpp +++ b/lib/LinkMobile.hpp @@ -166,7 +166,7 @@ class LinkMobile { * @brief ... */ void activate() { - lastError = {}; + error = {}; LINK_MOBILE_BARRIER; isEnabled = false; @@ -183,7 +183,7 @@ class LinkMobile { } void deactivate() { - lastError = {}; + error = {}; isEnabled = false; resetState(); stop(); @@ -203,11 +203,11 @@ class LinkMobile { return linkSPI->getDataSize(); } - Error getLastError(bool clear = true) { - auto error = lastError; + Error getError(bool clear = true) { + auto err = error; if (clear) - lastError = {}; - return error; + error = {}; + return err; } ~LinkMobile() { delete linkSPI; } @@ -395,7 +395,7 @@ class LinkMobile { u32 nextCommandDataSize = 0; bool hasPendingTransfer = false; u32 pendingTransfer = 0; - Error lastError = {}; + Error error = {}; volatile bool isEnabled = false; void processNewFrame() { @@ -568,7 +568,7 @@ class LinkMobile { } void abort(Error::Type errorType) { - lastError = + error = Error{.type = errorType, .state = state, .cmdId = (u8)(asyncCommand.cmd.header.commandId & (~OR_VALUE)), @@ -578,10 +578,10 @@ class LinkMobile { asyncCommand.direction == AsyncCommand::Direction::SENDING}; _LMLOG_( - "!! aborted:\n error:%d\n cmdId=%s%d\n cmdResult=%d\n " - "cmdErrorCode=%d", - lastError.type, lastError.cmdIsSending ? ">" : "<", lastError.cmdId, - lastError.cmdResult, lastError.cmdErrorCode); + "!! aborted:\n error: %d\n cmdId: %s$%X\n cmdResult: %d\n " + "cmdErrorCode: %d", + error.type, error.cmdIsSending ? ">" : "<", error.cmdId, + error.cmdResult, error.cmdErrorCode); resetState(); stop();