#pragma once // #include "FreeRTOS.h" // #include "semphr.h" #include "avr_err.h" #include "stdbool.h" #include "avr/interrupt.h" #include "avr/pgmspace.h" #define ZH_AVR_AC_DIMMER_INIT_CONFIG_DEFAULT() \ { \ .task_priority = configMAX_PRIORITIES, \ .stack_size = 124, \ .queue_size = 1, \ .a_gpio_number = 0, \ .b_gpio_number = 0, \ .pullup = false, \ .encoder_min_value = -100, \ .encoder_max_value = 100, \ .encoder_step = 1, \ .encoder_number = 0} #ifdef __cplusplus extern "C" { #endif typedef struct // Structure for initial initialization of AC dimmer. { uint8_t task_priority; // Task priority for the PCF8574 expander isr processing. @note It is not recommended to set a value less than configMAX_PRIORITIES. uint8_t stack_size; // Stack size for task for the PCF8574 expander isr processing processing. @note The minimum size is 124 byte. uint8_t i2c_address; // Expander I2C address. bool p0_gpio_work_mode; // Expander GPIO PO work mode. True for input, false for output. bool p1_gpio_work_mode; // Expander GPIO P1 work mode. True for input, false for output. bool p2_gpio_work_mode; // Expander GPIO P2 work mode. True for input, false for output. bool p3_gpio_work_mode; // Expander GPIO P3 work mode. True for input, false for output. bool p4_gpio_work_mode; // Expander GPIO P4 work mode. True for input, false for output. bool p5_gpio_work_mode; // Expander GPIO P5 work mode. True for input, false for output. bool p6_gpio_work_mode; // Expander GPIO P6 work mode. True for input, false for output. bool p7_gpio_work_mode; // Expander GPIO P7 work mode. True for input, false for output. uint8_t interrupt_gpio; // Interrupt GPIO. @attention Must be same for all PCF8574 expanders. uint8_t interrupt_port; // Interrupt port. } zh_avr_pcf8574_init_config_t; /** * @brief Initialize PCF8574 expander. * * @param[in] config Pointer to PCF8574 initialized configuration structure. Can point to a temporary variable. * @param[out] handle Pointer to unique PCF8574 handle. * * @attention I2C driver must be initialized first. * * @note Before initialize the expander recommend initialize zh_avr_pcf8574_init_config_t structure with default values. * * @code zh_avr_pcf8574_init_config_t config = ZH_AVR_PCF8574_INIT_CONFIG_DEFAULT() @endcode * * @return AVR_OK if success or an error code otherwise. */ avr_err_t zh_avr_pcf8574_init(const zh_avr_pcf8574_init_config_t *config, zh_avr_pcf8574_handle_t *handle); #ifdef __cplusplus } #endif