static void prvTestMasterTask( void *pvParameters ) { BaseType_t xError; /* The handle to the slave task is passed in as the task parameter. */ TaskHandle_t xTestSlaveTaskHandle = ( TaskHandle_t ) pvParameters; /* Avoid compiler warnings. */ ( void ) pvParameters; /* Create the event group used by the tasks ready for the initial tests. */ xEventGroup = xEventGroupCreate(); configASSERT( xEventGroup ); /* Perform the tests that block two tasks on different combinations of bits, then set each bit in turn and check the correct tasks unblock at the correct times. */ xError = prvSelectiveBitsTestMasterFunction(); for( ;; ) { /* Recreate the event group ready for the next cycle. */ xEventGroup = xEventGroupCreate(); configASSERT( xEventGroup ); /* Perform the tests that check the behaviour when a single task is blocked on various combinations of event bits. */ xError = prvBitCombinationTestMasterFunction( xError, xTestSlaveTaskHandle ); /* Perform the task synchronisation tests. */ xError = prvPerformTaskSyncTests( xError, xTestSlaveTaskHandle ); /* Delete the event group. */ vEventGroupDelete( xEventGroup ); /* Now all the other tasks should have completed and suspended themselves ready for the next go around the loop. */ if( eTaskGetState( xTestSlaveTaskHandle ) != eSuspended ) { xError = pdTRUE; } if( eTaskGetState( xSyncTask1 ) != eSuspended ) { xError = pdTRUE; } if( eTaskGetState( xSyncTask2 ) != eSuspended ) { xError = pdTRUE; } /* Only increment the cycle variable if no errors have been detected. */ if( xError == pdFALSE ) { ulTestMasterCycles++; } configASSERT( xError == pdFALSE ); } }
dispatch_queue::dispatch_queue(std::string name, size_t thread_cnt, size_t thread_stack_size) : name_(name), threads_(thread_cnt) { // Create the Mutex mutex_ = xSemaphoreCreateRecursiveMutex(); assert(mutex_ != NULL && "Failed to create mutex!"); // Create the event flags notify_flags_ = xEventGroupCreate(); assert(notify_flags_ != NULL && "Failed to create event group!"); // Dispatch thread setup for(size_t i = 0; i < threads_.size(); i++) { // Define the name threads_[i].name = std::string("Dispatch Thread " + std::to_string(i)); // Create the thread BaseType_t status = xTaskCreate(reinterpret_cast<void(*)(void*)>( BOUNCE(dispatch_queue, dispatch_thread_handler)), threads_[i].name.c_str(), thread_stack_size, reinterpret_cast<void*>(this), DISPATCH_Q_PRIORITY, &threads_[i].thread); assert(status == pdPASS && "Failed to create thread!"); } }
/*FUNCTION********************************************************************** * * Function Name : OSA_EventCreate * Description : This function is used to create a event object. * Return : Event handle of the new event, or NULL if failed. * *END**************************************************************************/ osaEventId_t OSA_EventCreate(bool_t autoClear) { #if osNumberOfEvents osaEventId_t eventId; osEventStruct_t* pEventStruct; OSA_InterruptDisable(); eventId = pEventStruct = osObjectAlloc(&osEventInfo); OSA_InterruptEnable(); if(eventId == NULL) { return NULL; } pEventStruct->event.eventHandler = xEventGroupCreate(); if (pEventStruct->event.eventHandler) { pEventStruct->event.autoClear = autoClear; } else { OSA_InterruptDisable(); osObjectFree(&osEventInfo, eventId); OSA_InterruptEnable(); eventId = NULL; } return eventId; #else (void)autoClear; return NULL; #endif }
static void prvExerciseEventGroupAPI( void ) { EventGroupHandle_t xEventGroup; EventBits_t xBits; const EventBits_t xBitsToWaitFor = ( EventBits_t ) 0xff, xBitToClear = ( EventBits_t ) 0x01; /* Exercise some event group functions. */ xEventGroup = xEventGroupCreate(); configASSERT( xEventGroup ); /* No bits should be set. */ xBits = xEventGroupWaitBits( xEventGroup, xBitsToWaitFor, pdTRUE, pdFALSE, mainDONT_BLOCK ); configASSERT( xBits == ( EventBits_t ) 0 ); /* Set bits and read back to ensure the bits were set. */ xEventGroupSetBits( xEventGroup, xBitsToWaitFor ); xBits = xEventGroupGetBits( xEventGroup ); configASSERT( xBits == xBitsToWaitFor ); /* Clear a bit and read back again using a different API function. */ xEventGroupClearBits( xEventGroup, xBitToClear ); xBits = xEventGroupSync( xEventGroup, 0x00, xBitsToWaitFor, mainDONT_BLOCK ); configASSERT( xBits == ( xBitsToWaitFor & ~xBitToClear ) ); /* Finished with the event group. */ vEventGroupDelete( xEventGroup ); }
void vStartEventGroupTasks( void ) { TaskHandle_t xTestSlaveTaskHandle; /* * This file contains fairly comprehensive checks on the behaviour of event * groups. It is not intended to be a user friendly demonstration of the * event groups API. * * NOTE: The tests implemented in this file are informal 'sanity' tests * only and are not part of the module tests that make use of the * mtCOVERAGE_TEST_MARKER macro within the event groups implementation. * * Create the test tasks as described at the top of this file. */ xTaskCreate( prvTestSlaveTask, "WaitO", configMINIMAL_STACK_SIZE, NULL, ebWAIT_BIT_TASK_PRIORITY, &xTestSlaveTaskHandle ); xTaskCreate( prvTestMasterTask, "SetB", configMINIMAL_STACK_SIZE, ( void * ) xTestSlaveTaskHandle, ebSET_BIT_TASK_PRIORITY, NULL ); xTaskCreate( prvSyncTask, "Rndv", configMINIMAL_STACK_SIZE, ( void * ) ebRENDESVOUS_TASK_1_SYNC_BIT, ebWAIT_BIT_TASK_PRIORITY, &xSyncTask1 ); xTaskCreate( prvSyncTask, "Rndv", configMINIMAL_STACK_SIZE, ( void * ) ebRENDESVOUS_TASK_2_SYNC_BIT, ebWAIT_BIT_TASK_PRIORITY, &xSyncTask2 ); /* If the last task was created then the others will have been too. */ configASSERT( xSyncTask2 ); /* Create the event group used by the ISR tests. The event group used by the tasks is created by the tasks themselves. */ xISREventGroup = xEventGroupCreate(); configASSERT( xISREventGroup ); }
void vStartnRFTasks( UBaseType_t uxPriority ) { /* 创建事件以同步中断与任务*/ xEventGruop = xEventGroupCreate(); xTaskCreate( vnRFTask, "nRF", configMINIMAL_STACK_SIZE, NULL, uxPriority, ( TaskHandle_t * ) NULL ); }
/// Create a thread and add it to Active Threads and set it to state READY. /// \param[in] thread_def thread definition referenced with \ref osThread. /// \param[in] argument pointer that is passed to the thread function as start argument. /// \return thread ID for reference by other functions or NULL in case of error. /// \note MUST REMAIN UNCHANGED: \b osThreadCreate shall be consistent in every CMSIS-RTOS. osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument) { // (void) argument; xTaskHandle handle; BaseType_t result; result = xTaskCreate((pdTASK_CODE)thread_def->pthread, (const portCHAR *)thread_def->name, (thread_def->stacksize/4), argument, makeFreeRtosPriority(thread_def->tpriority), &handle); if (pdPASS == result) { #if configSignalManagementSupport EventGroupHandle_t signals; signals = xEventGroupCreate(); if (signals == NULL) { /* The event group was not created because there was insufficient FreeRTOS heap available. */ CMSIS_OS_ERR("Create a EventGroup for a new thread failed\n"); } else { add_thread_signal_map(handle, signals); } #endif } else { CMSIS_OS_ERR("Create a new thread(%s) failed\r\n", thread_def->name); } return handle; }
static bool _start_network_event_task(){ if(!_network_event_group){ _network_event_group = xEventGroupCreate(); if(!_network_event_group){ log_e("Network Event Group Create Failed!"); return false; } xEventGroupSetBits(_network_event_group, WIFI_DNS_IDLE_BIT); } if(!_network_event_queue){ _network_event_queue = xQueueCreate(32, sizeof(system_event_t *)); if(!_network_event_queue){ log_e("Network Event Queue Create Failed!"); return false; } } if(!_network_event_task_handle){ xTaskCreatePinnedToCore(_network_event_task, "network_event", 4096, NULL, ESP_TASKD_EVENT_PRIO - 1, &_network_event_task_handle, ARDUINO_RUNNING_CORE); if(!_network_event_task_handle){ log_e("Network Event Task Start Failed!"); return false; } } return esp_event_loop_init(&_network_event_cb, NULL) == ESP_OK; }
void wifi_init_softap() { ap_event_group = xEventGroupCreate(); //tcpip_adapter_init(); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); wifi_config_t wifi_config = { .ap = { .ssid = EXAMPLE_DEFAULT_SSID, .ssid_len = 0, .max_connection=EXAMPLE_MAX_STA_CONN, .password = EXAMPLE_DEFAULT_PWD, .authmode = WIFI_AUTH_WPA_WPA2_PSK }, }; if (strlen(EXAMPLE_DEFAULT_PWD) ==0) { wifi_config.ap.authmode = WIFI_AUTH_OPEN; } ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP)); ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config)); ESP_ERROR_CHECK(esp_wifi_start()); ESP_LOGI(TAG, "wifi_init_softap finished.SSID:%s password:%s \n", EXAMPLE_DEFAULT_SSID, EXAMPLE_DEFAULT_PWD); }
static void prvTestAbortingEventGroupWait( void ) { TickType_t xTimeAtStart; EventGroupHandle_t xEventGroup; EventBits_t xBitsToWaitFor = ( EventBits_t ) 0x01, xReturn; #if( configSUPPORT_STATIC_ALLOCATION == 1 ) { static StaticEventGroup_t xEventGroupBuffer; /* Create the event group. Statically allocated memory is used so the creation cannot fail. */ xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer ); } #else { xEventGroup = xEventGroupCreate(); configASSERT( xEventGroup ); } #endif /* Note the time before the delay so the length of the delay is known. */ xTimeAtStart = xTaskGetTickCount(); /* This first delay should just time out. */ xReturn = xEventGroupWaitBits( xEventGroup, xBitsToWaitFor, pdTRUE, pdTRUE, xMaxBlockTime ); if( xReturn != 0x00 ) { xErrorOccurred = pdTRUE; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); /* Note the time before the delay so the length of the delay is known. */ xTimeAtStart = xTaskGetTickCount(); /* This second delay should be aborted by the primary task half way through. */ xReturn = xEventGroupWaitBits( xEventGroup, xBitsToWaitFor, pdTRUE, pdTRUE, xMaxBlockTime ); if( xReturn != 0x00 ) { xErrorOccurred = pdTRUE; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xHalfMaxBlockTime ); /* Note the time before the delay so the length of the delay is known. */ xTimeAtStart = xTaskGetTickCount(); /* This third delay should just time out again. */ xReturn = xEventGroupWaitBits( xEventGroup, xBitsToWaitFor, pdTRUE, pdTRUE, xMaxBlockTime ); if( xReturn != 0x00 ) { xErrorOccurred = pdTRUE; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); /* Not really necessary in this case, but for completeness. */ vEventGroupDelete( xEventGroup ); }
void mcual_i2c_master_init(mcual_i2c_id_t i2c_id, uint32_t frequency_Hz) { #ifdef CONFIG_MCUAL_I2C_USE_FREERTOS tx_queues[i2c_id] = xQueueCreate(mcual_i2c_get_tx_buffer_size(i2c_id), sizeof(uint8_t)); transfer_done[i2c_id] = xEventGroupCreate(); #endif I2C_TypeDef * reg = mcual_i2c_get_register(i2c_id); mcual_clock_id_t clock = MCUAL_CLOCK_PERIPHERAL_1; switch(i2c_id) { case MCUAL_I2C1: RCC->APB1ENR |= RCC_APB1ENR_I2C1EN; clock = MCUAL_CLOCK_PERIPHERAL_1; break; case MCUAL_I2C2: RCC->APB1ENR |= RCC_APB1ENR_I2C2EN; clock = MCUAL_CLOCK_PERIPHERAL_1; break; case MCUAL_I2C3: RCC->APB1ENR |= RCC_APB1ENR_I2C3EN; clock = MCUAL_CLOCK_PERIPHERAL_1; break; } //Reset i2c reg->CR1 = I2C_CR1_SWRST; reg->CR1 = 0; uint32_t clk_Hz = mcual_clock_get_frequency_Hz(clock); (void)clk_Hz; (void)frequency_Hz; frequency_Hz = 100000U; //reg->CCR = clk_Hz / (2 * frequency_Hz); //reg->CR2 = clk_Hz / 1000000U; //reg->TRISE = clk_Hz / 1000000U + 1; reg->CCR = 50; reg->CR2 = 10; reg->TRISE = 68; reg->CR1 = I2C_CR1_PE; reg->SR1 = 0; int irq_id = mcual_i2c_get_irq_ev_id(i2c_id); NVIC->IP[irq_id] = 13 << 4; NVIC->ISER[irq_id / 32] |= (1 << (irq_id % 32)); irq_id = mcual_i2c_get_irq_err_id(i2c_id); NVIC->IP[irq_id] = 13 << 4; NVIC->ISER[irq_id / 32] |= (1 << (irq_id % 32)); }
void app_main(void) { nvs_flash_init(); g_pot_event_group = xEventGroupCreate(); g_wifi_event_group = xEventGroupCreate(); setup_variables(); setup_wifi(); setup_gpios(); printf("v3 size: %d\n", sizeof(struct uni_proto_v3)); xTaskCreate(main_loop, "main_loop", 2048, NULL, 10, NULL); xTaskCreate(wifi_loop, "wifi_loop", 2048, NULL, 10, NULL); // xTaskCreate(test_loop, "test_loop", 2048, NULL, 10, NULL); // main_loop(NULL); }
int flag_event_init(flag_event_t* event){ #if defined(OS_FREERTOS) *event = xEventGroupCreate(); return (*event) ? 0 : -1; #elif defined(OS_UCOS) OS_ERR err; OSFlagCreate(event, "", 0, &err); return (err == OS_ERR_NONE) ? 0 : -1; #endif }
static void initialise_wifi(void) { wifi_event_group = xEventGroupCreate(); ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_start()); }
EventGroupHandle_t MPU_xEventGroupCreate( void ) { EventGroupHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); xReturn = xEventGroupCreate(); vPortResetPrivilege( xRunningPrivileged ); return xReturn; }
void meca_fish_init(void) { disabled = 0; busy = xEventGroupCreate(); next_state = MECA_FISH_MANUAL; current_state = MECA_FISH_MANUAL; meca_fish_close(0); xTaskCreate(meca_fish_task, "fish", 200, NULL, 2, NULL); }
int initAioDspResource(void) { int ret = 0; ret = initAioEcgDebugResource(); xDspPktAckEventGroup = xEventGroupCreate(); do{} while (NULL == xDspPktAckEventGroup); return ret; }
void register_ethernet() { eth_event_group = xEventGroupCreate(); tcpip_adapter_init(); ESP_ERROR_CHECK(esp_event_loop_init(eth_event_handler, NULL)); eth_config_t config = DEFAULT_ETHERNET_PHY_CONFIG; config.phy_addr = CONFIG_PHY_ADDRESS; config.gpio_config = eth_gpio_config_rmii; config.tcpip_input = tcpip_adapter_eth_input; config.clock_mode = CONFIG_PHY_CLOCK_MODE; #ifdef CONFIG_PHY_USE_POWER_PIN /* Replace the default 'power enable' function with an example-specific one that toggles a power GPIO. */ config.phy_power_enable = phy_device_power_enable_via_gpio; #endif ESP_ERROR_CHECK(esp_eth_init(&config)); eth_control_args.control = arg_str1(NULL, NULL, "<start|stop|info>", "Start/Stop Ethernet or Get info of Ethernet"); eth_control_args.end = arg_end(1); const esp_console_cmd_t cmd = { .command = "ethernet", .help = "Control Ethernet interface", .hint = NULL, .func = eth_cmd_control, .argtable = ð_control_args }; ESP_ERROR_CHECK(esp_console_cmd_register(&cmd)); iperf_args.ip = arg_str0("c", "client", "<ip>", "run in client mode, connecting to <host>"); iperf_args.server = arg_lit0("s", "server", "run in server mode"); iperf_args.udp = arg_lit0("u", "udp", "use UDP rather than TCP"); iperf_args.port = arg_int0("p", "port", "<port>", "server port to listen on/connect to"); iperf_args.interval = arg_int0("i", "interval", "<interval>", "seconds between periodic bandwidth reports"); iperf_args.time = arg_int0("t", "time", "<time>", "time in seconds to transmit for (default 10 secs)"); iperf_args.abort = arg_lit0("a", "abort", "abort running iperf"); iperf_args.end = arg_end(1); const esp_console_cmd_t iperf_cmd = { .command = "iperf", .help = "iperf command", .hint = NULL, .func = ð_cmd_iperf, .argtable = &iperf_args }; ESP_ERROR_CHECK(esp_console_cmd_register(&iperf_cmd)); }
void vUSBCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority ) { /* Event group used to indicate that bytes are available in the Rx buffer or that bytes have finished sending. */ xCDCEventBits = xEventGroupCreate(); configASSERT( xCDCEventBits ); /* Create the task that handles the console itself. */ xTaskCreate( prvCDCCommandConsoleTask, /* The task that implements the command console. */ "CLI", /* Text name assigned to the task. This is just to assist debugging. The kernel does not use this name itself. */ usStackSize, /* The size of the stack allocated to the task. */ NULL, /* The parameter is not used, so NULL is passed. */ uxPriority, /* The priority allocated to the task. */ NULL ); /* A handle is not required, so just pass NULL. */ }
/** * \brief Initialize tasks and resources for demo * * This function initializes the \ref oled1_xpro_io_group instance and the * \ref edbg_cdc_rx_group instance for reception, then creates all * the objects for FreeRTOS to run the demo. */ void demotasks_init(void) { // Initialize hardware for the OLED1 Xplained Pro driver instance oled1_init(&oled1); // Configure SERCOM USART for reception from EDBG Virtual COM Port cdc_rx_init(&cdc_usart, &cdc_rx_handler); display_mutex = xSemaphoreCreateMutex(); terminal_mutex = xSemaphoreCreateMutex(); terminal_in_queue = xQueueCreate(64, sizeof(uint8_t)); event_group = xEventGroupCreate(); xTaskCreate(about_task, (const char *)"About", configMINIMAL_STACK_SIZE, NULL, ABOUT_TASK_PRIORITY, NULL); xTaskCreate(graph_task, (const char *)"Graph", configMINIMAL_STACK_SIZE, NULL, GRAPH_TASK_PRIORITY, NULL); xTaskCreate(main_task, (const char *) "Main", configMINIMAL_STACK_SIZE, NULL, MAIN_TASK_PRIORITY, NULL); xTaskCreate(terminal_task, (const char *)"Term.", configMINIMAL_STACK_SIZE, NULL, TERMINAL_TASK_PRIORITY, NULL); xTaskCreate(uart_task, (const char *) "UART", configMINIMAL_STACK_SIZE, NULL, UART_TASK_PRIORITY, NULL); }
/*FUNCTION********************************************************************** * * Function Name : OSA_EventCreate * Description : This function is used to create a event object. Return * kStatus_OSA_Success if create successfully, otherwise return kStatus_OSA_Error. * *END**************************************************************************/ osa_status_t OSA_EventCreate(event_t *pEvent, osa_event_clear_mode_t clearMode) { assert(pEvent); pEvent->eventHandler = xEventGroupCreate(); if (pEvent->eventHandler) { pEvent->clearMode = clearMode; return kStatus_OSA_Success; } else { return kStatus_OSA_Error; } }
static portTASK_FUNCTION( vnRFTask, pvParameters ) { TickType_t xRate, xLastTime; BaseType_t Event_Status = 0; /* The parameters are not used. */ ( void ) pvParameters; nRF_SPI_IO_Init(); xRate = 10; /* We need to initialise xLastFlashTime prior to the first call to vTaskDelayUntil(). */ xLastTime = xTaskGetTickCount(); for(;;) { if (xEventGruop == NULL) { xEventGruop = xEventGroupCreate(); continue; } Event_Status = xEventGroupWaitBits(xEventGruop, Key_State_Down, pdTRUE, pdFALSE, (TickType_t)1000); if (Event_Status & Key_State_Down) { nRF_Buf.datatype = DataType_Key; nRF_Buf.data[0] = Get_Key_Status(); } if (Event_Status&Key_State_Down) { if (nRF_Start_Tx() == nRF_TX_OK) { BSP_LED_Toggle(LED2); if (nRF_Start_Rx() == nRF_RX_OK) { BSP_LED_Toggle(LED3); } } Event_Status = 0; } memset(&nRF_Buf, 0, sizeof(nRF_Tx_DataType)); //vTaskDelayUntil( &xLastTime, xRate ); } } /*lint !e715 !e818 !e830 Function definition must be standard for task creation. */
/** * \brief call FreeRTOS API, create and start tasks */ int main(void) { EMBARC_PRINTF("Benchmark CPU Frequency: %d Hz\r\n", BOARD_CPU_CLOCK); EMBARC_PRINTF("Benchmark will run %d times, please wait about %d ms\r\n", MAX_SAMPLES, (TASK_DELAY_MS*MAX_SAMPLES)); // Register interrupts int_handler_install(SWI_INTNO, (EXC_HANDLER)soft_interrupt); //int_pri_set(SWI_INTNO, INT_PRI_MIN); int_enable(SWI_INTNO); exc_handler_install(EXC_NO_TRAP, trap_exception); /*!< install the exception handler */ vTaskSuspendAll(); // Create Tasks if (xTaskCreate(task1, "task1", 128, (void *)1, TSK_PRIOR_LO, &task1_handle) != pdPASS) { /*!< FreeRTOS xTaskCreate() API function */ EMBARC_PRINTF("create task1 error\r\n"); return -1; } if (xTaskCreate(task2, "task2", 128, (void *)2, TSK_PRIOR_HI, &task2_handle) != pdPASS) { /*!< FreeRTOS xTaskCreate() API function */ EMBARC_PRINTF("create task2 error\r\n"); return -1; } // Create Mutex mux1_id = xSemaphoreCreateMutex(); // Create Semaphores sem1_id = xSemaphoreCreateBinary(); xSemaphoreGive(sem1_id); // Create Events evt1_cb = xEventGroupCreate(); // Create Queues dtq1_id = xQueueCreate(1, sizeof(uint32_t)); xTaskResumeAll(); vTaskSuspend(NULL); vTaskSuspend(NULL); return 0; }
static void wifi_conn_init(void) { tcpip_adapter_init(); wifi_event_group = xEventGroupCreate(); ESP_ERROR_CHECK( esp_event_loop_init(wifi_event_handler, NULL) ); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); wifi_config_t wifi_config = { .sta = { .ssid = EXAMPLE_WIFI_SSID, .password = EXAMPLE_WIFI_PASS, }, }; ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); ESP_ERROR_CHECK( esp_wifi_start() ); }
static void initialise_wifi(void) { tcpip_adapter_init(); wifi_event_group = xEventGroupCreate(); ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); wifi_config_t wifi_config = { .sta = { .ssid = EXAMPLE_WIFI_SSID, .password = EXAMPLE_WIFI_PASS, }, }; ESP_LOGI(TAG, "Setting WiFi configuration SSID %s...", wifi_config.sta.ssid); ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); ESP_ERROR_CHECK( esp_wifi_start() ); }
void initialise_wifi(void) { esp_log_level_set("wifi", ESP_LOG_WARN); static bool initialized = false; if (initialized) { return; } tcpip_adapter_init(); wifi_event_group = xEventGroupCreate(); ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) ); ESP_ERROR_CHECK( esp_wifi_start() ); initialized = true; }
//***************************************************************************** // // Funcion main(), Inicializa los perifericos, crea las tareas, etc... y arranca el bucle del sistema // //***************************************************************************** int main(void) { //Establecemos el color del led a apagado color[0]=0x0; color[1]=0x0; color[2]=0x0; confSys(); confUART(); confGPIO(); confADC(); confQueue(); confSemaphores(); //Creamos los flags xEventGroup = xEventGroupCreate(); xEventGroupClearBits( xEventGroup, TrazaBit | PilotoAutomaticoBit ); // // Mensaje de bienvenida inicial. // UARTprintf("\n\nBienvenido a la aplicacion Simulador Vuelo (curso 2014/15)!\n"); UARTprintf("\nAutores: Anabel Ramirez y Jose Antonio Yebenes "); confTasks(); // // Arranca el scheduler. Pasamos a ejecutar las tareas que se hayan activado. // confTimer(); vTaskStartScheduler(); //el RTOS habilita las interrupciones al entrar aqui, asi que no hace falta habilitarlas //De la funcion vTaskStartScheduler no se sale nunca... a partir de aqui pasan a ejecutarse las tareas. while(1) { //Si llego aqui es que algo raro ha pasado } }
static void prvCreateAndDeleteStaticallyAllocatedEventGroups( void ) { EventGroupHandle_t xEventGroup; /* StaticEventGroup_t is a publicly accessible structure that has the same size and alignment requirements as the real event group structure. It is provided as a mechanism for applications to know the size of the event group (which is dependent on the architecture and configuration file settings) without breaking the strict data hiding policy by exposing the real event group internals. This StaticEventGroup_t variable is passed into the xSemaphoreCreateEventGroupStatic() function calls within this function. */ StaticEventGroup_t xEventGroupBuffer; /* Create the event group. xEventGroupCreateStatic() has an extra parameter than the normal xEventGroupCreate() API function. The parameter is a pointer to the StaticEventGroup_t structure that will hold the event group structure. */ xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer ); /* The event group handle should equal the static event group structure passed into the xEventGroupCreateStatic() function. */ configASSERT( xEventGroup == ( EventGroupHandle_t ) &xEventGroupBuffer ); /* Ensure the event group passes a few sanity checks as a valid event group. */ prvSanityCheckCreatedEventGroup( xEventGroup ); /* Delete the event group again so the buffers can be reused. */ vEventGroupDelete( xEventGroup ); /* Now do the same using a dynamically allocated event group to ensure the delete function is working correctly in both the static and dynamic allocation cases. */ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) { xEventGroup = xEventGroupCreate(); configASSERT( xEventGroup != NULL ); prvSanityCheckCreatedEventGroup( xEventGroup ); vEventGroupDelete( xEventGroup ); } #endif }
int Uart3Init(void) { Uart3DmaBufferInit(); UartDeviceDefaultInit(&uart3_device); uart3_device.num = UART_NUM03; uart3_device.mode = UART_DMA_MODE; uart3_device.baudrate = B230400; uart3_device.ParityType = PARITY_EVEN; //PARITY_NONE,PARITY_EVEN ,PARITY_ODD; uart3_device.IRQPriority= IRQPriority12Uart23; uart3_device.pTxDMABuffer = &uart3_tx_dma_buf; uart3_device.pRxDMABuffer = &uart3_rx_dma_buf; xSerialTxHandleLock = xSemaphoreCreateMutex(); xSerialRxHandleLock = xSemaphoreCreateMutex(); xUart3RxEventGroup = xEventGroupCreate(); do{} while ((NULL == xSerialTxHandleLock) \ ||(NULL == xSerialRxHandleLock)\ ||(NULL == xUart3RxEventGroup)); return 0; }
static void wifi_init(void) { tcpip_adapter_init(); wifi_event_group = xEventGroupCreate(); ESP_ERROR_CHECK(esp_event_loop_init(wifi_event_handler, NULL)); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); wifi_config_t wifi_config = { .sta = { .ssid = CONFIG_WIFI_SSID, .password = CONFIG_WIFI_PASSWORD, }, }; ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config)); ESP_LOGI(TAG, "start the WIFI SSID:[%s]", CONFIG_WIFI_SSID); ESP_ERROR_CHECK(esp_wifi_start()); ESP_LOGI(TAG, "Waiting for wifi"); xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, false, true, portMAX_DELAY); }