- /*****************************************************************************
- File name : getertxt.c
- Description : Get error descriptions from error code
- COPYRIGHT (C) STMicroelectronics 2004.
- *****************************************************************************/
- /* Includes --------------------------------------------------------------- */
- #include "stddefs.h"
- #include "stdio.h"
- #include "stpio.h"
- #include "stflash.h"
- #include "stuart.h"
- /* Private Types ------------------------------------------------------ */
- /* Private Constants -------------------------------------------------- */
- /* Private Variables -------------------------------------------------- */
- static char *wts_Unrecognised = "*** wts_Unrecognised return code ***";
- /* Private Macros ----------------------------------------------------- */
- /* Private Function prototypes ---------------------------------------- */
- /* Functions ---------------------------------------------------------- */
- /*-------------------------------------------------------------------------
- * Function : wts_GeneralError
- * Return general error descriptions
- * Input : Error Code
- * Output :
- * Return : pointer to error description
- * ----------------------------------------------------------------------*/
- static char *wts_GeneralError( ST_ErrorCode_t Error )
- {
- switch( Error )
- {
- case ST_NO_ERROR:
- return("Ok");
- case ST_ERROR_BAD_PARAMETER:
- return("BAD_PARAMETER - Parameter(s) invalid");
- case ST_ERROR_NO_MEMORY:
- return("NO_MEMORY - Memory allocation failed");
- case ST_ERROR_UNKNOWN_DEVICE:
- return("UNKNOWN_DEVICE - Init call must precede access");
- case ST_ERROR_ALREADY_INITIALIZED:
- return("ALREADY_INITIALIZED - already initialised");
- case ST_ERROR_NO_FREE_HANDLES:
- return("NO_FREE_HANDLES - Channel already Open");
- case ST_ERROR_OPEN_HANDLE:
- return("OPEN_HANDLE - Handle(s) open on Termination");
- case ST_ERROR_INVALID_HANDLE:
- return("INVALID_HANDLE - Handle number not recognized");
- case ST_ERROR_FEATURE_NOT_SUPPORTED:
- return("FEATURE_NOT_SUPPORTED - Feature not supported");
- case ST_ERROR_INTERRUPT_INSTALL:
- return("INTERRUPT_INSTALL");
- case ST_ERROR_INTERRUPT_UNINSTALL:
- return("INTERRUPT_UNINSTALL");
- case ST_ERROR_TIMEOUT:
- return("TIMEOUT - Operation has timed out");
- case ST_ERROR_DEVICE_BUSY:
- return("DEVICE_BUSY - Device unable to satisfy request");
- default:
- break;
- }
- return wts_Unrecognised;
- }
- /*-------------------------------------------------------------------------
- * Function : wts_FLASHError
- * Return STFLASH error descriptions
- * Input : Error Code
- * Output :
- * Return : pointer to error description
- * ----------------------------------------------------------------------*/
- static char *wts_FLASHError( ST_ErrorCode_t Error )
- {
- #ifdef __STFLASH_H
- switch( Error )
- {
- case STFLASH_ERROR_WRITE:
- return("STFLASH_ERROR_WRITE - Error writing FLASH");
- case STFLASH_ERROR_ERASE:
- return("STFLASH_ERROR_ERASE - Error erasing FLASH");
- case STFLASH_ERROR_VPP_LOW:
- return("STFLASH_ERROR_VPP_LOW - Vpp Low Error");
- default:
- break;
- }
- #endif
- return wts_Unrecognised;
- }
- /*-------------------------------------------------------------------------
- * Function : wts_PIOError
- * Return STPIO error descriptions
- * Input : Error Code
- * Output :
- * Return : pointer to error description
- * ----------------------------------------------------------------------*/
- static char *wts_PIOError( ST_ErrorCode_t Error )
- {
- #ifdef __STPIO_H
- /* no API specific error codes */
- #endif
- return wts_Unrecognised;
- }
- /*-------------------------------------------------------------------------
- * Function : wts_UARTError
- * Return STUART error descriptions
- * Input : Error Code
- * Output :
- * Return : pointer to error description
- * ----------------------------------------------------------------------*/
- static char *wts_UARTError( ST_ErrorCode_t Error )
- {
- #ifdef __STUART_H
- switch( Error )
- {
- case STUART_ERROR_OVERRUN:
- return("STUART_ERROR_OVERRUN - read buffer overrun");
- case STUART_ERROR_PARITY:
- return("STUART_ERROR_PARITY - parity error has occurred");
- case STUART_ERROR_FRAMING:
- return("STUART_ERROR_FRAMING - framing error has occurred");
- case STUART_ERROR_ABORT:
- return("STUART_ERROR_ABORT - operation aborted");
- case STUART_ERROR_RETRIES:
- return("STUART_ERROR_RETRIES - error retrying transmit");
- case STUART_ERROR_PIO:
- return("STUART_ERROR_PIO - error calling PIO command");
- default:
- break;
- }
- #endif
- return wts_Unrecognised;
- }
- /*-------------------------------------------------------------------------
- * Function : wts_GetErrorText
- * Return error descriptions
- * Input : Error Code
- * Output :
- * Return : pointer to error description
- * ----------------------------------------------------------------------*/
- char *wts_GetErrorText( ST_ErrorCode_t Error )
- {
- int Driver_Id;
- char *ErrorTxt_p;
- static char ErrorText[128];
- Driver_Id = Error >> 16;
- switch( Driver_Id )
- {
- case STFLASH_DRIVER_ID: /* DVD-API-004 */
- ErrorTxt_p = wts_FLASHError( Error );
- break;
- case STPIO_DRIVER_ID: /* DVD-API-068 */
- ErrorTxt_p = wts_PIOError( Error );
- break;
- case STUART_DRIVER_ID: /* DVD-API-022 */
- ErrorTxt_p = wts_UARTError( Error );
- break;
- default:
- ErrorTxt_p = wts_GeneralError( Error );
- break;
- }
- if ( Error != 0 )
- {
- sprintf( ErrorText, "%s (0x%08x)", ErrorTxt_p, Error );
- }
- else
- {
- sprintf( ErrorText, "%s", ErrorTxt_p );
- }
- return ErrorText;
- }
- /* EOF --------------------------------------------------------------------- */