Beispiel #1
0
//***************************************************************************
// Main() - Main Routine
//***************************************************************************
void main(){
    OSCCON = 0xF0;      //Initialitation of Internal Oscillator
    OSCTUNEbits.PLLEN = 1;

    hardware_setup();   //Hardware initialization
    if ( !vscp_check_pstorage() )   // Check VSCP persistent storage and
        init_app_eeprom();          // restore if needed
    init_app_ram();     // Initialize data
    vscp_init();                    // Initialize the VSCP functionality
    
    while(1){ //Handler scheduler
        ClrWdt();			// Feed the dog
        if(timeEvent._10mS){    //10mS Event
            timeEvent._10mS = 0;
            vscp_10mS_Running();
            hardware_10mS();
        }
        if(timeEvent._100mS){   //100mS Event
            timeEvent._100mS = 0;
            vscp_100mS_Running();
            vscp_ledActivity();
        }
        if(timeEvent._1s){      //1second Event
            timeEvent._1s = 0;
            vscp_doOneSecondWork(); // Do VSCP one second jobs
            greenLed_pin = !greenLed_pin;
        }
        vscp_freeRunning();
        
        //TODO: Handling the override event
    }

}
Beispiel #2
0
int main(void)
{
	hardware_setup();

	while (1) {

	}

	return 0;
}
/*--------------------------------------------------------------------*/
int main(void)
{
	hardware_setup();
	uint32_t i=0;
	for (; i<10; i++)
	{
		uint32_t d=0;
		for (; d<2000000; d++) __asm__("nop");
		gpio_toggle(GPIOB, GPIO8);
		iwdg_reset();
	}

	gpio_set(GPIOB, GPIO9);
	
	while (1) {
	}

	return 0;
}
Beispiel #4
0
int linux_load(struct sys_info *info, const char *file, const char *cmdline)
{
    struct linux_header hdr;
    struct linux_params *params;
    uint32_t kern_addr, kern_size;
    char *initrd_file = NULL;

    fd = open_io(file);
    if (fd == -1) {
	return -1;
    }

    kern_addr = load_linux_header(&hdr);
    if (kern_addr == 0)
	return LOADER_NOT_SUPPORT;

    params = phys_to_virt(LINUX_PARAM_LOC);
    init_linux_params(params, &hdr);
    set_memory_size(params, info);
    initrd_file = parse_command_line(cmdline, phys_to_virt(COMMAND_LINE_LOC));
    set_command_line_loc(params, &hdr);

    kern_size = load_linux_kernel(&hdr, kern_addr);
    if (kern_size == 0) {
	if (initrd_file)
	    free(initrd_file);
	return -1;
    }

    if (initrd_file) {
	if (load_initrd(&hdr, info, kern_addr+kern_size, params, initrd_file)
		!= 0) {
	    free(initrd_file);
	    return -1;
	}
	free(initrd_file);
    }

    hardware_setup();

    start_linux(kern_addr, params);
    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(void)
{
  IntMasterDisable();

  /* Set up hardware */
  hardware_setup();
  init_semaphores();
  init_queues();

  /* Module initialization */
  if (spi_init() &&
      uart_init_task() &&
      uart_protocol_init_task() &&
      status_led_task_init() &&
      uart_echo_init() &&
      par_updater_init() &&
      (xTaskCreate(dreh_task,     NAME("Dreh"),    DEFAULT_STACK, NULL, PRIORITY_LOW,   &task_handles[DREH_T])) == pdPASS &&
      (xTaskCreate(lcd_task,      NAME("LCD"),     DEFAULT_STACK, NULL, PRIORITY_LOW,   &task_handles[LCD_T])) == pdPASS &&
      (xTaskCreate(menu_task,     NAME("Menu"),    LARGE_STACK,   NULL, PRIORITY_LOW,   &task_handles[MENU_T])) == pdPASS &&
      (xTaskCreate(numpad_task,   NAME("Numpad"),  DEFAULT_STACK, NULL, PRIORITY_LOW,   &task_handles[NUMPAD_T])) == pdPASS &&
      (xTaskCreate(control_task,  NAME("Control"), DEFAULT_STACK, NULL, PRIORITY_HIGH,  &task_handles[CONTROL_T])) == pdPASS &&
      (xTaskCreate(blink_task,    NAME("Blink"),   DEFAULT_STACK, NULL, PRIORITY_LOW,   &task_handles[BLINK_T])) == pdPASS &&
      uart_to_spi_init() &&
      step_response_init() &&
      itc_init_uartprinter()
      #ifdef DEBUG
      && spi_test_init()
      && runtimestats_init()
      #endif /* DEBUG */
     )
  {
    vTaskStartScheduler();
  }

  while (1)
  {
    /* Will only get here if initialization went wrong. */
  }

  return 1;
}
/***********************************************************************************************************************
* Function name: PowerON_Reset_PC
* Description  : This function is the MCU's entry point from a power-on reset.
*                The following steps are taken in the startup code:
*                1. The User Stack Pointer (USP) and Interrupt Stack Pointer (ISP) are both set immediately after entry 
*                   to this function. The USP and ISP stack sizes are set in the file bsp_config.h.
*                   Default sizes are USP=4K and ISP=1K.
*                2. The interrupt vector base register is set to point to the beginning of the relocatable interrupt 
*                   vector table.
*                3. The MCU is setup for floating point operations by setting the initial value of the Floating Point 
*                   Status Word (FPSW).
*                4. The MCU operating frequency is set by configuring the Clock Generation Circuit (CGC) in
*                   operating_frequency_set.
*                5. Calls are made to functions to setup the C runtime environment which involves initializing all 
*                   initialed data, zeroing all uninitialized variables, and configuring STDIO if used
*                   (calls to _INITSCT and _INIT_IOLIB).
*                6. Board-specific hardware setup, including configuring I/O pins on the MCU, in hardware_setup.
*                7. Global interrupts are enabled by setting the I bit in the Program Status Word (PSW), and the stack 
*                   is switched from the ISP to the USP.  The initial Interrupt Priority Level is set to zero, enabling 
*                   any interrupts with a priority greater than zero to be serviced.
*                8. The processor is optionally switched to user mode.  To run in user mode, set the macro 
*                   BSP_CFG_RUN_IN_USER_MODE above to a 1.
*                9. The bus error interrupt is enabled to catch any accesses to invalid or reserved areas of memory.
*
*                Once this initialization is complete, the user's main() function is called.  It should not return.
* Arguments    : none
* Return value : none
***********************************************************************************************************************/
void PowerON_Reset_PC(void)
{
    /* Stack pointers are setup prior to calling this function - see comments above */    
    
    /* Initialize the Interrupt Table Register */
    set_intb((void *)__sectop("C$VECT"));

    /* Initialize the Exception Table Register */
    set_extb((void *)__sectop("EXCEPTVECT"));

    /* Initialize FPSW for floating-point operations */
#ifdef __ROZ
#define FPU_ROUND 0x00000001  /* Let FPSW RMbits=01 (round to zero) */
#else 
#define FPU_ROUND 0x00000000  /* Let FPSW RMbits=00 (round to nearest) */
#endif 
#ifdef __DOFF 
#define FPU_DENOM 0x00000100  /* Let FPSW DNbit=1 (denormal as zero) */
#else 
#define FPU_DENOM 0x00000000  /* Let FPSW DNbit=0 (denormal as is) */
#endif 

    set_fpsw(FPSW_init | FPU_ROUND | FPU_DENOM);

    /* Switch to high-speed operation */
    operating_frequency_set();

    /* If the warm start Pre C runtime callback is enabled, then call it. */
#if BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED == 1
     BSP_CFG_USER_WARM_START_PRE_C_FUNCTION();
#endif

    /* Initialize C runtime environment */
    _INITSCT();

    /* If the warm start Post C runtime callback is enabled, then call it. */
#if BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED == 1
     BSP_CFG_USER_WARM_START_POST_C_FUNCTION();
#endif

#if BSP_CFG_IO_LIB_ENABLE == 1
    /* Comment this out if not using I/O lib */
    _INIT_IOLIB();
#endif

    /* Initialize MCU interrupt callbacks. */
    bsp_interrupt_open();

    /* Initialize register protection functionality. */
    bsp_register_protect_open();

    /* Configure the MCU and board hardware */
    hardware_setup();

    /* Change the MCU's user mode from supervisor to user */
    nop();
    set_psw(PSW_init);      
#if BSP_CFG_RUN_IN_USER_MODE==1
    chg_pmusr() ;
#endif

    /* Enable the bus error interrupt to catch accesses to illegal/reserved areas of memory */
    R_BSP_InterruptControl(BSP_INT_SRC_BUS_ERROR, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR);

    /* Call the main program function (should not return) */
    main();
    
#if BSP_CFG_IO_LIB_ENABLE == 1
    /* Comment this out if not using I/O lib - cleans up open files */
    _CLOSEALL();
#endif

    /* BCH - 01/16/2013 */
    /* Infinite loop is intended here. */    
    while(1) /* PRQA S 2740 */
    {
        /* Infinite loop. Put a breakpoint here if you want to catch an exit of main(). */
    }
}
    //#pragma section P UserAppStartSect        // Output PowerON_Reset to PResetPRG section
    void UserAppStart(void)
#endif
{
    /* Stack pointers are setup prior to calling this function - see comments above */    
    
    /* Initialise the MCU processor word */
#if __RENESAS_VERSION__ >= 0x01010000    
    set_intb((void *)__sectop("C$VECT"));
#else
    set_intb((unsigned long)__sectop("C$VECT"));
#endif    

#if (BSP_CFG_USE_CGC_MODULE == 0)
    /* Switch to high-speed operation */
    operating_frequency_set();
#else
    cgc_clock_config();
#endif

    /* If the warm start Pre C runtime callback is enabled, then call it. */
#if BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED == 1
     BSP_CFG_USER_WARM_START_PRE_C_FUNCTION();
#endif

    /* Initialize C runtime environment */
    _INITSCT();

    /* If the warm start Post C runtime callback is enabled, then call it. */
#if BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED == 1
     BSP_CFG_USER_WARM_START_POST_C_FUNCTION();
#endif

#if BSP_CFG_IO_LIB_ENABLE == 1
    /* Comment this out if not using I/O lib */
    _INIT_IOLIB();
#endif

    /* Initialize MCU interrupt callbacks. */
    bsp_interrupt_open();

    /* Initialize register protection functionality. */
    bsp_register_protect_open();

    /* Configure the MCU and board hardware */
    hardware_setup();

    /* Change the MCU's user mode from supervisor to user */
    nop();
    set_psw(PSW_init);      
#if BSP_CFG_RUN_IN_USER_MODE==1
    /* Use chg_pmusr() intrinsic if possible. */
    #if __RENESAS_VERSION__ >= 0x01010000
    chg_pmusr() ;
    #else
    Change_PSW_PM_to_UserMode();
    #endif
#endif

    /* Enable the bus error interrupt to catch accesses to illegal/reserved areas of memory */
    R_BSP_InterruptControl(BSP_INT_SRC_BUS_ERROR, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR);

    /* Call the main program function (should not return) */
    main();
    
#if BSP_CFG_IO_LIB_ENABLE == 1
    /* Comment this out if not using I/O lib - cleans up open files */
    _CLOSEALL();
#endif

    /* BCH - 01/16/2013 */
    /* Infinite loop is intended here. */    
    while(1) /* PRQA S 2740 */
    {
        /* Infinite loop. Put a breakpoint here if you want to catch an exit of main(). */
    }
}
Beispiel #9
0
int main(int argc, char *argv[]) 
{
	// Setup SDL
	if(SDL_setup() != 0)
		return -1;

	// Command line arguments
	char *ram_file 		= 0;
	char binary 		= 0;
	char little_endian	= 0;
	char debug_mode 	= 0;
	char enable_profiling 	= 0;
	
	// Parse the arguments
	for(int c = 1; c < argc; c++) {
		if(strcmp(argv[c], "-d") == 0) {
			debug_mode = 1;
		} else if(strcmp(argv[c], "-bl") == 0) {
			binary = 1;
			little_endian = 1;
		} else if(strcmp(argv[c], "-bb") == 0) {
			binary = 1;
			little_endian = 0;
		} else if(strcmp(argv[c], "-p") == 0) {
			enable_profiling = 1;
		} else {
			ram_file = argv[c];
		}
	}

	// Make sure the user specified a RAM file
	if(ram_file) {
		// Prepare the emulator
		if(emulator_setup(ram_file, binary, little_endian, enable_profiling) != 0)
			return -1;
	} else {
		PRINTF("No RAM file specified.\n");
		return 0;
	}
	
	// Setup hardware
	hardware_setup();

	// Start the emulator thread
	pthread_create(&emulator_thread, 0, (void *) &emulator_thread_func, (void *) &debug_mode);

	// SDL event loop
	while(running) {
		sdl_handle_events();
		sdl_render();
	}

	// Wait for the emulator thread to finish
	running = 0;
	pthread_join(emulator_thread, 0);

	// Cleanup
	hardware_release();

	// Quit SDL
	SDL_Quit();

	return 0;
}