#ifndef _PRINTER_H
#define _PRINTER_H

#include "include.h"

/***走纸步进电机****/
#define MOTOR_SLEEP_GPIO  GPIOF_REG
#define MOTOR_SLEEP_PIN   GPIO_PIN_2

#define MOTOR_AIN1_GPIO   GPIOF_REG
#define MOTOR_AIN1_PIN    GPIO_PIN_1
#define MOTOR_AIN2_GPIO   GPIOF_REG
#define MOTOR_AIN2_PIN    GPIO_PIN_0
#define MOTOR_BIN1_GPIO   GPIOE_REG
#define MOTOR_BIN1_PIN    GPIO_PIN_7
#define MOTOR_BIN2_GPIO   GPIOE_REG
#define MOTOR_BIN2_PIN    GPIO_PIN_6
/*********************/

/*******SPI******/
#define TPH_SPI_GPIO    GPIOA_REG
#define TPH_SPI_CLK     GPIO_PIN_3
#define TPH_SPI_DAT     GPIO_PIN_4
#define TPH_SPI_MHZ     6
/*********************/

/******打印头******/
#define TPH_LAT_GPIO   GPIOF_REG
#define TPH_LAT_PIN    GPIO_PIN_4

#define TPH_STB_GPIO   GPIOF_REG
#define TPH_STB_PIN    GPIO_PIN_5

#define TPH_VH_GPIO    GPIOF_REG
#define TPH_VH_PIN     GPIO_PIN_3
/******************/

//打印逻辑控制变量
typedef struct
{
    unsigned int motor_step;       //电机步数
    unsigned char tph_sequence;      //热敏片时序计数
    unsigned int picpt_offset;      //每行数据长度计数
}volatile PRINTER_COUNT;                     //打印初始化计数结构体
extern  volatile PRINTER_COUNT printer_count;

void printer_example(void);
void printer_init(void);

void tph_spi_send(unsigned char buf[],unsigned short len);
void motor_step_micro(unsigned char dir);
void tph_vh_enable(unsigned char enable);
void motor_driver_enable(unsigned char en);
void tph_latch_stop(void);
void tph_latch_star(void);
void tph_heat_star(void);
void tph_heat_stop(void);
void Timer_Printe_start(u32 us);   //行定时器启动us
void Timer_Motor_start(u32 us);   //电机定时器
void Timer_TPH_start(u32 us);   //热敏片定时器

#endif
