#ifndef APP_CONFIG_H
#define APP_CONFIG_H

#include "app_types.h"

/*
 * Markdown note:
 * - APP_ROLE_DEFAULT chooses firmware behavior at reset.
 * - Role can be changed at runtime by App_SetRole().
 * - Replace pin/channel values after CubeMX pinout is fixed.
 */

#define APP_ROLE_DEFAULT             APP_ROLE_MASTER // APP_ROLE_MASTER //APP_ROLE_SLAVE

#define APP_ZIGBEE_ENDPOINT           10U
#define APP_ZIGBEE_CLUSTER_INPUTS     0xFC10U
#define APP_ZIGBEE_REPORT_PERIOD_MS   100U
#define APP_ZIGBEE_CHANNEL            20U
#define APP_ZIGBEE_PAN_ID             0x1234U
#define APP_ZIGBEE_EXTENDED_PAN_ID    0x1122334455667788ULL
#define APP_ZIGBEE_PERMIT_JOIN_SEC    0xFFU
#define APP_ZIGBEE_PERMIT_REFRESH_MS  5000U
#define APP_ZIGBEE_REJOIN_FAIL_COUNT  3U
#define APP_ZIGBEE_REJOIN_RETRY_MS    15000U
#define APP_ZIGBEE_JOIN_WATCHDOG_MS   20000U

#define APP_BUTTON_COUNT              3U
#define APP_ADC_CHANNEL_COUNT         1U

#define APP_BUTTON_ACTIVE_LEVEL       0U
#define APP_BUTTON_DEBOUNCE_MS        20U
#define APP_BUTTON_GPIO_PORT          GPIOB
#define APP_BUTTON1_GPIO_PIN          GPIO_PIN_0
#define APP_BUTTON2_GPIO_PIN          GPIO_PIN_1
#define APP_BUTTON3_GPIO_PIN          GPIO_PIN_2

#define APP_ROLE_DETECT_ENABLED       0U
#define APP_ROLE_DETECT_GPIO_PORT     GPIOA
#define APP_ROLE_DETECT_GPIO_PIN      GPIO_PIN_9
#define APP_ROLE_DETECT_PULL          GPIO_PULLDOWN
#define APP_ROLE_DETECT_MASTER_LEVEL  GPIO_PIN_RESET

#define APP_ROLE_LED_GPIO_PORT        GPIOE
#define APP_ROLE_LED_GPIO_PIN         GPIO_PIN_4
#define APP_ROLE_LED_ACTIVE_LEVEL     GPIO_PIN_SET

#define APP_ANALOG_MIN_RAW            0U
#define APP_ANALOG_MAX_RAW            4095U

#endif
