int main(void) { int SYSm; /* Initialise MPU, I/O and SysTick */ SCS_init(); UART_init(); SysTick_init(); /* Finally change Thread mode to unprivileged * but continue using Main Stack Pointer */ SYSm = __MRS_control(); SYSm |= 1; __MSR_control(SYSm); /* Flush and refill pipline with unprivileged permissions */ __ISB(); printf("Cortex-M3 Example - Build 3\n"); /* Loop forever */ while( 1 ) { Display_80((char*) "."); } }
int main(void) // Input : - // Output : - // Function : main function. Runs the init function and then loops { //Initialization disable_global_int(); SysTick_init(); GPIO_init(); swtimers_init(); RTCS_init(); UART0_init(19200, 8, 1, 0); enable_global_int(); LCD_init(); queue_init(&display_lcd_queue); queue_init(&uart0_rx_queue); numpad_init(); open_queue(Q_LCD); open_queue(Q_INPUT); start_task( TASK_RTC, RTC_task); start_task( TASK_DISPLAY, display_task); start_task( TASK_LCD, LCD_task); start_task( TASK_NUMPAD, numpad_task); start_task( TASK_UI, ui_task); start_task( TASK_UART0, UART0_task); schedule(); return (0); }
int main(void) { SysTick_init(); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); uart_init(115200); Struct_Init(); Pid_Init(); MotoPwm_Init(); OLED_Init(); Key_Init(); I2cMaster_Init(); mpu_dmp_init(); GPIO_Config(); Filter_Init(); // NRF_Usart_Pin_Init();//无线初始化 // NRF_Read_Live_Init();//无线在线传输 // ReadData_Init(); Scheduler_Init(); while(1) { Scheduler_Loop(); } }
void task_run(void *arg) { SysTick_init(); mutex_init(); if(__init_GlobalLock()!=0) SysReset(); __GlobalLock(); platpara_init(); printf("\r\nstart runing...\r\n"); printf("platform make at:\033[1;31;40m%s \033[0m\r\n",MKTIME); printf("Sysetm \033[1;32;40m%s\033[0m start at:%s\r\n",SYSTEM_NAME,UTimeFormat(UTimeReadCurrent())); RunAppTask(); while(1) { rtc_update(1); if(UTimeReadCurrent()%300 == 0) printf("\r\nTime:%s\r\n",UTimeFormat(UTimeReadCurrent())); watchdog_feed(); #ifdef BIG_CONCENT shining_led(); #endif SysCheckTaskState(); sleep(50); } }
/* * 函数名:BSP_Init * 描述 :时钟初始化、硬件初始化 * 输入 :无 * 输出 :无 */ void BSP_Init(void) { SysTick_init(); switch (RCC_GetSYSCLKSource()) { case 0x00 : printf("\r\n HSI used as system clock.\r\n"); break; case 0x04 : printf("\r\n HSE used as system clock.\r\n"); break; case 0x08 : printf("\r\n PLL used as system clock.\r\n"); break; default: printf("\r\n * unkonwn clock soure. *"); break; } /* LED 端口初始化 */ LED_GPIO_Config(); //EXTI_Cfg(); USART1_Config(); ADC1_Init(); //DAC_Config(); //RTC_Configuration(); //SoftTimerInit(); //NVIC_Configuration(); }
void init(void){ GPIO_init(); USART_init(); CAN_Config(); SysTick_init(); accelerometer_init(); ADC_init(); TIM4_init(); TIM2_init(); }
void BSP_Init(void) { SystemInit(); SysTick_init(); MYLCD_Init(); USART1_Init(); Normal_Init(); DAC_Initialize(); DAC_Output(1, 2048); DAC_Output(2, 2048); }
int main(){ uint32_t Old_timer = 0; // RCC clocking: 8MHz oscillator -> 72MHz system rcc_clock_setup_in_hse_8mhz_out_72mhz(); GPIO_init(); usb_disconnect(); // turn off USB while initializing all steppers_init(); // USB usbd_dev = USB_init(); // SysTick is a system timer with 1ms period SysTick_init(); // wait a little and then turn on USB pullup // for (i = 0; i < 0x800000; i++) // __asm__("nop"); usb_connect(); // turn on USB while(1){ usbd_poll(usbd_dev); if(usbdatalen){ // there's something in USB buffer usbdatalen = parce_incoming_buf(usbdatabuf, usbdatalen); } //check_and_parce_UART(USART1); // also check data in UART buffers if(Timer - Old_timer > 999){ // one-second cycle Old_timer += 1000; }else if(Timer < Old_timer){ // Timer overflow Old_timer = 0; } } }
void lcd_init(void) { LCD_Init(); LCD_LayerInit(); SysTick_init (); pushbutton_init(); /* Enable the LTDC */ LTDC_Cmd(ENABLE); /* Set LCD foreground layer */ LCD_SetLayer(LCD_FOREGROUND_LAYER); LCD_SetTransparency(0); /* Set LCD background layer */ LCD_SetLayer(LCD_BACKGROUND_LAYER); /* LCD display message */ LCD_Clear(LCD_COLOR_BLACK); LCD_SetBackColor(LCD_COLOR_BLACK); LCD_SetTextColor(LCD_COLOR_WHITE); }
int main(){ //int i; uint32_t Shtr_blink_timer = 0, Old_timer = 0, lastTRDread = 0, lastTmon = 0, OW_timer = 0; int oldusbdatalen = 0; //SPI_read_status SPI_stat; // RCC clocking: 8MHz oscillator -> 72MHz system rcc_clock_setup_in_hse_8mhz_out_72mhz(); // turn off SWJ/JTAG AFIO_MAPR = AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_OFF; // GPIO GPIO_init(); usb_disconnect(); // turn off USB while initializing all // init USART3 (master) & USART1 (slave) UART_init(USART3); UART_init(USART1); // USB usbd_dev = USB_init(); // SysTick is a system timer with 1mc period SysTick_init(); // instead of SPI1 we use those pins to control shutter and system state // SPI2 used for working with external ADC switch_SPI(SPI2); // init SPI2 SPI_init(); // wait a little and then turn on USB pullup // for (i = 0; i < 0x800000; i++) // __asm__("nop"); // init ADC ADC_init(); ADC_calibrate_and_start(); steppers_init(); usb_connect(); // turn on USB shutter_init(); read_stored_data(); // copy stored data into RAM init_ow_dmatimer(); //OW_send_read_seq(); LED_STATUS_OK(); // All initialized - light up LED while(1){ init_on_poweron_proc(); usbd_poll(usbd_dev); if(oldusbdatalen != usbdatalen){ // there's something in USB buffer usbdatalen = parce_incoming_buf(usbdatabuf, usbdatalen, usb_send); oldusbdatalen = usbdatalen; } check_and_parce_UART(USART3); // check data in master UART buffers check_and_parce_UART(USART1); // also check data in slave UART buffers if(ad7794_on){ if(Timer != lastTRDread){ // run this not more than once in 1ms lastTRDread = Timer; read_next_TRD(); } } OW_process(); // process 1-wire commands // scan 1-wire each 1 second if(OW_scan && (Timer - OW_timer > 999 || Timer < OW_timer)){ OW_timer = Timer; scan_onewire(); } process_stepper_motors(); // check flags of motors' timers process_shutter(); // shutter state machine if(Timer - Shtr_blink_timer > 500 || Timer < Shtr_blink_timer){ Shtr_blink_timer = Timer; // shutter LED will be blinking until init occurs if(Shutter_State == SHUTTER_NOTREADY) gpio_toggle(LED_SHUTTER_PORT, LED_SHUTTER_PIN); } if(Timer - Old_timer > 999){ // one-second cycle Old_timer += 1000; // init shutter if error occurs if(Shutter_State == SHUTTER_NOTREADY){ shutter_init(); } }else if(Timer < Old_timer){ // Timer overflow Old_timer = 0; tOVRFL++; // this is an overflow counter - for workinkg in long-long time interval } if((Timer - lastTmon > 9999) || (Timer < lastTmon)){ // run constant monitoring of ADC values each 10 seconds lastTmon += 10000; if(ADC_monitoring){ print_time(lastsendfun); print_int_ad_vals(lastsendfun); print_ad_vals(lastsendfun); } } } }
void init(void){ GPIO_init(); USART_init(); CAN_Config(); SysTick_init(); }
int main(void) { LCD_Init(); LCD_LayerInit(); SysTick_init (); pushbutton_init(); /* Enable the LTDC */ LTDC_Cmd(ENABLE); /* Set LCD foreground layer */ LCD_SetLayer(LCD_FOREGROUND_LAYER); LCD_SetTransparency(0); /* Set LCD background layer */ LCD_SetLayer(LCD_BACKGROUND_LAYER); /* LCD display message */ LCD_Clear(LCD_COLOR_BLUE); LCD_SetBackColor(LCD_COLOR_BLUE); LCD_SetTextColor(LCD_COLOR_WHITE); std::stringstream output; std::string outputstring; const char * chararray; Timer mytimerobject(12,34,56); LCD_DisplayStringLine(LCD_LINE_0,(uint8_t*)"h_da "); LCD_DisplayStringLine(LCD_LINE_1,(uint8_t*)"RZS "); LCD_DisplayStringLine(LCD_LINE_2,(uint8_t*)"WS 15/16 "); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); // Super loop while(1) { switch(get_event()){ case TICK: if(mystate==RUNNING) systick_count++; output.str(std::string()); mytimerobject.setMin(systick_count/100/60); mytimerobject.setSec(systick_count/100); mytimerobject.setHun(systick_count/1); output << "Time " << mytimerobject.printtime(); outputstring = ""; outputstring = output.str(); chararray = ""; chararray = outputstring.c_str(); LCD_DisplayStringLine(LCD_LINE_3,(uint8_t*) chararray); LCD_ClearLine(LCD_LINE_4); break; case START_STOP: LCD_DisplayStringLine(LCD_LINE_4,(uint8_t*) "START_STOP"); if(mystate == RUNNING) { mystate = HALTED; LCD_ClearLine(LCD_LINE_5); LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*) "HALTED"); } else if(mystate == HALTED) { mystate = RUNNING; LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*) "RUNNING"); } break; default: break; } } }