예제 #1
0
wiced_result_t wiced_rtos_is_current_thread( wiced_thread_t* thread )
{
    if ( tx_thread_identify( ) == &thread->handle )
    {
        return WICED_SUCCESS;
    }
    else
    {
        return WICED_ERROR;
    }
}
예제 #2
0
/*FUNCTION*----------------------------------------------------------------
*
* Function Name    : DriveWriteSector
* Returned Value   : SUCCESS or ERROR
*   - SUCCESS
*   - ERROR_DDI_LDL_LDRIVE_INVALID_DRIVE_NUMBER
*   - ERROR_DDI_LDL_LDRIVE_NOT_INITIALIZED
*   - Others possible from drive type's WriteSector API
* Comments         :
*   Writes a sector of a logical drive.
*
*END*--------------------------------------------------------------------*/
RtStatus_t DriveWriteSector
(
    /* [IN] Unique tag for the drive to operate on. */
    DriveTag_t tag, 

    /* [IN] Sector to write; 0-based at the start of the drive. */
    uint32_t u32SectorNumber, 

    /* [IN] Pointer to buffer of sector data to write. */
    const SECTOR_BUFFER * pSectorData
)
{ /* Body */
    /* Get drive depending on its tag */
    LogicalDrive * drive = DriveGetDriveFromTag(tag);
    
    if (!drive)
    {
        return ERROR_DDI_LDL_LDRIVE_INVALID_DRIVE_NUMBER;
    }
    else if (!drive->isInitialized())
    {
        return ERROR_DDI_LDL_LDRIVE_NOT_INITIALIZED;
    } /* Endif */
    
#if defined(USE_NAND_STACK) && defined(NO_SDRAM)
    if (drive->getMedia()->getPhysicalType() != kMediaTypeMMC)
    {
        static RtStatus_t s_RetValue;
        TX_THREAD *pCurrentThread;
        
        tx_mutex_get(&g_NANDThreadSafeMutex, TX_WAIT_FOREVER);
        pCurrentThread = tx_thread_identify();
        if (pCurrentThread != NULL)
        {
            os_thi_SaveStackContext(&g_NewNandStackContext, pCurrentThread, &g_OldNandStackContext, 40);
        }

        s_RetValue = drive->writeSector(u32SectorNumber, pSectorData);
        
        if (pCurrentThread != NULL)
        {
            os_thi_RestoreStackContext(&g_OldNandStackContext, pCurrentThread);
        }
        tx_mutex_put(&g_NANDThreadSafeMutex);

        return s_RetValue;
    } /* Endif */
#endif /* Defined(USE_NAND_STACK) && defined(NO_SDRAM) */

    return drive->writeSector(u32SectorNumber, pSectorData);
} /* Endbody */
예제 #3
0
/*FUNCTION*----------------------------------------------------------------
*
* Function Name    : DriveFlush
* Returned Value   : SUCCESS of ERROR
*   - SUCCESS
*   - ERROR_DDI_LDL_LDRIVE_INVALID_DRIVE_NUMBER
*   - ERROR_DDI_LDL_LDRIVE_NOT_INITIALIZED
*   - ERROR_DDI_LDL_LMEDIA_MEDIA_NOT_INITIALIZED
*   - MMC_DATA_DRIVE_ERROR_WRITE_SECTOR_FAIL
*   - ERROR_DDI_LDL_LDRIVE_HARDWARE_FAILURE
* Comments         :
*   Flush the logical drive number's contents from RAM to physical media.
*
*END*--------------------------------------------------------------------*/
RtStatus_t DriveFlush
(
    /* [IN] Unique tag for the drive to operate on. */
    DriveTag_t tag
)
{ /* Body */
    /* Get drive object */
    LogicalDrive * drive = DriveGetDriveFromTag(tag);
    
    if (!drive)
    {
        return ERROR_DDI_LDL_LDRIVE_INVALID_DRIVE_NUMBER;
    }
    else if (!drive->isInitialized() )
    {
        return ERROR_DDI_LDL_LDRIVE_NOT_INITIALIZED;
    } /* Endif */

#if (defined(USE_NAND_STACK) && defined(NO_SDRAM))
    if (drive->getMedia()->getPhysicalType() != kMediaTypeMMC)
    {
        static RtStatus_t s_RetValue;
        TX_THREAD *pCurrentThread;
        
        tx_mutex_get(&g_NANDThreadSafeMutex, TX_WAIT_FOREVER);
        pCurrentThread=tx_thread_identify();
        if (pCurrentThread != NULL)
        {
            os_thi_SaveStackContext(&g_NewNandStackContext, pCurrentThread, &g_OldNandStackContext, 40);
        } /* Endif */

        s_RetValue = drive->flush();

        if (pCurrentThread != NULL)
        {
            os_thi_RestoreStackContext(&g_OldNandStackContext, pCurrentThread);
        } /* Endif */
        tx_mutex_put(&g_NANDThreadSafeMutex);
        
        return s_RetValue;
    } /* Endif */
#endif

    /* Flush */
    return drive->flush();
} /* Endbody */