#include "TYW_stdint.h"

/*SGM4591Q片选*/
typedef enum
{
  SGM4591Q_Chip1_1 = 0,
  SGM4591Q_Chip1_2,
  SGM4591Q_Chip1_3,
  SGM4591Q_Chip1_4,
  SGM4591Q_Chip2_1,
  SGM4591Q_Chip2_2,
  SGM4591Q_Chip2_3,
  SGM4591Q_Chip2_4,
  SGM4591Q_Chip3_1,
  SGM4591Q_Chip3_2,
  SGM4591Q_Chip3_3,
  SGM4591Q_Chip3_4,
  SGM4591Q_Chip4_1,
  SGM4591Q_Chip4_2,
  SGM4591Q_Chip4_3,
  SGM4591Q_Chip4_4,
} SGM4591Q_Chip;

/*SGM4591Q段选*/
typedef enum
{
  SGM4591Q_Segment0 = 0,
  SGM4591Q_Segment1,
} SGM4591Q_Segment;

typedef struct
{
    uint8_t PIN_0 : 1;
    uint8_t PIN_1 : 1;
    uint8_t PIN_2 : 1;
    uint8_t PIN_3 : 1;
    uint8_t PIN_4 : 1;
    uint8_t PIN_5 : 1;
    uint8_t PIN_6 : 1;
    uint8_t PIN_7 : 1;
} SGM4591Q_Bit_st;

typedef union
{
    uint8_t UINT8;
    SGM4591Q_Bit_st BIT;
} SGM4591Q_Pin_en;

/*PIN端口控制命令*/
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip1_1_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip1_1_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip1_2_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip1_2_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip1_3_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip1_3_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip1_4_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip1_4_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip2_1_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip2_1_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip2_2_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip2_2_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip2_3_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip2_3_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip2_4_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip2_4_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip3_1_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip3_1_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip3_2_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip3_2_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip3_3_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip3_3_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip3_4_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip3_4_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_1_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_1_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_2_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_2_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_3_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_3_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_4_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_4_Segment1;

extern uint16_t ADC_4;
void SGM4591Q_Init(void);
void SGM4591Q_Global_Control(uint8_t Chip, uint8_t Segment);
void SGM4591Q_Control(void);
