Skip to content

IRQManager: implement callback based method for custom irq handlers #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

facchinm
Copy link
Member

Could fix #310

I'm not 100% convinced about the freedom <-> ease of use trade off this API should have, in the meantime it's leaning towards the freedom (since the expected audience is not the beginner).

@delta-G what do you think?

Copying here the test sketch I added to the code

void irq_callback() {

}

bool config_my_funky_peripheral(unsigned int* last_interrupt, volatile uint32_t *irq_ptr, void* config) {
  funky_peripheral_cfg_t* cfg = (funky_peripheral_cfg_t*)config;
  *(irq_ptr + *last_interrupt) = (uint32_t)irq_callback;
  cfg->interrupt = *last_interrupt;
  *last_interrupt++;
  return true;
}

funky_peripheral_cfg_t funky_cfg;

void setup() {
  // put your setup code here, to run once:
  IRQManager::getInstance().addCustomPeripheral(config_my_funky_peripheral, &funky_cfg);
}

@facchinm facchinm marked this pull request as draft May 13, 2024 15:48
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels May 14, 2024
@delta-G
Copy link
Contributor

delta-G commented May 14, 2024

I could use that, but it's a little scary letting the general public have last_interrupt_index like that. May I propose an alternative that keeps the code inside IRQManager? All we need is a generic config struct that has an IRQn_Type, a priority, and an elc_event_t. The user passes in the even type and the priority and IRQManager fills in the irq number.

I've can put that code together real quick and push another PR and we can compare.

@facchinm facchinm closed this May 15, 2024
@per1234 per1234 added conclusion: resolved Issue was resolved conclusion: duplicate Has already been submitted and removed conclusion: resolved Issue was resolved labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: duplicate Has already been submitted topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IRQManager doesn't implement some interrupt types
3 participants