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:
2025-08-13 17:53:27 +03:00
parent 22668b6759
commit 61f8ed440e
17 changed files with 2453 additions and 1472 deletions

View File

@@ -0,0 +1,56 @@
/*
* SPDX-FileCopyrightText: 2025 Kozmotronik Tech developer@kozmotronik.com.tr
*
* SPDX-License-Identifier: MIT
*
* Expose the *_ctl functions required by *_core.c file.
*/
#pragma once
#include "relay_chn_priv_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize the relay channel control.
*
* @param output Pointer to the output object(s).
* @param run_info Pointer to the runtime information object(s).
*
* @return esp_err_t Returns ESP_OK on success, or an error code on failure.
*/
esp_err_t relay_chn_ctl_init(relay_chn_output_t *output, relay_chn_run_info_t *run_info);
/**
* @brief Deinitialize the relay channel control.
*
* This function cleans up resources used by the relay channel control.
*/
void relay_chn_ctl_deinit(void);
#if RELAY_CHN_COUNT > 1
/**
* @brief Get the control structure for a specific relay channel.
*
* @param chn_id The ID of the relay channel to retrieve.
*
* @return relay_chn_ctl_t* Pointer to the control structure for the specified channel, or NULL if not found.
*/
relay_chn_ctl_t *relay_chn_ctl_get(uint8_t chn_id);
/**
* @brief Get the control structures for all relay channels.
*
* @return relay_chn_ctl_t* Pointer to the array of control structures for all channels.
*/
relay_chn_ctl_t *relay_chn_ctl_get_all(void);
#else
relay_chn_ctl_t *relay_chn_ctl_get(void);
#endif // RELAY_CHN_COUNT > 1
#ifdef __cplusplus
}
#endif