Added control knobs for LINK_WIRELESS_PUT_ISR_IN_IWRAM

This commit is contained in:
Rodrigo Alfonso 2025-02-04 10:25:08 -03:00
parent d88d765e24
commit c1e1a167c4
3 changed files with 46 additions and 5 deletions

View File

@ -311,6 +311,11 @@ You can update these values at any time without creating a new instance:
- This is measured in words (1 message = 1 halfword). One word is used as a header, so a max transfer length of 11 could transfer up to 20 messages.
- `LINK_WIRELESS_PUT_ISR_IN_IWRAM`: to put critical functions in IWRAM, which can significantly improve performance due to its faster access. This is disabled by default to conserve IWRAM space, which is limited, but it's enabled in demos to showcase its performance benefits.
- If you enable this, make sure that `LinkWireless.cpp` gets compiled! For example, in a Makefile-based project, verify that the file is in your `SRCDIRS` list.
- Depending on how much IWRAM you have available, you might want to tweak these knobs:
* `LINK_WIRELESS_PUT_ISR_IN_IWRAM_SERIAL`: (default: `1`) Put the SERIAL ISR in IWRAM (recommended)
* `LINK_WIRELESS_PUT_ISR_IN_IWRAM_TIMER`: (default: `0`) Put the TIMER ISR in IWRAM (not so recommended)
* `LINK_WIRELESS_PUT_ISR_IN_IWRAM_SERIAL_LEVEL`: (default: `"-Ofast"`) Optimization level for the SERIAL ISR
* `LINK_WIRELESS_PUT_ISR_IN_IWRAM_TIMER_LEVEL`: (default: `"-Ofast"`) Optimization level for the TIMER ISR
- `LINK_WIRELESS_ENABLE_NESTED_IRQ`: to allow `LINK_WIRELESS_ISR_*` functions to be interrupted. This can be useful, for example, if your audio engine requires calling a VBlank handler with precise timing.
# 💻 LinkWirelessMultiboot

View File

@ -1,12 +1,29 @@
#include "LinkWireless.hpp"
#if defined(LINK_WIRELESS_PUT_ISR_IN_IWRAM) || \
defined(LINK_WIRELESS_ENABLE_NESTED_IRQ)
#ifdef LINK_WIRELESS_PUT_ISR_IN_IWRAM
#define _LINK_CODE LINK_CODE_IWRAM
#if LINK_WIRELESS_PUT_ISR_IN_IWRAM_SERIAL == 1
#define _LINK_SERIAL_ISR \
LINK_CODE_IWRAM \
__attribute__((optimize(LINK_WIRELESS_PUT_ISR_IN_IWRAM_SERIAL_LEVEL)))
#else
#define _LINK_CODE
#define _LINK_SERIAL_ISR
#endif
_LINK_CODE void LinkWireless::_onSerial() {
#if LINK_WIRELESS_PUT_ISR_IN_IWRAM_TIMER == 1
#define _LINK_TIMER_ISR \
LINK_CODE_IWRAM \
__attribute__((optimize(LINK_WIRELESS_PUT_ISR_IN_IWRAM_TIMER_LEVEL)))
#else
#define _LINK_TIMER_ISR
#endif
#endif
_LINK_SERIAL_ISR void LinkWireless::_onSerial() {
#ifdef LINK_WIRELESS_ENABLE_NESTED_IRQ
interrupt = true;
LINK_BARRIER;
@ -19,7 +36,8 @@ _LINK_CODE void LinkWireless::_onSerial() {
irqEnd();
#endif
}
void LinkWireless::_onTimer() {
_LINK_TIMER_ISR void LinkWireless::_onTimer() {
#ifdef LINK_WIRELESS_ENABLE_NESTED_IRQ
if (interrupt)
return;
@ -50,3 +68,5 @@ void LinkWireless::_onTimer() {
* - VBLANK interrupts are postponed if SERIAL or TIMER ISRs are running.
* - Nobody can interrupt VBLANK ISR.
*/
#endif

View File

@ -114,6 +114,21 @@
// #define LINK_WIRELESS_ENABLE_NESTED_IRQ
#endif
// --- LINK_WIRELESS_PUT_ISR_IN_IWRAM knobs ---
#ifndef LINK_WIRELESS_PUT_ISR_IN_IWRAM_SERIAL
#define LINK_WIRELESS_PUT_ISR_IN_IWRAM_SERIAL 1
#endif
#ifndef LINK_WIRELESS_PUT_ISR_IN_IWRAM_TIMER
#define LINK_WIRELESS_PUT_ISR_IN_IWRAM_TIMER 0
#endif
#ifndef LINK_WIRELESS_PUT_ISR_IN_IWRAM_SERIAL_LEVEL
#define LINK_WIRELESS_PUT_ISR_IN_IWRAM_SERIAL_LEVEL "-Ofast"
#endif
#ifndef LINK_WIRELESS_PUT_ISR_IN_IWRAM_TIMER_LEVEL
#define LINK_WIRELESS_PUT_ISR_IN_IWRAM_TIMER_LEVEL "-Ofast"
#endif
// ---
LINK_VERSION_TAG LINK_WIRELESS_VERSION = "vLinkWireless/v8.0.0";
#define LINK_WIRELESS_MAX_PLAYERS LINK_RAW_WIRELESS_MAX_PLAYERS
@ -856,7 +871,8 @@ class LinkWireless {
#endif
}
#ifdef LINK_WIRELESS_PUT_ISR_IN_IWRAM
#if defined(LINK_WIRELESS_PUT_ISR_IN_IWRAM) || \
defined(LINK_WIRELESS_ENABLE_NESTED_IRQ)
void _onSerial();
void _onTimer();
#else