Add single channel mode feature.
The addition of a single-channel mode implied further modularisation of the component. This commit has broken the component down into the following modules to avoid a huge single source file and to make unit testing easier. The modules: - Separation of public and private code - *types and *defs - public relay_chn API - *adapter - *output - *run_info - *core - *ctl (control) - *tilt Closes #957.
This commit is contained in:
113
private_include/relay_chn_output.h
Normal file
113
private_include/relay_chn_output.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Kozmotronik Tech
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Abstraction layer for controlling relay channel outputs. This is the layer
|
||||
* that interacts with the GPIO pins to control the relay channels.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "relay_chn_priv_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize relay channel outputs.
|
||||
*
|
||||
* Maps relay channels to GPIO pins and prepares them for operation.
|
||||
*
|
||||
* @param[in] gpio_map Array of GPIO pin numbers for each relay channel.
|
||||
* @param[in] gpio_count Number of GPIO pins (relay channels).
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_output_init(const uint8_t* gpio_map, uint8_t gpio_count);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize relay channel outputs.
|
||||
*
|
||||
* Releases resources and resets GPIO pins used for relay channels.
|
||||
*/
|
||||
void relay_chn_output_deinit(void);
|
||||
|
||||
#if RELAY_CHN_COUNT > 1
|
||||
/**
|
||||
* @brief Get the relay channel output object for a specific channel.
|
||||
*
|
||||
* @param[in] chn_id Channel ID.
|
||||
*
|
||||
* @return Pointer to relay channel output object, or NULL if invalid.
|
||||
*/
|
||||
relay_chn_output_t *relay_chn_output_get(uint8_t chn_id);
|
||||
|
||||
/**
|
||||
* @brief Get all relay channel output objects.
|
||||
*
|
||||
* @return Pointer to array of relay channel output objects.
|
||||
*/
|
||||
relay_chn_output_t *relay_chn_output_get_all(void);
|
||||
#else
|
||||
/**
|
||||
* @brief Get the relay channel output object.
|
||||
*
|
||||
* @return Pointer to relay channel output object.
|
||||
*/
|
||||
relay_chn_output_t *relay_chn_output_get(void);
|
||||
#endif // RELAY_CHN_COUNT > 1
|
||||
|
||||
/**
|
||||
* @brief Stop the relay channel output.
|
||||
*
|
||||
* Sets the relay channel to the stop state.
|
||||
*
|
||||
* @param[in] output Pointer to relay channel output object.
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_output_stop(relay_chn_output_t *output);
|
||||
|
||||
/**
|
||||
* @brief Set relay channel output to forward direction.
|
||||
*
|
||||
* @param[in] output Pointer to relay channel output object.
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_output_forward(relay_chn_output_t *output);
|
||||
|
||||
/**
|
||||
* @brief Set relay channel output to reverse direction.
|
||||
*
|
||||
* @param[in] output Pointer to relay channel output object.
|
||||
*
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t relay_chn_output_reverse(relay_chn_output_t *output);
|
||||
|
||||
/**
|
||||
* @brief Flip the direction of the relay channel output.
|
||||
*
|
||||
* Changes the direction from forward to reverse or vice versa.
|
||||
*
|
||||
* @param[in] output Pointer to relay channel output object.
|
||||
*/
|
||||
void relay_chn_output_flip(relay_chn_output_t *output);
|
||||
|
||||
/**
|
||||
* @brief Get the current direction of the relay channel output.
|
||||
*
|
||||
* @param[in] output Pointer to relay channel output object.
|
||||
*
|
||||
* @return Current direction of the relay channel.
|
||||
*/
|
||||
relay_chn_direction_t relay_chn_output_get_direction(relay_chn_output_t *output);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user