パラメータを適応変化させる事により圧縮率を向上させた動的ライス・ゴロム符号を利用した可逆圧縮方式。圧縮ソフト、圧縮率のMATLABシミュレーションは詳細はInterface誌2011年8月号に掲載されるRX62Nマイコン連動特集にて掲載予定。

Dependencies:   mbed

Committer:
lynxeyed_atsu
Date:
Wed Mar 30 06:05:24 2011 +0000
Revision:
0:d920d64db582
alpha

Who changed what in which revision?

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