1/** 2 * \brief this file contains the error specifications of the USB 3 */ 4 5/* 6 * Copyright (c) 2007-2013 ETH Zurich. 7 * All rights reserved. 8 * 9 * This file is distributed under the terms in the attached LICENSE file. 10 * If you do not find this file, copies can be found by writing to: 11 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 12 */ 13 14#include <usb/usb_error.h> 15 16/** 17 * USB error code to string translation table 18 */ 19static const char* usb_errstr_table[USB_ERR_MAX] = { 20 [USB_ERR_OK] = "USB_ERR_NORMAL_COMPLETION", 21 [USB_ERR_PENDING_REQUESTS] = "USB_ERR_PENDING_REQUESTS", 22 [USB_ERR_NOT_STARTED] = "USB_ERR_NOT_STARTED", 23 [USB_ERR_INVAL] = "USB_ERR_INVAL", 24 [USB_ERR_NOMEM] = "USB_ERR_NOMEM", 25 [USB_ERR_CANCELLED] = "USB_ERR_CANCELLED", 26 [USB_ERR_BAD_ADDRESS] = "USB_ERR_BAD_ADDRESS", 27 [USB_ERR_BAD_BUFSIZE] = "USB_ERR_BAD_BUFSIZE", 28 [USB_ERR_BAD_FLAG] = "USB_ERR_BAD_FLAG", 29 [USB_ERR_NO_CALLBACK] = "USB_ERR_NO_CALLBACK", 30 [USB_ERR_IN_USE] = "USB_ERR_IN_USE", 31 [USB_ERR_NO_ADDR] = "USB_ERR_NO_ADDR", 32 [USB_ERR_NO_PIPE] = "USB_ERR_NO_PIPE", 33 [USB_ERR_ZERO_NFRAMES] = "USB_ERR_ZERO_NFRAMES", 34 [USB_ERR_ZERO_MAXP] = "USB_ERR_ZERO_MAXP", 35 [USB_ERR_SET_ADDR_FAILED] = "USB_ERR_SET_ADDR_FAILED", 36 [USB_ERR_NO_POWER] = "USB_ERR_NO_POWER", 37 [USB_ERR_TOO_DEEP] = "USB_ERR_TOO_DEEP", 38 [USB_ERR_IOERROR] = "USB_ERR_IOERROR", 39 [USB_ERR_NOT_CONFIGURED] = "USB_ERR_NOT_CONFIGURED", 40 [USB_ERR_TIMEOUT] = "USB_ERR_TIMEOUT", 41 [USB_ERR_SHORT_XFER] = "USB_ERR_SHORT_XFER", 42 [USB_ERR_STALLED] = "USB_ERR_STALLED", 43 [USB_ERR_INTERRUPTED] = "USB_ERR_INTERRUPTED", 44 [USB_ERR_DMA_LOAD_FAILED] = "USB_ERR_DMA_LOAD_FAILED", 45 [USB_ERR_BAD_CONTEXT] = "USB_ERR_BAD_CONTEXT", 46 [USB_ERR_NO_ROOT_HUB] = "USB_ERR_NO_ROOT_HUB", 47 [USB_ERR_NO_INTR_THREAD] = "USB_ERR_NO_INTR_THREAD", 48 [USB_ERR_NOT_LOCKED] = "USB_ERR_NOT_LOCKED", 49 [USB_ERR_BAD_REQUEST] = "USB_ERR_BAD_REQUEST", 50}; 51 52 53/** 54 * \brief translates the error code to an error string 55 * 56 * \param errno the error code to translate 57 * 58 * \return char array containint the error string. 59 */ 60const char* usb_get_error_string(usb_error_t errno) 61{ 62 if (errno > USB_ERR_MAX) { 63 return ("USB_ERROR_UNKNOWN"); 64 } else { 65 return (usb_errstr_table[errno]); 66 } 67} 68