Flipper Zero Firmware
Loading...
Searching...
No Matches
digital_signal.h File Reference

Simple digital signal container for the DigitalSequence library. More...

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

Go to the source code of this file.

Macros

#define DIGITAL_SIGNAL_MS(x)
 
#define DIGITAL_SIGNAL_US(x)
 
#define DIGITAL_SIGNAL_NS(x)
 
#define DIGITAL_SIGNAL_PS(x)
 

Typedefs

typedef struct DigitalSignal DigitalSignal
 

Functions

DigitalSignaldigital_signal_alloc (uint32_t max_size)
 Allocate a DigitalSignal instance with a defined maximum size.
 
void digital_signal_free (DigitalSignal *signal)
 Delete a previously allocated DigitalSignal instance.
 
void digital_signal_add_period (DigitalSignal *signal, uint32_t ticks)
 Append one period to the end of the DigitalSignal instance.
 
void digital_signal_add_period_with_level (DigitalSignal *signal, uint32_t ticks, bool level)
 Append one period to the end of the DigitalSignal instance, with the level specified.
 
bool digital_signal_get_start_level (const DigitalSignal *signal)
 Get the current start level contained in the DigitalSignal instance.
 
void digital_signal_set_start_level (DigitalSignal *signal, bool level)
 Set the start level contained in the DigitalSignal instance.
 
uint32_t digital_signal_get_size (const DigitalSignal *signal)
 Get the number of periods currently stored in a DigitalSignal instance.
 

Detailed Description

Simple digital signal container for the DigitalSequence library.

Each signal is represented by its start level (high or low) and one or more periods. The output will transition to its inverse value on each period boundary.

Example: A signal with n periods and HIGH start level.

----+ +------+ +- ... -+
t0 | t1 | t2 | t3 | | tn - 1
+--------+ +----+ +--------

Macro Definition Documentation

◆ DIGITAL_SIGNAL_MS

#define DIGITAL_SIGNAL_MS ( x)
Value:
((x) * 100000000UL)

◆ DIGITAL_SIGNAL_NS

#define DIGITAL_SIGNAL_NS ( x)
Value:
((x) * 100UL)

◆ DIGITAL_SIGNAL_PS

#define DIGITAL_SIGNAL_PS ( x)
Value:
((x) / 10UL)

◆ DIGITAL_SIGNAL_US

#define DIGITAL_SIGNAL_US ( x)
Value:
((x) * 100000UL)

Function Documentation

◆ digital_signal_add_period()

void digital_signal_add_period ( DigitalSignal * signal,
uint32_t ticks )

Append one period to the end of the DigitalSignal instance.

Parameters
[in,out]signalpointer to a the instance to append to.
[in]ticksthe period length, in 10 picosecond units.

◆ digital_signal_add_period_with_level()

void digital_signal_add_period_with_level ( DigitalSignal * signal,
uint32_t ticks,
bool level )

Append one period to the end of the DigitalSignal instance, with the level specified.

If the level is the same as the last level contained in the instance, then it is extened by the given ticks value. Otherwise, the behaviour is identical to digital_signal_add_period().

Example 1: add tc with HIGH level

before:
... ------+
ta | tb
+-------
after:
... ------+ +-------
ta | tb | tc
+------+

Example 2: add tc with LOW level

before:
... ------+
ta | tb
+-------
after:
... ------+
ta | tb + tc
+--------------
Parameters
[in,out]signalpointer to the instance to append to.
[in]ticksthe period length, in 10 picosecond units.
[in]levelthe level to be set during the period.

◆ digital_signal_alloc()

DigitalSignal * digital_signal_alloc ( uint32_t max_size)

Allocate a DigitalSignal instance with a defined maximum size.

Parameters
[in]max_sizethe maximum number of periods the instance will be able to contain.
Returns
pointer to the allocated instance.

◆ digital_signal_free()

void digital_signal_free ( DigitalSignal * signal)

Delete a previously allocated DigitalSignal instance.

Parameters
[in,out]signalpointer to the instance to be deleted.

◆ digital_signal_get_size()

uint32_t digital_signal_get_size ( const DigitalSignal * signal)

Get the number of periods currently stored in a DigitalSignal instance.

Parameters
[in]signalpointer to the instance to be queried.
Returns
the number of periods stored in the instance.

◆ digital_signal_get_start_level()

bool digital_signal_get_start_level ( const DigitalSignal * signal)

Get the current start level contained in the DigitalSignal instance.

If not explicitly set with digital_signal_set_start_level(), it defaults to false.

Parameters
[in]signalpointer to the instance to be queried.
Returns
the start level value.

◆ digital_signal_set_start_level()

void digital_signal_set_start_level ( DigitalSignal * signal,
bool level )

Set the start level contained in the DigitalSignal instance.

Parameters
[in,out]signalpointer to the instance to be modified.
[in]levelsignal level to be set as the start level.