int main( void ) { const uint32_t ulLongTime_ms = 250UL; /* Create a mutex that is used to guard against the console being accessed by more than one task simultaniously. */ xConsoleMutex = xSemaphoreCreateMutex(); /* Initialise the network interface. Tasks that use the network are created in the network event hook when the network is connected and ready for use. The address values passed in here are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be contacted. */ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); /* Register commands with the FreeRTOS+CLI command interpreter. */ vRegisterCLICommands(); /* Start the RTOS scheduler. */ vTaskStartScheduler(); /* If all is well, the scheduler will now be running, and the following line will never be reached. If the following line does execute, then there was insufficient FreeRTOS heap memory available for the idle and/or timer tasks to be created. See the memory management section on the FreeRTOS web site for more details (this is standard text that is not not really applicable to the Win32 simulator port). */ for( ;; ) { Sleep( ulLongTime_ms ); } }
int main( void ) { /* The examples assume that all priority bits are assigned as preemption priority bits. */ NVIC_SetPriorityGrouping( 0UL ); /* Start the timers that demonstrate FreeRTOS software timers and basic GPIO functionality. */ vGPIOSoftwareTimersStart(); /* Start the tasks that implements the command console on the UART, as described above. */ vUARTCommandConsoleStart(); /* Start the task that demonstrates the SSP port being used in SPI mode to write to the 7 segment display. */ vSPIWriteTaskStart(); /* Start the task that uses an I2C peripheral to communicate with the OLED and the EEPROM. */ vI2CTaskStart(); /* Register two command line commands to show task stats and run time stats respectively. */ vRegisterCLICommands(); /* Start the FreeRTOS scheduler. */ vTaskStartScheduler(); /* The following line should never execute. If it does, it means there was insufficient FreeRTOS heap memory available to create the Idle and/or timer tasks. See the memory management section on the http://www.FreeRTOS.org web site for more information. */ for( ;; ); }
int main( void ) { const uint32_t ulLongTime_ms = 250UL; /* Initialise the trace recorder and create the label used to post user events to the trace recording on each tick interrupt. */ vTraceInitTraceData(); xTickTraceUserEvent = xTraceOpenLabel( "tick" ); /* Create the queue used to pass messages from the queue send task to the queue receive task. */ xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) ); /* Give the queue a name for the FreeRTOS+Trace log. */ vTraceSetQueueName( xQueue, "DemoQ" ); /* Start the two tasks as described in the comments at the top of this file. */ xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */ "Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */ configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. Not actually used as a stack in the Win32 simulator port. */ NULL, /* The parameter passed to the task - not used in this example. */ mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */ NULL ); /* The task handle is not required, so NULL is passed. */ xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL ); /* Create the task that handles the CLI on a UDP port. The port number is set using the configUDP_CLI_PORT_NUMBER setting in FreeRTOSConfig.h. */ xTaskCreate( vUDPCommandInterpreterTask, "CLI", configMINIMAL_STACK_SIZE, NULL, mainUDP_CLI_TASK_PRIORITY, NULL ); /* Register commands with the FreeRTOS+CLI command interpreter. */ vRegisterCLICommands(); /* Start the tasks and timer running. */ vTaskStartScheduler(); /* If all is well, the scheduler will now be running, and the following line will never be reached. If the following line does execute, then there was insufficient FreeRTOS heap memory available for the idle and/or timer tasks to be created. See the memory management section on the FreeRTOS web site for more details (this is standard text that is not not really applicable to the Win32 simulator port). */ for( ;; ) { Sleep( ulLongTime_ms ); } }
int main( void ) { /* Prepare the trace recorder library. */ #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 vTraceInitTraceData(); #endif /* The examples assume that all priority bits are assigned as preemption priority bits. */ NVIC_SetPriorityGrouping( 0UL ); /* Start the timer that just toggles an LED to show the demo is running. */ vLEDsInitialise(); /* Start the tasks that implements the command console on the UART, as described above. */ vCDCCommandConsoleStart( mainCDC_COMMAND_CONSOLE_STACK_SIZE, mainCDC_COMMAND_CONSOLE_TASK_PRIORITY ); /* Register CLI commands. */ vRegisterCLICommands(); /* Initialise the network interface. Tasks that use the network are created in the network event hook when the network is connected and ready for use. The address values passed in here are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be contacted. */ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); /* If the trace recorder code is included... */ #if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 { extern xQueueHandle xNetworkEventQueue; /* Name the queue for viewing in FreeRTOS+Trace. */ vTraceSetQueueName( xNetworkEventQueue, "IPStackEvent" ); } #endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 */ /* Start the FreeRTOS scheduler. */ vTaskStartScheduler(); /* The following line should never execute. If it does, it means there was insufficient FreeRTOS heap memory available to create the Idle and/or timer tasks. See the memory management section on the http://www.FreeRTOS.org web site for more information. */ for( ;; ); }
/* Init FreeRTOS */ void MX_FREERTOS_Init(void) { /* Create a defaultTask */ xTaskCreate(StartDefaultTask, (const char *) "DefaultTask", configMINIMAL_STACK_SIZE, NULL, osPriorityNormal, &defaultTaskHandle); /* Create tasks for module ports */ xTaskCreate(PxTask, (const char *) "P1Task", configMINIMAL_STACK_SIZE, (void *) P1, osPriorityNormal, &P1TaskHandle); xTaskCreate(PxTask, (const char *) "P2Task", configMINIMAL_STACK_SIZE, (void *) P2, osPriorityNormal, &P2TaskHandle); xTaskCreate(PxTask, (const char *) "P3Task", configMINIMAL_STACK_SIZE, (void *) P3, osPriorityNormal, &P3TaskHandle); xTaskCreate(PxTask, (const char *) "P4Task", configMINIMAL_STACK_SIZE, (void *) P4, osPriorityNormal, &P4TaskHandle); xTaskCreate(PxTask, (const char *) "P5Task", configMINIMAL_STACK_SIZE, (void *) P5, osPriorityNormal, &P5TaskHandle); #if (HO01R1 || HO02R0 || HO01R2 || HO02R1 || HO01R3 || HO02R2) xTaskCreate(PxTask, (const char *) "P6Task", configMINIMAL_STACK_SIZE, (void *) P6, osPriorityNormal, &P6TaskHandle); #endif /* Create the front-end task */ xTaskCreate(FrontEndTask, (const char *) "FrontEndTask", configMINIMAL_STACK_SIZE, NULL, osPriorityAboveNormal, &FrontEndTaskHandle); /* Create the motor continuous rotation task */ // xTaskCreate(ContRotationTask, (const char *) "ContRotationTask", configMINIMAL_STACK_SIZE, NULL, osPriorityAboveNormal, &ContRotationHandle); /* Create semaphores to protect module ports (FreeRTOS vSemaphoreCreateBinary didn't work) */ osSemaphoreDef(SemaphoreP1); PxSemaphoreHandle[P1] = osSemaphoreCreate(osSemaphore(SemaphoreP1), 1); osSemaphoreDef(SemaphoreP2); PxSemaphoreHandle[P2] = osSemaphoreCreate(osSemaphore(SemaphoreP2), 1); osSemaphoreDef(SemaphoreP3); PxSemaphoreHandle[P3] = osSemaphoreCreate(osSemaphore(SemaphoreP3), 1); osSemaphoreDef(SemaphoreP4); PxSemaphoreHandle[P4] = osSemaphoreCreate(osSemaphore(SemaphoreP4), 1); osSemaphoreDef(SemaphoreP5); PxSemaphoreHandle[P5] = osSemaphoreCreate(osSemaphore(SemaphoreP5), 1); #if (HO01R1 || HO02R0 || HO01R2 || HO02R1 || HO01R3 || HO02R2) osSemaphoreDef(SemaphoreP6); PxSemaphoreHandle[P6] = osSemaphoreCreate(osSemaphore(SemaphoreP6), 1); #endif /* Register command line commands */ vRegisterCLICommands(); /* Start the tasks that implements the command console on the UART */ vUARTCommandConsoleStart(); }
void create_usb_cdc_cli_task(uint16_t stack_depth_words, unsigned portBASE_TYPE task_priority) { /* Register the default CLI commands. */ vRegisterCLICommands(); /* Create the semaphore used to signal the arrival of new data. */ vSemaphoreCreateBinary(cdc_new_data_semaphore); configASSERT(cdc_new_data_semaphore); /* Create the semaphore used to access the CDC port as it is written to from more than one task. */ access_mutex = xSemaphoreCreateMutex(); configASSERT(access_mutex); /* Create the USART CLI task. */ xTaskCreate( usb_cdc_command_console_task, /* The task that implements the command console. */ (const int8_t *const) "CDC_CLI", /* Text name assigned to the task. This is just to assist debugging. The kernel does not use this name itself. */ stack_depth_words, /* The size of the stack allocated to the task. */ NULL, /* The parameter is not used. */ task_priority, /* The priority allocated to the task. */ NULL); /* Used to store the handle to the created task - in this case the handle is not required. */ }
static portTASK_FUNCTION( vComRxTask, pvParameters ) { signed char cExpectedByte, cByteRxed; portBASE_TYPE xResyncRequired = pdFALSE, xErrorOccurred = pdFALSE; portBASE_TYPE xGotChar; int ch, mm=0; char s[30]; /* Just to stop compiler warnings. */ ( void ) pvParameters; vTaskDelay(1); //vSerialPutString(xPort, "mulakan\r\n", 9); init_banner(); //set_env_default(); baca_konfig_rom(); // hardware/iap.c //load_data_rtc(); cmd_shell(); st_hw.init++; #ifdef PAKAI_RTC //init_RTC_sh(); start_uptime(); #endif #ifdef PAKAI_SDCARD st_hw.sdc = 0; //disk_initialize(SDC); disk_initialize(0); set_fs_mount(); cek_fs_free(); //mount_disk(0); // 0: SDCARD //uprintf("Cek Memori SDCARD: ..."); //cek_free_cluster(); st_hw.sdc = 1; #endif #ifdef configUSE_IDLE_HOOK st_hw.init++; #endif do { vTaskDelay(100); } while (st_hw.init != uxTaskGetNumberOfTasks()); //vTaskDelay(100); #ifdef PAKAI_SDCARD //uprintf("Cek Memori SDCARD: ..."); //cek_free_cluster(); #endif vTaskDelay(100); sprintf(s, "%s$ ", PROMPT); #ifdef PAKAI_FREERTOS_CLI // gak jadi pake FreeRTOS-CLI uprintf(s); vRegisterCLICommands(); for(;;) { //uprintf("Merdeka!!!\r\n"); //vSerialPutString(xPort, "tes\r\n", 5); xGotChar = xSerialGetChar( xPort, &ch, 10 ); if( xGotChar == pdTRUE ) { //if( xSerialGetChar( xPort, &ch, comRX_BLOCK_TIME ) ) { // comRX_BLOCK_TIME = 0xffff //tinysh_char_in((unsigned char) ch); toogle_led_utama(); if ((uchr) ch=='\r') { sprintf(s, "\r\n%s$ ", PROMPT); uprintf(s); } } vTaskDelay(10); } #endif #ifdef PAKAI_TINYSH tinysh_set_prompt(s); tinysh_char_in('\r'); vTaskDelay(500); for( ;; ) { //vTaskDelay(10); //printf("testing\r\n"); xGotChar = xSerialGetChar( xPort, &ch, 10 ); if( xGotChar == pdTRUE ) { tinysh_char_in((unsigned char) ch); toogle_led_utama(); } if (st_hw.mm>=120) { // cron tiap 1 menit //if (st_hw.mm >= 10) { // cron tiap 10detik //if (st_hw.mm>=2) { // cron tiap 1 detik st_hw.mm = 0; st_hw.uuwaktu++; #ifdef PAKAI_FILE_SIMPAN simpan_file_data(); #endif } qrprintf(0); } #endif for( ;; ) { vTaskDelay(10); } }