Skip to content
Snippets Groups Projects
Commit 0b845e99 authored by rahix's avatar rahix
Browse files

chore(interrupts): Make api_interrupt_trigger() return void


api_interrupt_trigger() cannot fail except by a programmer error
(passing an invalid ID) in which case we should raise an assertion.
Thus, make it return `void` instead of `int`.

This is also in preparation for future work to schedule interrupts
asynchroneously.

Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 12992926
No related branches found
No related tags found
No related merge requests found
#include "api/interrupt-sender.h" #include "api/interrupt-sender.h"
#include "api/common.h" #include "api/common.h"
#include "tmr_utils.h" #include "tmr_utils.h"
#include <assert.h>
static bool int_enabled[EPIC_INT_NUM]; static bool int_enabled[EPIC_INT_NUM];
int api_interrupt_trigger(api_int_id_t id) void api_interrupt_trigger(api_int_id_t id)
{ {
if (id >= EPIC_INT_NUM) { assert(id < EPIC_INT_NUM);
return -EINVAL;
}
if (int_enabled[id]) { if (int_enabled[id]) {
while (API_CALL_MEM->int_id != (api_int_id_t)(-1)) while (API_CALL_MEM->int_id != (api_int_id_t)(-1))
...@@ -17,7 +16,6 @@ int api_interrupt_trigger(api_int_id_t id) ...@@ -17,7 +16,6 @@ int api_interrupt_trigger(api_int_id_t id)
API_CALL_MEM->int_id = id; API_CALL_MEM->int_id = id;
TMR_TO_Start(MXC_TMR5, 1, 0); TMR_TO_Start(MXC_TMR5, 1, 0);
} }
return 0;
} }
void api_interrupt_init(void) void api_interrupt_init(void)
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
#include "api/common.h" #include "api/common.h"
void api_interrupt_init(void); void api_interrupt_init(void);
int api_interrupt_trigger(api_int_id_t id); void api_interrupt_trigger(api_int_id_t id);
...@@ -140,7 +140,10 @@ static int max86150_handle_sample(struct max86150_sensor_data *data) ...@@ -140,7 +140,10 @@ static int max86150_handle_sample(struct max86150_sensor_data *data)
LOG_WARN("max86150", "queue full"); LOG_WARN("max86150", "queue full");
return -EIO; return -EIO;
} }
return api_interrupt_trigger(EPIC_INT_MAX86150);
api_interrupt_trigger(EPIC_INT_MAX86150);
return 0;
} }
static int max86150_fetch_fifo(void) static int max86150_fetch_fifo(void)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment