int main(void){ DisableInterrupts(); TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz Random_Init(1); Nokia5110_Init(); PF1Init(); //SysTick_Init(2666666); //Initialize SysTick with 30 Hz interrupts SysTick_Init(2666666*4); //Increased period by 4 for actual hardware to make the game run at a playable speed Nokia5110_ClearBuffer(); Nokia5110_DisplayBuffer(); // draw buffer ADC0_Init(); Game_Init(); SwitchLed_Init(); Sound_Init(); Timer2_Init(&Sound_Play,7256); //11.025 kHz. 80,000,000/11,025 cycles, which is about 7256 GameOverFlag = 0; EnableInterrupts(); while(1){ while(Semaphore==0){}; Semaphore = 0; if(GameOverFlag){ State_GameOver(); } else{ Draw_GameFrame(); // update the LCD } if((GameOverFlag == 0) && (Check_GameOver())){ //just detected game over Delay100ms(2);//Delay 200ms GameOverFlag = Check_GameOver(); //SysTick_Init(2666666);//Re-initialize with 30 Hz interrupt SysTick_Init(2666666*4); //Increased period by 4 for actual hardware to make the game run at a playable speed } } }
// *************************** Capture image dimensions out of BMP********** int main(void){ TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz Output_Init(); ADC0_Init(); DAC_Init(); SysTick_Init(); Menu_Init(); Sound_Init(); UART1_Init(); Button0_Init(); Timer0_Init(Play, 80000000/11025); // 11.025 kHz 80000000/11025 Timer1_Init(Master_Funk, 80000000/60); //Timer2_Init(SomeUART function, high speed); //for UART /* ST7735_FillScreen(0x0000); // set screen to black ST7735_SetCursor(1, 1); ST7735_OutString("GAME OVER"); ST7735_SetCursor(1, 2); ST7735_OutString("Nice try,"); ST7735_SetCursor(1, 3); ST7735_OutString("Earthling!"); ST7735_SetCursor(2, 4); LCD_OutDec(1234); */ while(1){ } }
// Initialize LCD // Inputs: none // Outputs: none void LCD_Init(void){ SYSCTL_RCGC2_R |= 0x00000003; // 1) activate clock for Ports A and B while((SYSCTL_PRGPIO_R&0x03) != 0x03){};// ready? GPIO_PORTB_AMSEL_R &= ~0xFF; // 3) disable analog function on PB7-0 GPIO_PORTA_AMSEL_R &= ~0xC0; // disable analog function on PA7-6 GPIO_PORTB_PCTL_R = 0x00000000; // 4) configure PB7-0 as GPIO GPIO_PORTA_PCTL_R &= ~0xFF000000; // configure PA7-6 as GPIO GPIO_PORTB_DIR_R = 0xFF; // 5) set direction register GPIO_PORTA_DIR_R |= 0xC0; GPIO_PORTB_AFSEL_R = 0x00; // 6) regular port function GPIO_PORTA_AFSEL_R &= ~0xC0; GPIO_PORTB_DEN_R = 0xFF; // 7) enable digital port GPIO_PORTA_DEN_R |= 0xC0; GPIO_PORTB_DR8R_R = 0xFF; // enable 8 mA drive GPIO_PORTA_DR8R_R |= 0xC0; SysTick_Init(); // Volume 1 Program 4.7, Volume 2 Program 2.10 LCDCMD = 0; // E=0, R/W=0, RS=0 SysTick_Wait(T15ms); // Wait >15 ms after power is applied OutCmd(0x30); // command 0x30 = Wake up SysTick_Wait(T5ms); // must wait 5ms, busy flag not available OutCmd(0x30); // command 0x30 = Wake up #2 SysTick_Wait(T160us); // must wait 160us, busy flag not available OutCmd(0x30); // command 0x30 = Wake up #3 SysTick_Wait(T160us); // must wait 160us, busy flag not available OutCmd(0x38); // Function set: 8-bit/2-line OutCmd(0x10); // Set cursor OutCmd(0x0C); // Display ON; Cursor ON OutCmd(0x06); // Entry mode set }
/** * @brief 主函数 * @param 无 * @retval 无 */ int main(void) { /* LED 端口初始化 */ LED_GPIO_Config(); /* 初始化触屏 */ Touch_Init(); /* 初始化定时器 */ SysTick_Init(); /*CRC和emWin没有关系,只是他们为了库的保护而做的,这样STemWin的库只能用在ST的芯片上面,别的芯片是无法使用的。 */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE); /* 初始化GUI */ GUI_Init(); /* 初始化串口*/ USART1_Config(); DEBUG("\r\n wildfire ISO board emWin test \r\n"); GUI_Delay (20); /* 触摸校准demo */ Touch_MainTask(); }
int main(void){ //Initialize all below: TExaS_Init(); // Bus clock is 80 MHz ADC_Init(); // initialize to sample ADC1 ST7735_InitR(INITR_REDTAB); SysTick_Init(); UART_Init(); FiFo_Init(); PortF_Init(); EnableInterrupts(); while(1){ while(ADCStatus == 0){}; //Poll ADCStatus flag ADCStatus = 0; //clear flag //Prints from a full FIFO --> BUT must know when //we get to the end --> uses while loop to check this condition, //and a for loop to print 5 times ST7735_SetCursor(6,5); //Infinite loop if the fifo is empty / if returns fail while (FiFo_Get(&data) == 0) {}; FiFo_Get(&data); for(int i = 1; i <= 5; i++){ ST7735_OutChar(data); FiFo_Get(&data); } FiFo_Get(&data); FiFo_Get(&data); ST7735_SetCursor(12,5); ST7735_OutString(" cm"); // print " cm" } }
int main(void) { unsigned int nCount; unsigned char vEncoder[20]="--------------------"; int i; RCC_Configuration(); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); NVIC_Configuration(); EXTI_Configuration(); USART1_Init(); USART2_Init(); USART3_Init(); UART4_Init(); UART5_Init(); SPI2_Init(); SysTick_Init(); //init_NRF24L01(); RX_Mode(); //nRF24L01_ISR(); while(1) { //Serial_PutString("While "); } }
void EXTI4_IRQHandler(void) { //USART1_printf(USART2, "%d\r\n",TIM2->CNT); //启动自动完成编码器角度标定 (由于转向电机不能很好的伺服,故该操作效果不明显) #ifdef Startup if (!Start_Due) { zero = TIM2->CNT; Car_Turn(0); SysTick_Init(72); Start_Due = 1; Delay(0xF); Car_Turn_Angle(0); //回零点 } else { TIM2 -> CNT = zero; //自动标0,防止编码器发生偏移 } #endif #ifndef Startup //TIM2 -> CNT = zero; //手动标定 #endif EXTI_ClearITPendingBit(EXTI_Line4); }
int main(void){ volatile unsigned long delay; //TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_NoScope); TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_Scope); ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 Nokia5110_Init(); // initialize Nokia5110 LCD SysTick_Init(1999999); // initialize SysTick for 40 Hz interrupts // initialize profiling on PF1 (optional) // wait for clock to stabilize SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF; // activate port F delay = SYSCTL_RCGC2_R; GPIO_PORTF_DIR_R |= 0x04; // make PF2 out (built-in LED) GPIO_PORTF_AFSEL_R &= ~0x04; // disable alt funct on PF2 GPIO_PORTF_DEN_R |= 0x04; // enable digital I/O on PF2 // configure PF2 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF EnableInterrupts(); Nokia5110_Clear(); Nokia5110_OutString((unsigned char *)"UT.6.01x Lab 14 Start"); while(1){ if(Flag) { UART_ConvertDistance(Distance); Nokia5110_SetCursor(0, 3); Nokia5110_OutString(String); Flag = 0; } } }
void Music_Play(const unsigned short *instrument, int instrumentSize, const struct Songs* song, int songSize){ int noteIndex=0; int i=0; int pause=0; while(1){ if(play){ pause=1-pause; resetSwitches(); } if(rewind||mode){ break; } if(lenPush&&!pause){ Timer0A_Init(song->duration[noteIndex]); SysTick_Init(402000/(song->notes[noteIndex])); noteIndex=(noteIndex+1)%songSize; } if(notePush&&!pause){ notePush=0; DAC_Out(instrument[i]); i=(i+1)%instrumentSize; } } /* //in class he mentioned something about having to layer two interrupts ontop of each other and how that can help, we may //have to do something with that. I plan on asking the TA's about it tomorrow. DAC_Out(song->notes[Time&0x1F] + instrument[Time&0x1F]); // DAC_Out(song->notes[Time&0x1F]); // DAC_Out(instrument[Time&0x1F]); Time = Time + 1; SysTick_Wait(song->duration[Time&0x1F]); */ }
int main(void){ TExaS_Init(); // Bus clock is 80 MHz ST7735_InitR(INITR_REDTAB); PortF_Init(); ADC_Init(); // turn on ADC, set channel to 1 SysTick_Init(); //Initialize SysTick for(;;){ while(ADCStatus == 0){} //Poll ADCStatus flag uint32_t x = ADCMail; //read ADCMail (input) ADCStatus = 0; //clear flag x = Convert(x); //convert the input ST7735_SetCursor(1,7); ST7735_OutString("D = "); //print "D = " ST7735_SetCursor(5,7); LCD_OutFix(x); // print the fixed point value ST7735_SetCursor(10,7); ST7735_OutString(" cm"); // print " cm" ///////////////////// ST7735_SetCursor(1,2); ST7735_OutString("Lab 8:"); ST7735_SetCursor(1,3); ST7735_OutString("Measurment of"); ST7735_SetCursor(1,4); ST7735_OutString("Distance :)"); } }
/** * @brief 主函数 * @param 无 * @retval 无 */ int main(void) { /* 系统定时器 1us 定时初始化 */ SysTick_Init(); LCD_Init(); /* GRAM扫描方向为左下脚->右上角 */ Lcd_GramScan(2); LCD_Clear(0, 0, 320, 240, BACKGROUND); /*------------------------------------------------------------------------------------------------------*/ /* 触摸屏IO和中断初始化 */ Touch_Init(); /* 等待触摸屏校正完毕 */ while(Touch_Calibrate() !=0); /* 触摸取色板初始化 */ Palette_Init(); while( 1 ) { if(touch_flag == 1) /*如果触笔按下了*/ { /*获取点的坐标*/ if(Get_touch_point(&display, Read_2046_2(), &touch_para ) !=DISABLE) { Palette_draw_point(display.x,display.y); } } } }
int main(void) { SysTick_Init(); RCC_Init(); USART2_Init(); InitRF(); Tag_Init(); //send_alive_cmd_to_master(); IWDG_Init(); while(1) { if(sysTime1ms % 50 == 0) { Feed_IWDG(); } usart_msg_handle(); if(tag_check_flag) { Tag_state_check(); tag_check_flag = 0; } SendWakeMsg(); } }
int main(void) {volatile unsigned long delay; SysTick_Init(); SYSCTL_RCGC2_R |= 0x32; // 1) B E delay = SYSCTL_RCGC2_R; // 2) no need to unlock GPIO_PORTE_AMSEL_R &= ~0x07; // 3) disable analog function on PE1-0 GPIO_PORTE_PCTL_R &= ~0x00000FFF; // 4) enable regular GPIO GPIO_PORTE_DIR_R &= ~0x07; // 5) inputs on PE1-0 GPIO_PORTE_AFSEL_R &= ~0x07; // 6) regular function on PE1-0 GPIO_PORTE_DEN_R |= 0x07; // 7) enable digital on PE1-0 GPIO_PORTB_AMSEL_R &= ~0x3F; // 3) disable analog function on PB5-0 GPIO_PORTB_PCTL_R &= ~0x00FFFFFF; // 4) enable regular GPIO GPIO_PORTB_DIR_R |= 0x3F; // 5) outputs on PB5-0 GPIO_PORTB_AFSEL_R &= ~0x3F; // 6) regular function on PB5-0 GPIO_PORTB_DEN_R |= 0x3F; // 7) enable digital on PB5-0 GPIO_PORTF_LOCK_R = 0x4C4F434B; // 2) unlock GPIO Port F GPIO_PORTF_CR_R = 0x1F; // allow changes to PF4-0 GPIO_PORTF_AMSEL_R &= ~0x0A; GPIO_PORTF_PCTL_R &= ~0x000FFF0; GPIO_PORTF_DIR_R |= 0x0A; GPIO_PORTF_AFSEL_R &= ~0x0A; GPIO_PORTF_DEN_R |= 0x0A; S = goN; while(1){ LIGHT = FSM[S].Out; // set lights PED_LIGHT = FSM[S].Out2; SysTick_Wait10ms(FSM[S].Time); Input = SENSOR; // read sensors S = FSM[S].Next[Input]; } }
} void init() { volatile unsigned long delay; SYSCTL_RCGC2_R |= 0x32; // Port B,E,F clock delay = SYSCTL_RCGC2_R; // wait 3-5 bus cycles SysTick_Init(); GPIO_PORTB_DIR_R |= MASK_PORTB; GPIO_PORTB_AFSEL_R &= ~MASK_PORTB; // not alternative GPIO_PORTB_AMSEL_R &= ~MASK_PORTB; // no analog GPIO_PORTB_PCTL_R &= ~0x00FFFFFF; GPIO_PORTB_DEN_R |= MASK_PORTB; GPIO_PORTE_DIR_R &= ~MASK_PORTE; //PE0-2 Inputs GPIO_PORTE_AFSEL_R &= ~MASK_PORTE; GPIO_PORTE_AMSEL_R &= ~MASK_PORTE; // no analog GPIO_PORTE_PCTL_R &= ~0x00000FFF; // bits for PD3, PD0 GPIO_PORTE_DEN_R |= MASK_PORTE; // enable PD3, PD0 GPIO_PORTF_DIR_R |= MASK_PORTF; // PD3 output GPIO_PORTF_AFSEL_R &= ~MASK_PORTF; // not alternative GPIO_PORTF_AMSEL_R &= ~MASK_PORTF; // no analog GPIO_PORTF_PCTL_R &= ~0x0000F0F0; // bits for PD3, PD0
// Time delay using busy wait. // This assumes 50 MHz system clock. void SysTick_10ms_wait(unsigned long delay){ unsigned long i; SysTick_Init(500000); for(i=0; i<delay; i++){ SysTick_Wait(500000); // wait 10ms (assumes 50 MHz clock) } }
int main() { // unsigned char onechar = 'a'; PLL_Init(); PortA_Init(); PortC_Init(); SysTick_Init(); Nokia5110_Init(); // Зеленый светодиод выкл, PC9. Синий сетодиод вкл, PC8. Положительная логика GPIOC_BSRR = 0x2000100; Nokia5110_Clear(); while(1){ if((GPIOA_IDR & 0x1)){ // Проверяем нажатие кнопки, PA0. Положительная логика GPIOC_BSRR = 0x1000200; // Синий LED off. Зеленый LED on SysTick_Wait10ms(20); // задержка 200 мс GPIOC_BSRR = 0x3000000; // Синий LED off. Зеленый LED off SysTick_Wait10ms(20); // задержка 200 мс Nokia5110_OutString("Hello,World!"); } else GPIOC_BSRR = 0x2000100; // Синий светодиод вкл. Зеленый сетодиод выкл } }
int main(void){ uint8_t n; // state number uint32_t Input; PLL_Init(Bus80MHz); // initialize 50 MHz system clock SysTick_Init(); // initialize SysTick timer SYSCTL_RCGCGPIO_R |= 0x12; // activate clock for Port E and Port B // allow time for clock to stabilize while((SYSCTL_PRGPIO_R&0x12) == 0){}; GPIO_PORTB_DIR_R |= 0x3F; // make PB5-0 out GPIO_PORTB_AFSEL_R &= ~0x3F; // disable alt funct on PB5-0 GPIO_PORTB_DEN_R |= 0x3F; // enable digital I/O on PB5-0 // configure PB5-0 as GPIO GPIO_PORTB_PCTL_R = (GPIO_PORTB_PCTL_R&0xFF000000)+0x00000000; GPIO_PORTB_AMSEL_R &= ~0x3F; // disable analog functionality on PB5-0 GPIO_PORTE_DIR_R &= ~0x03; // make PE1-0 in GPIO_PORTE_AFSEL_R &= ~0x03; // disable alt funct on PE1-0 GPIO_PORTE_DEN_R |= 0x03; // enable digital I/O on PE1-0 // configure PE1-0 as GPIO GPIO_PORTE_PCTL_R = (GPIO_PORTE_PCTL_R&0xFFFFFF00)+0x00000000; GPIO_PORTE_AMSEL_R &= ~0x03; // disable analog functionality on PE1-0 n = goN; // initial state: Green north; Red east while(1){ LIGHT = FSM[n].Out; // set lights to current state's Out value SysTick_Wait10ms(FSM[n].Time); // wait 10 ms * current state's Time value Input = SENSOR; // get new input from car detectors n = FSM[n].Next[Input]; // transition to next state } }
//------------main---------------------------- int main(void){ PLL_Init(); SysTick_Init(); Switch_Init(); Output_Init(); // print intro screen to lab printf(" Fixed-point Lab\n"); printf("\n\n\n\n\n\n\n\n\n\n"); printf(" By:\n"); printf(" Brandon Boesch\n"); printf(" Curtis Martin\n"); printf(" Press SW2 to begin\n"); ST7735_DrawBitmap(30, 108, bmp_Logo, 70, 100); // begin tests while(PF0 == 0x01){}; Fixed_uDecOut2_test(); while(PF0 == 0x01){}; Fixed_sDecOut3_test(); while(PF0 == 0x01){}; Fixed_uBinOut8_test(); while(PF0 == 0x01){}; // outro screen Output_Clear(); ST7735_SetCursor(0,0); printf("Tests complete!"); ST7735_DrawBitmap(6, 159, bmp_thumbs, 114, 146); while(1){}; }
int main(void){ unsigned long i,last,now, SW1, SW2; TExaS_Init(SW_PIN_PF40, LED_PIN_PF1); // activate grader and set system clock to 16 MHz PortF_Init(); // initialize PF1 to output SysTick_Init(); // initialize SysTick, runs at 16 MHz i = 0; // array index last = NVIC_ST_CURRENT_R; EnableInterrupts(); // enable interrupts for the grader while(1){ SW1= GPIO_PORTF_DATA_R & 0x01; SW2= GPIO_PORTF_DATA_R & 0x10; if(!SW1 || !SW2) { Led = GPIO_PORTF_DATA_R; // read previous Led = Led^0x02; // toggle red LED GPIO_PORTF_DATA_R = Led; // output if(i<50){ now = NVIC_ST_CURRENT_R; Time[i] = (last-now)&0x00FFFFFF; // 24-bit time difference //Data[i] = GPIO_PORTF_DATA_R&0x02; // record PF1 Data[i] = GPIO_PORTF_DATA_R&0x13; // record PF1 last = now; i++; } Delay(); } else { GPIO_PORTF_DATA_R &=~0x02 ; // output } } }
int main(void) { int order; SysTick_Init(); NVIC_Config(); LedBlink_Init(); uart_init(); printf("###########################################################################\r\n "); printf("Using USART2 As serial port, Baurd: 57600, TX: GPIO PD5, RX: GPIO PD6\r\n\r\n"); printf("Please select testcase to run...\r\n"); print_test_cases(); while(1) { Delay(200); for (order = TEST_START; order < TEST_END; order++) { // c = GetChar(); // if (c) { // printf("Get char: %c\r\n", c); // } // c = c - '0'; printf("\r\n=======================================================\r\n"); test_funcs[order](); //break; } while(1); } }
//Blinks the south LED void role_2(void) { Blox_LED_Init(); SysTick_Init(); while(1) { Blox_LED_Toggle(LED2); SysTick_Wait(1000); } }
void BSP_Init(void) { Key_Init(); LED_Init(); //MyLCD_Init(); Touch_Init(); SysTick_Init(); }
//Blinks the east LED void role_1(void) { Blox_LED_Init(); SysTick_Init(); while(1) { SysTick_Wait(500); Blox_LED_Toggle(LED1); } }
int main(void) { // unsigned long x, a, b, c, d; // char cool[5]; //int i = 0; SysTick_Init(); ADC_Init(1); PORTG_Init(1); PORTD_Init(); PORTA_Init(); PORTF_Init(); PORTB_Init(); PORTE_Init(1); PORTH_Init(); LCD_Init(); Touch_Init(); Camera_Init(); /* while(1) { x = ADC_In(); a = x/1000; x -= a * 1000; b = x/100; x -= b * 100; c = x/10; x -= c * 10; d = x; cool[0] = (char)(a + 48); cool[1] = (char)(b + 48); cool[2] = (char)(c + 48); cool[3] = (char)(d + 48); cool[4] = 0; TFT_Fill(purple); TFT_Text(&cool[0], 50, 50, 16, black, purple); } */ while(1) { GPIO_PORTG_DATA_R ^= 0x04; if(ADC_In() != 1023) { TFT_Fill(yellow); } else { TFT_Fill(purple); } } //TFT_H_Line(50,150,50,black); // return 1; }
int main(void){ TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz DisableInterrupts(); Random_Init(1); Nokia5110_Init(); Nokia5110_ClearBuffer(); Nokia5110_DisplayBuffer(); SysTick_Init(); // initialize Timer2 after Nokia5110_Init because of // error-prone registers operations (old and new registers // are not working good together) // 80MHz/11,025 cycles, which is about 7256 Timer2_Init(7256); Ports_Init(); InitSprites(NumberOfEnemies); RestartGame(); // Countdown, after which all interrupts are enabled! // print 3 Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_03, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); // print 2 Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_02, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); // print 1 Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_01, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); // print GO Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_GO, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); EnableInterrupts(); while(1){ if (Flag == 1) { Nokia5110_DisplayBuffer(); Flag = 0; } } }
int main1(void){ TExaS_Init(); ADC_Init(); // turn on ADC, set channel to 1 ST7735_InitR(INITR_REDTAB); PortF_Init(); SysTick_Init(); // This makes things work UART1_Init(); while(1){} // do-nothing loop }
/******************************************************************************* 函 数 名: SysHard_Init 功能说明: 初始化系统硬件相关内容 参 数: 无 返 回 值: 无 *******************************************************************************/ void SysHard_Init(void) { #if (1u == CURRENT_DEV_FLASH_SIZE) FlashSizeFlagInit(); #endif SysTick_Init(32); //初始化系统时钟 I2C_Init(); //IIC初始化 Si4432_Init(); //433无线模块初始化 }
int main(void) { uint32_t JumpAddress = 0; SysTick_Init(); memcpy((uint8*)&tag_info.net_flag_set, (void*)STORE_SYS_INFO_PAGE_ADDR, sizeof(tag_flash_info_t)); #ifdef QRCODE /*check if qrcode can be gernerate*/ if(tag_info.qr_set_flag == SYS_PARA_MAGIC_NUM && tag_info.qr_crc != cal_crc16(&tag_info.qrcode[0], 63)) { if (((*(__IO uint32_t*)APP_ERCODE_ADDRESS) & 0x2FFE0000 ) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (APP_ERCODE_ADDRESS + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ __set_MSP(*(__IO uint32_t*) APP_ERCODE_ADDRESS); /* Jump to application */ Jump_To_Application(); } } #endif /*check if soft update flag is set*/ if(SYS_PARA_MAGIC_NUM == tag_info.update_software_flag) { if(tag_info.software_crc == cal_crc16((uint8*)APP_ERCODE_ADDRESS, 0x400*29)) { if(1 == program_move(tag_info.software_crc)) { while(1) { //error update } } } } if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS); /* Jump to application */ Jump_To_Application(); } }
int main(void) { LED_Init(LED_2 | LED_3); Beep_Init(); SysTick_Init(1, SYSTICK_MS); LED_On(LED_2 | LED_3); Usart_Init(); //Beep_On(); SysTick_Delay(200, SYSTICK_MS); //Beep_Off(); LED_Off(LED_2 | LED_3); Key_Init(KEY_S1 | KEY_S2 | KEY_S3 | KEY_S4); Keyboard_Init(); //LCD_Init(); ADS1118_Init(); while(1) { printf("准备完毕 开始转换!\n"); ADS1118_CS_Reset(); while(!GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_6)); ConversionValue = ADS1118_Read(count);//8283 ADS1118_CS_Set(); printf(" The Value is 0X%08x ,%08d\n",ConversionValue,ConversionValue); ad= ConversionValue*4.096/32768; printf("AD=%fV\n",ad); SysTick_Delay(1000, SYSTICK_MS); // Keyboard_Loop(); // //LCD_Clear(Color_White); // //LCD_Set_ForeColor(Color_Red); // //if(Keyboard_Scan() == KEYBOARD_S1) { LCD_Show_String(30,50,200,16,16, "Key Board Test"); } // if(Keyboard_Detect(KEYBOARD_S1, KEYBOARD_DOWN)) { printf("S1\r\n"); } // if(Keyboard_Detect(KEYBOARD_S2, KEYBOARD_DOWN)) { printf("S2\r\n"); } // if(Keyboard_Detect(KEYBOARD_S3, KEYBOARD_DOWN)) { printf("S3\r\n"); } // if(Keyboard_Detect(KEYBOARD_S4, KEYBOARD_DOWN)) { printf("S4\r\n"); } // if(Keyboard_Detect(KEYBOARD_S5, KEYBOARD_DOWN)) { printf("S5\r\n"); } // if(Keyboard_Detect(KEYBOARD_S6, KEYBOARD_DOWN)) { printf("S6\r\n"); } // if(Keyboard_Detect(KEYBOARD_S7, KEYBOARD_DOWN)) { printf("S7\r\n"); } // if(Keyboard_Detect(KEYBOARD_S8, KEYBOARD_DOWN)) { printf("S8\r\n"); } // if(Keyboard_Detect(KEYBOARD_S9, KEYBOARD_DOWN)) { printf("S9\r\n"); } // if(Keyboard_Detect(KEYBOARD_S10, KEYBOARD_DOWN)) { printf("S10\r\n"); } // if(Keyboard_Detect(KEYBOARD_S11, KEYBOARD_DOWN)) { printf("S11\r\n"); } // if(Keyboard_Detect(KEYBOARD_S12, KEYBOARD_DOWN)) { printf("S12\r\n"); } // if(Keyboard_Detect(KEYBOARD_S13, KEYBOARD_DOWN)) { printf("S13\r\n"); } // if(Keyboard_Detect(KEYBOARD_S14, KEYBOARD_DOWN)) { printf("S14\r\n"); } // if(Keyboard_Detect(KEYBOARD_S15, KEYBOARD_DOWN)) { printf("S15\r\n"); } // if(Keyboard_Detect(KEYBOARD_S16, KEYBOARD_DOWN)) { printf("S16\r\n"); } // //LCD_Set_ForeColor(Color_Green); // //LCD_Show_String(30,70,200,16,16, "TFT-LCD test"); // //LCD_Set_ForeColor(Color_Blue); // //LCD_Show_String(30,90,200,16,16, "www.doflye.net"); // //LCD_Draw_Circle(100,180,20); // //SysTick_Delay(1000, SYSTICK_MS); } }
//debug code int main(void){ unsigned char i; unsigned char * data; // char string[20]; // global to assist in debugging // unsigned long n; // // Set the clocking to run at 50MHz from the PLL. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); SysTick_Init(); Output_Init(); Output_Color(15); UART_Init(); // initialize UART Xbee_Init(12); SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOG; i = 0; i += 1; GPIO_PORTG_DEN_R |= 0x04; GPIO_PORTG_DIR_R |= 0x04; GPIO_PORTG_DATA_R &= ~0x04; // OutCRLF(); // for(i='A'; i<='Z'; i=i+1){// print the uppercase alphabet // UART_OutChar(i); // } // OutCRLF(); // UART_OutChar(' '); // for(i='a'; i<='z'; i=i+1){// print the lowercase alphabet // UART_OutChar(i); // } // OutCRLF(); // UART_OutChar('-'); // UART_OutChar('-'); // UART_OutChar('>'); // EnableInterrupts(); while(1){ // UART_OutString("InString: "); // UART_InString(string,19); // UART_OutString(" OutString="); UART_OutString(string); OutCRLF(); // UART_OutString("InUDec: "); n=UART_InUDec(); // UART_OutString(" OutUDec="); UART_OutUDec(n); OutCRLF(); // UART_OutString("InUHex: "); n=UART_InUHex(); // UART_OutString(" OutUHex="); UART_OutUHex(n); OutCRLF(); // WaitForInterrupt(); GPIO_PORTG_DATA_R ^= 0x04; data = receiveData(); if (data!=0) printf("%c", data[0] + 0x20); //XBee_RecieveRxFrame(); // XBee_TxStatus(); // XBee_Display(); } }