Custom SPMC designed for high throughput handling of CAN message streams.
More...
#include "spmc.h"
#include "stm32f407xx.h"
|
| void | SPMC_init (SPMC_t *spmc) |
| | Initializes the SPMC instance and configures CAN RX interrupts.
|
| |
| SPMC_status_t | 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 priority to prevent preemption in the middle of a write.
|
| |
| size_t | SPMC_master_peek_all (SPMC_t *spmc, timestamped_frame_t **first_item, size_t *total_unread) |
| | Peeks at the next batch of frames available for processing by the master (SD logging) without committing the tail. Intended to be used with a DMA operation.
|
| |
| void | SPMC_master_commit_tail (SPMC_t *spmc, size_t num_consumed) |
| | Commits the specified number of consumed frames by advancing the master tail pointer.
|
| |
| SPMC_status_t | SPMC_follower_pop (SPMC_t *spmc, timestamped_frame_t **out, uint32_t *consecutive_items) |
| | Pops a single frame for the follower (Ethernet transmission) and advances the follower tail pointer. todo: this function is incomplete todo: optimize for DMA batch transfers, similar to the master's function.
|
| |
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)
-
Shriya Balu (balu@.nosp@m.purd.nosp@m.ue.ed.nosp@m.u)
◆ SPMC_enqueue_from_ISR()
Enqueues a received CAN message into the SPMC buffer from an ISR context. ! the two producer ISRs must have the same priority to prevent preemption in the middle of a write.
- Parameters
-
| spmc | Pointer to the SPMC instance. |
| incoming_frame | Pointer to the timestamped_frame_t containing the received CAN message. |
- Returns
- SPMC_OK if the frame was enqueued successfully, or SPMC_FULL if the buffer is full and the frame was dropped.
◆ SPMC_follower_pop()
Pops a single frame for the follower (Ethernet transmission) and advances the follower tail pointer. todo: this function is incomplete todo: optimize for DMA batch transfers, similar to the master's function.
- Parameters
-
| spmc | Pointer to the SPMC instance. |
| out | Output pointer to the popped frame. |
| consecutive_items | Output pointer to the number of consecutive frames available. |
- Returns
- SPMC_OK if a frame was successfully popped, or SPMC_EMPTY if the buffer is empty.
◆ SPMC_init()
| void SPMC_init |
( |
SPMC_t * | spmc | ) |
|
Initializes the SPMC instance and configures CAN RX interrupts.
- Parameters
-
| spmc | Pointer to the SPMC instance to initialize. |
◆ SPMC_master_commit_tail()
| void SPMC_master_commit_tail |
( |
SPMC_t * | spmc, |
|
|
size_t | num_consumed ) |
Commits the specified number of consumed frames by advancing the master tail pointer.
- Parameters
-
| spmc | Pointer to the SPMC instance. |
| num_consumed | The number of frames to commit. |
◆ SPMC_master_peek_all()
Peeks at the next batch of frames available for processing by the master (SD logging) without committing the tail. Intended to be used with a DMA operation.
- Parameters
-
| spmc | Pointer to the SPMC instance. |
| first_item | Output pointer that will point to the first item in the batch if available, or NULL if no items are available. |
| total_unread | Output pointer that will be set to the total number of unread frames available in the buffer. |
- Returns
- The number of contiguous items available in the batch.