rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
ppm.h
Go to the documentation of this file.
1
27
28#ifndef RCBENCH_PPM_H
29#define RCBENCH_PPM_H
30
31#include <stdbool.h>
32#include <stddef.h>
33#include <stdint.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
43#define PPM_MAX_CHANNELS 8u
44
49#define PPM_MAX_RUNS ((PPM_MAX_CHANNELS + 1u) * 2u)
50
57#define PPM_CHANNEL_MIN_US 400u
58#define PPM_CHANNEL_MAX_US 2500u
59
60#define PPM_DEFAULT_MARK_US 300u
61#define PPM_DEFAULT_FRAME_US 22500u
62
70#define PPM_SYNC_MIN_US 3000u
71
72typedef struct {
73 uint16_t mark_us;
74 uint16_t frame_us;
75 uint16_t sync_min_us;
76} ppm_cfg_t;
77
78#define PPM_CFG_DEFAULT() \
79 (ppm_cfg_t) { \
80 .mark_us = PPM_DEFAULT_MARK_US, \
81 .frame_us = PPM_DEFAULT_FRAME_US, \
82 .sync_min_us = PPM_SYNC_MIN_US, \
83 }
84
105size_t ppm_frame(const uint16_t *channel_us, uint8_t channels,
106 const ppm_cfg_t *cfg, uint16_t *runs, size_t max_runs);
107
123uint32_t ppm_min_frame_us(uint8_t channels, const ppm_cfg_t *cfg);
124
125#ifdef __cplusplus
126}
127#endif
128
129#endif /* RCBENCH_PPM_H */
size_t ppm_frame(const uint16_t *channel_us, uint8_t channels, const ppm_cfg_t *cfg, uint16_t *runs, size_t max_runs)
Lay a frame out as alternating run lengths in microseconds.
Definition ppm.c:47
uint32_t ppm_min_frame_us(uint8_t channels, const ppm_cfg_t *cfg)
The shortest frame that can carry channels channels whatever they are commanded to,...
Definition ppm.c:37
Definition ppm.h:72
uint16_t mark_us
Definition ppm.h:73
uint16_t frame_us
Definition ppm.h:74
uint16_t sync_min_us
Definition ppm.h:75