- /**
- ******************************************************************************
- * @file motor control.c
- * @author MCD Application Team
- * @version
- * @date 12-May-2013
- * @brief This file provides all the Application firmware functions.
- ******************************************************************************
- * @attention
- *
- * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
- * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
- * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
- * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
- * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
- * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
- *
- ******************************************************************************
- */
- /* Includes ------------------------------------------------------------------*/
- #include "scan200dpi.h"
- #include "gpio.h"
- #include "globalVar.h"
- #include "commun.h"
- #include "usbd_hid_core.h"
- #include "readticket.h"
- #include "motor.h"
- #include "readticket.h"
- #include "adc.h"
- #include "timer.h"
- #include "usbd_hid_api.h"
- //#define nop5() {__nop() __nop() __nop() __nop() __nop() __nop()}
-
- volatile uint8_t cnt24 =1;
- volatile uint32_t Index23=0;
- void nop3(void)
- {
- __nop();
- // __nop();
- // __nop();
-
- }
- void nop5(void)
- {
- __nop();
- __nop();
- __nop();
- // __nop();
- // __nop();
- }
- void nop7(void)
- {
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- // __nop();
- // __nop();
- }
- void nop9(void)
- {
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- // __nop();
- // __nop();
- }
- void nop10(void)
- {
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- // __nop();
- // __nop();
- // __nop();
- }
- /******************************/
- #if 0
- void ScanOneLine200(void)
- {
- __IO uint32_t i;
- __IO uint8_t OneByteData=0;
- __IO uint32_t temp=0;
- uint32_t scanbufIndexStart;
- uint32_t scanbufIndexEnd;
- checkpaperIndex=scan_buffer_Windex;
- scanbufIndexStart=scan_buffer_Windex;
- scanbufIndexEnd=scan_buffer_Windex+84;
- scan_buffer_Windex+=256;
-
-
- GPIOC813=ApiSetReaderParameter.ScanRefVoltageValue;
- CISCNTLOW;
- CISCLKLOW;
- CISSILOW;
- scanEnter();
- TIM2->SR = (uint16_t)~TIM_IT_Update;
- TIM2->CNT=0;
- TIM2->ARR = 330;//300;//TIM_SetAutoreload;
- TIM2->CR1 |=0x0001;
- /**************************************/
- CISSIHIGH;//si high
- CISLEDON;
- nnop8;
- nnop8;
- nnop8;
- nnop8;
- nnop8;
-
- CISCLKHIGH; //clk high
- nnop8;
- nnop3;
-
- CISCLKLOW; //clk low
- nnop10;
- CISSILOW; //si low
- nnop8;
- // nnop8;
-
-
- for(i=0;i<60;i++)
- {
- CISCLKHIGH; //clk high
- nnop4;
- CISCLKLOW; //clk low
- nnop5;
- }
- for(i=0;i<8;i++)
- {
- CISCLKHIGH; //clk high
- nnop6;
- //nnop1;
- CISCLKLOW; //clk low
- // nnop4;
- nnop10;
- //nnop6;
- }
-
- CISCLKHIGH; //clk high
- nnop6;
- CISCLKLOW; //clk low
- nnop2;
-
- for(i=scanbufIndexStart;i<scanbufIndexEnd;i++) // 85
- {
-
- CISCLKHIGH; //1
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- CISCLKLOW;
- nnop10;
- // nnop5;
-
- CISCLKHIGH; //2
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- CISCLKLOW;
- nnop10;
- // nnop5;
-
-
- CISCLKHIGH; //3
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- CISCLKLOW;
- nnop10;
- // nnop5;
- CISCLKHIGH; //4
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- CISCLKLOW;
- nnop10;
- // nnop5;
-
- CISCLKHIGH; //5
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- CISCLKLOW;
- nnop10;
- // nnop5;
-
-
- CISCLKHIGH; //6
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- CISCLKLOW;
- nnop10;
- // nnop5;
-
-
- CISCLKHIGH; //7
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- CISCLKLOW;
- nnop10;
- // nnop5;
-
-
- CISCLKHIGH; //8
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- CISCLKLOW;
- ScanBuffer[i]=OneByteData;
- OneByteData=0;
-
- }
-
- for(i=0;i<16;i++)
- {
- CISCLKHIGH; //clk high
- nnop4;
- CISCLKLOW; //clk low
- nnop8;
- }
- scanExit();
-
- }
- #endif
- #if 1
- void ScanOneLine200(void) //old protocol old scaner //470uS
- {
-
- uint32_t i;
- uint8_t OneByteData=0;
- uint32_t scanbufIndexStart;
- uint32_t scanbufIndexEnd;
- checkpaperIndex=scan_buffer_Windex;
- scanbufIndexStart=scan_buffer_Windex;
- scanbufIndexEnd=scan_buffer_Windex+84;
- //scan_buffer_Windex+=256;
- scan_buffer_Windex+=128;
- GPIOC813=ApiSetReaderParameter.ScanRefVoltageValue;
- CISCNTLOW;
- scanEnter();
- TIM2->SR = (uint16_t)~TIM_IT_Update;
- TIM2->CNT=0;
- TIM2->ARR = 350;//330;//TIM_SetAutoreload;
- TIM2->CR1 |=0x0001;
- CISLEDON;
- ADC_CLK_High();//GPIOB->BSRRL = GPIO_Pin_8; //C H
- Delay(1);
- ADC_CLK_Low();//GPIOB->BSRRH = GPIO_Pin_8; //C L
- __nop();
- ADC_SPO_High();//GPIOB->BSRRL = GPIO_Pin_9; //O H
- __nop();
- ADC_CLK_High();//GPIOB->BSRRL = GPIO_Pin_8;
- Delay(1);
- ADC_CLK_Low();//GPIOB->BSRRH = GPIO_Pin_8;
- Delay(1);
- ADC_CLK_High();//GPIOB->BSRRL = GPIO_Pin_8;
- Delay(1);
- ADC_CLK_Low();//GPIOB->BSRRH = GPIO_Pin_8;
- __nop();
- ADC_SPO_Low();//GPIOB->BSRRH = GPIO_Pin_9;
- __nop();
- for(i=0;i<56;i++) //56 clocks before scan:0-55
- {
- ADC_CLK_High();
- __nop();
- __nop();
- __nop();
-
- ADC_CLK_Low();
- __nop();
- __nop();
- }
- for(i=0;i<8;i++) //56 clocks before scan:0-55
- {
- ADC_CLK_High();
- __nop();
- __nop();
- __nop();
- __nop();
- ADC_CLK_Low();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- }
-
- for(i=scanbufIndexStart;i<scanbufIndexEnd;i++) // 216
- {
-
-
-
- ADC_CLK_High(); //1
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- else
- __nop();
- ADC_CLK_Low();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
-
- ADC_CLK_High(); //2
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- else
- __nop();
- ADC_CLK_Low();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- // __nop();
-
- ADC_CLK_High(); //3
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- else
- __nop();
- ADC_CLK_Low();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- // __nop();
-
- ADC_CLK_High(); //4
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- else
- __nop();
- ADC_CLK_Low();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- // __nop();
-
- ADC_CLK_High(); //5
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- else
- __nop();
- ADC_CLK_Low();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- // __nop();
-
- ADC_CLK_High(); //6
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- else
- __nop();
- ADC_CLK_Low();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- // __nop();
-
- ADC_CLK_High(); //7
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- else
- __nop();
- ADC_CLK_Low();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- __nop();
- // __nop();
-
- ADC_CLK_High(); //8
- OneByteData <<=1;
- if ((GPIOE->IDR & GPIO_Pin_11) == (uint32_t)Bit_RESET) //one bit data
- OneByteData |=1;
- else
- __nop();
- ADC_CLK_Low();
- ScanBuffer[i]=OneByteData; //j256
- OneByteData=0;
- }
- __nop();
- // CISLEDOFF;
- for(i=0;i<32;i++) //add 32 clocks after scan
- {
- ADC_CLK_High();
- __nop();
- __nop();
- __nop();
- // __nop();
- // __nop();
- // __nop();
- // __nop();
- ADC_CLK_Low();
- __nop();
- __nop();
- __nop();
- __nop();//
- }
- scanExit();
-
- //ScanBuffer[scanbufIndexStart+8]=0x0f;
- //ScanBuffer[scanbufIndexStart+41]=0xff;
- }
- #endif
- uint8_t rollFrontProcess(void);
- volatile uint32_t ValueLine=0;
- volatile uint32_t ValueCNT=0;
- extern volatile uint8_t SLEDF;
- volatile uint32_t ScanBufSendIndex=0;
- volatile uint8_t dotcnt=0;
- volatile uint8_t dotcnt2=0;
- /*************************************************/
- uint8_t ScanBy200dpiProcess(void)
- {
- // uint32_t i;
- // uint32_t startp=0;
- // uint32_t *p1;
- // uint32_t *p2;
- uint8_t (*CheckData)(uint16_t sdpi);
- // SendScanDataType *p=(SendScanDataType *)struCommuCon.byTxcBuf;
- CheckData=CheckOneLineData;
-
- if(Light_Status!=0) //?????
- {
- if(rollFront.sRunFlag!=RESET)
- {
- while(RunOneStepFlag!=SET);//wait
- RunOneStepFlag=RESET;
- // while(MotRunStepEnable!=SET);
- // MotRunStepEnable=RESET;
- // StepMotorDrive8841();
- // TIM3->ARR = (uint32_t) AddSpeedTable[MotStepCount];//TIM_SetAutoreload(TIM3, AddSpeedTable[MotStepCount]);
- // TIM3->CR1 |= TIM_CR1_CEN;//TIM_Cmd(TIM3, ENABLE);
-
- ScanOneLine200();
- scan_buffer_Windex=0;//roll
- rollFront.mCnt++; //
- // rollFront.sCnt++; //
- rollFront.sReplyDataFlag=SET;
- if ((*CheckData)(200)==1)
- rollFront.CheckDataCnt++; //
- else
- rollFront.CheckDataCnt=0; //
- if (MotStepCount < MotStepCountEnd)
- MotStepCount+=2;
- //
- if (rollFront.CheckDataCnt>=2) //2 find ticket
- {
- ReaderStatus=sNormal;
- rollFront.sRunFlag=RESET;//
- Read_Ticket_Front=RESET;
- ReadTicketFlag=SET; //enable read ticket
- scan_line_count=0; //clear scan line
- scan_buffer_Windex=2560;
- CIT_BUFFER_DATA_LINE=10;
- //MotStepCountEnd=110;//MotStepCountEnd=ApiSetReaderParameter.ScanMaxSpeedStep;//MotStepCountEnd=120;//30-10m;//108;//25;
- TIM7_Disable();
- Tim7RunStatus=0;
-
- usbsenddataCount=0;
- ScanBufSendIndex=0;
- TIM6->ARR =3000; //??????
- TIM6->CNT=0;
- TIM6_Enable();
- Tim6RunStatus=0;
-
- }
- else //rollFront.CheckDataCnt<2
- {
- // if(sReplyDataFlag!=RESET)
- // rollFront.sCnt=0;
- // if(rollFront.sCnt>10)
- // {
- // rollFront.sCnt=0;
- // rollFront.sReplyDataFlag=SET;
- // }
-
- if(rollFront.mCnt>2000)//
- {
- #ifdef OldProtocol
- A4_Cmd_2(ReadFail);
- #endif
-
- rollFront.mReplyDataFlag=SET;
- // TIM7_Disable();
- // Tim7RunStatus=0;
-
- }
-
- }
- }
- else
- {
-
- if(Read_Ticket_Front!=RESET)//if(rollFront.sInitEnableFlag!=RESET)//has front flag
- {
- rollFront.CheckDataCnt=0;
- rollFront.mCnt=0;
- rollFront.sCnt=0;
- rollFront.mReplyDataFlag=RESET;
- rollFront.sReplyDataFlag=RESET;
- rollFront.sRunFlag=SET;
-
- ReaderStatus=sRollFront;//????????????0
- MotStepCount=0;//5;
- MotStepCountEnd=84;//94;//50;//94;//80;//25;
- ScanOneLine200();
- scan_buffer_Windex=0;//roll
- MotorRunDirection=FORWARD;//forward
- TIM3->CR1 |= TIM_CR1_CEN; //enable tim3 //1
-
- // TIM3->ARR = (uint32_t) AddSpeedTable[MotStepCount];//TIM_SetAutoreload(TIM3, AddSpeedTable[MotStepCount]);
- // TIM3->CR1 |= TIM_CR1_CEN;//TIM_Cmd(TIM3, ENABLE);
-
- TIM7->ARR =800; //reinit tim7
- TIM7->CNT=0;
- TIM7_Enable();
- Tim7RunStatus=2;
- BUZZ_Off();
-
-
-
- }
- }
- if(ReadTicketFlag!=RESET) //?????ticket ????
- {
- while(RunOneStepFlag==RESET);
- RunOneStepFlag=RESET; //one step
-
- // while(MotRunStepEnable!=SET);
- // MotRunStepEnable=RESET;
- // StepMotorDrive8841();
- // TIM3->ARR = (uint32_t) AddSpeedTable[MotStepCount];//TIM_SetAutoreload(TIM3, AddSpeedTable[MotStepCount]);
- // TIM3->CR1 |= TIM_CR1_CEN;//TIM_Cmd(TIM3, ENABLE);
- ScanOneLine200();
-
- //ScanBuffer[checkpaperIndex+112]=(1<<dotcnt2);
- // ScanBuffer[checkpaperIndex+110]=(1<<(dotcnt++));
- // if(dotcnt>7)
- // {
- // dotcnt=0;
- //// dotcnt2++;
- //// if(dotcnt2>7)
- //// dotcnt2=0;
- // }
- // if((scan_buffer_Windex-checkpaperIndex)==128)
- // ScanBuffer[checkpaperIndex+112]=0x05;
-
- checkpaperby200();
- if(scan_buffer_Windex>=SCAN_BUFFER_SIZE)//if(scan_buffer_Hindex>=240) //80*256 buffer
- scan_buffer_Windex=0;
- //startp=(uint32_t)(CIT_BUFFER_DATA_LINE*128);
- CIT_BUFFER_DATA_LINE++;
- scan_line_count++;
-
- if(CIT_BUFFER_DATA_LINE>=24)
- {
- CIT_BUFFER_DATA_LINE=0;
- usbsenddataCount++;
- //__nop();
- }
- // p2=(uint32_t *)&ScanBuffer[checkpaperIndex];
- // p1=(uint32_t *)&(p->TxDataBuf[startp]);//struCommuCon.byTxcBuf[startp];//
- // for(i=0;i<21;i++)//endp
- // {
- // *p1=*p2;//0x0f0f0f0f;//*p2;//ScanBuffer[checkpaperIndex+i];//*p2;
- // //*p2=0;
- // p1++;
- // p2++;
- // }
- if(usbsenddataCount>12)
- {
- if(MotStepCountEnd>59)//300mm/s
- MotStepCountEnd--;
- }
- else if(usbsenddataCount<5)
- {
- if(MotStepCountEnd<86)//108)//430mm/s
- MotStepCountEnd++;
- }
- if(scan_line_count>4900)//rollcount)
- {
- MotStop();
- TIM3->CR1 &= (uint16_t)~TIM_CR1_CEN;//disable tim3
- //TICKET_READ_START=RESET;
- PrintImageFlag=RESET;
- /***/ check_ticket_finish=RESET;
- check_ticket_end_line=0;
- scan_line_count=0;
- check_ticket_end=SET;
- // read_ticket_exit=SET;
- Light_Status=0;
- SLEDF=0;
- Read_Ticket_Front=SET;
- ReadTicketFlag=RESET;
- SCANNER_ENABLE=SET;
- TICKET_READ_PAUSE=SET;
- TIM5_Enable();
- nopapercount=0;
- TicketReadPauseCount=0;
- scan_buffer_Rindex=0;
- scan_buffer_Windex=0;
- CIT_BUFFER_DATA_LINE=0;
- ReaderStatus=1;//??
- ValueCNT=TIM6->CNT;
- TIM6_Disable();
- ValueLine=scan_line_count;
-
-
- }
- }
- }
-
- if(ReplyScanDataFlag==RESET)
- return 0;
- if(bySendFlag!=0)
- return 0;
- switch(ReaderStatus)
- {
- case sNormal:
-
- if(usbsenddataCount>0)
- {
- usbsenddataCount--;
- ReplyScanDataFlag=RESET;
- bySendFlag =1;
- // ReplyScanDataProcess
- // (ReaderStatus,
- // (uint8_t *)(ScanBuffer+256*scan_buffer_Rindex),
- // 3072);
- /*****************************/
- //ReplyScanDataHeadProcess();
- ReplyScanDataProcess();
-
- ScanBufSendIndex+=3072;
- if(ScanBufSendIndex>=SCAN_BUFFER_SIZE)
- ScanBufSendIndex=0;
- /*****************************/
- // scan_buffer_Rindex+=12;
- // if(scan_buffer_Rindex>=240)
- // scan_buffer_Rindex=0;
- }
- else if(read_ticket_exit!=RESET)
- {
- ReplyScanDataFlag=RESET;
- ReplyDataProcess
- (CMDsStartReadticket,
- ReaderStatus,
- CommuPID,
- ExecuteSuccess,
- 0,
- 0);
-
- read_ticket_exit=RESET;
- scan_buffer_Rindex=0;
- scan_buffer_Windex=0;
- CIT_BUFFER_DATA_LINE=0;
-
- }
-
- break;
-
- case sInputBlock:
-
- ReplyScanDataFlag=RESET;
- usbsenddataCount=0;
- ReplyDataProcess
- (CMDsStartReadticket,
- ReaderStatus,//??
- CommuPID,
- ExecuteSuccess,
- 0,
- 0);
- Beep(3);
-
- break;
-
- case sOutputBlock:
- case sSelfcheck:
- case sCoverOpen:
-
- break;
-
- case sRollFront:
- if(rollFront.mReplyDataFlag!=RESET)
- {
- rollFront.mReplyDataFlag=RESET;
-
- ReaderStatus=0;
- TICKET_READ_START=RESET;
- Light_Status=0;
- MotStop();
- TIM3->CR1 &= (uint16_t)~TIM_CR1_CEN;//disable tim3
- MotSteps=1;
- TIM7_Disable();
- // DelayNms(10); //old qctest
-
- ReplyScanDataFlag=RESET;
- ReplyDataProcess
- (CMDsStartReadticket,
- ReaderStatus,//
- CommuPID,
- Executefail,
- 0,
- 0);
- //Beep(3);
- rollFront.sRunFlag=RESET;
- TIM7_Disable();
- Tim7RunStatus=0;
-
-
- }
- else
- {
-
- rollFront.sReplyDataFlag=RESET;
- ReplyScanDataFlag=RESET;
- ReplyDataProcess
- (CMDsStartReadticket,
- ReaderStatus,//
- CommuPID,
- ExecuteSuccess,
- 0,
- 0);
-
- }
-
- break;
- default:
- break;
- }
-
- return 0;
- }
- uint8_t checkpaperby200(void)
- {
- if(check_ticket_finish==RESET)//&&(BetTicketFlag==RESET)) //???
- {
- if(scan_line_count<320)
- return 0;
- else
- check_ticket_finish=SET;
-
- }
- else
- {
- if(CheckTicketComplete(2,6,(uint8_t *)&ScanBuffer[checkpaperIndex])==1)
- // if(CheckTicketComplete(2,(uint8_t *)&ScanBuffer[checkpaperIndex],
- // (uint8_t *)&ScanBuffer[checkpaperIndex+42])==1)
- check_ticket_end_line++;
- else
- check_ticket_end_line=0;
- if(check_ticket_end_line>24)//(check_ticket_end_line>20) //ticket end
- {
- TIM3->CR1 &= (uint16_t)~TIM_CR1_CEN;//disable tim3
- MotStop();
- check_ticket_end_line=0;
- //scan_line_count=0;
- check_ticket_end=SET;
- read_ticket_exit=SET;
- Light_Status=0;
- SLEDF=0;
- Read_Ticket_Front=SET;
- ReadTicketFlag=RESET;
- SCANNER_ENABLE=SET;
- // A4_Cmd_2();
- TICKET_READ_PAUSE=SET;
- TIM5_Enable();
- nopapercount=0;
- TicketReadPauseCount=0;
- scan_buffer_Rindex=0;
- scan_buffer_Windex=0;
- CIT_BUFFER_DATA_LINE=0;
- check_ticket_finish=RESET;
- // printf(" exit ticket ");
- ValueCNT=TIM6->CNT;
- // ValueARR=TIM6->ARR;
- TIM6_Disable();
- ValueLine=scan_line_count;
- // __nop();
- sendPrizeInformation(0,0);
- }
- }
- return 1;
- }
- /*******************************************/
- uint8_t rollFrontProcess(void)//(uint16_t cdpi)
- {
- uint8_t (*CheckData)(uint16_t sdpi);
- CheckData=CheckOneLineData;
- if(rollFront.sRunFlag!=RESET)
- {
- while(RunOneStepFlag!=SET);//wait
- RunOneStepFlag=RESET;
- ScanOneLine200();
- scan_buffer_Windex=0;//roll
- rollFront.mCnt++; //
- rollFront.sCnt++; //
- if ((*CheckData)(200)==1)
- rollFront.CheckDataCnt++; //
- else
- rollFront.CheckDataCnt=0; //
- //
- if (rollFront.CheckDataCnt>=2) //2 find ticket
- {
- ReaderStatus=sNormal;
- rollFront.sRunFlag=RESET;//
- Read_Ticket_Front=RESET;
- ReadTicketFlag=SET; //enable read ticket
- scan_line_count=0; //clear scan line
- scan_buffer_Windex=2560;
- CIT_BUFFER_DATA_LINE=10;
- MotStepCountEnd=ApiSetReaderParameter.ScanMaxSpeedStep;//MotStepCountEnd=120;//30-10m;//108;//25;
- }
- else //rollFront.CheckDataCnt<2
- {
- if(rollFront.sCnt>10)
- {
- rollFront.sCnt=0;
- rollFront.sReplyDataFlag=SET;
- }
-
- if(rollFront.mCnt>2000)//
- {
- #ifdef OldProtocol
- A4_Cmd_2(ReadFail);
- #endif
- rollFront.mReplyDataFlag=SET;
-
- }
-
-
- }
- //
-
- }
- else
- {
- if(Read_Ticket_Front!=RESET)//if(rollFront.sInitEnableFlag!=RESET)//has front flag
- {
- rollFront.CheckDataCnt=0;
- rollFront.mCnt=0;
- rollFront.sCnt=0;
- rollFront.mReplyDataFlag=RESET;
- rollFront.sReplyDataFlag=RESET;
- rollFront.sRunFlag=SET;
-
- ReaderStatus=sRollFront;//????????????0
- MotStepCount=0;//5;
- MotStepCountEnd=94;//80;//25;
- ScanOneLine200();
- scan_buffer_Windex=0;//roll
- MotorRunDirection=FORWARD;//forward
- TIM3->CR1 |= TIM_CR1_CEN; //enable tim3 //1
-
-
- }
- }
- return 0;
- }
复制代码 |