Skip to content

Conversation

@victor-Lopez25
Copy link
Contributor

@victor-Lopez25 victor-Lopez25 commented Dec 8, 2025

Unfortunately the dummy is necessary but now we only need to specify a domain in a single place.

Had to add ## to VA_ARGS for it to remove the comma when there are no varargs. This does not work in msvc unless -Zc:preprocessor is specified because their implementation of macros works differently

Unfortunately the dummy is necessary but now we only need to specify a domain in a single place
had to add ## to __VA_ARGS__ for it to remove the comma when there are no varargs
this does not work in msvc unless -Zc:preprocessor is specified because their implementation of macros works differently
@victor-Lopez25
Copy link
Contributor Author

Dummy also needed an Entry structure but with that it worked :)

@victor-Lopez25
Copy link
Contributor Author

main.cpp used:

//#include "main.h"
#include "ST-LIB.hpp"

using ST_LIB::DigitalOutputDomain;

constexpr DigitalOutputDomain::DigitalOutput led1{ST_LIB::PB0};
constexpr DigitalOutputDomain::DigitalOutput led2{ST_LIB::PE1};
constexpr DigitalOutputDomain::DigitalOutput led3{ST_LIB::PB14};
int main(void) {
  using myBoard = ST_LIB::Board<led1, led2, led3>;
  myBoard::init();

  auto &green_led = myBoard::instance_of<led1>();
  auto &yellow_led = myBoard::instance_of<led2>();
  auto &gred_led = myBoard::instance_of<led3>();

  while (1) {
    green_led.toggle();
    yellow_led.toggle();
    gred_led.toggle();

    //wait_one_second();
    for(uint32_t i = 0; i < 500000; i++)
        __NOP();
  }
}

void Error_Handler(void) {
    ErrorHandler("HAL error handler triggered");
    while (1) {
    }
}

extern "C" {
void assert_failed(uint8_t *file, uint32_t line) {
  while (1) {
  }
}
}

@jorgesg82
Copy link
Contributor

At the end, this feature won't work, as the MPUManager needs more flexibility. Check #537

@victor-Lopez25
Copy link
Contributor Author

I don't see where the MPUManager needs more flexibility but if it does, it can still work with the XList, just don't include it in the XList:

#define DomainXList \
    X(GPIODomain, gpio) \
    X(DigitalOutputDomain, dout, GPIODomain::Init<gpioN>::instances) \
    X(DigitalInputDomain, din, GPIODomain::Init<gpioN>::instances)

// Do not use this class
struct Dummy {
    static const std::size_t max_instances{1};
    struct Entry { uint32_t dummy; };
};

#define X(x, y, ...) x,
using DomainsCtx = BuildCtx<DomainXList Dummy, MPUManager>;
// etc.

@victor-Lopez25
Copy link
Contributor Author

Okay, I saw where it does need more flexibility, but my point still stands. Both can coexist.

@victor-Lopez25 victor-Lopez25 marked this pull request as draft January 27, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants