Use original names for config parameters
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
This commit is contained in:
@@ -10,15 +10,15 @@
|
||||
#include "relay_chn_output.h"
|
||||
#include "relay_chn_core.h"
|
||||
|
||||
#if RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
#include "relay_chn_nvs.h"
|
||||
#endif
|
||||
|
||||
|
||||
static const char *TAG = "RELAY_CHN_OUTPUT";
|
||||
|
||||
#if RELAY_CHN_COUNT > 1
|
||||
static relay_chn_output_t outputs[RELAY_CHN_COUNT];
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
static relay_chn_output_t outputs[CONFIG_RELAY_CHN_COUNT];
|
||||
#else
|
||||
static relay_chn_output_t output;
|
||||
#endif
|
||||
@@ -27,16 +27,16 @@ static relay_chn_output_t output;
|
||||
static esp_err_t relay_chn_output_check_gpio_capabilities(uint8_t gpio_count)
|
||||
{
|
||||
// Check if the device's GPIOs are enough for the number of channels
|
||||
if (RELAY_CHN_COUNT > (GPIO_PIN_COUNT / 2)) {
|
||||
if (CONFIG_RELAY_CHN_COUNT > (GPIO_PIN_COUNT / 2)) {
|
||||
ESP_LOGE(TAG, "Not enough GPIOs for the number of channels!");
|
||||
ESP_LOGE(TAG, "Max available num of channels: %d, requested channels: %d", GPIO_PIN_COUNT / 2, RELAY_CHN_COUNT);
|
||||
ESP_LOGE(TAG, "Max available num of channels: %d, requested channels: %d", GPIO_PIN_COUNT / 2, CONFIG_RELAY_CHN_COUNT);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Check if the provided GPIOs correspond to the number of channels
|
||||
if (gpio_count != RELAY_CHN_COUNT * 2) {
|
||||
if (gpio_count != CONFIG_RELAY_CHN_COUNT * 2) {
|
||||
ESP_LOGE(TAG, "Invalid number of GPIOs provided: %d", gpio_count);
|
||||
ESP_LOGE(TAG, "Expected number of GPIOs: %d", RELAY_CHN_COUNT * 2);
|
||||
ESP_LOGE(TAG, "Expected number of GPIOs: %d", CONFIG_RELAY_CHN_COUNT * 2);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return ESP_OK;
|
||||
@@ -73,7 +73,7 @@ static esp_err_t relay_chn_output_ctl_init(relay_chn_output_t *output,
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
static esp_err_t relay_chn_output_load_direction(uint8_t ch, relay_chn_direction_t *direction)
|
||||
{
|
||||
esp_err_t ret = relay_chn_nvs_get_direction(ch, direction);
|
||||
@@ -93,15 +93,15 @@ esp_err_t relay_chn_output_init(const uint8_t* gpio_map, uint8_t gpio_count)
|
||||
ret = relay_chn_output_check_gpio_capabilities(gpio_count);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Device does not support the provided GPIOs");
|
||||
|
||||
#if RELAY_CHN_COUNT > 1
|
||||
for (int i = 0; i < RELAY_CHN_COUNT; i++) {
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
relay_chn_output_t* output = &outputs[i];
|
||||
int gpio_index = i << 1; // gpio_index = i * 2
|
||||
gpio_num_t forward_pin = (gpio_num_t) gpio_map[gpio_index];
|
||||
gpio_num_t reverse_pin = (gpio_num_t) gpio_map[gpio_index + 1];
|
||||
|
||||
relay_chn_direction_t direction = RELAY_CHN_DIRECTION_DEFAULT;
|
||||
#if RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
// If NVS storage is enabled, retrieve the direction from storage
|
||||
ret = relay_chn_output_load_direction(i, &direction);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load direction from storage for channel %d", i);
|
||||
@@ -111,7 +111,7 @@ esp_err_t relay_chn_output_init(const uint8_t* gpio_map, uint8_t gpio_count)
|
||||
}
|
||||
#else
|
||||
relay_chn_direction_t direction = RELAY_CHN_DIRECTION_DEFAULT;
|
||||
#if RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
// If NVS storage is enabled, retrieve the direction from storage
|
||||
ret = relay_chn_output_load_direction(0, &direction);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load direction from storage for channel %d", 0);
|
||||
@@ -130,16 +130,16 @@ static void relay_chn_output_ctl_deinit(relay_chn_output_t *output)
|
||||
|
||||
void relay_chn_output_deinit()
|
||||
{
|
||||
#if RELAY_CHN_COUNT > 1
|
||||
for (int i = 0; i < RELAY_CHN_COUNT; i++) {
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
relay_chn_output_ctl_deinit(&outputs[i]);
|
||||
}
|
||||
#else
|
||||
relay_chn_output_ctl_deinit(&output);
|
||||
#endif // RELAY_CHN_COUNT > 1
|
||||
#endif // CONFIG_RELAY_CHN_COUNT > 1
|
||||
}
|
||||
|
||||
#if RELAY_CHN_COUNT > 1
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
relay_chn_output_t *relay_chn_output_get(uint8_t chn_id)
|
||||
{
|
||||
if (!relay_chn_is_channel_id_valid(chn_id)) {
|
||||
@@ -157,7 +157,7 @@ relay_chn_output_t *relay_chn_output_get(void)
|
||||
{
|
||||
return &output;
|
||||
}
|
||||
#endif // RELAY_CHN_COUNT > 1
|
||||
#endif // CONFIG_RELAY_CHN_COUNT > 1
|
||||
|
||||
esp_err_t relay_chn_output_stop(relay_chn_output_t *output)
|
||||
{
|
||||
@@ -194,10 +194,10 @@ void relay_chn_output_flip(relay_chn_output_t *output)
|
||||
? RELAY_CHN_DIRECTION_FLIPPED
|
||||
: RELAY_CHN_DIRECTION_DEFAULT;
|
||||
|
||||
#if RELAY_CHN_ENABLE_NVS == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
|
||||
uint8_t ch = 0;
|
||||
#if RELAY_CHN_COUNT > 1
|
||||
for (uint8_t i = 0; i < RELAY_CHN_COUNT; i++) {
|
||||
#if CONFIG_RELAY_CHN_COUNT > 1
|
||||
for (uint8_t i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
|
||||
if (output == &outputs[i]) {
|
||||
ch = i;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user