Skip to content

File syn_gpio.c

File List > drivers > syn_gpio.c

Go to the documentation of this file

#if __has_include("syn_config.h")
#include "syn_config.h"
#endif

#if !defined(SYN_USE_GPIO) || SYN_USE_GPIO

#include "../util/syn_assert.h"
#include "syn_gpio.h"

SYN_Status syn_gpio_init_multiple(const SYN_GPIO_Pin *pins, size_t count, SYN_GPIO_Mode mode)
{
    if (pins == NULL && count > 0) {
        return SYN_INVALID_PARAM;
    }
    SYN_ASSERT(pins != NULL || count == 0);

    for (size_t i = 0; i < count; i++) {
        SYN_Status status = syn_port_gpio_init(pins[i], mode);
        if (status != SYN_OK) {
            return status;
        }
    }
    return SYN_OK;
}

SYN_Status syn_gpio_write_multiple(const SYN_GPIO_Pin *pins, size_t count, SYN_GPIO_State state)
{
    if (pins == NULL && count > 0) {
        return SYN_INVALID_PARAM;
    }
    SYN_ASSERT(pins != NULL || count == 0);

    for (size_t i = 0; i < count; i++) {
        SYN_Status status = syn_port_gpio_write(pins[i], state);
        if (status != SYN_OK) {
            return status;
        }
    }
    return SYN_OK;
}

#endif /* SYN_USE_GPIO */