/* * heater3.h * * Created: 25.06.2019 12:29:07 * Author: naa */ #ifndef HEATER3_H_ #define HEATER3_H_ #include #include #include #include #include #include #define TX_LENGTH 16 #define TWI_FREQ 500000 #define BAUD_RATE 38400 #define U2X0_SET 1 #define ADC_MEAS1 0 #define ADC_MEAS2 1 #define ADC_CUR1 2 #define ADC_CUR2 3 #define LEDPORT PORTC #define LED1 PORTC2 #define LED2 PORTC3 #define GATEPORT PORTC #define GATE1 PORTC6 #define GATE2 PORTC7 #define V12POWER PORTC4 #define OCP1 PORTD2 #define OCP2 PORTD3 #define BTNPIN PIND #define BTN1 PORTD4 #define BTN2 PORTD5 #define BTN3 PORTD6 #define BTN4 PORTD7 #define CH0 0 #define CH1 1 #define MAXADDR 0x06 #define START_BYTE 0x55 #define CURR_MAX 2500 #define DISP_OFF 0 #define DISP_MAIN 1 #define DISP_DBG 2 #define DISP_VER 3 typedef union { uint8_t byte[4]; uint16_t word[2]; uint32_t dword; } btw32_t; typedef union { uint8_t byte[2]; uint16_t word; } btw16_t; typedef enum { CIRC_OPEN, CIRC_SHORT, CIRC_MOSFET, CIRC_RES_DIODE, CIRC_RES, CIRC_DIODE } circ_t; typedef struct { uint8_t channel : 1; uint8_t onoff : 1; uint8_t heating : 1; uint8_t ocp : 1; uint8_t calib : 2; circ_t circuit : 3; uint8_t couple : 3; } status_str; typedef struct { volatile status_str status; uint8_t preset; int8_t tintr; int16_t tcouple; int16_t tmeas; uint16_t tmeas_raw; uint16_t tset; uint16_t tset_raw; uint16_t current; uint8_t gain; uint8_t shift; uint8_t drive; } heater_str; typedef enum { CMD_RESET, CMD_REQ, CMD_CHONOFF, CMD_SETTEMP, CMD_SETRANGE, CMD_SETVDRIVE, CMD_SWPRESET, CMD_LOADDATA, CMD_HEATING, CMD_CALIBRATION } cmd_t; typedef enum { REQ_RST, REQ_ACK, REQ_NACK, REQ_MAINDATA, REQ_DEBUGDATA, REQ_PRESETTABLE, REQ_PRESETDATA } txreq_t; typedef enum { CAL_OFF, CAL_AUTO, CAL_MANUAL } cal_t; typedef struct { char start; uint8_t len; cmd_t command; uint8_t data[160]; uint8_t checksum; } comdata_str; typedef struct { uint8_t set; uint8_t blink_cnt; uint8_t pressed; } menu_str; typedef struct { uint16_t temp; uint16_t adcdata; } record_str; typedef struct { uint8_t number; char header[12]; uint8_t gain; uint8_t shift; uint8_t drive; record_str curve[16]; } preset_str; typedef struct { uint16_t oc : 1; uint16_t scg : 1; uint16_t scv : 1; uint16_t : 1; uint16_t intt_frac : 4; uint16_t intt_int : 8; uint16_t fault : 1; uint16_t : 1; uint16_t tct_frac : 2; uint16_t tct_int : 12; } max31855_t; typedef struct { uint8_t pressed : 1; uint8_t released : 1; uint8_t holded : 1; uint8_t holdcnt : 5; uint8_t code : 4; uint8_t prev_code : 4; } btn_t; int lcd_putchar(char c, FILE *stream); int uart_putchar(char c, FILE *stream); void ProcessCommand(); #endif /* HEATER3_H_ */