int __init hboot_init(void) { int ret; printk("hboot_init\n"); ret = buffers_init(); if (ret < 0) { printk(KERN_WARNING CTRL_DEVNAME ": Failed to initialize buffers table\n"); return ret; } ret = register_chrdev(0, CTRL_DEVNAME, &hbootctrl_ops); if (ret < 0) { printk(KERN_WARNING CTRL_DEVNAME ": Failed to register dev\n"); buffers_destroy(); return ret; } dev_major = ret; if (ret < 0) { printk(KERN_WARNING CTRL_DEVNAME ": Failed to create dev\n"); unregister_chrdev(dev_major, CTRL_DEVNAME); buffers_destroy(); return ret; } printk(KERN_INFO CTRL_DEVNAME ": Successfully registered dev\n"); return 0; }
void platform_init_OT() { buffers_init(); //buffers init must be first in order to do core dumps vl_init(); //Veelite init must be second radio_init(); //radio init third sys_init(); //system init last }
int main(void) { //run at 8 Mhz CLKPR = 0x80; CLKPR = 0x00; io_init(); edge_interrupts_init(); usart_init(); buffers_init(); debug_init(); sei(); for(;;) { if(UCSR0A & (1 << RXC0)) { cli(); if(rx_buffer_size_cache == 0) { rx_buffer_cahce = UDR0; rx_buffer_size_cache++; sei(); } else { if(rx_buffer_size_cache <= BUF_MAX_SIZE) { buffer_put(&rx_buffer, UDR0); rx_buffer_size_cache++; } sei(); } } if(tx_buffer_size_cache != 0) { usart_send(buffer_take(&tx_buffer)); tx_buffer_size_cache--; } } return 0; }
/* Main task, initialize hardware and start the FreeRTOS scheduler */ int main(void) { // stop the watchdog timer WDTCTL = WDTPW | WDTHOLD | WDTCNTCL | WDTSSEL; immediate_debug(pdFALSE); /******************************************************/ /* Initialize the SmartGrains hardware */ /******************************************************/ hardware_setup(); debug_init(0); queue_app = xQueueCreate( 4, sizeof( main_event_t ) ); // buffers initialization if (buffers_init()!=START_SUCCESS) { debug("Buffer init failed!!\r\n"); } /********************************************************/ /* Initialize the STACK including smart_mac & smart_nwk */ /********************************************************/ if (stack_init()==START_SUCCESS) { debug("OK\r\n");} else { debug("failed!!\r\n"); } address_utils_debug_address(&lgaddr_mac, ADDR_FULL); // blinking LEDs // Code is Green-Red-Green LEDS_OFF_CHECK_MODE(led_mode); LED0_ON_CHECK_MODE(led_mode); // G clock_pause(200); LED0_OFF_CHECK_MODE(led_mode); clock_pause(200); LED1_ON_CHECK_MODE(led_mode); // R clock_pause(200); LED1_OFF_CHECK_MODE(led_mode); clock_pause(200); LED0_ON_CHECK_MODE(led_mode); // G clock_pause(200); LED0_OFF_CHECK_MODE(led_mode); // Demo App xTaskCreate( vDemo, "AppDemo", configMINIMAL_STACK_SIZE+200, NULL, (tskIDLE_PRIORITY + 1 ), NULL ); vTaskStartScheduler(); return 0; }
int main(int argc, char **argv) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { fprintf(stderr, "Failed to initialize SDL: %s\n", SDL_GetError()); return 1; } if (TTF_Init() != 0) { fprintf(stderr, "Failed to initialize TTF: %s\n", SDL_GetError()); return 1; } if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096)) { fprintf(stderr, "Failed to load Mixer: %s", SDL_GetError()); } int imgFlags = IMG_INIT_JPG|IMG_INIT_PNG; if(!(IMG_Init(imgFlags) & imgFlags)) { fprintf(stderr,"Failed to initialize Image: %s",SDL_GetError()); } screen = SDL_CreateWindow(WINDOW_TITLE, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_BORDERLESS); if (screen == NULL) { fprintf(stderr, "Failed to create window: %s\n", SDL_GetError()); return 1; } renderer = SDL_CreateRenderer(screen, -1, 0); if (renderer == NULL) { fprintf(stderr, "Failed to create renderer: %s\n", SDL_GetError()); return 1; } char* path = buildPath(ASSETS,"fonts/FONT.TTF"); font = TTF_OpenFont(path, 12); if (font == NULL) { fprintf(stderr, "Failed to load font: %s\n",TTF_GetError()); return 1; } free(path); /*Mix_Music* music = loadMusic(buildPath(ASSETS,"music/song.mp3"));*/ /*playMusic(music);*/ // Black backround SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); game_init(); if (buffers_init(renderer) != 0) { fprintf(stderr, "Failed to craete buffers: %s", SDL_GetError()); return 1; } curr_buffer = buffer; SDL_Event e; SDL_Rect render_rect; render_rect.x = 0; render_rect.y = 0; render_rect.w = WINDOW_WIDTH; render_rect.h = WINDOW_HEIGHT; bool quit = false; int deltaTime = 0; int currentFrame = SDL_GetTicks(); int lastFrame; int fpsMs = 1000 / MAX_FPS; map_tex = renderMap(renderer, map); camera.x = 0; camera.y = 0; camera.w = WINDOW_WIDTH; camera.h = WINDOW_HEIGHT; while (!quit) { lastFrame = currentFrame; currentFrame = SDL_GetTicks(); deltaTime = currentFrame - lastFrame; renderClear(renderer); update(deltaTime); draw(deltaTime); while (SDL_PollEvent(&e)) { if (e.type == SDL_QUIT) quit = true; else event(e, deltaTime); } // Reset the target SDL_SetRenderTarget(renderer, NULL); // Copy the buffer SDL_RenderCopy(renderer, curr_buffer, &camera, &render_rect); // Draw the buffer to window SDL_RenderPresent(renderer); // Delay if we are drawing more that 100 fps float delay = fpsMs - deltaTime / 1000; if (delay > 0) SDL_Delay(delay); } SDL_Quit(); return 0; }
int main(void) { /* Early system initialisation */ early_board_init(); system_init_early(); leds_init(); set_busy_led(1); set_dirty_led(0); /* Due to an erratum in the LPC17xx chips anything that may change */ /* peripheral clock scalers must come before system_init_late() */ uart_init(); #ifndef SPI_LATE_INIT spi_init(SPI_SPEED_SLOW); #endif timer_init(); i2c_init(); /* Second part of system initialisation, switches to full speed on ARM */ system_init_late(); enable_interrupts(); /* Prompt software name and version string */ uart_puts_P(PSTR("\r\nNODISKEMU " VERSION "\r\n")); /* Internal-only initialisation, called here because it's faster */ buffers_init(); buttons_init(); /* Anything that does something which needs the system clock */ /* should be placed after system_init_late() */ rtc_init(); // accesses I2C disk_init(); // accesses card read_configuration(); // restores configuration, may change device address filesystem_init(0); // FIXME: change_init(); #ifdef CONFIG_REMOTE_DISPLAY /* at this point all buffers should be free, */ /* so just use the data area of the first to build the string */ uint8_t *strbuf = buffers[0].data; ustrcpy_P(strbuf, versionstr); ustrcpy_P(strbuf+ustrlen(strbuf), longverstr); if (display_init(ustrlen(strbuf), strbuf)) { display_address(device_address); display_current_part(0); } #endif set_busy_led(0); #if defined(HAVE_SD) /* card switch diagnostic aid - hold down PREV button to use */ if (menu_system_enabled && get_key_press(KEY_PREV)) board_diagnose(); #endif if (menu_system_enabled) lcd_splashscreen(); bus_interface_init(); bus_init(); read_configuration(); late_board_init(); for (;;) { if (menu_system_enabled) lcd_refresh(); else { lcd_clear(); lcd_printf("#%d", device_address); } /* Unit number may depend on hardware and stored settings */ /* so present it here at last */ printf("#%02d\r\n", device_address); bus_mainloop(); bus_interface_init(); bus_init(); // needs delay, inits device address with HW settings } }
int main(void) { /* Early system initialisation */ board_init(); system_init_early(); leds_init(); set_busy_led(1); set_dirty_led(0); /* Due to an erratum in the LPC17xx chips anything that may change */ /* peripheral clock scalers must come before system_init_late() */ uart_init(); #ifndef SPI_LATE_INIT spi_init(SPI_SPEED_SLOW); #endif timer_init(); bus_interface_init(); i2c_init(); /* Second part of system initialisation, switches to full speed on ARM */ system_init_late(); enable_interrupts(); /* Internal-only initialisation, called here because it's faster */ buffers_init(); buttons_init(); /* Anything that does something which needs the system clock */ /* should be placed after system_init_late() */ bus_init(); // needs delay rtc_init(); // accesses I2C disk_init(); // accesses card read_configuration(); fatops_init(0); change_init(); uart_puts_P(PSTR("\r\nsd2iec " VERSION " #")); uart_puthex(device_address); uart_putcrlf(); #ifdef CONFIG_REMOTE_DISPLAY /* at this point all buffers should be free, */ /* so just use the data area of the first to build the string */ uint8_t *strbuf = buffers[0].data; ustrcpy_P(strbuf, versionstr); ustrcpy_P(strbuf+ustrlen(strbuf), longverstr); if (display_init(ustrlen(strbuf), strbuf)) { display_address(device_address); display_current_part(0); } #endif set_busy_led(0); #if defined(HAVE_SD) && BUTTON_PREV != 0 /* card switch diagnostic aid - hold down PREV button to use */ if (!(buttons_read() & BUTTON_PREV)) { while (buttons_read() & BUTTON_NEXT) { set_dirty_led(sdcard_detect()); # ifndef SINGLE_LED set_busy_led(sdcard_wp()); # endif } reset_key(0xff); } #endif bus_mainloop(); while (1); }