Nexus Embedded Platform 0.1.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1
8#ifndef NEXUS_TIMER_H
9#define NEXUS_TIMER_H
10
11#include "nexus/core/status.h"
12#ifdef __cplusplus
13extern "C" {
14#endif
20typedef struct {
21 uint32_t period_ticks;
22 uint32_t duty_ticks;
23 uint32_t tick_hz;
24 bool running;
26
33typedef struct {
34 nx_result_t (*set)(void* context, uint32_t period_ticks,
35 uint32_t duty_ticks);
36 nx_result_t (*start)(void* context);
37 nx_result_t (*stop)(void* context);
38 nx_result_t (*state)(const void* context, nx_pwm_state_t* state);
40
48 void* context;
49};
50
69nx_result_t nx_pwm_port_set(const nx_pwm_port_t* port, uint32_t period_ticks,
70 uint32_t duty_ticks);
97#ifdef __cplusplus
98}
99#endif
100
101#endif
Small vendor-independent result vocabulary.
nx_result_t
Operation result; success at submission means admission only.
Definition status.h:21
Shared read-only methods using one provider state.
Definition timer.h:33
nx_result_t(* stop)(void *context)
Definition timer.h:37
nx_result_t(* set)(void *context, uint32_t period_ticks, uint32_t duty_ticks)
Definition timer.h:34
nx_result_t(* start)(void *context)
Definition timer.h:36
nx_result_t(* state)(const void *context, nx_pwm_state_t *state)
Definition timer.h:38
Immutable interface pointing to caller-owned state.
Definition timer.h:46
void * context
Definition timer.h:48
const nx_pwm_ops_t * ops
Definition timer.h:47
PWM counts refer to the fixed declared post-prescaler timer clock.
Definition timer.h:20
uint32_t tick_hz
Definition timer.h:23
uint32_t period_ticks
Definition timer.h:21
bool running
Definition timer.h:24
uint32_t duty_ticks
Definition timer.h:22
nx_result_t nx_pwm_port_state(const nx_pwm_port_t *port, nx_pwm_state_t *state)
Query staged PWM counts and selected timer clock.
nx_result_t nx_pwm_port_stop(const nx_pwm_port_t *port)
Stop PWM at its declared Board inactive electrical level.
nx_result_t nx_pwm_port_start(const nx_pwm_port_t *port)
Enable a previously configured fixed PWM output.
nx_result_t nx_pwm_port_set(const nx_pwm_port_t *port, uint32_t period_ticks, uint32_t duty_ticks)
Atomically stage a reviewed fixed-base PWM duty.
struct nx_pwm_port nx_pwm_port_t
Definition timer.h:15