PER Firmware
Loading...
Searching...
No Matches
spmc.h File Reference

Custom SPMC designed for high throughput handling of CAN message streams. More...

#include <stddef.h>
#include <stdint.h>
#include "timestamped_frame.h"

Go to the source code of this file.

Classes

struct  SPMC_t
 

Functions

void SPMC_init (SPMC_t *spmc)
 Initializes the SPMC instance and configures CAN RX interrupts.
 
bool SPMC_enqueue_from_ISR (SPMC_t *spmc, timestamped_frame_t *incoming_frame)
 Enqueues a received CAN message into the SPMC buffer from an ISR context. ! the two producer ISRs must have the same NVIC priority to prevent preemption of each other in the middle of a write.
 
bool SPMC_master_peek_chunk (SPMC_t *spmc, timestamped_frame_t **first_item)
 Peeks at the next chunk for the master (SD logging) without committing the tail.
 
void SPMC_master_advance_tail (SPMC_t *spmc)
 Advances the master tail pointer by one chunk.
 
size_t SPMC_follower_peek_minis (SPMC_t *spmc, timestamped_frame_t **first_item)
 Peeks at the number of contiguous mini chunks available for the follower without lapping the master's tail without committing the tail.
 
void SPMC_follower_advance_tail (SPMC_t *spmc, size_t minis_consumed)
 Advances the follower tail pointer by a given number of mini chunks.
 

Variables

SPMC_t g_spmc
 

Detailed Description

Custom SPMC designed for high throughput handling of CAN message streams.

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Function Documentation

◆ SPMC_enqueue_from_ISR()

bool SPMC_enqueue_from_ISR ( SPMC_t * spmc,
timestamped_frame_t * incoming_frame )

Enqueues a received CAN message into the SPMC buffer from an ISR context. ! the two producer ISRs must have the same NVIC priority to prevent preemption of each other in the middle of a write.

Parameters
spmcPointer to the SPMC instance.
incoming_framePointer to the timestamped_frame_t containing the received CAN message.
Returns
true if the frame was enqueued successfully, or false if the buffer is full and the frame was dropped.

◆ SPMC_follower_peek_minis()

size_t SPMC_follower_peek_minis ( SPMC_t * spmc,
timestamped_frame_t ** first_item )

Peeks at the number of contiguous mini chunks available for the follower without lapping the master's tail without committing the tail.

Returns
The number of contiguous mini chunks available.

◆ SPMC_init()

void SPMC_init ( SPMC_t * spmc)

Initializes the SPMC instance and configures CAN RX interrupts.

Parameters
spmcPointer to the SPMC instance to initialize.

◆ SPMC_master_advance_tail()

void SPMC_master_advance_tail ( SPMC_t * spmc)

Advances the master tail pointer by one chunk.

Warning
this function should only be called by the master consumer context
Parameters
spmcPointer to the SPMC instance.

◆ SPMC_master_peek_chunk()

bool SPMC_master_peek_chunk ( SPMC_t * spmc,
timestamped_frame_t ** first_item )

Peeks at the next chunk for the master (SD logging) without committing the tail.

Parameters
spmcPointer to the SPMC instance.
first_itemOutput pointer that will point to the first item in the chunk if available, or NULL if no items are available.
Returns
true if a chunk is available, false if no items/not enough are available