/**@brief Function for application main entry. */ int main(void) { uint32_t err_code; bool erase_bonds; // Initialize. timers_init(); buttons_leds_init(&erase_bonds); ble_stack_init(); device_manager_init(erase_bonds); gap_params_init(); advertising_init(); services_init(); sensor_simulator_init(); conn_params_init(); ble_evt_pool = osPoolCreate(osPool(ble_evt_pool)); ble_stack_msg_box = osMessageCreate(osMessageQ(ble_stack_msg_box), NULL); // Start execution. ble_stack_thread_id = osThreadCreate(osThread(ble_stack_thread), NULL); UNUSED_VARIABLE(ble_stack_thread_id); application_timers_start(); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;; ) { UNUSED_VARIABLE(osDelay(1000)); } }
/**************************************************************************//** * @brief * Main function is a CMSIS RTOS thread in itself * * @note * This example uses threads, memory pool and message queue to demonstrate the * usage of these CMSIS RTOS features. In this simple example, the same * functionality could more easily be achieved by doing everything in the main * loop. *****************************************************************************/ int main(void) { int count = 0; /* Chip errata */ CHIP_Init(); /* Initialize CMSIS RTOS structures */ /* create memory pool */ mpool = osPoolCreate(osPool(mpool)); /* create msg queue */ msgBox = osMessageCreate(osMessageQ(msgBox), NULL); /* create thread 1 */ osThreadCreate(osThread(PrintLcdThread), NULL); /* Infinite loop */ while (1) { count = (count + 1) & 0xF; /* Send message to PrintLcdThread */ /* Allocate memory for the message */ lcdText_t *mptr = osPoolAlloc(mpool); /* Set the message content */ (*mptr)[0] = count >= 10 ? '1' : '0'; (*mptr)[1] = count % 10 + '0'; (*mptr)[2] = '\0'; /* Send message */ osMessagePut(msgBox, (uint32_t) mptr, osWaitForever); /* Wait now for half a second */ osDelay(500); } }
/**@brief Function for application main entry. */ int main(void) { uint32_t err_code; // Initialize. ble_stack_init(); timers_init(); APP_GPIOTE_INIT(1); err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code); device_manager_init(); gap_params_init(); advertising_init(); services_init(); sensor_simulator_init(); conn_params_init(); ble_evt_pool = osPoolCreate(osPool(ble_evt_pool)); ble_stack_msg_box = osMessageCreate(osMessageQ(ble_stack_msg_box), NULL); // Start execution. ble_stack_thread_id = osThreadCreate(osThread(ble_stack_thread), NULL); UNUSED_VARIABLE(ble_stack_thread_id); application_timers_start(); advertising_start(); // Enter main loop. for (;; ) { UNUSED_VARIABLE(osDelay(1000)); } }
/*---------------------------------------------------------------------------- * Main: *---------------------------------------------------------------------------*/ int main (void) { /* program execution starts here */ mpool = osPoolCreate(osPool(mpool)); /* create memory pool */ MsgBox = osMessageCreate(osMessageQ(MsgBox), NULL); /* create msg queue */ tid_thread1 = osThreadCreate(osThread(send_thread), NULL); tid_thread2 = osThreadCreate(osThread(recv_thread), NULL); osDelay(osWaitForever); for (;;); }
void tskEthernetManager(void const * argument) { uint8_t preLinkStatus; uint8_t curLinkStatus; int8_t ret; sockMutexId = osMutexCreate(osMutex(sockMutex)); spiMutexId = osMutexCreate(osMutex(spiMutex)); NetMemPoolId = osPoolCreate(osPool(NetMemPool)); #if NETINFO_NTP_USE osThreadDef(ntptask, tskNTP, osPriorityBelowNormal, 0, 512); tskNTPId = osThreadCreate(osThread(ntptask), NULL); #endif //NETINFO_NTP_USE wizSystemInit(); #if WIZSYSTEM_DEBUG printf("TASK: Ethernet manager start.\r\n"); #endif while(1) { osDelay(1000);// Every sec curLinkStatus = isLinked(); if(preLinkStatus != curLinkStatus) { preLinkStatus = curLinkStatus; if(curLinkStatus) { leaseTime = 0; } else { #if WIZSYSTEM_DEBUG printf("Ethernet Unliked. W5500 Reinitialize.\r\n"); wizSystemInit(); //W5500 initialize #endif } } if(NetInfo.dhcp == NETINFO_DHCP && DHCPLeasedTime+leaseTime < time(NULL)) { ret = DHCPTimeOut(NETINFO_DHCP_TIMEOUT); if(ret == DHCP_IP_LEASED) { DHCPLeasedTime = time(NULL); return; } else { leaseTime = 0; } } } }
/**************************************************************************//** * @brief * Main function is a CMSIS RTOS thread in itself * * @note * This example uses threads, memory pool and message queue to demonstrate the * usage of these CMSIS RTOS features. In this simple example, the same * functionality could more easily be achieved by doing everything in the main * loop. *****************************************************************************/ int main(void) { int count = 0; /* Chip errata */ CHIP_Init(); /* If first word of user data page is non-zero, enable eA Profiler trace */ BSP_TraceProfilerSetup(); #if 0 /* Reduce power consumption by disabling part of RAM */ /* this requires changing linker script to avoid placing */ /* data in RAM above 32kB. Blocks 1,2,3 are turn off. */ EMU_MemPwrDown(_EMU_MEMCTRL_POWERDOWN_BLK123); BURTC->POWERDOWN |= BURTC_POWERDOWN_RAM; /* turn BURTC RAM off */ LESENSE->POWERDOWN |= LESENSE_POWERDOWN_RAM; /* turn off LESENSE RAM */ #endif /* Initialize CMSIS RTOS structures */ /* create memory pool */ mpool = osPoolCreate(osPool(mpool)); /* create msg queue */ msgBox = osMessageCreate(osMessageQ(msgBox), NULL); /* create thread 1 */ osThreadCreate(osThread(PrintLcdThread), NULL); /* Infinite loop */ while (1) { count = (count + 1) & 0xF; /* Send message to PrintLcdThread */ /* Allocate memory for the message */ lcdText_t *mptr = osPoolAlloc(mpool); /* Set the message content */ (*mptr)[0] = count >= 10 ? '1' : '0'; (*mptr)[1] = count % 10 + '0'; (*mptr)[2] = '\0'; /* Send message */ osMessagePut(msgBox, (uint32_t) mptr, osWaitForever); /* Wait now for half a second */ osDelay(500); } }
/**************************************************************************//** * @brief * Main function is a CMSIS RTOS thread in itself * * @note * This example uses threads, memory pool and message queue to demonstrate the * usage of these CMSIS RTOS features. In this simple example, the same * functionality could more easily be achieved by doing everything in the main * loop. *****************************************************************************/ int main(void) { int count = 0; /* Chip errata */ CHIP_Init(); /* If first word of user data page is non-zero, enable eA Profiler trace */ BSP_TraceProfilerSetup(); /* Initialize LED driver */ BSP_LedsInit(); /* Initialize the LCD driver */ SegmentLCD_Init(false); /* Initialize CMSIS RTOS structures */ /* create memory pool */ mpool = osPoolCreate(osPool(mpool)); /* create msg queue */ msgBox = osMessageCreate(osMessageQ(msgBox), NULL); /* create thread 1 */ osThreadCreate(osThread(PrintLcdThread), NULL); /* Infinite loop */ while (1) { count = (count+1)&0xF; BSP_LedsSet(count); /* Send message to PrintLcdThread */ /* Allocate memory for the message */ lcdText_t *mptr = osPoolAlloc(mpool); /* Set the message content */ (*mptr)[0] = count>=10 ? '1' : '0'; (*mptr)[1] = count%10 + '0'; (*mptr)[2] = '\0'; /* Send message */ osMessagePut(msgBox, (uint32_t)mptr, osWaitForever); /* Wait now for half a second */ osDelay(500); } }
// Initialize command processing. void commandInit(void) { // Initialize the message and memory pool for command processing. commandMemPool = osPoolCreate(osPool(commandMemPool)); commandQueue = osMessageCreate(osMessageQ(commandQueue), NULL); }
// creates the memory pool and the message queues void create_mem_pool_and_msg_queues(void){ mem_pool = osPoolCreate(osPool(mem_pool)); pitch_queue = osMessageCreate(osMessageQ(pitch_queue), NULL); temp_queue = osMessageCreate(osMessageQ(temp_queue), NULL); keypad_queue = osMessageCreate(osMessageQ(keypad_queue), NULL); }
// == Function Definitions == int main(void) { /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_USART1_UART_Init(); MX_USART2_UART_Init(); // Initialise global flags globalFlags.states.commState = COMM_STATE_AUTO; globalFlags.states.wifiState = GEN_STATE_READY; // Default to busy until initialised globalFlags.procedures.wifiProcedures = WIFI_PROC_NONE; /* USER CODE BEGIN RTOS_MUTEX */ /* add mutexes, ... */ /* USER CODE END RTOS_MUTEX */ /* USER CODE BEGIN RTOS_SEMAPHORES */ /* add semaphores, ... */ /* USER CODE END RTOS_SEMAPHORES */ /* USER CODE BEGIN RTOS_TIMERS */ /* start timers, add new ones, ... */ /* USER CODE END RTOS_TIMERS */ /* Create the thread(s) */ osThreadDef(bossTask, StartBossTask, osPriorityNormal, 0, 128); bossTaskHandle = osThreadCreate(osThread(bossTask), NULL); osThreadDef(USARTInTask, StartUSARTInTask, osPriorityNormal, 0, 128); USARTInTaskHandle = osThreadCreate(osThread(USARTInTask), NULL); osThreadDef(USARTOutTask, StartUSARTOutTask, osPriorityNormal, 0, 128); USARTOutTaskHandle = osThreadCreate(osThread(USARTOutTask), NULL); /* USER CODE BEGIN RTOS_QUEUES */ // Generic messaging and string message memory pools genericMPool = osPoolCreate(osPool(genericMPool)); strBufMPool = osPoolCreate(osPool(strBufMPool)); // USART In Task String Queue msgQUSARTIn = osMessageCreate(osMessageQ(msgQUSARTIn), NULL); // USART Out Task Queue msgQUSARTOut = osMessageCreate(osMessageQ(msgQUSARTOut), NULL); // Boss Task Queue msgQBoss = osMessageCreate(osMessageQ(msgQBoss), NULL); /* USER CODE END RTOS_QUEUES */ /* Start scheduler */ osKernelStart(); /* We should never get here as control is now taken by the scheduler */ /* Infinite loop */ while (1) { __asm("nop"); } }