void main(void) { char x=10; char y=10; CLK->CKDIVR = 0; disableInterrupts(); Init_GPIO(); Init_TIM1(); Init_Clock(); usb_init(); enableInterrupts(); while(usb_ready == 0) { usb_process(); } while(1) { delay(100); if(get_random_byte()>127) { x=-x; y=-y; } data_buffer[0] = 0x00; data_buffer[1] = x; data_buffer[2] = y; data_buffer[3] = 0x00; usb_send_data(&data_buffer[0], 4, 0); } }
/******************************************************** 用TIM2产生0.01S的时钟~然后循环100次产生1S的延迟~用PD显示 ********************************************************/ void main(void) { Init_GPIO(); Init_Tim2(); _asm("rim"); //开启全局中断 while (1); }
void main() { Start_TP(); Init_GPIO(); Init_SDIO(); Init_Ext_Mem(); Init_FAT(); RTC_Init(); I2C2_Init_Advanced(400000, &_GPIO_MODULE_I2C2_PF01); UART2_Init_Advanced(9600, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART2_PD5_PA3); MPU9150A_FSY = 0; MPU9150A_Init(); MPU9150A_Detect(); MAG_Detect(); tmrTicks = 0; initTimer2(); Timer2_On(); MPU9150A_Read(); //initial read delay_ms(10); while (1) { DisableInterrupts(); Check_TP(); EnableInterrupts(); //DrawScreen(&Boot); //DrawScreen(&Speedometer_graphics); Run_logger(); } }
//****************************************************************************** // Main function //****************************************************************************** void main() { Start_TP(); Init_GPIO(); Init_SDIO(); Init_FAT(); RTC_Init(); while (1) { DisableInterrupts(); Check_TP(); EnableInterrupts(); Run_Example(); } }
void main(void) { u8 ch; u8 *p; Init_EEPROM(); Init_GPIO(); p=(u8 *)0x40f0; *p=0x61; while((FLASH_IAPSR & 0x04)==0); PD_ODR=*p; while (1); }
int main(void) { //SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN| SYSCTL_XTAL_8MHZ); //8MHz SysCtlClockSet( SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); //20MHz //SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); //50Mhz Init_GPIO(); Init_UART(); while (1) { } }
int main(void) { if (SysTick_Config(SystemCoreClock / 1000)) { while (1) {}; } Init_GPIO(); Init_SPI(); Init_RNG(); Init_LCD(); int counter=1; int counter2 =0; int x = 0; int y = 0; DrawFillRectangle(1,1,128,160,0xFFFFFF); for ( x = 160; x > 0; x-- ) for ( y = 1; y <= 84; y++ ) DrawFillRectangle(y+22, x, 1, 1, Image[(y-1)*160+161-x]-0x010101); while(1) { //DrawFillRectangle(RNG->DR%128,RNG->DR%160,RNG->DR%128,RNG->DR%160,RNG->DR); /*if ( counter2 == 60000 ) { DrawFillRectangle(counter-1, counter-1, 20, 20, 0x000000); DrawFillRectangle(counter, counter, 20, 20, RNG->DR); //DrawFillRectangle(1,1,128,160,0x00000); counter+=1; counter2=0; } counter2+=1; if ( counter == 108 ) { DrawFillRectangle(1,1,128,160,0x00000); counter = 0; }*/ /*GPIOD->ODR^=GreenLed; Delay(1); GPIOD->ODR^=OrangeLed; Delay(1); GPIOD->ODR^=RedLed; Delay(1); GPIOD->ODR^=BlueLed; Delay(1);*/ } return 0; }
/*--------------------------------------------------- Main Routine */ int main() { char cmd[2]; Init_GPIO(); myled1 = 0; myled2 = 0; myled3 = 0; myled4 = 0; while(1) { myled4 = 0; myled1 = 1; cmd[0] = OutputPort0; cmd[1] = 0xfe; i2c.write(addr, cmd, 2); wait(0.2); myled1 = 0; myled2 = 1; cmd[1] = 0xfd; i2c.write(addr, cmd, 2); wait(0.2); myled2 = 0; myled3 = 1; cmd[1] = 0xfb; i2c.write(addr, cmd, 2); wait(0.2); myled3 = 0; myled4 = 1; cmd[1] = 0xf7; i2c.write(addr, cmd, 2); wait(0.2); cmd[0] = InputPort1; i2c.write(addr, cmd, 1, true); i2c.read(addr, cmd, 1); pc.printf("\r\n Input - %02x", (unsigned char)cmd[0]); wait(0.2); } }
int main (void) { uint32_t execution_cycle; //actual execution cycle char ch; #ifdef CMSIS // If we are conforming to CMSIS, we need to call start here start(); #endif printf("\n\rRunning the LQRUG_bme_ex2 project.\n\r"); if (RCM_SRS0 & RCM_SRS0_WAKEUP_MASK) { printf("Wakeup initialization flow\n\r"); systick_init(); cnt_start_value = SYST_CVR; Init_BME_GPIO(); ADC_BME_Trigger(); //Set LPTMR to timeout about 1 second Lptmr_BME_Init(1000, LPOCLK); ADC_BME_Init(); Calibrate_BME_ADC(); ADC_BME_Init(); ADC_Start(ADC0_CHANB); // Enable the ADC interrupt in NVIC #ifdef CMSIS enable_irq(ADC0_IRQn) ; // ready for this interrupt. enable_irq(LPTimer_IRQn); #else enable_irq(ADC0_irq_no) ; // ready for this interrupt. enable_irq(LPTMR0_irq_no); #endif cnt_end_value = SYST_CVR; execution_cycle = cnt_start_value - cnt_end_value - overhead; systick_disable(); #ifdef DEBUG_PRINT printf("Systick start value: 0x%x\n\r", cnt_start_value); printf("Systick end value: 0x%x\n\r", cnt_end_value); printf("Actual execution cycle for initialization phase in normal C code: 0x%x\n\r", execution_cycle); #endif } else { printf("Normal initialization flow\n\r"); //make sure the two printf has the same characters to output systick_init(); cnt_start_value = SYST_CVR; Init_GPIO(); ADC_Trigger(); //Set LPTMR to timeout about 1 second Lptmr_Init(1000, LPOCLK); ADC_Init(); Calibrate_ADC(); ADC_Init(); ADC_Start(ADC0_CHANB); // Enable the ADC interrupt in NVIC #ifdef CMSIS enable_irq(ADC0_IRQn) ; // ready for this interrupt. enable_irq(LPTimer_IRQn); #else enable_irq(ADC0_irq_no) ; // ready for this interrupt. enable_irq(LPTMR0_irq_no); #endif cnt_end_value = SYST_CVR; execution_cycle = cnt_start_value - cnt_end_value - overhead; systick_disable(); #ifdef DEBUG_PRINT printf("Systick start value: 0x%x\n\r", cnt_start_value); printf("Systick end value: 0x%x\n\r", cnt_end_value); printf("Actual execution cycle for initialization phase in normal C code: 0x%x\n\r", execution_cycle); #endif } Lptmr_Start(); #ifndef FREEDOM printf("ADC conversion for potentiometer started, press any key to stop ADC conversion\n\r"); #else printf("No potentiometer or LED on FREEDOM board, press any key to stop ADC conversion\n\r"); #endif while(!char_present()) { #ifndef FREEDOM if (cycle_flags == ADC0A_DONE) { printf("\r R0A=%8d",result0A); cycle_flags &= ~ADC0A_DONE ; } #endif } in_char(); //Read out any available characters ADC_Stop(); printf("ADC conversion stopped, press 'l' to enter VLLS1 mode\n\r"); #ifndef FREEDOM printf("Press SW3 or SW4(Reset button) on TWR-KL25Z48M to exit VLLS1 mode\n\r"); #else printf("Press SW1(Reset button) on FREEDOM board to exit VLLS1 mode\n\r"); #endif while(1) { ch = in_char(); //out_char(ch); if(ch != 'l') printf("Incorrect character input, Press 'l' to enter VLLS1 mode\n\r"); else break; } llwu_configure(0x0080/*PTC3*/, LLWU_PIN_FALLING, 0x0); /* Configure SW3 - init for GPIO PTC3/LLWU_P7/UART1_RX/FTM0_CH2/CLKOUT*/ PORTC_PCR3 = ( PORT_PCR_MUX(1) | PORT_PCR_PE_MASK | PORT_PCR_PFE_MASK | PORT_PCR_PS_MASK); enter_vlls1(); }
void main(void) { uint32_t nResult= SUCCESS; /* Buffer pointer used to get the frames with data */ void *pVideoBuffer=NULL; uint32_t *pTemp = (uint32_t *)&buffer[0]; //MT9M114_VIDEO_BUF *pBufTemp; //uint32_t *pBuf; //int32_t nSize; /* Initialize the ADI components such as pin muxing etc */ adi_initComponents(); /* auto-generated code */ /* Initialize DMC */ adi_DMCamInit(); /* By default, Graphics is not used to draw the bounding rectangle around the detected dot */ InitTitle((void*)(*pTemp)); nBoundingRectFlag = 0; #if defined(FINBOARD) nIllumination = prevIllumination = 1; #endif /* Registering the MDMA callback for Channel-1(Dest) with Interrupt ID 91 (page 219, HRM) * to Core-B since it is used to mark the canny output */ //nSize = sizeof(uint32_t); /******************************************************/ /*mcapi_finalize(&mcapi_status); if (MCAPI_SUCCESS != mcapi_status) { exit(1); }*/ #ifdef DEBUG_INFO printf("[CORE A]: BF609_MCAPI_msg: %s\n", retVal == PASS ? "All done" : "Error..."); #endif /******************************************************/ do { /* Initialize the power services*/ if (adi_pwr_Init (PROC_CLOCK_IN, PROC_MAX_CORE_CLOCK, PROC_MAX_SYS_CLOCK, PROC_MIN_VCO_CLOCK) != ADI_PWR_SUCCESS) { printf ("Failed to initialize Power service\n"); nResult= FAILURE; break; } /* Set the required core clock and system clock */ if(adi_pwr_SetFreq(PROC_REQ_CORE_CLOCK, PROC_REQ_SYS_CLOCK)!= ADI_PWR_SUCCESS ) { printf ("Failed to initialize Power service\n"); nResult= FAILURE; break; } /* Initialize the GPIO for enabling/disabling the PB1 which inturn control the graphics to draw the rectangle around the detected dots */ if(Init_GPIO()!= SUCCESS) { printf("\n GPIO initialization failed \n"); nResult= FAILURE; break; } #if !defined(FINBOARD) /* Configure the Software controlled switches on BF609 EZ-Board */ ConfigSoftSwitches_BF609(); #else // !defined(FINBOARD) FINBOARD_CLK_Synth_Restore(); // restore firmware settings FINBOARD_LED_Drivers_Init(); FINBOARD_LED_Drivers_Config( nIllumination ); #endif // defined(FINBOARD) /* Configure the sensor */ if(ConfigureSensor() != SUCCESS) { printf("Failed to configure Sensor \n"); nResult= FAILURE; break; } /* Configure the sensor for display */ if(ConfigureEncoder() != SUCCESS) { printf("Failed to configure LCD \n"); nResult= FAILURE; break; } #if defined(FINBOARD) FINBOARD_ADV7511_16bit_Mode(); #endif /* Submit the first frame for filling */ if(SubmitEmptyVideoFrame() != SUCCESS) { printf("Failed to submit empty video frame to the sensor \n"); nResult= FAILURE; break; } /* Submit the second frame for filling */ if(SubmitEmptyVideoFrame() != SUCCESS) { printf("Failed to submit empty video frame to the sensor \n"); nResult= FAILURE; break; } /* Submit first buffer to encoder */ if(SubmitEncBuf(pEncDispStartBuf) != SUCCESS) { printf("Failed to submit video frame to the encoder \n"); nResult= FAILURE; break; } /* Submit same buffer since we will be waiting for the first frame from the sensor */ if(SubmitEncBuf(pEncDispStartBuf) != SUCCESS) { printf("Failed to submit video frame to the encoder \n"); nResult= FAILURE; break; } /* Wait till the first frame is captured */ /* Enable the sensor to capture the frames */ if(EnableDisplay(true) != SUCCESS) { printf("Failed to enable video encoder \n"); nResult= FAILURE; break; } if(EnableSensor(true) != SUCCESS) { printf("Failed to enable sensor \n"); nResult= FAILURE; break; } /* Start the display */ while( NumFramesCaptured == 0 ); }while(0); printf( "\nVersion: %s-%s\n", __DATE__, __TIME__); /* A while loop to timeout the example*/ while(NumFramesCaptured < EXAMPLE_TIMEOUT && nResult == SUCCESS ) { /* Get the video display frame */ pVideoBuffer = NULL; while(pVideoBuffer == NULL) { GetProcessedSensorBuf (&pVideoBuffer); } if(pVideoBuffer != NULL ) { #if defined(FINBOARD) if ( prevIllumination != nIllumination ) { prevIllumination = nIllumination; FINBOARD_LED_Drivers_Config( nIllumination ); } #endif } /* Increment the counter */ NumFilledFrames++; } /* end of while loop */ if(nResult == SUCCESS) { printf("All done \n"); } else { printf("Failed to run dot count application.\n"); } }