#ifndef  __DEFINE_H__
#define  __DEFINE_H__
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "CONFIG.h"
#include "HAL.h"

#define LOG_OUTPUT_TIME						                    3000

#define Timecount                                               256

#define REBYTE_LEN                                              512
#define SEND_LEN                                                128

#define HIGH							                        1
#define LOW							                            0

#define SOFTWARE_VERSION					                    0x10
#define HARDWARE_VERSION					                    0x14

#define AES_ENABLE						                        0

/* OTA upgrade logo */
#define IMAGE_OTA_FLAG       			                        0x03

/* Store on the DataFlash address, the position of Bluetooth cannot be occupied */
#define OTA_DATAFLASH_ADDR                                      0x08077000

#define IMAGE_FLAG_1                                            0x1A
#define IMAGE_FLAG_2                                            0x2A
#define IMAGE_FLAG_3                                            0x3A

#define USER_WS2812B_COUNT_DEFAULT                              6

#define KEY_GPIO_RCC_ENABLE					                    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE)
#define ELECT_01_OPEN_GPIO                                    	GPIOB
#define ELECT_01_OPEN_PIN                                     	GPIO_Pin_5
#define ELECT_01_OPEN_ON						                GPIO_WriteBit(ELECT_01_OPEN_GPIO, ELECT_01_OPEN_PIN, Bit_SET)
#define ELECT_01_OPEN_OFF						                GPIO_WriteBit(ELECT_01_OPEN_GPIO, ELECT_01_OPEN_PIN, Bit_RESET)

#define ELECT_01_CLOSE_GPIO                                   	GPIOB
#define ELECT_01_CLOSE_PIN                                    	GPIO_Pin_4
#define ELECT_01_CLOSE_ON						                GPIO_WriteBit(ELECT_01_CLOSE_GPIO, ELECT_01_CLOSE_PIN, Bit_SET)
#define ELECT_01_CLOSE_OFF						            	GPIO_WriteBit(ELECT_01_CLOSE_GPIO, ELECT_01_CLOSE_PIN, Bit_RESET)

#define ELECT_02_OPEN_GPIO                                    	GPIOB
#define ELECT_02_OPEN_PIN                                     	GPIO_Pin_3
#define ELECT_02_OPEN_ON						                GPIO_WriteBit(ELECT_02_OPEN_GPIO, ELECT_02_OPEN_PIN, Bit_SET)
#define ELECT_02_OPEN_OFF						                GPIO_WriteBit(ELECT_02_OPEN_GPIO, ELECT_02_OPEN_PIN, Bit_RESET)

#define ELECT_02_CLOSE_GPIO                                   	GPIOD
#define ELECT_02_CLOSE_PIN                                    	GPIO_Pin_2
#define ELECT_02_CLOSE_ON						                GPIO_WriteBit(ELECT_02_CLOSE_GPIO, ELECT_02_CLOSE_PIN, Bit_SET)
#define ELECT_02_CLOSE_OFF						            	GPIO_WriteBit(ELECT_02_CLOSE_GPIO, ELECT_02_CLOSE_PIN, Bit_RESET)

#define ELECT_03_OPEN_GPIO                                    	GPIOC
#define ELECT_03_OPEN_PIN                                     	GPIO_Pin_12
#define ELECT_03_OPEN_ON						                GPIO_WriteBit(ELECT_03_OPEN_GPIO, ELECT_03_OPEN_PIN, Bit_SET)
#define ELECT_03_OPEN_OFF						                GPIO_WriteBit(ELECT_03_OPEN_GPIO, ELECT_03_OPEN_PIN, Bit_RESET)

#define ELECT_03_CLOSE_GPIO                                   	GPIOC
#define ELECT_03_CLOSE_PIN                                    	GPIO_Pin_11
#define ELECT_03_CLOSE_ON						                GPIO_WriteBit(ELECT_03_CLOSE_GPIO, ELECT_03_CLOSE_PIN, Bit_SET)
#define ELECT_03_CLOSE_OFF						            	GPIO_WriteBit(ELECT_03_CLOSE_GPIO, ELECT_03_CLOSE_PIN, Bit_RESET)

#define ELECT_04_OPEN_GPIO                                    	GPIOA
#define ELECT_04_OPEN_PIN                                     	GPIO_Pin_15
#define ELECT_04_OPEN_ON						                GPIO_WriteBit(ELECT_04_OPEN_GPIO, ELECT_04_OPEN_PIN, Bit_SET)
#define ELECT_04_OPEN_OFF						                GPIO_WriteBit(ELECT_04_OPEN_GPIO, ELECT_04_OPEN_PIN, Bit_RESET)

#define ELECT_04_CLOSE_GPIO                                   	GPIOC
#define ELECT_04_CLOSE_PIN                                    	GPIO_Pin_10
#define ELECT_04_CLOSE_ON						                GPIO_WriteBit(ELECT_04_CLOSE_GPIO, ELECT_04_CLOSE_PIN, Bit_SET)
#define ELECT_04_CLOSE_OFF						            	GPIO_WriteBit(ELECT_04_CLOSE_GPIO, ELECT_04_CLOSE_PIN, Bit_RESET)

#define ELECT_05_OPEN_GPIO                                    	GPIOD
#define ELECT_05_OPEN_PIN                                     	GPIO_Pin_5
#define ELECT_05_OPEN_ON						                GPIO_WriteBit(ELECT_05_OPEN_GPIO, ELECT_05_OPEN_PIN, Bit_SET)
#define ELECT_05_OPEN_OFF						                GPIO_WriteBit(ELECT_05_OPEN_GPIO, ELECT_05_OPEN_PIN, Bit_RESET)

#define ELECT_05_CLOSE_GPIO                                   	GPIOD
#define ELECT_05_CLOSE_PIN                                    	GPIO_Pin_6
#define ELECT_05_CLOSE_ON						                GPIO_WriteBit(ELECT_05_CLOSE_GPIO, ELECT_05_CLOSE_PIN, Bit_SET)
#define ELECT_05_CLOSE_OFF						            	GPIO_WriteBit(ELECT_05_CLOSE_GPIO, ELECT_05_CLOSE_PIN, Bit_RESET)


#endif /* USER_DEFINE_H_ */
