disable unnecessary prints

Dependents:   PLAUCI_full

Committer:
legwinskij
Date:
Thu Oct 22 17:16:11 2015 +0000
Revision:
0:e042bdf9c219
Child:
1:1538f5588c56
Completely refactored fw, changelog in main

Who changed what in which revision?

UserRevisionLine numberNew contents of line
legwinskij 0:e042bdf9c219 1 /*
legwinskij 0:e042bdf9c219 2 **************************************************************************************************************
legwinskij 0:e042bdf9c219 3 * NXP USB Host Stack
legwinskij 0:e042bdf9c219 4 *
legwinskij 0:e042bdf9c219 5 * (c) Copyright 2008, NXP SemiConductors
legwinskij 0:e042bdf9c219 6 * (c) Copyright 2008, OnChip Technologies LLC
legwinskij 0:e042bdf9c219 7 * All Rights Reserved
legwinskij 0:e042bdf9c219 8 *
legwinskij 0:e042bdf9c219 9 * www.nxp.com
legwinskij 0:e042bdf9c219 10 * www.onchiptech.com
legwinskij 0:e042bdf9c219 11 *
legwinskij 0:e042bdf9c219 12 * File : usbhost_lpc17xx.h
legwinskij 0:e042bdf9c219 13 * Programmer(s) : Ravikanth.P
legwinskij 0:e042bdf9c219 14 * Version :
legwinskij 0:e042bdf9c219 15 *
legwinskij 0:e042bdf9c219 16 **************************************************************************************************************
legwinskij 0:e042bdf9c219 17 */
legwinskij 0:e042bdf9c219 18
legwinskij 0:e042bdf9c219 19 #ifndef USBHOST_LPC17xx_H
legwinskij 0:e042bdf9c219 20 #define USBHOST_LPC17xx_H
legwinskij 0:e042bdf9c219 21
legwinskij 0:e042bdf9c219 22 /*
legwinskij 0:e042bdf9c219 23 **************************************************************************************************************
legwinskij 0:e042bdf9c219 24 * INCLUDE HEADER FILES
legwinskij 0:e042bdf9c219 25 **************************************************************************************************************
legwinskij 0:e042bdf9c219 26 */
legwinskij 0:e042bdf9c219 27
legwinskij 0:e042bdf9c219 28 #include "usbhost_inc.h"
legwinskij 0:e042bdf9c219 29
legwinskij 0:e042bdf9c219 30 /*
legwinskij 0:e042bdf9c219 31 **************************************************************************************************************
legwinskij 0:e042bdf9c219 32 * PRINT CONFIGURATION
legwinskij 0:e042bdf9c219 33 **************************************************************************************************************
legwinskij 0:e042bdf9c219 34 */
legwinskij 0:e042bdf9c219 35
legwinskij 0:e042bdf9c219 36 #define PRINT_ENABLE 1
legwinskij 0:e042bdf9c219 37
legwinskij 0:e042bdf9c219 38 #if PRINT_ENABLE
legwinskij 0:e042bdf9c219 39 #define PRINT_Log(...) printf(__VA_ARGS__)
legwinskij 0:e042bdf9c219 40 #define PRINT_Err(rc) printf("ERROR: In %s at Line %u - rc = %d\n", __FUNCTION__, __LINE__, rc)
legwinskij 0:e042bdf9c219 41
legwinskij 0:e042bdf9c219 42 #else
legwinskij 0:e042bdf9c219 43 #define PRINT_Log(...) do {} while(0)
legwinskij 0:e042bdf9c219 44 #define PRINT_Err(rc) do {} while(0)
legwinskij 0:e042bdf9c219 45
legwinskij 0:e042bdf9c219 46 #endif
legwinskij 0:e042bdf9c219 47
legwinskij 0:e042bdf9c219 48 /*
legwinskij 0:e042bdf9c219 49 **************************************************************************************************************
legwinskij 0:e042bdf9c219 50 * GENERAL DEFINITIONS
legwinskij 0:e042bdf9c219 51 **************************************************************************************************************
legwinskij 0:e042bdf9c219 52 */
legwinskij 0:e042bdf9c219 53
legwinskij 0:e042bdf9c219 54 #define DESC_LENGTH(x) x[0]
legwinskij 0:e042bdf9c219 55 #define DESC_TYPE(x) x[1]
legwinskij 0:e042bdf9c219 56
legwinskij 0:e042bdf9c219 57
legwinskij 0:e042bdf9c219 58 #define HOST_GET_DESCRIPTOR(descType, descIndex, data, length) \
legwinskij 0:e042bdf9c219 59 Host_CtrlRecv(USB_DEVICE_TO_HOST | USB_RECIPIENT_DEVICE, GET_DESCRIPTOR, \
legwinskij 0:e042bdf9c219 60 (descType << 8)|(descIndex), 0, length, data)
legwinskij 0:e042bdf9c219 61
legwinskij 0:e042bdf9c219 62 #define HOST_SET_ADDRESS(new_addr) \
legwinskij 0:e042bdf9c219 63 Host_CtrlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE, SET_ADDRESS, \
legwinskij 0:e042bdf9c219 64 new_addr, 0, 0, NULL)
legwinskij 0:e042bdf9c219 65
legwinskij 0:e042bdf9c219 66 #define USBH_SET_CONFIGURATION(configNum) \
legwinskij 0:e042bdf9c219 67 Host_CtrlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE, SET_CONFIGURATION, \
legwinskij 0:e042bdf9c219 68 configNum, 0, 0, NULL)
legwinskij 0:e042bdf9c219 69
legwinskij 0:e042bdf9c219 70 #define USBH_SET_INTERFACE(ifNum, altNum) \
legwinskij 0:e042bdf9c219 71 Host_CtrlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_INTERFACE, SET_INTERFACE, \
legwinskij 0:e042bdf9c219 72 altNum, ifNum, 0, NULL)
legwinskij 0:e042bdf9c219 73
legwinskij 0:e042bdf9c219 74 /*
legwinskij 0:e042bdf9c219 75 **************************************************************************************************************
legwinskij 0:e042bdf9c219 76 * OHCI OPERATIONAL REGISTER FIELD DEFINITIONS
legwinskij 0:e042bdf9c219 77 **************************************************************************************************************
legwinskij 0:e042bdf9c219 78 */
legwinskij 0:e042bdf9c219 79
legwinskij 0:e042bdf9c219 80 /* ------------------ HcControl Register --------------------- */
legwinskij 0:e042bdf9c219 81 #define OR_CONTROL_CLE 0x00000010
legwinskij 0:e042bdf9c219 82 #define OR_CONTROL_BLE 0x00000020
legwinskij 0:e042bdf9c219 83 #define OR_CONTROL_HCFS 0x000000C0
legwinskij 0:e042bdf9c219 84 #define OR_CONTROL_HC_OPER 0x00000080
legwinskij 0:e042bdf9c219 85 /* ----------------- HcCommandStatus Register ----------------- */
legwinskij 0:e042bdf9c219 86 #define OR_CMD_STATUS_HCR 0x00000001
legwinskij 0:e042bdf9c219 87 #define OR_CMD_STATUS_CLF 0x00000002
legwinskij 0:e042bdf9c219 88 #define OR_CMD_STATUS_BLF 0x00000004
legwinskij 0:e042bdf9c219 89 /* --------------- HcInterruptStatus Register ----------------- */
legwinskij 0:e042bdf9c219 90 #define OR_INTR_STATUS_WDH 0x00000002
legwinskij 0:e042bdf9c219 91 #define OR_INTR_STATUS_RHSC 0x00000040
legwinskij 0:e042bdf9c219 92 /* --------------- HcInterruptEnable Register ----------------- */
legwinskij 0:e042bdf9c219 93 #define OR_INTR_ENABLE_WDH 0x00000002
legwinskij 0:e042bdf9c219 94 #define OR_INTR_ENABLE_RHSC 0x00000040
legwinskij 0:e042bdf9c219 95 #define OR_INTR_ENABLE_MIE 0x80000000
legwinskij 0:e042bdf9c219 96 /* ---------------- HcRhDescriptorA Register ------------------ */
legwinskij 0:e042bdf9c219 97 #define OR_RH_STATUS_LPSC 0x00010000
legwinskij 0:e042bdf9c219 98 #define OR_RH_STATUS_DRWE 0x00008000
legwinskij 0:e042bdf9c219 99 /* -------------- HcRhPortStatus[1:NDP] Register -------------- */
legwinskij 0:e042bdf9c219 100 #define OR_RH_PORT_CCS 0x00000001
legwinskij 0:e042bdf9c219 101 #define OR_RH_PORT_PRS 0x00000010
legwinskij 0:e042bdf9c219 102 #define OR_RH_PORT_CSC 0x00010000
legwinskij 0:e042bdf9c219 103 #define OR_RH_PORT_PRSC 0x00100000
legwinskij 0:e042bdf9c219 104
legwinskij 0:e042bdf9c219 105
legwinskij 0:e042bdf9c219 106 /*
legwinskij 0:e042bdf9c219 107 **************************************************************************************************************
legwinskij 0:e042bdf9c219 108 * FRAME INTERVAL
legwinskij 0:e042bdf9c219 109 **************************************************************************************************************
legwinskij 0:e042bdf9c219 110 */
legwinskij 0:e042bdf9c219 111
legwinskij 0:e042bdf9c219 112 #define FI 0x2EDF /* 12000 bits per frame (-1) */
legwinskij 0:e042bdf9c219 113 #define DEFAULT_FMINTERVAL ((((6 * (FI - 210)) / 7) << 16) | FI)
legwinskij 0:e042bdf9c219 114
legwinskij 0:e042bdf9c219 115 /*
legwinskij 0:e042bdf9c219 116 **************************************************************************************************************
legwinskij 0:e042bdf9c219 117 * TRANSFER DESCRIPTOR CONTROL FIELDS
legwinskij 0:e042bdf9c219 118 **************************************************************************************************************
legwinskij 0:e042bdf9c219 119 */
legwinskij 0:e042bdf9c219 120
legwinskij 0:e042bdf9c219 121 #define TD_ROUNDING (USB_INT32U) (0x00040000) /* Buffer Rounding */
legwinskij 0:e042bdf9c219 122 #define TD_SETUP (USB_INT32U)(0) /* Direction of Setup Packet */
legwinskij 0:e042bdf9c219 123 #define TD_IN (USB_INT32U)(0x00100000) /* Direction In */
legwinskij 0:e042bdf9c219 124 #define TD_OUT (USB_INT32U)(0x00080000) /* Direction Out */
legwinskij 0:e042bdf9c219 125 #define TD_DELAY_INT(x) (USB_INT32U)((x) << 21) /* Delay Interrupt */
legwinskij 0:e042bdf9c219 126 #define TD_TOGGLE_0 (USB_INT32U)(0x02000000) /* Toggle 0 */
legwinskij 0:e042bdf9c219 127 #define TD_TOGGLE_1 (USB_INT32U)(0x03000000) /* Toggle 1 */
legwinskij 0:e042bdf9c219 128 #define TD_CC (USB_INT32U)(0xF0000000) /* Completion Code */
legwinskij 0:e042bdf9c219 129
legwinskij 0:e042bdf9c219 130 /*
legwinskij 0:e042bdf9c219 131 **************************************************************************************************************
legwinskij 0:e042bdf9c219 132 * USB STANDARD REQUEST DEFINITIONS
legwinskij 0:e042bdf9c219 133 **************************************************************************************************************
legwinskij 0:e042bdf9c219 134 */
legwinskij 0:e042bdf9c219 135
legwinskij 0:e042bdf9c219 136 #define USB_DESCRIPTOR_TYPE_DEVICE 1
legwinskij 0:e042bdf9c219 137 #define USB_DESCRIPTOR_TYPE_CONFIGURATION 2
legwinskij 0:e042bdf9c219 138 #define USB_DESCRIPTOR_TYPE_INTERFACE 4
legwinskij 0:e042bdf9c219 139 #define USB_DESCRIPTOR_TYPE_ENDPOINT 5
legwinskij 0:e042bdf9c219 140 /* ----------- Control RequestType Fields ----------- */
legwinskij 0:e042bdf9c219 141 #define USB_DEVICE_TO_HOST 0x80
legwinskij 0:e042bdf9c219 142 #define USB_HOST_TO_DEVICE 0x00
legwinskij 0:e042bdf9c219 143 #define USB_REQUEST_TYPE_CLASS 0x20
legwinskij 0:e042bdf9c219 144 #define USB_RECIPIENT_DEVICE 0x00
legwinskij 0:e042bdf9c219 145 #define USB_RECIPIENT_INTERFACE 0x01
legwinskij 0:e042bdf9c219 146 /* -------------- USB Standard Requests -------------- */
legwinskij 0:e042bdf9c219 147 #define SET_ADDRESS 5
legwinskij 0:e042bdf9c219 148 #define GET_DESCRIPTOR 6
legwinskij 0:e042bdf9c219 149 #define SET_CONFIGURATION 9
legwinskij 0:e042bdf9c219 150 #define SET_INTERFACE 11
legwinskij 0:e042bdf9c219 151
legwinskij 0:e042bdf9c219 152 /*
legwinskij 0:e042bdf9c219 153 **************************************************************************************************************
legwinskij 0:e042bdf9c219 154 * TYPE DEFINITIONS
legwinskij 0:e042bdf9c219 155 **************************************************************************************************************
legwinskij 0:e042bdf9c219 156 */
legwinskij 0:e042bdf9c219 157
legwinskij 0:e042bdf9c219 158 typedef struct hcEd { /* ----------- HostController EndPoint Descriptor ------------- */
legwinskij 0:e042bdf9c219 159 volatile USB_INT32U Control; /* Endpoint descriptor control */
legwinskij 0:e042bdf9c219 160 volatile USB_INT32U TailTd; /* Physical address of tail in Transfer descriptor list */
legwinskij 0:e042bdf9c219 161 volatile USB_INT32U HeadTd; /* Physcial address of head in Transfer descriptor list */
legwinskij 0:e042bdf9c219 162 volatile USB_INT32U Next; /* Physical address of next Endpoint descriptor */
legwinskij 0:e042bdf9c219 163 } HCED;
legwinskij 0:e042bdf9c219 164
legwinskij 0:e042bdf9c219 165 typedef struct hcTd { /* ------------ HostController Transfer Descriptor ------------ */
legwinskij 0:e042bdf9c219 166 volatile USB_INT32U Control; /* Transfer descriptor control */
legwinskij 0:e042bdf9c219 167 volatile USB_INT32U CurrBufPtr; /* Physical address of current buffer pointer */
legwinskij 0:e042bdf9c219 168 volatile USB_INT32U Next; /* Physical pointer to next Transfer Descriptor */
legwinskij 0:e042bdf9c219 169 volatile USB_INT32U BufEnd; /* Physical address of end of buffer */
legwinskij 0:e042bdf9c219 170 } HCTD;
legwinskij 0:e042bdf9c219 171
legwinskij 0:e042bdf9c219 172 typedef struct hcca { /* ----------- Host Controller Communication Area ------------ */
legwinskij 0:e042bdf9c219 173 volatile USB_INT32U IntTable[32]; /* Interrupt Table */
legwinskij 0:e042bdf9c219 174 volatile USB_INT32U FrameNumber; /* Frame Number */
legwinskij 0:e042bdf9c219 175 volatile USB_INT32U DoneHead; /* Done Head */
legwinskij 0:e042bdf9c219 176 volatile USB_INT08U Reserved[116]; /* Reserved for future use */
legwinskij 0:e042bdf9c219 177 volatile USB_INT08U Unknown[4]; /* Unused */
legwinskij 0:e042bdf9c219 178 } HCCA;
legwinskij 0:e042bdf9c219 179
legwinskij 0:e042bdf9c219 180 /*
legwinskij 0:e042bdf9c219 181 **************************************************************************************************************
legwinskij 0:e042bdf9c219 182 * EXTERN DECLARATIONS
legwinskij 0:e042bdf9c219 183 **************************************************************************************************************
legwinskij 0:e042bdf9c219 184 */
legwinskij 0:e042bdf9c219 185
legwinskij 0:e042bdf9c219 186 extern volatile HCED *EDBulkIn; /* BulkIn endpoint descriptor structure */
legwinskij 0:e042bdf9c219 187 extern volatile HCED *EDBulkOut; /* BulkOut endpoint descriptor structure */
legwinskij 0:e042bdf9c219 188 extern volatile HCTD *TDHead; /* Head transfer descriptor structure */
legwinskij 0:e042bdf9c219 189 extern volatile HCTD *TDTail; /* Tail transfer descriptor structure */
legwinskij 0:e042bdf9c219 190 extern volatile USB_INT08U *TDBuffer; /* Current Buffer Pointer of transfer descriptor */
legwinskij 0:e042bdf9c219 191
legwinskij 0:e042bdf9c219 192 /*
legwinskij 0:e042bdf9c219 193 **************************************************************************************************************
legwinskij 0:e042bdf9c219 194 * FUNCTION PROTOTYPES
legwinskij 0:e042bdf9c219 195 **************************************************************************************************************
legwinskij 0:e042bdf9c219 196 */
legwinskij 0:e042bdf9c219 197
legwinskij 0:e042bdf9c219 198 void Host_Init (void);
legwinskij 0:e042bdf9c219 199
legwinskij 0:e042bdf9c219 200 extern "C" void USB_IRQHandler(void) __irq;
legwinskij 0:e042bdf9c219 201
legwinskij 0:e042bdf9c219 202 USB_INT32S Host_EnumDev (void);
legwinskij 0:e042bdf9c219 203
legwinskij 0:e042bdf9c219 204 USB_INT32S Host_ProcessTD(volatile HCED *ed,
legwinskij 0:e042bdf9c219 205 volatile USB_INT32U token,
legwinskij 0:e042bdf9c219 206 volatile USB_INT08U *buffer,
legwinskij 0:e042bdf9c219 207 USB_INT32U buffer_len);
legwinskij 0:e042bdf9c219 208
legwinskij 0:e042bdf9c219 209 void Host_DelayUS ( USB_INT32U delay);
legwinskij 0:e042bdf9c219 210 void Host_DelayMS ( USB_INT32U delay);
legwinskij 0:e042bdf9c219 211
legwinskij 0:e042bdf9c219 212
legwinskij 0:e042bdf9c219 213 void Host_TDInit (volatile HCTD *td);
legwinskij 0:e042bdf9c219 214 void Host_EDInit (volatile HCED *ed);
legwinskij 0:e042bdf9c219 215 void Host_HCCAInit (volatile HCCA *hcca);
legwinskij 0:e042bdf9c219 216
legwinskij 0:e042bdf9c219 217 USB_INT32S Host_CtrlRecv ( USB_INT08U bm_request_type,
legwinskij 0:e042bdf9c219 218 USB_INT08U b_request,
legwinskij 0:e042bdf9c219 219 USB_INT16U w_value,
legwinskij 0:e042bdf9c219 220 USB_INT16U w_index,
legwinskij 0:e042bdf9c219 221 USB_INT16U w_length,
legwinskij 0:e042bdf9c219 222 volatile USB_INT08U *buffer);
legwinskij 0:e042bdf9c219 223
legwinskij 0:e042bdf9c219 224 USB_INT32S Host_CtrlSend ( USB_INT08U bm_request_type,
legwinskij 0:e042bdf9c219 225 USB_INT08U b_request,
legwinskij 0:e042bdf9c219 226 USB_INT16U w_value,
legwinskij 0:e042bdf9c219 227 USB_INT16U w_index,
legwinskij 0:e042bdf9c219 228 USB_INT16U w_length,
legwinskij 0:e042bdf9c219 229 volatile USB_INT08U *buffer);
legwinskij 0:e042bdf9c219 230
legwinskij 0:e042bdf9c219 231 void Host_FillSetup( USB_INT08U bm_request_type,
legwinskij 0:e042bdf9c219 232 USB_INT08U b_request,
legwinskij 0:e042bdf9c219 233 USB_INT16U w_value,
legwinskij 0:e042bdf9c219 234 USB_INT16U w_index,
legwinskij 0:e042bdf9c219 235 USB_INT16U w_length);
legwinskij 0:e042bdf9c219 236
legwinskij 0:e042bdf9c219 237
legwinskij 0:e042bdf9c219 238 void Host_WDHWait (void);
legwinskij 0:e042bdf9c219 239
legwinskij 0:e042bdf9c219 240
legwinskij 0:e042bdf9c219 241 USB_INT32U ReadLE32U (volatile USB_INT08U *pmem);
legwinskij 0:e042bdf9c219 242 void WriteLE32U (volatile USB_INT08U *pmem,
legwinskij 0:e042bdf9c219 243 USB_INT32U val);
legwinskij 0:e042bdf9c219 244 USB_INT16U ReadLE16U (volatile USB_INT08U *pmem);
legwinskij 0:e042bdf9c219 245 void WriteLE16U (volatile USB_INT08U *pmem,
legwinskij 0:e042bdf9c219 246 USB_INT16U val);
legwinskij 0:e042bdf9c219 247 USB_INT32U ReadBE32U (volatile USB_INT08U *pmem);
legwinskij 0:e042bdf9c219 248 void WriteBE32U (volatile USB_INT08U *pmem,
legwinskij 0:e042bdf9c219 249 USB_INT32U val);
legwinskij 0:e042bdf9c219 250 USB_INT16U ReadBE16U (volatile USB_INT08U *pmem);
legwinskij 0:e042bdf9c219 251 void WriteBE16U (volatile USB_INT08U *pmem,
legwinskij 0:e042bdf9c219 252 USB_INT16U val);
legwinskij 0:e042bdf9c219 253
legwinskij 0:e042bdf9c219 254 #endif