Sequencer
Loading...
Searching...
No Matches
sequencer.h File Reference

Simple timed sequencer (millisecond precission), which generates simple events. More...

#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  sequencer_entry
struct  sequencer

Enumerations

enum  sequencer_mode { SEQUENCER_MODE_SINGLE , SEQUENCER_MODE_REPEAT , SEQUENCER_MODES }

Functions

void sequencer_init (struct sequencer *self, struct sequencer_entry *entries, size_t capacity)
void sequencer_set_mode (struct sequencer *self, uint8_t mode)
bool sequencer_add_entry (struct sequencer *self, uint16_t timer_ms, uint8_t event)
size_t sequencer_get_entry_count (struct sequencer *self)
void sequencer_reset (struct sequencer *self)
void sequencer_clean (struct sequencer *self)
uint16_t sequencer_update (struct sequencer *self, uint16_t delta_time_ms)

Detailed Description

Simple timed sequencer (millisecond precission), which generates simple events.

This file contains the software implementation of the sequencer. The design is hardware-agnostic, requiring an external adaptation layer for hardware interaction.

Conventions: C89, Linux kernel style, MISRA, rule of 10, No hardware specific code, only generic C and some binding layer. Be extra specific about types.

Scientific units where posible at end of the names, for example:

  • timer_10s (timer_10s has a resolution of 10s per bit)
  • power_150w (power 150W per bit or 0.15kw per bit)

Keep variables without units if they're unknown or not specified or hard to define with short notation.

Copyright (c) 2025 furdog <https://github.com/furdog>
SPDX-License-Identifier: 0BSD

Be free, be wise and take care of yourself! With best wishes and respect, furdog

Enumeration Type Documentation

◆ sequencer_mode

Sequencer working mode. Changes behaviour

Enumerator
SEQUENCER_MODE_SINGLE 

Sequencer will do its work only once

SEQUENCER_MODE_REPEAT 

Sequencer will repeat its work forever

SEQUENCER_MODES 

Total count of sequencer modes

Function Documentation

◆ sequencer_init()

void sequencer_init ( struct sequencer * self,
struct sequencer_entry * entries,
size_t capacity )

Initializes sequencer, takes entries array and its capacity to work with

◆ sequencer_set_mode()

void sequencer_set_mode ( struct sequencer * self,
uint8_t mode )

Sets sequencer working mode. SEQUENCER_MODE_SINGLE is default

◆ sequencer_add_entry()

bool sequencer_add_entry ( struct sequencer * self,
uint16_t timer_ms,
uint8_t event )

Adds entry into a sequencer, return false if no capacity

◆ sequencer_get_entry_count()

size_t sequencer_get_entry_count ( struct sequencer * self)

Returns sequencer entry count

◆ sequencer_reset()

void sequencer_reset ( struct sequencer * self)

Resets the sequencer (starts from very beginning)

◆ sequencer_clean()

void sequencer_clean ( struct sequencer * self)

Resets and cleanups the sequencer (zeroes entry count)

◆ sequencer_update()

uint16_t sequencer_update ( struct sequencer * self,
uint16_t delta_time_ms )

Updates sequencer, returns an event if exceed single entry timer. Advances to the next entry after entry timer exceed. Resets entry count to zero if last entry processed