MeshX 0.4
This repository provides an implementation for Bluetooth Low Energy (BLE) Mesh network nodes. The project allows you to create BLE mesh nodes that can communicate with each other, enabling the development of smart home solutions or other IoT-based applications.
Loading...
Searching...
No Matches
meshx_pwm.h
Go to the documentation of this file.
1/**
2 * @file meshx_pwm.h
3 * @brief MeshX PWM Interface
4 *
5 * This file defines the MeshX PWM interface for platform-abstracted PWM operations.
6 *
7 * @author MeshX Team
8 * @date 2024
9 */
10
11#ifndef __MESHX_PWM_H
12#define __MESHX_PWM_H
13
14#include <stdint.h>
15#include "../../inc/meshx_err.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/**
22 * @brief Initialize PWM subsystem
23 *
24 * This function initializes the PWM subsystem based on YAML configuration.
25 *
26 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
27 */
29
30/**
31 * @brief Deinitialize PWM subsystem
32 *
33 * This function deinitializes the PWM subsystem and releases all resources.
34 *
35 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
36 */
38
39/**
40 * @brief Start PWM output on pin
41 *
42 * @param logical_pin Logical pin number (0-255)
43 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
44 */
45meshx_err_t meshx_pwm_start(uint8_t logical_pin);
46
47/**
48 * @brief Stop PWM output on pin
49 *
50 * @param logical_pin Logical pin number (0-255)
51 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
52 */
53meshx_err_t meshx_pwm_stop(uint8_t logical_pin);
54
55/**
56 * @brief Set PWM duty cycle
57 *
58 * @param logical_pin Logical pin number (0-255)
59 * @param duty_cycle Duty cycle (0-100%)
60 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
61 */
62meshx_err_t meshx_pwm_set_duty_cycle(uint8_t logical_pin, uint8_t duty_cycle);
63
64/**
65 * @brief Get PWM duty cycle
66 *
67 * @param logical_pin Logical pin number (0-255)
68 * @param[out] duty_cycle Pointer to store duty cycle
69 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
70 */
71meshx_err_t meshx_pwm_get_duty_cycle(uint8_t logical_pin, uint8_t *duty_cycle);
72
73/**
74 * @brief Set PWM frequency
75 *
76 * @param logical_pin Logical pin number (0-255)
77 * @param frequency Frequency in Hz
78 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
79 */
80meshx_err_t meshx_pwm_set_frequency(uint8_t logical_pin, uint32_t frequency);
81
82/**
83 * @brief Get PWM frequency
84 *
85 * @param logical_pin Logical pin number (0-255)
86 * @param[out] frequency Pointer to store frequency
87 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
88 */
89meshx_err_t meshx_pwm_get_frequency(uint8_t logical_pin, uint32_t *frequency);
90
91/**
92 * @brief Set PWM resolution
93 *
94 * @param logical_pin Logical pin number (0-255)
95 * @param resolution Resolution in bits (typically 8-16)
96 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
97 */
98meshx_err_t meshx_pwm_set_resolution(uint8_t logical_pin, uint8_t resolution);
99
100/**
101 * @brief Get PWM resolution
102 *
103 * @param logical_pin Logical pin number (0-255)
104 * @param[out] resolution Pointer to store resolution
105 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
106 */
107meshx_err_t meshx_pwm_get_resolution(uint8_t logical_pin, uint8_t *resolution);
108
109#ifdef __cplusplus
110}
111#endif
112
113#endif /* __MESHX_PWM_H */
MeshX Error Codes.
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
meshx_err_t meshx_pwm_deinit(void)
Deinitialize PWM subsystem.
Definition meshx_pwm.c:119
meshx_err_t meshx_pwm_init(void)
Initialize PWM subsystem.
Definition meshx_pwm.c:69
meshx_err_t meshx_pwm_get_frequency(uint8_t logical_pin, uint32_t *frequency)
Get PWM frequency.
Definition meshx_pwm.c:562
meshx_err_t meshx_pwm_set_duty_cycle(uint8_t logical_pin, uint8_t duty_cycle)
Set PWM duty cycle.
Definition meshx_pwm.c:433
meshx_err_t meshx_pwm_stop(uint8_t logical_pin)
Stop PWM output on pin.
Definition meshx_pwm.c:373
meshx_err_t meshx_pwm_start(uint8_t logical_pin)
Start PWM output on pin.
Definition meshx_pwm.c:295
meshx_err_t meshx_pwm_set_resolution(uint8_t logical_pin, uint8_t resolution)
Set PWM resolution.
Definition meshx_pwm.c:597
meshx_err_t meshx_pwm_get_duty_cycle(uint8_t logical_pin, uint8_t *duty_cycle)
Get PWM duty cycle.
Definition meshx_pwm.c:480
meshx_err_t meshx_pwm_get_resolution(uint8_t logical_pin, uint8_t *resolution)
Get PWM resolution.
Definition meshx_pwm.c:634
meshx_err_t meshx_pwm_set_frequency(uint8_t logical_pin, uint32_t frequency)
Set PWM frequency.
Definition meshx_pwm.c:515