void timer0_ISR(void) { DelayMs(100); cont--; D8Led_symbol(numbers[cont]); if (cont == 0) { rINTMSK = rINTMSK | BIT_TIMER0; //disable timer0 rI_ISPC = BIT_TIMER0; //key = -1; //DelayMs(200); //rINTMSK = rINTMSK & ~(BIT_TIMER4); //enable timer4 rINTMSK = rINTMSK & ~(BIT_TIMER1); //enable timer1 } rI_ISPC = BIT_TIMER0; }
void iic_putByte_stop(uint8 byte) { // Escribe el dato IICDS = byte; // Comienza la trasmisión del dato (borrando pending bit del IICCON) IICCON &= ~(1 << 4); // Espera la recepción de ACK while (!(IICCON & 0x10)); //while (IICSTAT & 0x1); // Máster Tx, stop condition, Tx/Rx habilitada IICSTAT = (IICSTAT & 0x0F) | 0xD0; // Comienza la trasmisión de STOP (borrando pending bit del IICCON) IICCON &= ~(1 << 4); // Espera a que la stop condition tenga efecto (5 ms para la at24c04) DelayMs(5); }
void write_code_P18F67KXX( unsigned long address, unsigned char* data, char blocksize, char lastblock ) { char blockcounter; //FIXME: this only needs to be done on FIRST_BLOCK if( (address & 0x60) == 0 ) //package must be 128 bytes, so only do this every four packages. { pic_send( 4, 0x00, 0x8E7F ); //BSF EECON1, EEPGD pic_send( 4, 0x00, 0x9C7F ); //BSF EECON1, CFGS pic_send( 4, 0x00, 0x847F ); //BSF EECON1, WREN set_address_P18( address ); } for( blockcounter = 0; blockcounter < (blocksize - 2); blockcounter += 2 ) { //write 2 bytes and post increment by 2 // MSB LSB pic_send( 4, 0x0D, ((unsigned int) *(data + blockcounter)) | (((unsigned int) *(data + 1 + blockcounter)) << 8) ); } if( (address & 0x60) == 0x60 || (lastblock & BLOCKTYPE_LAST) ) { //write last 2 bytes of the block and start programming pic_send( 4, 0x0F, ((unsigned int) *(data + blockcounter)) | (((unsigned int) *(data + 1 + blockcounter)) << 8) ); pic_send_n_bits( 3, 0 ); PGChigh(); //hold PGC high for P9 and low for P10 DelayMs( P9 ); PGClow(); DelayMs( P10 ); pic_send_word( 0x0000 ); } else pic_send( 4, 0x0D, ((unsigned int) *(data + blockcounter)) | (((unsigned int) *(data + 1 + blockcounter)) << 8) ); }
int32_t ServerDrv_CheckDataSent(uint8_t sock) { uint16_t timeout = 0; uint8_t _data = 0; uint8_t _dataLen = 0; const uint16_t TIMEOUT_DATA_SENT = 25; do { //WAIT_FOR_SLAVE_SELECT(); SpiDrv_WaitForSlaveReady(); SpiDrv_SlaveSelect(); // Send Command SpiDrv_SendCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1); SpiDrv_SendParam(&sock, sizeof(sock), LAST_PARAM); //Wait the reply elaboration SpiDrv_WaitForSlaveReady(); // Wait for reply if (!SpiDrv_WaitResponseCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen)) { //WARN("error waitResponse isDataSent"); } SpiDrv_SlaveDeselect(); if (_data) { timeout = 0; } else { ++timeout; DelayMs(100); } }while((_data==0)&&(timeout<TIMEOUT_DATA_SENT)); if(timeout==TIMEOUT_DATA_SENT) { return (0); } else { return (1); } }
void SetupMenu() // Set up menu { uint8 i; while(1) { i = GetMenuItem("TERMINAL SETUP","WiFi Setup","ESPUSB Fudge","Scan WiFi","Test Wifi","Exit"); if(i==1) SetupWIFI(); if(i==2) // Open USB in CDC Mode passthough to ESP-01 { SerialPurge(WIFI_UART); CLS(); LCDWriteStrAt(0,4, " USB <-> ESP01 "); LCDWriteStrAt(0,6, " PROGRAMMIING "); LCDWriteStrAt(0,10," PRESS KEY TO "); LCDWriteStrAt(0,12," CONTINUE "); PORTSetPinsDigitalIn(IOPORT_C, BIT_2 ); PPSUnLock; // Unlock PPS (Peripheral Pin Select) to allow PIN Mapping PPSOutput(4,RPC2,NULL); PPSLock; // lock PPS ESP_PGM(0); WIFI_PWR(1); i = WaitEvent(9999); CLS(); WIFI_PWR(0); ESP_PGM(1); DelayMs(500); WIFI_PWR(1); LCDWriteStrAt(0,4, " USB <-> ESP01 "); LCDWriteStrAt(0,6, " PASSTHROUGH "); LCDWriteStrAt(0,10," POWER OFF TO "); LCDWriteStrAt(0,12," RESUME "); while(1); } if(i==4) { if(CheckWIFI()) LCDInform("SUCCESS","Connection OK"); } if(i==3) { LCDInform("WARNING","Not Implemented"); } if(i==0 ||i==5) return; } }
// wait for reponse from modem within specific time out // maximum waiting period = (time / 10) seconds uint8_t MODEM_Wait(const uint8_t *res, uint32_t time) { uint8_t c, i=0; time *= 100; while(time--){ DelayMs(1); while(RINGBUF_Get(&commBuf, &c)==0){ if(c==res[i]){ if(res[++i]==0)return 1; }else if(c==res[0]) i = 1; else i = 0; } } return 0; }
/*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ** 函数名称: KEY_Scan ** 功能描述: 按键扫描程序 ** 参数描述:KEY_Status标志位 返回的值分别对应按键值 ** 作 者: Dream ** 日 期: 2011年6月20日 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ uint8_t KEY_Scan(void) { static uint8_t KEY_Status =1; //定义一个按键标志位 if(KEY_Status&&(KEY_USER==0||KEY_S==0||KEY_D==0||KEY_L==0||KEY_R==0||KEY_U==0))//判断是否有按键按下 { DelayMs(10);//去抖动 KEY_Status =0; if(KEY_USER==0) return 1; //按键USER按下返回1 else if(KEY_S==0) return 2; //按键JOY-SEN按下返回1 else if(KEY_D==0) return 3; //按键JOY-DOWN按下返回1 else if(KEY_L==0) return 4; //按键JOY-LEFT按下返回1 else if(KEY_R==0) return 5; //按键JOY-RIGHT按下返回1 else if(KEY_U==0) return 6; //按键JOY-DOWN按下返回1 }else if(KEY_USER==1&&KEY_S==1&&KEY_D==1&&KEY_L==1&&KEY_R==1&&KEY_U==1)KEY_Status=1; return 0; //无按键按下返回0 }
/********************************************************************* * Function: void TouchGetCalPoints(WORD* ax, WORD* ay) * * PreCondition: InitGraph() must be called before * * Input: ax - pointer to array receiving 3 X touch positions * ay - pointer to array receiving 3 Y touch positions * * Output: none * * Side Effects: none * * Overview: gets values for 3 touches * * Note: none * ********************************************************************/ void TouchGetCalPoints(WORD* ax, WORD* ay){ static const XCHAR calStr[] = {'C','A','L','I','B','R','A','T','I','O','N',0}; XCHAR calTouchLeft[] = {'3',' ','t','o','u','c','h','e','s',' ','l','e','f','t',0}; SHORT counter; SHORT x,y; SetFont((void*)&GOLFontDefault); SetColor(BRIGHTRED); OutTextXY((GetMaxX()-GetTextWidth((XCHAR*)calStr,(void*)&GOLFontDefault))>>1, (GetMaxY()-GetTextHeight((void*)&GOLFontDefault))>>1, (XCHAR*)calStr); for(counter=0; counter<3; counter++){ SetColor(BRIGHTRED); calTouchLeft[0] = '3' - counter; OutTextXY((GetMaxX()-GetTextWidth(calTouchLeft,(void*)&GOLFontDefault))>>1, (GetMaxY()+GetTextHeight((void*)&GOLFontDefault))>>1, calTouchLeft); // Wait for press do{ x=ADCGetX(); y=ADCGetY(); }while((y==-1)||(x==-1)); Beep(); *(ax+counter) = x; *(ay+counter) = y; // Wait for release do{ x=ADCGetX(); y=ADCGetY(); }while((y!=-1)&&(x!=-1)); SetColor(WHITE); OutTextXY((GetMaxX()-GetTextWidth(calTouchLeft,(void*)&GOLFontDefault))>>1, (GetMaxY()+GetTextHeight((void*)&GOLFontDefault))>>1, calTouchLeft); DelayMs(500); } }
int main(void) { //初始化系统时钟 使用外部50M晶振 PLL倍频到100M SystemClockSetup(ClockSource_EX50M,CoreClock_100M); DelayInit(); //初始化LED LED_Init(LED_PinLookup_CHK60EVB, kNumOfLED); //将LED1设置为高电平 LED_Set(kLED1); while(1) { //2LED闪烁 LED_Toggle(kLED1); LED_Toggle(kLED2); DelayMs(500); } }
/****************************************************************************** * Function: void LCDUpdate(void) * * PreCondition: LCDInit() must have been called once * * Input: LCDText[] * * Output: None * * Side Effects: None * * Overview: Copies the contents of the local LCDText[] array into the * LCD's internal display buffer. Null terminators in * LCDText[] terminate the current line, so strings may be * printed directly to LCDText[]. * * Note: None *****************************************************************************/ void LCDUpdate(void) { BYTE i, j; // Go home LCDWrite(0, 0x02); DelayMs(2); // Output first line for(i = 0; i < 16u; i++) { // Erase the rest of the line if a null char is // encountered (good for printing strings directly) if(LCDText[0][i] == 0u) { for(j=i; j < 16u; j++) { LCDText[0][j] = ' '; } } LCDWrite(1, LCDText[0][i]); Delay10us(5); } // Set the address to the second line LCDWrite(0, 0xC0); Delay10us(5); // Output second line // for(i = 16; i < 32u; i++) for(i = 0; i < 16u; i++) { // Erase the rest of the line if a null char is // encountered (good for printing strings directly) if(LCDText[1][i] == 0u) { //for(j=i; j < 32u; j++) for(j=i; j < 16u; j++) { LCDText[1][j] = ' '; } } LCDWrite(1, LCDText[1][i]); Delay10us(5); } }
/**************************************************************************** Function: void SelfTest() Description: This routine performs a self test of the hardware. Precondition: None Parameters: None - None Returns: None Remarks: None ***************************************************************************/ static void SelfTest(void) { char value = 0; char* buf[32]; Exosite_Init("microchip","dv102412",IF_WIFI, 1); // Configure Sensor Serial Port UARTConfigure(SENSOR_UART, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(SENSOR_UART, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(SENSOR_UART, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(SENSOR_UART, GetPeripheralClock(), 9600); UARTEnable(SENSOR_UART, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); // Verify MRF24WB/G0MA MAC Address if(AppConfig.MyMACAddr.v[0] == 0x00 && AppConfig.MyMACAddr.v[1] == 0x1E) { //******************************************************************** // Prints a label using ESC/P commands to a Brother PT-9800PCN printer //******************************************************************** // Send ESC/P Commands to setup printer UARTTxBuffer("\033ia\000\033@\033X\002",9); // ESC i a 0 = Put Printer in ESC/P Mode // ESC @ = Reset Printer to Default settings // ESC X 2 = Specify Character Size // Send the Info to Print for the MAC Address label UARTTxBuffer("MRF24WB0MA\r",11); sprintf((char *)buf,"MAC: %02X%02X%02X%02X%02X%02X",AppConfig.MyMACAddr.v[0],AppConfig.MyMACAddr.v[1],AppConfig.MyMACAddr.v[2],AppConfig.MyMACAddr.v[3],AppConfig.MyMACAddr.v[4], AppConfig.MyMACAddr.v[5]); UARTTxBuffer((char *)buf, strlen((const char *)buf)); // Print the label UARTTxBuffer("\f",1); // Toggle LED's while(1) { LED0_IO = value; LED1_IO = value >> 1; LED2_IO = value >> 2; DelayMs(400); if(value == 8) value = 0; else value++; } }
void iic_putByte_stop( uint8 byte ) { // Escribe el dato rIICDS = byte; // Comienza la trasmisión del dato (borrando pending bit del IICCON) rIICCON= rIICCON & 0xef; // Espera la recepción de ACK while ((rIICCON & 0x10) == 0); // Máster Tx, stop condition, Tx/Rx habilitada rIICSTAT= 0xd0; // Comienza la trasmisión de STOP (borrando pending bit del IICCON) rIICCON= rIICCON & 0xef; // Espera a que la stop condition tenga efecto (5 ms para la at24c04) DelayMs(5); }
void ADXL362_PolledInit(void) { SpiInitPolledMode(ACCEL_ADXL362); // Software Reset ADXL362_WriteReg(ADXL362_SOFT_RESET, ADXL362_RESET_CMD); DelayMs(10); ADXL362_WriteReg(ADXL362_SOFT_RESET, 0x00); // Enable Measurement ADXL362_WriteReg(ADXL362_POWER_CTL, (2 << ADXL362_MEASURE)); s_adxl362_state = ADXL362_WaitForCommand; SpiStop(BARO_MS5611); }
/**********************************************函数定义***************************************************** * 函数名称: void MotoSet(u8 moto, u8 sleep) * 输入参数: u8 moto, u8 sleep * 返回参数: void * 功 能: 打开电机 * 作 者: by lhb_steven * 日 期: 2016/7/14 ************************************************************************************************************/ u8 MotoOpen(u8 moto, u8 dir) { //压纸电机 if(moto == 0) { moto1.zero_time = 0; if(dir == 0) { //压纸 moto1.dir = ste_dr_pla_counter; moto1.pla_hd_time = 0;//转速时间 } else { //收刀 moto1.dir = ste_dr_pla_positive; } if(autu_n.specal_old == 0) { UART1_CR2_RIEN = 0;//关闭接收中断使能 } PHASE_EN = 1;//开启转速中断 moto1.en = 1;//打开压纸电机 TIM2_CR1 = 0x01; //压纸电机方向 PLATEN_DIR = moto1.dir; } else { //操作切纸电机 moto2.zero_time = 0; if(dir == 0) {//复位 moto2.dir = ste_dr_cut_counter; } else {//切纸 autu_n.specal_rst = 0; EepromWrite(13,autu_n.specal_rst); moto2.dir = ste_dr_cut_positive; } if(autu_n.specal_old == 0) { UART1_CR2_RIEN = 0;//关闭接收中断使能 } moto2.en = 1;//打开切纸电机 CUTTER_SLEEP = 0;//低电平有效 //切纸电机方向使能 CUTTER_DIR = moto2.dir; } //开启中断 //等待继电器稳定 DelayMs(300); //使能电源 POWER_EN = 1; return 0; }
int main(void) { UINT8 mpu_address = MPU6050_ADDRESS_AD0_LOW; initAll(); UINT8 acc[2] = {0}; INT16 acc16 = 0; float acc_g = 0; UINT8 data = 0; while(TRUE) { requestReadBytes(MPU6050_ADDRESS_AD0_LOW, (UINT8)MPU6050_RA_ACCEL_XOUT_H, acc, 2); // burst read two bytes. PORTToggleBits(IOPORT_F, BIT_0); // LED5. DelayMs(1000); acc16 = (INT16)((acc[0] << 8) | acc[1]); acc_g = (float)acc16 / 16384.0; printf("\n\rACC X: %f\n\r", acc_g); } return (EXIT_SUCCESS); }
/******************************************************* *函数名称:keyscan() *功 能:扫描4*3矩阵键盘,并返回键值 *出口参数:若有按键则返回键值,若无按键返回15 *4*3矩阵键盘: 0 1 2 3 * 4 5 6 7 * 8 9 A b *******************************************************/ unsigned char KeyScan() { unsigned char key=0; ROW = 0x0f; //先置三行输出低电平 if((COL & 0x0f)!= 0x0f) //是否有按键 { DelayMs(300); ROW = 0xbf; //扫描第一行 if((COL & 0x0f)== 0x0f) { ROW = 0xdf; //扫描第二行 if((COL & 0x0f)== 0x0f) { ROW = 0xef; //扫描第三行 if((COL & 0x0f)== 0x0f) key = 16; else key = ~((ROW & 0XF0)|(COL & 0X0F)); } else key = ~((ROW & 0XF0)|(COL & 0X0F)); } else key = ~((ROW & 0XF0)|(COL & 0X0F)); if(key != 16) switch(key) //获取有效地键值 { case 0x48: key=0; break; case 0x44: key=1; break; case 0x42: key=2; break; case 0x41: key=3; break; case 0x28: key=4; break; case 0x24: key=5; break; case 0x22: key=6; break; case 0x21: key=7; break; case 0x18: key=8; break; case 0x14: key=9; break; case 0x12: key=10;break; case 0x11: key=11;break; default: key=16; } } else key = 16; keyval=key; return key; }
int main(void) { /* 初始化 Delay */ DelayInit(); /* 将GPIO设置为输入模式 芯片内部自动配置上拉电阻 */ GPIO_QuickInit(HW_GPIOE, 26, kGPIO_Mode_IPU); /* 设置为输出 */ GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP); while(1) { KEY_Scan(); //调用按键扫描程序 DelayMs(10); if(gRetValue == KEY_SINGLE) //按键按下,小灯反正 { LED1 = !LED1; } } }
uint8_t MODEM_CheckResponse(uint8_t *str,uint32_t t) { COMPARE_TYPE cmp; uint8_t c; InitFindData(&cmp,str); while(t--) { DelayMs(1); if(RINGBUF_Get(&commBuf,&c) == 0) { if(FindData(&cmp,c) == 0) { return 0; } } } return 0xff; }
void initlcd(void) { _RES = 1; // Set _RES HIGH. _SCE = 1; // Disable Chip. _RES = 0; // Reset the LCD. DelayMs(100); // Wait 100ms. _RES = 1; // Awake LCD from RESET state. writecom(0x21); // Activate Chip and H=1. writecom(0xC2); // Set LCD Voltage to about 7V. writecom(0x13); // Adjust voltage bias. writecom(0x20); // Horizontal addressing and H=0. writecom(0x09); // Activate all segments. clearram(); // Erase all pixel on the DDRAM. writecom(0x08); // Blank the Display. writecom(0x0C); // Display Normal. cursorxy(0,0); // Cursor Home. }
int32_t WiFiDrv_GetHostByName(uint8_t* aHostname, uint8_t *aResult) { uint8_t retry = 10; if (WiFiDrv_ReqHostByName(aHostname)) { while(!_GetHostByName(aResult) && --retry > 0) { DelayMs(1000); } } else { return (0); } return (retry > 0); }
int main(void) { board_init(); //Initialize the circuit board configurations changeState(START); //Initialize the state enque(DIAGNOSTIC); //first do diagnostic //motorsInit(); //motorDir(CLOCKWISE); #ifdef SHOW_MESSAGES hal_sendString_UART1("Machine started"); hal_sendChar_UART1('\n'); #endif //INTEnableInterrupts(); //INTEnableSystemMultiVectoredInt(); SKPIC32_Init(); SKPIC32_GLCDInit(); SKPIC32_GLCDWriteText(0, 0, "Hello World!"); SKPIC32_GLCDWriteText(0, 1, "This is SKPIC32!"); SKPIC32_GLCDWriteText(0, 2, "1234567890"); SKPIC32_GLCDWrite(0, 3, 0x31); DelayMs(2000); while(1){ uint8 nextEvent = deque(); //get next event if(nextEvent) { stateMachine(nextEvent); //enter the event functions } if(keyuse ==(uint8)PRODUCT) //check key press for product selection { keypad_pole(); } else if(keyuse ==(uint8)AMOUNT) //check key press for amount selection { keypad_pole(); } } }
void BoardInitMcu( void ) { if( McuInitialized == false ) { #if defined( USE_BOOTLOADER ) // Set the Vector Table base location at 0x3000 SCB->VTOR = FLASH_BASE | 0x3000; #endif HAL_Init( ); SystemClockConfig( ); #if defined( USE_USB_CDC ) UartInit( &UartUsb, UART_USB_CDC, NC, NC ); UartConfig( &UartUsb, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL ); DelayMs( 1000 ); // 1000 ms for Usb initialization #endif RtcInit( ); BoardUnusedIoInit( ); I2cInit( &I2c, I2C_1, I2C_SCL, I2C_SDA ); } else { SystemClockReConfig( ); } AdcInit( &Adc, BAT_LEVEL_PIN ); SpiInit( &SX1272.Spi, SPI_1, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); if( McuInitialized == false ) { McuInitialized = true; if( GetBoardPowerSource( ) == BATTERY_POWER ) { CalibrateSystemWakeupTime( ); } } }
void SampleSensors(void) { // Turn on sensors SENSORS_ENABLE = 1; // Settle time DelayMs(10); { sensorVals.temp = AdcSampleTemp(); sensorVals.tempCx10 = ConvertTempToCelcius(sensorVals.temp); DBG_INFO("\r\nTemp:"); DBG_PRINT_INT(sensorVals.tempCx10); } { // Using lookup and linear interpolate and temperature from above, see excel sheet unsigned char temp8 = (sensorVals.tempCx10 + 5)/10; // Truncate to 1C resolution sensorVals.humid = SampleHumidity(); // Sample sensorVals.humidSat = ConvertHumidityToSat(sensorVals.humid,temp8); DBG_INFO("\r\nHumidity:"); DBG_PRINT_INT((sensorVals.humidSat>>8)); DBG_INFO("."); DBG_PRINT_INT((40*(sensorVals.humidSat&0xff))>>10); } { sensorVals.light = SampleLight(); sensorVals.lightLux = ConvertLightToLux(sensorVals.light); DBG_INFO("\r\nLight:"); DBG_PRINT_INT(sensorVals.lightLux); } { sensorVals.fvr = SampleFvrForVdd(); sensorVals.vddmv = ConvertFvrToVddMv(sensorVals.fvr); DBG_INFO("\r\nBatt:"); DBG_PRINT_INT(sensorVals.vddmv); } { // We dont want to do this or the state change could be missed //sensorVals.switchState = SWITCH; } // Turn off sensors SENSORS_ENABLE = 0; // Done... }
// 显示空闲时用户界面 // show an idle UI void ShowIdleMainUI(uchar *pbForceUpdate, uchar bShowGallery, int iGallery_Image_Num) { static uchar szLastTime[5+1] = {"00000"}; uchar szCurTime[16+1]; GetEngTime(szCurTime); if( *pbForceUpdate || memcmp(szLastTime, &szCurTime[11], 4)!=0 ) // Reset magstripe reader every 10 minutes { MagClose(); MagOpen(); MagReset(); } if(bShowGallery){ ShowGallery(iGallery_Image_Num); } if( *pbForceUpdate || memcmp(szLastTime, &szCurTime[11], 5)!=0) { // refresh UI sprintf((char *)szLastTime, "%.5s", &szCurTime[11]); // Gui_ClearScr(); // removed by Kim_LinHB 2014-08-13 v1.01.0003 bug512 // Modified by Kim_LinHB 2014-8-11 v1.01.0003 //Gui_ShowMsgBox(szCurTime, gl_stTitleAttr, NULL, gl_stCenterAttr, GUI_BUTTON_NONE, 0,NULL); Gui_UpdateTitle(szCurTime, gl_stTitleAttr); //Gui_DrawText(szCurTime, gl_stTitleAttr, 0, 5); if(*pbForceUpdate){ if(!bShowGallery) { Gui_UpdateKey(XUI_KEYFUNC, _T("FUNC"), NULL, NULL); Gui_UpdateKey(XUI_KEYMENU, _T("MENU"), NULL, NULL); Gui_SetVirtualButton(1, 1); DispSwipeCard(TRUE); } else Gui_SetVirtualButton(0,0); } *pbForceUpdate = FALSE; } #ifdef _WIN32 DelayMs(100); #endif }
unsigned int print_ticket(unsigned int source,unsigned int destination) { unsigned int final_amount =0,final_amount_cpy =0,fx =0,final_length_cpy =0,j,final_amount_length =0; unsigned char final_disp[20],afx[5]; if(source > destination) { final_amount = (source - destination)*5; } if(destination>source) { final_amount = (destination - source)*5; } final_amount_cpy = final_amount; final_disp[0] = 'R'; final_disp[1] = 's'; final_disp[2] = ':'; final_disp[3] = '1'; final_disp[4] = '*'; final_amount_length=10; for(j=0;j<=final_amount_length;j++) { fx=final_amount_cpy%10; afx[j]=inttochar(fx); final_amount_cpy = final_amount_cpy/10; } final_length_cpy=final_amount_length; for(j=0;j<=final_amount_length;j++) { final_disp[j+5]=afx[final_length_cpy-1]; final_length_cpy=final_length_cpy-1; } final_disp[final_amount_length+5] = '='; final_length_cpy=final_amount_length; for(j=0;j<=final_amount_length;j++) { final_disp[final_amount_length+6+j]=afx[final_length_cpy-1]; final_length_cpy=final_length_cpy-1; } DelayMs(2); strcpypgm2ram((char*)LCDText, final_disp); display_row(1); //display_row(1,final_disp); return final_amount; }
int main(void) { uint8_t i; DelayInit(); GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP); UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200); printf("flexbus lcd test\r\n"); ili9320_init(); printf("controller id:0x%X\r\n", ili9320_get_id()); while(1) { i++; i%= ARRAY_SIZE(ColorTable); ili9320_clear(ColorTable[i]); GPIO_ToggleBit(HW_GPIOE, 6); DelayMs(500); } }
static UINT8 SetMode_idle(void) { UINT8 networkType; WF_CPGetNetworkType(iwconfigCb.cpId, &networkType); if (FALSE == iwconfigCb.isIdle ) { if (WF_CMDisconnect() != WF_SUCCESS) { putsUART("Disconnect failed. Disconnect is allowed only when module is in connected state\r\n"); } WF_PsPollDisable(); #ifdef STACK_USE_CERTIFICATE_DEBUG DelayMs(100); #endif } return networkType; }
int key_detect1() { GPIO_InitTypeDef GPIO_InitStruct1; GPIO_InitStruct1.GPIO_Pin=GPIO_Pin_29; GPIO_InitStruct1.GPIO_InitState=Bit_RESET; GPIO_InitStruct1.GPIO_IRQMode=GPIO_IT_DISABLE; GPIO_InitStruct1.GPIO_Mode=GPIO_Mode_IPU; GPIO_InitStruct1.GPIOx=PTA; GPIO_Init(&GPIO_InitStruct1); if(GPIO_ReadInputDataBit(PTA,GPIO_Pin_29)==0){ DelayMs(20); if(GPIO_ReadInputDataBit(PTA,GPIO_Pin_29)==0){ while(!GPIO_ReadInputDataBit(PTA,GPIO_Pin_29)); return 1; } } else return 0; }
/* Sleep function */ void SleepMs(uint32_t MilliSeconds) { /* Lookup */ MCoreDevice_t *tDevice = DmGetDevice(DeviceTimer); MCoreTimerDevice_t *Timer = NULL; /* Sanity */ if (tDevice == NULL) { DelayMs(MilliSeconds); return; } /* Cast */ Timer = (MCoreTimerDevice_t*)tDevice->Data; /* Go */ Timer->Sleep(Timer->TimerData, MilliSeconds); }
void SleepNs(uint32_t NanoSeconds) { /* Lookup */ MCoreDevice_t *tDevice = DmGetDevice(DevicePerfTimer); MCoreTimerDevice_t *Timer = NULL; /* Sanity */ if (tDevice == NULL) { DelayMs((NanoSeconds / 1000) + 1); return; } /* Cast */ Timer = (MCoreTimerDevice_t*)tDevice->Data; /* Go */ Timer->Sleep(Timer->TimerData, NanoSeconds); }