Esempio n. 1
0
File: mutex.c Progetto: tve/esp-idf
void osi_mutex_global_deinit(void)
{
    vSemaphoreDelete(gl_mutex);
}
Esempio n. 2
0
/** Delete a semaphore
 * @param mutex the mutex to delete */
void sys_mutex_free(sys_mutex_t *pxMutex)
{
    SYS_STATS_DEC(mutex.used);
    vSemaphoreDelete(*pxMutex);
    *pxMutex = NULL;
}
Esempio n. 3
0
// Deallocates a semaphore
void
sys_sem_free(sys_sem_t *sem)
{
  vSemaphoreDelete(*sem);
}
DSTATUS USB_HostMsdInitializeDisk(BYTE pdrv)
{
    uint32_t address;

    if (s_CommandSemaphore == NULL)
    {
        s_CommandSemaphore = xSemaphoreCreateCounting(0x01U, 0x00U);
    }
    else
    {
        vSemaphoreDelete(s_CommandSemaphore);
        s_CommandSemaphore = xSemaphoreCreateCounting(0x01U, 0x00U);
    }
    if (NULL == s_CommandSemaphore)
    {
        return RES_ERROR;
    }

    /* test unit ready */
    if (g_UsbFatfsClassHandle == NULL)
    {
        return RES_ERROR;
    }
    if (USB_HostMsdTestUnitReady(g_UsbFatfsClassHandle, 0, USB_HostMsdUfiCallback, NULL) != kStatus_USB_Success)
    {
        return STA_NOINIT;
    }
    if (pdTRUE != xSemaphoreTake(s_CommandSemaphore, portMAX_DELAY)) /* wait the command */
    {
        return RES_ERROR;
    }

    /*request sense */
    if (g_UsbFatfsClassHandle == NULL)
    {
        return RES_ERROR;
    }
    if (USB_HostMsdRequestSense(g_UsbFatfsClassHandle, 0, s_UsbMsdBuffer, sizeof(usb_host_ufi_sense_data_t),
                                USB_HostMsdUfiCallback, NULL) != kStatus_USB_Success)
    {
        return STA_NOINIT;
    }
    if (pdTRUE != xSemaphoreTake(s_CommandSemaphore, portMAX_DELAY)) /* wait the command */
    {
        return RES_ERROR;
    }

    /* get the sector size */
    if (g_UsbFatfsClassHandle == NULL)
    {
        return RES_ERROR;
    }
    if (USB_HostMsdReadCapacity(g_UsbFatfsClassHandle, 0, s_UsbMsdBuffer, sizeof(usb_host_ufi_read_capacity_t),
                                USB_HostMsdUfiCallback, NULL) != kStatus_USB_Success)
    {
        return STA_NOINIT;
    }
    else
    {
        if (pdTRUE != xSemaphoreTake(s_CommandSemaphore, portMAX_DELAY)) /* wait the command */
        {
            return RES_ERROR;
        }
        if (ufiStatus == kStatus_USB_Success)
        {
            address = (uint32_t)&s_UsbMsdBuffer[0];
            address = (uint32_t)((usb_host_ufi_read_capacity_t *)(address))->blockLengthInBytes;
            s_FatfsSectorSize = USB_LONG_FROM_BIG_ENDIAN_ADDRESS(((uint8_t *)address));
        }
        else
        {
            s_FatfsSectorSize = 512;
        }
    }

    return 0x00;
}
Esempio n. 5
0
modem_dte_t *esp_modem_dte_init(const esp_modem_dte_config_t *config)
{
    esp_err_t res;
    /* malloc memory for esp_dte object */
    esp_modem_dte_t *esp_dte = calloc(1, sizeof(esp_modem_dte_t));
    MODEM_CHECK(esp_dte, "calloc esp_dte failed", err_dte_mem);
    /* malloc memory to storing lines from modem dce */
    esp_dte->buffer = calloc(1, ESP_MODEM_LINE_BUFFER_SIZE);
    MODEM_CHECK(esp_dte->buffer, "calloc line memory failed", err_line_mem);
    /* Set attributes */
    esp_dte->uart_port = config->port_num;
    esp_dte->parent.flow_ctrl = config->flow_control;
    /* Bind methods */
    esp_dte->parent.send_cmd = esp_modem_dte_send_cmd;
    esp_dte->parent.send_data = esp_modem_dte_send_data;
    esp_dte->parent.send_wait = esp_modem_dte_send_wait;
    esp_dte->parent.change_mode = esp_modem_dte_change_mode;
    esp_dte->parent.process_cmd_done = esp_modem_dte_process_cmd_done;
    esp_dte->parent.deinit = esp_modem_dte_deinit;
    /* Config UART */
    uart_config_t uart_config = {
        .baud_rate = config->baud_rate,
        .data_bits = config->data_bits,
        .parity = config->parity,
        .stop_bits = config->stop_bits,
        .flow_ctrl = (config->flow_control == MODEM_FLOW_CONTROL_HW) ? UART_HW_FLOWCTRL_CTS_RTS : UART_HW_FLOWCTRL_DISABLE
    };
    MODEM_CHECK(uart_param_config(esp_dte->uart_port, &uart_config) == ESP_OK, "config uart parameter failed", err_uart_config);
    if (config->flow_control == MODEM_FLOW_CONTROL_HW) {
        res = uart_set_pin(esp_dte->uart_port, CONFIG_MODEM_TX_PIN, CONFIG_MODEM_RX_PIN,
                           CONFIG_MODEM_RTS_PIN, CONFIG_MODEM_CTS_PIN);
    } else {
        res = uart_set_pin(esp_dte->uart_port, CONFIG_MODEM_TX_PIN, CONFIG_MODEM_RX_PIN,
                           UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
    }
    MODEM_CHECK(res == ESP_OK, "config uart gpio failed", err_uart_config);
    /* Set flow control threshold */
    if (config->flow_control == MODEM_FLOW_CONTROL_HW) {
        res = uart_set_hw_flow_ctrl(esp_dte->uart_port, UART_HW_FLOWCTRL_CTS_RTS, UART_FIFO_LEN - 8);
    } else if (config->flow_control == MODEM_FLOW_CONTROL_SW) {
        res = uart_set_sw_flow_ctrl(esp_dte->uart_port, true, 8, UART_FIFO_LEN - 8);
    }
    MODEM_CHECK(res == ESP_OK, "config uart flow control failed", err_uart_config);
    /* Install UART driver and get event queue used inside driver */
    res = uart_driver_install(esp_dte->uart_port, CONFIG_UART_RX_BUFFER_SIZE, CONFIG_UART_TX_BUFFER_SIZE,
                              CONFIG_UART_EVENT_QUEUE_SIZE, &(esp_dte->event_queue), 0);
    MODEM_CHECK(res == ESP_OK, "install uart driver failed", err_uart_config);
    /* Set pattern interrupt, used to detect the end of a line. */
    res = uart_enable_pattern_det_intr(esp_dte->uart_port, '\n', 1, MIN_PATTERN_INTERVAL, MIN_POST_IDLE, MIN_PRE_IDLE);
    /* Set pattern queue size */
    res |= uart_pattern_queue_reset(esp_dte->uart_port, CONFIG_UART_PATTERN_QUEUE_SIZE);
    MODEM_CHECK(res == ESP_OK, "config uart pattern failed", err_uart_pattern);
    /* Create Event loop */
    esp_event_loop_args_t loop_args = {
        .queue_size = ESP_MODEM_EVENT_QUEUE_SIZE,
        .task_name = NULL
    };
    MODEM_CHECK(esp_event_loop_create(&loop_args, &esp_dte->event_loop_hdl) == ESP_OK, "create event loop failed", err_eloop);
    /* Create semaphore */
    esp_dte->process_sem = xSemaphoreCreateBinary();
    MODEM_CHECK(esp_dte->process_sem, "create process semaphore failed", err_sem);
    /* Create UART Event task */
    BaseType_t ret = xTaskCreate(uart_event_task_entry,             //Task Entry
                                 "uart_event",                      //Task Name
                                 CONFIG_UART_EVENT_TASK_STACK_SIZE, //Task Stack Size(Bytes)
                                 esp_dte,                           //Task Parameter
                                 CONFIG_UART_EVENT_TASK_PRIORITY,   //Task Priority
                                 & (esp_dte->uart_event_task_hdl)   //Task Handler
                                );
    MODEM_CHECK(ret == pdTRUE, "create uart event task failed", err_tsk_create);
    return &(esp_dte->parent);
    /* Error handling */
err_tsk_create:
    vSemaphoreDelete(esp_dte->process_sem);
err_sem:
    esp_event_loop_delete(esp_dte->event_loop_hdl);
err_eloop:
    uart_disable_pattern_det_intr(esp_dte->uart_port);
err_uart_pattern:
    uart_driver_delete(esp_dte->uart_port);
err_uart_config:
    free(esp_dte->buffer);
err_line_mem:
    free(esp_dte);
err_dte_mem:
    return NULL;
}

esp_err_t esp_modem_add_event_handler(modem_dte_t *dte, esp_event_handler_t handler, void *handler_args)
{
    esp_modem_dte_t *esp_dte = __containerof(dte, esp_modem_dte_t, parent);
    return esp_event_handler_register_with(esp_dte->event_loop_hdl, ESP_MODEM_EVENT, ESP_EVENT_ANY_ID, handler, handler_args);
}
Esempio n. 6
0
/**
* @brief Delete a Semaphore
* @param  semaphore_id  semaphore object referenced with \ref osSemaphore.
* @retval  status code that indicates the execution status of the function.
* @note   MUST REMAIN UNCHANGED: \b osSemaphoreDelete shall be consistent in every CMSIS-RTOS.
*/
osStatus osSemaphoreDelete (osSemaphoreId semaphore_id)
{
  vSemaphoreDelete(semaphore_id);  
  
  return osOK;
}
Esempio n. 7
0
/*!
	\brief 	This function deletes a locking object.

	\param	pLockObj	-	pointer to the locking object control block

	\return upon successful deletion the function should return 0
			Otherwise, a negative value indicating the error code shall be returned
	\note
	\warning
*/
OsiReturnVal_e _osi_LockObjDelete(OsiLockObj_t* pLockObj)
{
    vSemaphoreDelete((SemaphoreHandle_t)*pLockObj );
    return OSI_OK;
}
static void USB_HostMsdCommandTest(usb_host_msd_command_instance_t *msdCommandInstance)
{
    usb_status_t status;
    uint32_t blockSize = 512;
    uint8_t maxLunNumber;
    uint32_t address;
    
    if (msdCommandInstance->commandSemaphore == NULL)
    {
        msdCommandInstance->commandSemaphore = xSemaphoreCreateCounting(0x01U, 0x00U);
    }
    else
    {
        vSemaphoreDelete(msdCommandInstance->commandSemaphore);
        msdCommandInstance->commandSemaphore = xSemaphoreCreateCounting(0x01U, 0x00U);
    }
    if (NULL == msdCommandInstance->commandSemaphore)
    {
        usb_echo("create semaphore fail\r\n");
        return;
    }

    usb_echo("........................test start....................\r\n");

    usb_echo("get max logical units....");
    status = USB_HostMsdGetMaxLun(msdCommandInstance->classHandle, &maxLunNumber, USB_HostMsdUfiCallback,
                                  msdCommandInstance);
    if (status != kStatus_USB_Success)
    {
        usb_echo("error\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (pdTRUE != xSemaphoreTake(msdCommandInstance->commandSemaphore, portMAX_DELAY)) /* wait the command */
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (ufiStatus == kStatus_USB_Success) /* print the command result */
    {
        usb_echo("success, logical units: %d\r\n", maxLunNumber);
    }
    else
    {
        usb_echo("fail\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }

    if (msdCommandInstance->deviceState != kStatus_DEV_Attached)
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    usb_echo("test unit ready....");
    status = USB_HostMsdTestUnitReady(msdCommandInstance->classHandle, 0, USB_HostMsdUfiCallback, msdCommandInstance);
    if (status != kStatus_USB_Success)
    {
        usb_echo("error\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (pdTRUE != xSemaphoreTake(msdCommandInstance->commandSemaphore, portMAX_DELAY)) /* wait the command */
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if ((ufiStatus == kStatus_USB_Success) || (ufiStatus == kStatus_USB_MSDStatusFail)) /* print the command result */
    {
        usb_echo("success, unit status: %s\r\n", ufiStatus == kStatus_USB_MSDStatusFail ? "not ready" : "ready");
    }
    else
    {
        usb_echo("fail\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }

    if (msdCommandInstance->deviceState != kStatus_DEV_Attached)
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    usb_echo("request sense....");
    status = USB_HostMsdRequestSense(msdCommandInstance->classHandle, 0, msdCommandInstance->testUfiBuffer,
                                     sizeof(usb_host_ufi_sense_data_t), USB_HostMsdUfiCallback, msdCommandInstance);
    if (status != kStatus_USB_Success)
    {
        usb_echo("error\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (pdTRUE != xSemaphoreTake(msdCommandInstance->commandSemaphore, portMAX_DELAY)) /* wait the command */
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (ufiStatus == kStatus_USB_Success) /* print the command result */
    {
        usb_echo("success\r\n");
    }
    else
    {
        usb_echo("fail\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }

    if (msdCommandInstance->deviceState != kStatus_DEV_Attached)
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    usb_echo("inquiry...");
    status = USB_HostMsdInquiry(msdCommandInstance->classHandle, 0, msdCommandInstance->testUfiBuffer,
                                sizeof(usb_host_ufi_inquiry_data_t), USB_HostMsdUfiCallback, msdCommandInstance);
    if (status != kStatus_USB_Success)
    {
        usb_echo("error\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (pdTRUE != xSemaphoreTake(msdCommandInstance->commandSemaphore, portMAX_DELAY)) /* wait the command */
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (ufiStatus == kStatus_USB_Success) /* print the command result */
    {
        usb_echo("success\r\n");
    }
    else
    {
        usb_echo("fail\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }

    if (msdCommandInstance->deviceState != kStatus_DEV_Attached)
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    usb_echo("read capacity...");
    status = USB_HostMsdReadCapacity(msdCommandInstance->classHandle, 0, msdCommandInstance->testUfiBuffer,
                                     sizeof(usb_host_ufi_read_capacity_t), USB_HostMsdUfiCallback, msdCommandInstance);
    if (status != kStatus_USB_Success)
    {
        usb_echo("error\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (pdTRUE != xSemaphoreTake(msdCommandInstance->commandSemaphore, portMAX_DELAY)) /* wait the command */
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (ufiStatus == kStatus_USB_Success) /* print the command result */
    {
        address = (uint32_t) & (msdCommandInstance->testUfiBuffer[0]);
        address = (uint32_t)((usb_host_ufi_read_capacity_t *)(address))->blockLengthInBytes;
        blockSize = USB_LONG_FROM_BIG_ENDIAN_ADDRESS(((uint8_t *)address));
        address = (uint32_t) & (msdCommandInstance->testUfiBuffer[0]);
        address = (uint32_t)((usb_host_ufi_read_capacity_t *)(address))->lastLogicalBlockAddress;
        usb_echo("success, last logical block:%d block length:%d\r\n",
                 USB_LONG_FROM_BIG_ENDIAN_ADDRESS(((uint8_t *)address)), blockSize);
    }
    else
    {
        usb_echo("fail\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }

    if (msdCommandInstance->deviceState != kStatus_DEV_Attached)
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (blockSize == 0)
    {
        blockSize = 512;
    }
    usb_echo("read(10)...");
    status = USB_HostMsdRead10(msdCommandInstance->classHandle, 0, 0, msdCommandInstance->testUfiBuffer, blockSize, 1,
                               USB_HostMsdUfiCallback, msdCommandInstance);
    if (status != kStatus_USB_Success)
    {
        usb_echo("error\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (pdTRUE != xSemaphoreTake(msdCommandInstance->commandSemaphore, portMAX_DELAY)) /* wait the command */
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (ufiStatus == kStatus_USB_Success) /* print the command result */
    {
        usb_echo("success\r\n");
    }
    else
    {
        usb_echo("fail\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }

    if (msdCommandInstance->deviceState != kStatus_DEV_Attached)
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    usb_echo("write(10)...");
    status = USB_HostMsdWrite10(msdCommandInstance->classHandle, 0, 0, msdCommandInstance->testUfiBuffer, blockSize, 1,
                                USB_HostMsdUfiCallback, msdCommandInstance);
    if (status != kStatus_USB_Success)
    {
        usb_echo("error\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (pdTRUE != xSemaphoreTake(msdCommandInstance->commandSemaphore, portMAX_DELAY)) /* wait the command */
    {
        msd_command_test_done(msdCommandInstance);
        return;
    }
    if (ufiStatus == kStatus_USB_Success) /* print the command result */
    {
        usb_echo("success\r\n");
    }
    else
    {
        usb_echo("fail\r\n");
        msd_command_test_done(msdCommandInstance);
        return;
    }

#if MSD_THROUGHPUT_TEST_ENABLE
    uint64_t totalTime;
    uint32_t testSize;
    uint32_t blockAddress;
    uint8_t testIndex;

    /* time delay (~100ms) */
    for (testSize = 0; testSize < 400000; ++testSize)
    {
        __ASM("nop");
    }

    CoreDebug->DEMCR |= (1 << CoreDebug_DEMCR_TRCENA_Pos);

    for (testSize = 0; testSize < (THROUGHPUT_BUFFER_SIZE / 4); ++testSize)
    {
        testThroughputBuffer[testSize] = testSize;
    }

    usb_echo("throughput test:\r\n");
    for (testIndex = 0; testIndex < (sizeof(testSizeArray) / 4); ++testIndex)
    {
        totalTime = 0;
        blockAddress = 0;
        testSize = testSizeArray[testIndex] * 1024;
        while (testSize)
        {
            if (msdCommandInstance->deviceState != kStatus_DEV_Attached)
            {
                msd_command_test_done(msdCommandInstance);
                return;
            }
            DWT->CYCCNT = 0;
            DWT->CTRL |= (1 << DWT_CTRL_CYCCNTENA_Pos);
            status =
                USB_HostMsdWrite10(msdCommandInstance->classHandle, 0, blockAddress,
                                   (uint8_t *)&testThroughputBuffer[0], THROUGHPUT_BUFFER_SIZE,
                                   (THROUGHPUT_BUFFER_SIZE / blockSize), USB_HostMsdUfiCallback, msdCommandInstance);
            if (status != kStatus_USB_Success)
            {
                usb_echo("    error\r\n");
                msd_command_test_done(msdCommandInstance);
                return;
            }
            if (pdTRUE != xSemaphoreTake(msdCommandInstance->commandSemaphore, portMAX_DELAY)) /* wait the command */
            {
                msd_command_test_done(msdCommandInstance);
                return;
            }
            totalTime += DWT->CYCCNT;
            DWT->CTRL &= ~(1U << DWT_CTRL_CYCCNTENA_Pos);
            if (ufiStatus != kStatus_USB_Success)
            {
                usb_echo("fail\r\n");
                msd_command_test_done(msdCommandInstance);
                return;
            }
            testSize -= THROUGHPUT_BUFFER_SIZE;
            blockAddress += (THROUGHPUT_BUFFER_SIZE / blockSize);
        }
        testSize = testSizeArray[testIndex];
        usb_echo("    write %dKB data the speed is %d KB/s\r\n", testSize,
                 (uint32_t)((uint64_t)testSize * (uint64_t)MCU_CORE_CLOCK / (uint64_t)totalTime));

        totalTime = 0;
        blockAddress = 0;
        testSize = testSizeArray[testIndex] * 1024;
        while (testSize)
        {
            if (msdCommandInstance->deviceState != kStatus_DEV_Attached)
            {
                msd_command_test_done(msdCommandInstance);
                return;
            }
            DWT->CYCCNT = 0;
            DWT->CTRL |= (1 << DWT_CTRL_CYCCNTENA_Pos);
            status =
                USB_HostMsdRead10(msdCommandInstance->classHandle, 0, blockAddress, (uint8_t *)&testThroughputBuffer[0],
                                  THROUGHPUT_BUFFER_SIZE, (THROUGHPUT_BUFFER_SIZE / blockSize), USB_HostMsdUfiCallback,
                                  msdCommandInstance);
            if (status != kStatus_USB_Success)
            {
                usb_echo("    error\r\n");
                msd_command_test_done(msdCommandInstance);
                return;
            }
            if (pdTRUE != xSemaphoreTake(msdCommandInstance->commandSemaphore, portMAX_DELAY)) /* wait the command */
            {
                msd_command_test_done(msdCommandInstance);
                return;
            }
            totalTime += DWT->CYCCNT;
            DWT->CTRL &= ~(1U << DWT_CTRL_CYCCNTENA_Pos);
            if (ufiStatus != kStatus_USB_Success)
            {
                usb_echo("fail\r\n");
                msd_command_test_done(msdCommandInstance);
                return;
            }
            testSize -= THROUGHPUT_BUFFER_SIZE;
            blockAddress += (THROUGHPUT_BUFFER_SIZE / blockSize);
        }
        testSize = testSizeArray[testIndex];
        usb_echo("    read %dKB data the speed is %d KB/s\r\n", testSize,
                 (uint32_t)((uint64_t)testSize * (uint64_t)MCU_CORE_CLOCK / (uint64_t)totalTime));
    }
#endif /* MSD_THROUGHPUT_TEST_ENABLE */

    msd_command_test_done(msdCommandInstance); /* all test are done */
}
int os_semaphore_destroy(os_semaphore_t semaphore)
{
    vSemaphoreDelete(semaphore);
    return 0;
}
Esempio n. 10
0
/*!
	\brief 	This function deletes a sync object

	\param	pSyncObj	-	pointer to the sync object control block

	\return upon successful deletion the function should return 0
			Otherwise, a negative value indicating the error code shall be returned
	\note
	\warning
*/
OsiReturnVal_e osi_SyncObjDelete(OsiSyncObj_t* pSyncObj)
{
    vSemaphoreDelete(*pSyncObj );
    return OSI_OK;
}
int os_mutex_recursive_destroy(os_mutex_recursive_t mutex)
{
    vSemaphoreDelete(mutex);
    return 0;
}
int os_mutex_destroy(os_mutex_t mutex)
{
    vSemaphoreDelete(mutex);
    return 0;
}
 ~Lock() {
     vSemaphoreDelete(semaphore);
 }
Esempio n. 14
0
/*---------------------------------------------------------------------------*
 * Routine:  sys_sem_free
 *---------------------------------------------------------------------------*
 * Description:
 *      Deallocates a semaphore
 * Inputs:
 *      sys_sem_t sem           -- Semaphore to free
 *---------------------------------------------------------------------------*/
void sys_sem_free(sys_sem_t *pxSemaphore)
{
    SYS_STATS_DEC(sem.used);
    vSemaphoreDelete(*pxSemaphore);
    *pxSemaphore = NULL;
}
Esempio n. 15
0
static void esp_apptrace_test(esp_apptrace_test_cfg_t *test_cfg)
{
    int i, k;
    int tims_in_use[TIMER_GROUP_MAX][TIMER_MAX] = {{0, 0}, {0, 0}};
    esp_apptrace_test_task_arg_t dummy_task_arg[1];

    memset(dummy_task_arg, 0, sizeof(dummy_task_arg));
    dummy_task_arg[0].core = 0;
    dummy_task_arg[0].prio = 3;
    dummy_task_arg[0].task_func = esp_apptrace_test_task_crash;
    dummy_task_arg[0].data.buf = NULL;
    dummy_task_arg[0].data.buf_sz = 0;
    dummy_task_arg[0].data.period = 500000;
    dummy_task_arg[0].timers_num = 0;
    dummy_task_arg[0].timers = NULL;
#if ESP_APPTRACE_TEST_USE_PRINT_LOCK == 1
    s_print_lock = xSemaphoreCreateBinary();
    if (!s_print_lock) {
        ets_printf("%s: Failed to create print lock!", TAG);
        return;
    }
    xSemaphoreGive(s_print_lock);
#else
#endif

    for (i = 0; i < test_cfg->tasks_num; i++) {
        test_cfg->tasks[i].data.mask = 0xFF;
        test_cfg->tasks[i].stop = 0;
        test_cfg->tasks[i].done = xSemaphoreCreateBinary();
        if (!test_cfg->tasks[i].done) {
            ESP_APPTRACE_TEST_LOGE("Failed to create task completion semaphore!");
            goto on_fail;
        }
        for (k = 0; k < test_cfg->tasks[i].timers_num; k++) {
            test_cfg->tasks[i].timers[k].data.mask = 0xFF;
            tims_in_use[test_cfg->tasks[i].timers[k].group][test_cfg->tasks[i].timers[k].id] = 1;
        }
    }

    int found = 0;
    for (i = 0; i < TIMER_GROUP_MAX; i++) {
        for (k = 0; k < TIMER_MAX; k++) {
            if (!tims_in_use[i][k]) {
                ESP_APPTRACE_TEST_LOGD("Found timer%d.%d", i, k);
                found = 1;
                break;
            }
        }
        if (found) {
            break;
        }
    }
    if (!found) {
        ESP_APPTRACE_TEST_LOGE("No free timer for TS!");
        goto on_fail;
    }
    esp_apptrace_test_ts_init(i, k);

    for (int i = 0; i < test_cfg->tasks_num; i++) {
        char name[30];
        TaskHandle_t thnd;
        sprintf(name, "apptrace_test%d", i);
        xTaskCreatePinnedToCore(test_cfg->tasks[i].task_func, name, 2048, &test_cfg->tasks[i], test_cfg->tasks[i].prio, &thnd, test_cfg->tasks[i].core);
        ESP_APPTRACE_TEST_LOGI("Created task %x", thnd);
    }
    xTaskCreatePinnedToCore(esp_apptrace_dummy_task, "dummy0", 2048, &dummy_task_arg[0], dummy_task_arg[0].prio, NULL, 0);
#if CONFIG_FREERTOS_UNICORE == 0
    xTaskCreatePinnedToCore(esp_apptrace_dummy_task, "dummy1", 2048, &dummy_task_arg[0], dummy_task_arg[0].prio, NULL, 1);
#endif
    for (int i = 0; i < test_cfg->tasks_num; i++) {
        //arg1.stop = 1;
        xSemaphoreTake(test_cfg->tasks[i].done, portMAX_DELAY);
    }

on_fail:
    for (int i = 0; i < test_cfg->tasks_num; i++) {
        if (test_cfg->tasks[i].done) {
            vSemaphoreDelete(test_cfg->tasks[i].done);
        }
    }
    esp_apptrace_test_ts_cleanup();

#if ESP_APPTRACE_TEST_USE_PRINT_LOCK == 1
    vSemaphoreDelete(s_print_lock);
#else
#endif
}
Esempio n. 16
0
static void msd_command_test_done(usb_host_msd_command_instance_t *msdCommandInstance)
{
    vSemaphoreDelete(msdCommandInstance->commandSemaphore);
    msdCommandInstance->commandSemaphore = NULL;
    usb_echo("........................test done....................\r\n");
}
Esempio n. 17
0
void KMutexDelete( KMutex* pMutex )
{
  if( pMutex ) {
    vSemaphoreDelete( pMutex->hSem );
  }
}
Esempio n. 18
0
void AJ_MutexDelete(struct AJ_Mutex* m)
{
    vSemaphoreDelete(m->m);
}
Esempio n. 19
0
Mutex::~Mutex()
{
    vSemaphoreDelete(mutex_);
}
Esempio n. 20
0
MutexRecursive::~MutexRecursive()
{
    vSemaphoreDelete(mutex_);
}
 /*
	function : 
		销毁信号量			
	input : 
		crs_sem_handler_t *sem  
	return value : 
		success :
		fail : 	
*/
void crs_sem_destroy( crs_sem_handler_t *sem )
{
	vSemaphoreDelete(sem -> sem_cb);
}
Esempio n. 22
0
 int FreeMutex(wolfSSL_Mutex* m)
 {
     vSemaphoreDelete( *m );
     return 0;
 }
Esempio n. 23
0
 MTD_FLASHMEM Mutex::~Mutex()
 {
     vSemaphoreDelete(m_handle);
 }
Esempio n. 24
0
void BT_kMutexDestroy(void *pMutex) {
	vSemaphoreDelete(pMutex);
}
void vIOUtilsCreateTransferControlStructure( Transfer_Control_t **ppxTransferControl )
{
Transfer_Control_t *pxTransferControl = *ppxTransferControl;

	/* Does the transfer control structure already exist? */
	if( pxTransferControl == NULL )
	{
		/* The transfer control structure does not exist.  Create it. */
		*ppxTransferControl = ( Transfer_Control_t * ) pvPortMalloc( sizeof( Transfer_Control_t ) );
	}
	else
	{
		/* The transfer control structure does already exist, so there is
		no need to create it, however the state structure it points to is being
		changed, so delete the existing state structure, and anything it might
		contain. */
		switch( pxTransferControl->ucType )
		{
			case ioctlUSE_ZERO_COPY_TX :

				#if ioconfigUSE_ZERO_COPY_TX == 1
				{
					Zero_Copy_Tx_State_t *pxZeroCopyState;

					/* In this case, the pvTransferState member points to a zero
					copy state structure, which in turn contains a mutex that needs
					to be deleted. */
					pxZeroCopyState = ( Zero_Copy_Tx_State_t * ) ( pxTransferControl->pvTransferState );
					vSemaphoreDelete( pxZeroCopyState->xWriteAccessMutex );
					vPortFree( pxZeroCopyState );
				}
				#endif /* ioconfigUSE_ZERO_COPY_TX */
				break;


			case ioctlUSE_CHARACTER_QUEUE_TX	:
			case ioctlUSE_CHARACTER_QUEUE_RX	:

				#if ( ioconfigUSE_TX_CHAR_QUEUE == 1 ) || ( ioconfigUSE_RX_CHAR_QUEUE == 1 )
				{
					Character_Queue_State_t *pxCharQueueState;

					/* In this case the pvTrasactionState member points to a character
					queue state structure, which in turn contains a queue that needs
					to be deleted. */
					pxCharQueueState = ( Character_Queue_State_t * ) ( pxTransferControl->pvTransferState );
					vQueueDelete( pxCharQueueState->xQueue );
					vPortFree( pxCharQueueState );
				}
				#endif /* ( ioconfigUSE_TX_CHAR_QUEUE == 1 ) || ( ioconfigUSE_RX_CHAR_QUEUE == 1 ) */
				break;


			case ioctlUSE_CIRCULAR_BUFFER_RX	:

				#if ioconfigUSE_CIRCULAR_BUFFER_RX == 1
				{
					Circular_Buffer_Rx_State_t *pxCircularBufferState;

					/* In this case, the pvTransferState member points to a
					circular buffer structure, which in turn contains a semaphore
					and a buffer, both of which need to be deleted. */
					pxCircularBufferState = ( Circular_Buffer_Rx_State_t * ) ( pxTransferControl->pvTransferState );
					vSemaphoreDelete( pxCircularBufferState->xNewDataSemaphore );
					vPortFree( ( void * ) ( pxCircularBufferState->pucBufferStart ) );
					vPortFree( pxCircularBufferState );
				}
				#endif /* ioconfigUSE_CIRCULAR_BUFFER_RX */
				break;


			case ioctlUSE_POLLED_TX	:

				/* Default assumes no specific kernel objects are being used. */
				vPortFree( pxTransferControl->pvTransferState );
				break;


			default	:

				/* To get here a transfer structure must have existed, but
				with a valid pvTransferState member.  This can happen when a
				peripheral is being polled, and both the Tx and Rx transfer
				structures use the same state structure (for example, in an NXP
				SSP/SPI driver where data cannot be received without data also
				being transmitted).  There is nothing to do here. */
				break;
		}

		pxTransferControl->pvTransferState = NULL;
	}
}
Esempio n. 26
0
void fifo_destroy(struct fifo *fifo)
{
    if (fifo->xMutex)
        vSemaphoreDelete(fifo->xMutex);
}
Esempio n. 27
0
File: mutex.c Progetto: tve/esp-idf
/** Delete a semaphore
 * @param mutex the mutex to delete */
void osi_mutex_free(osi_mutex_t *mutex)
{
    vSemaphoreDelete(*mutex);
    *mutex = NULL;
}