The config parameter names defined in the relay_chn_defs.h file have been changed back to their original names (with the CONFIG_ prefix), so that they are not confused with application-level defines. Refs #1085
113 lines
2.8 KiB
C
113 lines
2.8 KiB
C
/*
|
|
* 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 CONFIG_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 // CONFIG_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 |