Esempio n. 1
0
/* Main ----------------------------------------------------------------------*/
int main(void)
{
	SystemInit();
	prvHardwareInit();

	vTraceInitTraceData();

	c_common_usart_puts(USART2, "Programa iniciado!\n\r");
	vTraceConsoleMessage("Starting application...");

	//sprintf(str, "Line, %d \n\r", __LINE__);
	//c_common_usart_puts(USART2, str);

	if (! uiTraceStart() )
		vTraceConsoleMessage("Could not start recorder!");

	/* create tasks */
	xTaskCreate(blink_led_task, (signed char *)"Blink led", configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY+1, NULL);
  xTaskCreate(sonar_task, (signed char *)"Sonar task", configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY+1, NULL);
	//xTaskCreate(echo_task, (signed char *)"Echo task", configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY+1, NULL);
	//xTaskCreate(blctrl_task,  (signed char *)"blctrl task" , configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY+1, NULL);
	//xTaskCreate(uart_task	  , (signed char *)"UART task", configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY+1, NULL);
	//xTaskCreate(rc_servo_task , (signed char *)"Servo task", configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY+1, NULL);

	/* Start the scheduler. */
	vTaskStartScheduler();

	/* should never reach here! */
	for(;;);
}
Esempio n. 2
0
/*******************************************************************************
 * vTracePortSave
 *
 * Saves the trace to a file on a local file system. The path is set in a 
 * separate function, vTracePortSetOutFile, since the Win32 port calls 
 * vTracePortSave in vTracePortEnd if WIN32_PORT_SAVE_WHEN_STOPPED is set.
 ******************************************************************************/
void vTracePortSave()
{
    char buf[180];
    FILE* f;

    if (prvFileName == NULL)
    {
        prvFileName = "FreeRTOSPlusTrace.dump";
        sprintf(buf, "No filename specified, using default \"%s\".", prvFileName);
        vTraceConsoleMessage(buf);
    }

    fopen_s(&f, prvFileName, "wb");
    if (f)
    {
        fwrite(RecorderDataPtr, sizeof(RecorderDataType), 1, f);
        fclose(f);
        sprintf(buf, "\n\r[FreeRTOS+Trace] Saved in: %s\n\r", prvFileName);
        vTraceConsoleMessage(buf);
    }
    else
    {
        sprintf(buf, "\n\r[FreeRTOS+Trace] Failed to write to output file!\n\r");
        vTraceConsoleMessage(buf);
    }
}
Esempio n. 3
0
File: main.cpp Progetto: 0x00f/stm32
/**
 * TASK 3: Toggle LED via Inter-Process Communication (IPC)
 *
 */
void ToggleLED_IPC(void *pvParameters) {
  
  int sig;
  portBASE_TYPE status;
  
  while (1) {
    status = xQueueReceive(pbq, &sig, portMAX_DELAY); /* Receive Message */
    												  /* portMAX_DELAY blocks task indefinitely if queue is empty */
    if(status == pdTRUE) {
      myled2 = myled2 ^ 1;
      vTraceConsoleMessage("Toggle PB LED");
    }
  }
}
Esempio n. 4
0
/*******************************************************************************
 * vTracePortEnd
 * 
 * This function is called by the monitor when a recorder stop is detected.
 * This is used by the Win32 port to store the trace to a file. The file path is
 * set using vTracePortSetOutFile.
 ******************************************************************************/
void vTracePortEnd()
{
    vTraceConsoleMessage("\n\r[FreeRTOS+Trace] Running vTracePortEnd.\n\r");

    #if (WIN32_PORT_SAVE_WHEN_STOPPED == 1)
    vTracePortSave();
    #endif

    #if (WIN32_PORT_EXIT_WHEN_STOPPED == 1)
    /* In the FreeRTOS/Win32 demo, this allows for killing the application 
    when the recorder is stopped (e.g., when the buffer is full) */
    system("pause");
    exit(0);
    #endif
}
Esempio n. 5
0
File: main.cpp Progetto: 0x00f/stm32
/**
 * TASK 1: Toggle LED via RTOS Timer
 */
void ToggleLED_Timer(void *pvParameters){
  
  while (1) {
    vTraceConsoleMessage("Toogle LED");
    myled1 = myled1 ^ 1;
    
    /*
    Delay for a period of time. vTaskDelay() places the task into
    the Blocked state until the period has expired.
    The delay period is spacified in 'ticks'. We can convert
    yhis in milisecond with the constant portTICK_RATE_MS.
    */
    vTaskDelay(1500 / portTICK_RATE_MS);
  }
}
Esempio n. 6
0
File: main.cpp Progetto: 0x00f/stm32
/**
 * TASK 2: Detect Button Press
 * 			And Signal Event via Inter-Process Communication (IPC)
 */
void DetectButtonPress(void *pvParameters){
  
  int sig = 1;
  
  while (1) {
    /* Detect Button Press  */

    if(pb > 0) {
      while(pb > 0)
        vTaskDelay(100 / portTICK_RATE_MS); /* Button Debounce Delay 100 ms */
      while(pb == 0)
        vTaskDelay(100 / portTICK_RATE_MS); /* Button Debounce Delay 100 ms */
      
      vTraceConsoleMessage("PB Event Detected");
      xQueueSendToBack(pbq, &sig, 0); /* Send Message */
    }
  }
}
Esempio n. 7
0
File: main.cpp Progetto: 0x00f/stm32
int main(void)
{
  vTraceInitTraceData ();
  if (!uiTraceStart())
  	vTraceConsoleMessage("Could not start recorder!");

  /* Create IPC variables */
  pbq = xQueueCreate(10, sizeof(int));
  if (pbq == 0) {
    while(1); /* fatal error */
  }
  
  /* Create tasks */
  xTaskCreate(
		  ToggleLED_Timer,                 /* Function pointer */
		  "Task1",                          /* Task name - for debugging only*/
		  configMINIMAL_STACK_SIZE,         /* Stack depth in words */
		  (void*) NULL,                     /* Pointer to tasks arguments (parameter) */
		  tskIDLE_PRIORITY + 2UL,           /* Task priority*/
		  NULL                              /* Task handle */
  );
  
  xTaskCreate(
		  DetectButtonPress,
		  "Task2",
		  configMINIMAL_STACK_SIZE,
		  (void*) NULL,
		  tskIDLE_PRIORITY + 2UL,
		  NULL);

  xTaskCreate(
		  ToggleLED_IPC,
		  "Task3",
		  configMINIMAL_STACK_SIZE,
		  (void*) NULL,
		  tskIDLE_PRIORITY + 2UL,
		  NULL);
  
  /* Start the RTOS Scheduler */
  vTaskStartScheduler();
  
  /* HALT */
  while(1); 
}