历史上的今天
今天是:2024年10月14日(星期一)
2019年10月14日 | lpc1114热敏打印机源程序
2019-10-14 来源:eefocus
主程序预览:
//本文件主要定义可程序的入口函数main, main函数里主要对系统、参数、硬件接口进新初始化,之后等待读取串口数据
#include #include #include #include "LPC11xx.h" /* LPC11xx definitions */ #include "uart.h" #include "timer32.h" #include"aw_print.h" #include"aw_init_printHead.h" #include "aw_config.h" #include "aw_font.h" #include"aw_key_led.h" #include "user.h" #include"aw_char_app.h" #include"aw_graph_app.h" #include"aw_barcode_app.h" #include "aw_command.h" #include "pmu.h" //初始化系统中的部分全局变量 void init_Global_Variables(void) { current_char_index=0; DealBuffer_counter=0; memset((low_power_t *)&low_power_Paramter,0,sizeof(low_power_t)); memset((printer_work_Parameter_t *)&printer_work_Parameter,0,sizeof(printer_work_Parameter_t)); printer_work_Parameter.printer_work_model=PRINTER_IDLE; feed_dot_step=0; paper_out_flag=0; head_up_flag=0; clear_buffer(); memset((Key_IRQ_Parameter *)key_IRQ_Parameter,0,KEY_NUM*sizeof(Key_IRQ_Parameter)); } int main(void) { #if UART_DEBUG char buffer[1024]; uint32_t counter,timer; SystemInit(); Init_Sys_Parameter(); init_Global_Varibles(); UARTInit(sys_Parameter.uart_para.baudrate); #ifdef PROJECT_DEBUG printf("nr-- Printer_Project V1.0 --nr"); printf("nr-- Serial Communication test --nr"); #endif counter=0; timer=0; memset(buffer,0,1024); while(1) { if(UartBuffer_read()==1) { timer=0;memcpy(buffer+counter,&DealBuffer,DealBuffer_counter); counter+=DealBuffer_counter; } else { if(timer<10) { timer++; } else if(timer==10) { if(counter!=0) { #ifdef PROJECT_DEBUG printf("%s",buffer); #endif counter=0; memset(buffer,0,1024); timer=11; } } } #elif SPIFLASH_DEBUG uint32_t BaseAdd; uint32_t Address; uint8_t MSB=0xce,LSB=0xa1; uint8_t dot[118]; SystemInit(); spi_flash_init();; while(1) { BaseAdd=BASEADD_GB2312_11X12; if(MSB>=0xA1&&MSB<=0Xa9&&LSB>=0xA1) { Address=((MSB-0xA1)*94+(LSB-0xA1))*24+BaseAdd; } else if(MSB>=0xB0&&MSB<=0xF7&&LSB>=0xA1) { Address=((MSB-0xA1)*94+(LSB-0xA1)+846)*24+BaseAdd; } read_spi_flash(Address,&dot[0],118); /*取点阵*/ LSB++; } #elif PRINTER_HEAD_DEBUG int i,keyval,keyval_bak; uint32_t j; SystemInit(); Init_Sys_Parameter(); init_Global_Variables(); init_Printer_port(); init_key(); /*4、按键初始化*/ while(1) { } #elif TIMER_TEST uint16_t time; uint8_t i; SystemInit(); Init_Sys_Parameter(); init_Global_Variables(); UARTInit(115200); common_timer(1,1000); while(1); #else uint32_t timer=0; /*用于记录连续读不到串口数据的次数*/ uint16_t get_dot_count; uint16_t effective_dot,num; /*可以用于打印的点的个数*/ SystemInit(); Init_Sys_Parameter(); Init_project_Parameter(); init_Global_Variables(); UARTInit(sys_Parameter.uart_para.baudrate); /*1、数据终端通讯串口初始化*/ init_Printer_port(); /*2、热敏打印头接口初始化 */ spi_flash_init(); /*3、字库芯片通讯初始化 */ init_key(); /*4、按键led 初始化*/ init_led(); common_timer(1,COMMON_TIME); /*启动公共定时器*/ for(timer=0;timer<0xf000;timer++) //延时,保证先前的初始化起作用 { ; } init_cutter_position(); /*让切纸刀回到 限位开关的位置 */ motor_driver_step40(); /*让电机先反正转40 步*/ Hardware_flow_control(UART_FREE); /*初始化结束,允许串口接收数据*/ timer=0; while(1) { current_char_index=0; if(UartBuffer_read()==1) /*读取串口数据*/ { timer=0; /*串口有数据时,将此计数器复位*/ while(current_char_index switch(project_Parameter.print_type) /*处理串口读出的数据*/ { case DATA_TYPE_CHAR_COMMAND: /*字符或、命令*/ if(determine_data_command((uint8_t *)(DealBuffer+current_char_index))==0) { if(Save_char()==0) { continue; } if(printer_work_Parameter.printer_work_model==PRINTER_IDLE) /*空闲*/ { if(calculate_get_char_num(&num,&get_dot_count)==1) /*有一行数据需要打印*/ { start_print(PRINT_CHAR); } } } else /*命令处理*/ { command_deal((uint8_t *)DealBuffer); } break; #ifdef VERTICAL_GRAPH case DATA_TYPE_VERTICAL_GRAPH: /*垂直取模图形*/ if(save_graph()==DATA_ENOUGH) /*数据取完,恢复默认数据类型*/ { project_Parameter.print_type=DATA_TYPE_CHAR_COMMAND; } break; #endif case DATA_TYPE_HORIZONTAL_GRAPH: /*水平取模图形*/ if(save_graph()==DATA_ENOUGH) /*数据取完*/ { graph_data.data_finish=1; project_Parameter.print_type=DATA_TYPE_CHAR_COMMAND; } /*空闲时,并且有一行以上的数据需要打印*/ if((printer_work_Parameter.printer_work_model==PRINTER_IDLE)&&(graph_data.buffer_counter/graph_data.horizontal_mode.horizontal_byteCount>0)) { start_print(PRINT_HORIZONTAL_GRAPH); } else if((printer_work_Parameter.printer_pause==1)&&(printer_work_Parameter.printer_work_model==PRINT_HORIZONTAL_GRAPH)) { /*从暂停状态恢复打印*/ /* 数据接收结束*/ if((graph_data.data_finish==1)||((graph_data.buffer_counter-graph_data.printed_byteCount)/graph_data.horizontal_mode.horizontal_byteCount>0)) { /*还有至少一整行数据*/ Resume_Print_from_pause(printer_work_Parameter.printer_work_model); } } else if((graph_data.data_finish==1)&&(printer_work_Parameter.printer_work_model!=PRINT_HORIZONTAL_GRAPH)) { /*图片数据接收完,并且打印机还在做别的工作, 取消本次图片打印*/ memset((graph_data_t *)&graph_data,0,sizeof(graph_data_t)); } break; //case DATA_TYPE_BARCODE: /*条形码图形*/ // num=save_barcode((uint8_t *)(DealBuffer+current_char_index)); //if(num==DATA_ENOUGH) //{ // save_barcode_parity_bit(); /*数据取完开始打印*/ // while(printer_work_Parameter.printer_work_model!=PRINTER_IDLE) // { // ;
史海拾趣
|
看到网上很多网友对TI 6000系列DSP优化工作感到苦恼,在此我总结下我的优化经验,希望对大家有帮助。 一、首先考虑从系统结构上优化,比如尽量减少待处理数据的无谓搬移,考虑你DSP片内存储量和每次处理数据量对系统结构优化,这部分的优化应该最 ...… 查看全部问答> |
|
【ATMEL技术问题】关于KEIL下AT91R40008启动代码问题 用KEIL 软件建立一个工程,自动生成一个启动代码STartup.S ; 但是问题来了,这个代码有点不知所云,编译出错哦啊,请大侠指点!下面是代码 /*****************************************************************************/;/* STARTUP.S: Start ...… 查看全部问答> |
|
菜鸟提问:SHBrowseForForlder()不能用,怎么代替 我是个初学者,我这个平台不能使用SHBrowseForForlder()这个方法,想找另外一个方法来代替SHBrowseForFolder,达到相同的效果, 或者可以不用打开浏览文件夹着个对话框,直接可以保存文件到指定目录也可以。劳驾各位帮忙啊… 查看全部问答> |
|
关于BT与WIFI共存时的设计,小弟有些问题,实在是不太明白,请教各位高手。 1. 我在网上看到有人说如果蓝牙和WIFI的物理隔离达到30dB以上,则两者之间的相互影响可以基本忽略。请问如果才能做到物理隔离达到30dB以上呢?是否天线距离远一些就可以 ...… 查看全部问答> |
|
小弟刚刚做了一块基于pc104总线的DA板卡,但是现在要与基于pc104总线的3350主板进行交互,主要是对pc104总线的数据进行读取,需要制作驱动,小弟第一次开发,有那位大侠能够给一个例子或其他的资料,多谢… 查看全部问答> |
|
有一个如下的uc/os-II源代码,就是采用信号量机制使两个任务共享一个串口com1,去打印一条字符串。 [code] #include \"config.h\" #define Task0StkLengh 64   ...… 查看全部问答> |
|
课后练习七之定时器 (定时器看起来简单,却搞了好久,和之前的430定时器不太一样,看了很多次,还有很多没弄出来的地方,有几个地方还是没懂) 1.TIMER_A由以下部分组成 [1] 计数器部分 输入的时钟源具有4种选择,所选择的时钟源又可 ...… 查看全部问答> |
|
5位半的数字万用表没有一千块RMB是拿不下来的,本帖想讨论能否设计一种廉价的方案实施一个5位半表呢? ICL7135是4位半AD转换器,价格低廉,才4块钱多些,如果采用过采样编程技术,是否可以做出一个5位半分辨率的万用表呢? 欢迎讨论。 如果经研 ...… 查看全部问答> |




