Loading...
Searching...
No Matches
Message based implementation of Bottom Half Processor

Bottom Half Processor module for generic IRQ offloading using messages. More...

Detailed Description

Bottom Half Processor module for generic IRQ offloading using messages.

Note
Offloading ISRs with messages is in general a terrible idea, because messages can be lost. Use it with care or prefer alternatives such as Event based implementation of Bottom Half Processor.
Author
José I. Alamos jose..nosp@m.alam.nosp@m.os@ha.nosp@m.w-ha.nosp@m.mburg.nosp@m..de

Data Structures

struct  bhp_msg_t
 Message based Bottom Half Processor descriptor. More...
 

Macros

#define BHP_MSG_BH_REQUEST   0x1539
 The message type to trigger Bottom Half Processing.
 

Functions

void bhp_msg_init (bhp_msg_t *bhp_msg, bhp_cb_t cb, void *ctx)
 Init a Bottom Half Processor to be used with messages.
 
void bhp_msg_isr_cb (void *bhp_msg_ctx)
 Message based Bottom Half Processor ISR callback To be called from ISR in order to trigger the Bottom Half Processor.
 
static void bhp_msg_claim_thread (bhp_msg_t *bhp_msg, kernel_pid_t pid)
 Claim a thread with a message queue to be used as Bottom Half Processor.
 
static void bhp_msg_handler (msg_t *msg)
 Handle a Bottom Half Processor message with type BHP_MSG_BH_REQUEST.
 

Macro Definition Documentation

◆ BHP_MSG_BH_REQUEST

#define BHP_MSG_BH_REQUEST   0x1539

The message type to trigger Bottom Half Processing.

Definition at line 38 of file msg.h.

Function Documentation

◆ bhp_msg_claim_thread()

static void bhp_msg_claim_thread ( bhp_msg_t bhp_msg,
kernel_pid_t  pid 
)
inlinestatic

Claim a thread with a message queue to be used as Bottom Half Processor.

Parameters
[in]bhp_msgThe message based Bottom Half Processor descriptor
[in]pidPID of the target thread

Definition at line 81 of file msg.h.

◆ bhp_msg_handler()

static void bhp_msg_handler ( msg_t msg)
inlinestatic

Handle a Bottom Half Processor message with type BHP_MSG_BH_REQUEST.

This function will call bhp_irq_handler internally.

Note
This function asserts that the message type is BHP_MSG_BH_REQUEST.
Parameters
[in]msgPointer to the Bottom Half Processor message.

Definition at line 95 of file msg.h.

◆ bhp_msg_init()

void bhp_msg_init ( bhp_msg_t bhp_msg,
bhp_cb_t  cb,
void *  ctx 
)

Init a Bottom Half Processor to be used with messages.

Postcondition
the target PID is set to KERNEL_PID_UNDEF
Parameters
[in]bhp_msgThe message based Bottom Half Processor descriptor
[in]cbBottom Half Processor callback
[in]ctxContext of cb

◆ bhp_msg_isr_cb()

void bhp_msg_isr_cb ( void *  bhp_msg_ctx)

Message based Bottom Half Processor ISR callback To be called from ISR in order to trigger the Bottom Half Processor.

This sends a message with type BHP_MSG_BH_REQUEST to the target thread, which should process the event accordingly by calling bhp_msg_handler.

Note
This function asserts that the target PID is valid. Therefore, make sure to call bhp_msg_claim_thread beforehand.
Parameters
[in]bhp_msg_ctxPointer to the message based Bottom Half Processor (bhp_msg_t) Bottom Half Processor.