资源简介

STM32F105RC芯片,IAR编译器,U盘IAP升级程序的bootloader源码。可参考修改后使用U盘对设备升级程序。

资源截图

代码片段和文件信息

/* Includes*/
#include “main.h“

#define DSR GPIO_Pin_9
#define DSRPORT GPIOC
#define tab_num 11


u16 PrintGapTimeMin;//打印间隔计时
u16 PrintGapTimeSec;//打印间隔计时
u8 SaveRUNState = 0;
u8 SaveNow_seg = 0;//用于判断当前段数是否改变
//u8 SaveFAC = 0;//用于判断仪表类型是否改变




char welcome[] =     “WELCOME TO USE OUR PRODUCTS!“;
char DeviceString[] = “DEVICE:AK-TEST“;
char VerCycString[] = “VERSION:S1.01.01“;//开机信息

char StateString0[] = “DATA:2019-07-22 12:00:00“;//
char StateString1[] = “STE :STOP  PRCYCLE:9999MIN“;//状态改变或日期改变时打印
char StateString2[] = “CYC :00/00 RUNTIME:000:00:00“;//
char StateString3[] = “MEG :00/00 STETIME:000:00/000:00“;//
char StateString41[] = “TIME |  TV/TS ℃ |  HV/HS %|IV %“;//人工气候
char StateString42[] = “  TIME |  TV/TS ℃ |  HV/HS %“;//恒温恒湿
char StateString43[] = “  TIME |  TV/TS ℃ |IV %“;//恒温光照

char TimingString1[] = “12:00| 25.0/ 30.0|50.0/80.0| 50“;//人工气候
char TimingString2[] = “  12:00| 25.0/ 30.0| 50.0/80.0“;//恒温恒湿
char TimingString3[] = “  12:00| 25.0/ 30.0| 50“;//恒温光照

char PARString[] =     “--------------------------------“;


PRINT_PARA PRIPARA;// 打印参数结构体


void printerUART_Init(void)
{
    //GPIO端口设置
    GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
 
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD ENABLE);
     //USART1_TX   PC12
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_Init(GPIOC &GPIO_InitStructure);
   
    //USART1_RX   PD2
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_Init(GPIOD &GPIO_InitStructure);
    
    //打印机忙状态输入
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;  
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_Init(GPIOC &GPIO_InitStructure);
    
    
    NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3 ;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;        //IRQ通道使能
NVIC_Init(&NVIC_InitStructure);                                //根据NVIC_InitStruct中指定的参数初始化外设NVIC寄存器USART5 
    
    
USART_InitStructure.USART_BaudRate = 9600;                    //一般设置为9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
    USART_Init(UART5 &USART_InitStructure);
//    USART_ITConfig(USART5 USART_IT_RXNE ENABLE);//开启中断打印机不需要接收中断
    USART_Cmd(UART5 ENABLE);                    //使能串口 
    prt_init();//清空缓存复位打印机至开机默认

评论

共有 条评论