+/rtos
git clone https://git.julia.blue/+/rtos
83915e3
master
1//***************************************************************************** 2// 3// usbdma.c - USB Library DMA handling functions. 4// 5// Copyright (c) 2012-2017 Texas Instruments Incorporated. All rights reserved. 6// Software License Agreement 7// 8// Texas Instruments (TI) is supplying this software for use solely and 9// exclusively on TI's microcontroller products. The software is owned by 10// TI and/or its suppliers, and is protected under applicable copyright 11// laws. You may not combine this software with "viral" open-source 12// software in order to form a larger program. 13// 14// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. 15// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT 16// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY 18// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL 19// DAMAGES, FOR ANY REASON WHATSOEVER. 20// 21// This is part of revision 2.1.4.178 of the Tiva USB Library. 22// 23//***************************************************************************** 24 25#include "tivaware/hw_ints.h" 26#include "tivaware/hw_memmap.h" 27#include "tivaware/hw_sysctl.h" 28#include "tivaware/hw_types.h" 29#include "tivaware/hw_udma.h" 30#include "tivaware/rom.h" 31#include "tivaware/rom_map.h" 32#include "tivaware/rtos_bindings.h" 33#include "tivaware/udma.h" 34#include "tivaware/usb.h" 35#include "usblib/usblib.h" 36#include "usblib/usblibpriv.h" 37#include <stdbool.h> 38#include <stdint.h> 39 40#define ASSERT (X ) 41 42//***************************************************************************** 43// 44//! \addtogroup usblib_dma_api Internal USB DMA functions 45//! @{ 46// 47//***************************************************************************** 48 49//***************************************************************************** 50// 51// There are two sets of functions in this file, one is used with uDMA while 52// the other is used with USB controllers with an integrated DMA controller. 53// The functions with the IDMA prefix are for the integrated DMA controller and 54// the functions that are specific to the uDMA controller are prefixed with 55// uDMA. Any common functions are have just the DMA prefix. 56// 57//***************************************************************************** 58static tUSBDMAInstance g_psUSBDMAInst [1 ]; 59 60//***************************************************************************** 61// 62// Macros used to determine if a uDMA endpoint configuration is used for 63// receive or transmit. 64// 65//***************************************************************************** 66#define UDMAConfigIsRx (ui32Config ) \ 67 ((ui32Config & UDMA_SRC_INC_NONE) == UDMA_SRC_INC_NONE) 68#define UDMAConfigIsTx (ui32Config ) \ 69 ((ui32Config & UDMA_DEST_INC_NONE) == UDMA_DEST_INC_NONE) 70 71//***************************************************************************** 72// 73// USBLibDMAChannelStatus() for USB controllers that use the uDMA for DMA. 74// 75//***************************************************************************** 76static uint32_t uDMAUSBChannelStatus (tUSBDMAInstance * psUSBDMAInst , 77uint32_t ui32Channel ) { 78uint32_t ui32Status ; 79 80// 81// Initialize the current status to no events. 82// 83ui32Status = USBLIBSTATUS_DMA_IDLE ; 84 85// 86// Check if there is a pending DMA transfer. 87// 88if (psUSBDMAInst -> ui32Complete & (1 << (ui32Channel - 1 ))) { 89// 90// Return that the DMA transfer has completed and clear the 91// DMA pending flag. 92// 93ui32Status = USBLIBSTATUS_DMA_COMPLETE ; 94 }else if (psUSBDMAInst -> ui32Pending & (1 << (ui32Channel - 1 ))) { 95// 96// DMA transfer is still pending. 97// 98ui32Status = USBLIBSTATUS_DMA_PENDING ; 99 }else { 100// 101// DMA transfer is still pending. 102// 103ui32Status = USBLIBSTATUS_DMA_IDLE ; 104 } 105 106return (ui32Status ); 107} 108 109//***************************************************************************** 110// 111// USBLibDMAChannelStatus() for USB controllers with an integrated DMA 112// controller. 113// 114//***************************************************************************** 115static uint32_t iDMAUSBChannelStatus (tUSBDMAInstance * psUSBDMAInst , 116uint32_t ui32Channel ) { 117uint32_t ui32Status ; 118 119// 120// Initialize the current status to no events. 121// 122ui32Status = USBLIBSTATUS_DMA_IDLE ; 123 124// 125// Check if an error has occurred. 126// 127if (USBDMAChannelStatus (psUSBDMAInst -> ui32Base ,ui32Channel )== 128USB_DMA_STATUS_ERROR ) { 129ui32Status = USBLIBSTATUS_DMA_ERROR ; 130 } 131// 132// Otherwise check if there a pending DMA transfer has completed. 133// 134else if (psUSBDMAInst -> ui32Complete & (1 << (ui32Channel - 1 ))) { 135// 136// Return that the DMA transfer has completed and clear the 137// DMA pending flag. 138// 139ui32Status = USBLIBSTATUS_DMA_COMPLETE ; 140 }else if (psUSBDMAInst -> ui32Pending & (1 << (ui32Channel - 1 ))) { 141// 142// DMA transfer is still pending. 143// 144ui32Status = USBLIBSTATUS_DMA_PENDING ; 145 }else { 146// 147// DMA Channel is idle. 148// 149ui32Status = USBLIBSTATUS_DMA_IDLE ; 150 } 151 152return (ui32Status ); 153} 154 155//***************************************************************************** 156// 157// USBLibDMAIntStatus() for USB controllers that use uDMA. 158// 159//***************************************************************************** 160static uint32_t uDMAUSBIntStatus (tUSBDMAInstance * psUSBDMAInst ) { 161uint32_t ui32Status ,ui32Pending ; 162int32_t i32Channel ; 163 164// 165// Initialize the current status to no events. 166// 167ui32Status = 0 ; 168 169// 170// No pending interrupts by default. 171// 172ui32Status = 0 ; 173 174// 175// Save the pending channels. 176// 177ui32Pending = psUSBDMAInst -> ui32Pending ; 178 179// 180// Loop through channels to find out if any pending DMA transfers have 181// completed. 182// 183for (i32Channel = 0 ;i32Channel < USB_MAX_DMA_CHANNELS ;i32Channel ++ ) { 184// 185// If pending and stopped then the DMA completed. 186// 187if ((ui32Pending & 1 )&& 188 (MAP_uDMAChannelModeGet (i32Channel )== UDMA_MODE_STOP )) { 189ui32Status |= (1 <<i32Channel ); 190 } 191ui32Pending >>=1 ; 192 193// 194// Done if this is zero. 195// 196if (ui32Pending == 0 ) { 197break ; 198 } 199 } 200 201return (ui32Status ); 202} 203 204//***************************************************************************** 205// 206// USBLibDMAIntStatus() for USB controllers with an integrated DMA controller. 207// 208//***************************************************************************** 209static uint32_t iDMAUSBIntStatus (tUSBDMAInstance * psUSBDMAInst ) { 210// 211// Read the current DMA status, unfortunately this clears the 212// pending interrupt status. 213// 214return (USBDMAChannelIntStatus (psUSBDMAInst -> ui32Base )); 215} 216 217//***************************************************************************** 218// 219// USBLibDMAIntStatusClear() for USB controllers that use uDMA for DMA or have 220// an integrated DMA controller. 221// 222//***************************************************************************** 223static void DMAUSBIntStatusClear (tUSBDMAInstance * psUSBDMAInst , 224uint32_t ui32Status ) { 225// 226// Clear out the requested interrupts. Since the USB interface does not 227// have a true interrupt clear, this clears the current completed 228// status for the requested channels. 229// 230psUSBDMAInst -> ui32Complete &= ~ui32Status ; 231 232return ; 233} 234 235//***************************************************************************** 236// 237// USBLibDMAIntHandler() for USB controllers that use uDMA for DMA or have an 238// integrated DMA controller. 239// 240//***************************************************************************** 241static void DMAUSBIntHandler (tUSBDMAInstance * psUSBDMAInst , 242uint32_t ui32DMAIntStatus ) { 243uint32_t ui32Channel ; 244 245if (ui32DMAIntStatus == 0 ) { 246return ; 247 } 248 249// 250// Determine if the uDMA is used or the USB DMA controller. 251// 252for (ui32Channel = 0 ;ui32Channel < USB_MAX_DMA_CHANNELS ;ui32Channel ++ ) { 253// 254// Mark any pending interrupts as completed. 255// 256if (ui32DMAIntStatus & 1 ) { 257psUSBDMAInst -> ui32Pending &= ~(1 <<ui32Channel ); 258psUSBDMAInst -> ui32Complete |= (1 <<ui32Channel ); 259 } 260 261// 262// Check the next channel. 263// 264ui32DMAIntStatus >>=1 ; 265 266// 267// Break if there are no more pending DMA interrupts. 268// 269if (ui32DMAIntStatus == 0 ) { 270break ; 271 } 272 } 273} 274 275//***************************************************************************** 276// 277// USBLibDMAChannelEnable() for USB controllers that use uDMA. 278// 279//***************************************************************************** 280static void uDMAUSBChannelEnable (tUSBDMAInstance * psUSBDMAInst , 281uint32_t ui32Channel ) { 282uint32_t ui32IntEnabled ; 283 284// 285// Save if the interrupt was enabled or not. 286// 287ui32IntEnabled = ROM_IntIsEnabled (psUSBDMAInst -> ui32IntNum ); 288 289// 290// Disable the USB interrupt if it was enabled. 291// 292if (ui32IntEnabled ) { 293OS_INT_DISABLE (psUSBDMAInst -> ui32IntNum ); 294 } 295 296// 297// Mark this channel as pending and not complete. 298// 299psUSBDMAInst -> ui32Pending |= (1 << (ui32Channel - 1 )); 300psUSBDMAInst -> ui32Complete &= ~(1 << (ui32Channel - 1 )); 301 302// 303// Enable DMA for the endpoint. 304// 305if (UDMAConfigIsRx (psUSBDMAInst -> pui32Config [ui32Channel - 1 ])) { 306MAP_USBEndpointDMAEnable (psUSBDMAInst -> ui32Base , 307psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 308USB_EP_DEV_OUT |USB_EP_HOST_IN ); 309 }else { 310MAP_USBEndpointDMAEnable (psUSBDMAInst -> ui32Base , 311psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 312USB_EP_DEV_IN |USB_EP_HOST_OUT ); 313 } 314 315// 316// Enable the DMA in the uDMA controller. 317// 318MAP_uDMAChannelEnable (ui32Channel - 1 ); 319 320// 321// Enable the USB interrupt if it was enabled before. 322// 323if (ui32IntEnabled ) { 324OS_INT_ENABLE (psUSBDMAInst -> ui32IntNum ); 325 } 326} 327 328//***************************************************************************** 329// 330// USBLibDMAChannelEnable() for USB controllers with an integrated DMA 331// controller. 332// 333//***************************************************************************** 334static void iDMAUSBChannelEnable (tUSBDMAInstance * psUSBDMAInst , 335uint32_t ui32Channel ) { 336uint32_t ui32IntEnabled ; 337 338// 339// Save if the interrupt was enabled or not. 340// 341ui32IntEnabled = ROM_IntIsEnabled (psUSBDMAInst -> ui32IntNum ); 342 343// 344// Disable the USB interrupt if it was enabled. 345// 346if (ui32IntEnabled ) { 347OS_INT_DISABLE (psUSBDMAInst -> ui32IntNum ); 348 } 349 350// 351// Mark this channel as pending and not complete. 352// 353psUSBDMAInst -> ui32Pending |= (1 << (ui32Channel - 1 )); 354psUSBDMAInst -> ui32Complete &= ~(1 << (ui32Channel - 1 )); 355 356// 357// Enable the interrupt for this DMA channel. 358// 359USBDMAChannelIntEnable (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ); 360 361// 362// Enable the DMA channel. 363// 364USBDMAChannelEnable (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ); 365 366// 367// Enable the USB interrupt if it was enabled before. 368// 369if (ui32IntEnabled ) { 370OS_INT_ENABLE (psUSBDMAInst -> ui32IntNum ); 371 } 372} 373 374//***************************************************************************** 375// 376// USBLibDMAChannelDisable() for USB controllers that use uDMA. 377// 378//***************************************************************************** 379static void uDMAUSBChannelDisable (tUSBDMAInstance * psUSBDMAInst , 380uint32_t ui32Channel ) { 381// 382// Disable DMA for the endpoint. 383// 384if (UDMAConfigIsRx (psUSBDMAInst -> pui32Config [ui32Channel - 1 ])) { 385MAP_USBEndpointDMADisable (psUSBDMAInst -> ui32Base , 386psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 387USB_EP_DEV_OUT ); 388 }else { 389MAP_USBEndpointDMADisable (psUSBDMAInst -> ui32Base , 390psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 391USB_EP_DEV_IN ); 392 } 393 394// 395// Disable the DMA channel in the uDMA controller. 396// 397MAP_uDMAChannelDisable (ui32Channel - 1 ); 398 399// 400// Clear out any pending or complete flag set for this DMA channel. 401// 402psUSBDMAInst -> ui32Pending &= ~(1 << (ui32Channel - 1 )); 403psUSBDMAInst -> ui32Complete &= ~(1 << (ui32Channel - 1 )); 404} 405 406//***************************************************************************** 407// 408// USBLibDMAChannelDisable() for USB controllers with an integrated DMA 409// controller. 410// 411//***************************************************************************** 412static void iDMAUSBChannelDisable (tUSBDMAInstance * psUSBDMAInst , 413uint32_t ui32Channel ) { 414// 415// Disable the DMA channel. 416// 417USBDMAChannelDisable (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ); 418 419// 420// Disable the interrupt for this DMA channel. 421// 422USBDMAChannelIntDisable (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ); 423 424// 425// Clear out any pending or complete flag set for this DMA channel. 426// 427psUSBDMAInst -> ui32Pending &= ~(1 << (ui32Channel - 1 )); 428psUSBDMAInst -> ui32Complete &= ~(1 << (ui32Channel - 1 )); 429} 430 431//***************************************************************************** 432// 433// USBLibDMAChannelIntEnable() for USB controllers that use uDMA. 434// 435//***************************************************************************** 436static void uDMAUSBChannelIntEnable (tUSBDMAInstance * psUSBDMAInst , 437uint32_t ui32Channel ) { 438// 439// There is no way to Enable channel interrupts when using uDMA. 440// 441} 442 443//***************************************************************************** 444// 445// USBLibDMAChannelIntEnable() for USB controllers with an integrated DMA 446// controller. 447// 448//***************************************************************************** 449static void iDMAUSBChannelIntEnable (tUSBDMAInstance * psUSBDMAInst , 450uint32_t ui32Channel ) { 451// 452// Enable the interrupt for this DMA channel. 453// 454USBDMAChannelIntEnable (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ); 455} 456 457//***************************************************************************** 458// 459// USBLibDMAChannelIntDisable() for USB controllers that use uDMA. 460// 461//***************************************************************************** 462static void uDMAUSBChannelIntDisable (tUSBDMAInstance * psUSBDMAInst , 463uint32_t ui32Channel ) { 464// 465// There is no way to Disable channel interrupts when using uDMA. 466// 467} 468 469//***************************************************************************** 470// 471// USBLibDMAChannelIntDisable() for USB controllers with an integrated DMA 472// controller. 473// 474//***************************************************************************** 475static void iDMAUSBChannelIntDisable (tUSBDMAInstance * psUSBDMAInst , 476uint32_t ui32Channel ) { 477// 478// Disable the interrupt for this DMA channel. 479// 480USBDMAChannelIntDisable (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ); 481} 482 483//***************************************************************************** 484// 485// USBLibDMATransfer() for USB controllers that use the uDMA controller. 486// 487//***************************************************************************** 488static uint32_t uDMAUSBTransfer (tUSBDMAInstance * psUSBDMAInst , 489uint32_t ui32Channel ,void * pvBuffer , 490uint32_t ui32Size ) { 491void * pvFIFO ; 492uint32_t uluDMAChannel ; 493uint32_t ui32PacketCount ; 494uint32_t ui32TransferCount ; 495 496if ((ui32Size < 64 )|| ((uint32_t )pvBuffer & 0x3 )) { 497return (0 ); 498 } 499 500// 501// Mark this channel as pending and not complete. 502// 503psUSBDMAInst -> ui32Pending |= (1 << (ui32Channel - 1 )); 504psUSBDMAInst -> ui32Complete &= ~(1 << (ui32Channel - 1 )); 505 506// 507// Save the pointer to the data and the byte count. 508// 509psUSBDMAInst -> ppui32Data [ui32Channel - 1 ]= pvBuffer ; 510psUSBDMAInst -> pui32Count [ui32Channel - 1 ]= ui32Size ; 511 512// 513// Need the address of the FIFO. 514// 515pvFIFO = (void * )USBFIFOAddrGet (psUSBDMAInst -> ui32Base , 516psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ]); 517 518// 519// Calculate the uDMA channel for this RX channel. 520// 521uluDMAChannel = UDMA_CHANNEL_USBEP1RX + ui32Channel - 1 ; 522 523ui32TransferCount = ui32Size ; 524 525if ((psUSBDMAInst -> pui32Config [ui32Channel - 1 ]& UDMA_SIZE_32 )== 526UDMA_SIZE_32 ) { 527ui32TransferCount >>=2 ; 528 }else if ((psUSBDMAInst -> pui32Config [ui32Channel - 1 ]& UDMA_SIZE_32 )== 529UDMA_SIZE_32 ) { 530ui32TransferCount >>=1 ; 531 } 532 533// 534// If source increment is none this is an RX transfer. 535// 536if (UDMAConfigIsRx (psUSBDMAInst -> pui32Config [ui32Channel - 1 ])) { 537MAP_uDMAChannelTransferSet (uluDMAChannel ,UDMA_MODE_BASIC ,pvFIFO , 538pvBuffer ,ui32TransferCount ); 539 }else { 540MAP_uDMAChannelTransferSet (uluDMAChannel ,UDMA_MODE_BASIC ,pvBuffer , 541pvFIFO ,ui32TransferCount ); 542 } 543 544// 545// Set the mode based on the size of the transfer. More than one 546// packet requires mode 1. 547// 548if (ui32Size > psUSBDMAInst -> pui32MaxPacketSize [ui32Channel - 1 ]) { 549// 550// Calculate the number of packets required for this transfer. 551// 552ui32PacketCount = 553 ((ui32Size /psUSBDMAInst -> pui32MaxPacketSize [ui32Channel - 1 ])); 554 555// 556// Set the packet count so that the last packet does not generate 557// another IN request. 558// 559USBEndpointPacketCountSet (psUSBDMAInst -> ui32Base , 560psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 561ui32PacketCount ); 562 563// 564// Configure the USB endpoint in mode 1 for this DMA transfer. 565// 566USBEndpointDMAConfigSet (psUSBDMAInst -> ui32Base , 567psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 568psUSBDMAInst -> pui32EPDMAMode1 [ui32Channel - 1 ]); 569 }else { 570// 571// Configure the USB endpoint in mode 0 for this DMA transfer. 572// 573USBEndpointDMAConfigSet (psUSBDMAInst -> ui32Base , 574psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 575psUSBDMAInst -> pui32EPDMAMode0 [ui32Channel - 1 ]); 576 } 577 578// 579// Enable the uDMA channel to start the transfer 580// 581uDMAUSBChannelEnable (psUSBDMAInst ,ui32Channel ); 582 583return (ui32Size ); 584} 585 586//***************************************************************************** 587// 588// USBLibDMATransfer() for USB controllers with an integrated DMA controller. 589// 590//***************************************************************************** 591static uint32_t iDMAUSBTransfer (tUSBDMAInstance * psUSBDMAInst , 592uint32_t ui32Channel ,void * pvBuffer , 593uint32_t ui32Size ) { 594uint32_t ui32PacketCount ; 595 596if ((uint32_t )pvBuffer & 0x3 ) { 597return (0 ); 598 } 599 600// 601// Mark this channel as pending and not complete. 602// 603psUSBDMAInst -> ui32Pending |= (1 << (ui32Channel - 1 )); 604psUSBDMAInst -> ui32Complete &= ~(1 << (ui32Channel - 1 )); 605 606// 607// Save the pointer to the data and the byte count. 608// 609psUSBDMAInst -> ppui32Data [ui32Channel - 1 ]= pvBuffer ; 610psUSBDMAInst -> pui32Count [ui32Channel - 1 ]= ui32Size ; 611 612// 613// Set the address. 614// 615USBDMAChannelAddressSet (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ,pvBuffer ); 616 617// 618// Set the number of transfers. 619// 620USBDMAChannelCountSet (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ,ui32Size ); 621 622// 623// Set the mode based on the size of the transfer. More than one 624// packet requires mode 1. 625// 626if (ui32Size > psUSBDMAInst -> pui32MaxPacketSize [ui32Channel - 1 ]) { 627// 628// Calculate the number of packets required for this transfer. 629// 630ui32PacketCount = 631ui32Size /psUSBDMAInst -> pui32MaxPacketSize [ui32Channel - 1 ]; 632 633if (ui32Size %psUSBDMAInst -> pui32MaxPacketSize [ui32Channel - 1 ]) { 634ui32PacketCount += 1 ; 635 } 636 637USBEndpointPacketCountSet (psUSBDMAInst -> ui32Base , 638psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 639ui32PacketCount ); 640 641// 642// Configure the USB DMA controller for mode 1. 643// 644USBEndpointDMAConfigSet (psUSBDMAInst -> ui32Base , 645psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 646psUSBDMAInst -> pui32EPDMAMode1 [ui32Channel - 1 ]); 647 648USBDMAChannelConfigSet (psUSBDMAInst -> ui32Base ,ui32Channel - 1 , 649psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 650psUSBDMAInst -> pui32Config [ui32Channel - 1 ] | 651USB_DMA_CFG_MODE_1 ); 652 653// 654// Enable DMA on the endpoint. 655// 656if (psUSBDMAInst -> pui32Config [ui32Channel - 1 ]& USB_DMA_CFG_DIR_TX ) { 657// 658// Make sure that DMA is enabled on the endpoint. 659// 660MAP_USBEndpointDMAEnable ( 661psUSBDMAInst -> ui32Base , 662psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ],USB_EP_HOST_OUT ); 663 }else { 664// 665// Make sure that DMA is enabled on the endpoint. 666// 667MAP_USBEndpointDMAEnable ( 668psUSBDMAInst -> ui32Base , 669psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ],USB_EP_HOST_IN ); 670 } 671 672// 673// Enable the DMA channel. 674// 675USBDMAChannelEnable (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ); 676 }else { 677// 678// Configure the USB DMA controller for mode 0. 679// 680USBEndpointDMAConfigSet (psUSBDMAInst -> ui32Base , 681psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 682psUSBDMAInst -> pui32EPDMAMode0 [ui32Channel - 1 ]); 683 684USBDMAChannelConfigSet (psUSBDMAInst -> ui32Base ,ui32Channel - 1 , 685psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ], 686psUSBDMAInst -> pui32Config [ui32Channel - 1 ] | 687USB_DMA_CFG_MODE_0 ); 688 689// 690// In mode 0 only enable DMA transfer for mode 0. 691// 692if (psUSBDMAInst -> pui32Config [ui32Channel - 1 ]& USB_DMA_CFG_DIR_TX ) { 693// 694// Make sure that DMA is enabled on the endpoint. 695// 696MAP_USBEndpointDMAEnable ( 697psUSBDMAInst -> ui32Base , 698psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ],USB_EP_HOST_OUT ); 699// 700// Enable the DMA channel. 701// 702USBDMAChannelEnable (psUSBDMAInst -> ui32Base ,ui32Channel - 1 ); 703 }else { 704// 705// Make sure that DMA is disabled on the endpoint, it will 706// be enabled when the endpoint interrupt occurs. 707// 708MAP_USBEndpointDMADisable ( 709psUSBDMAInst -> ui32Base , 710psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ],USB_EP_HOST_IN ); 711 } 712 } 713 714return (ui32Size ); 715} 716 717//***************************************************************************** 718// 719// USBLibDMAChannelAllocate() for USB controllers that use uDMA for DMA. 720// 721//***************************************************************************** 722static uint32_t uDMAUSBChannelAllocate (tUSBDMAInstance * psUSBDMAInst , 723uint8_t ui8Endpoint , 724uint32_t ui32MaxPacketSize , 725uint32_t ui32Config ) { 726uint32_t ui32Channel ; 727 728// 729// The DMA channels are organized in pairs on this controller and the 730// transmit channels are 1, 3, and 5 while receive are 0, 2, and 4. 731// 732if (ui32Config & USB_DMA_EP_RX ) { 733ui32Channel = 0 ; 734 }else { 735ui32Channel = 1 ; 736 } 737 738// 739// Search for an available DMA channel to use. 740// 741for (;ui32Channel < USB_MAX_DMA_CHANNELS_0 ;ui32Channel += 2 ) { 742// 743// If the current endpoint value is zero then this channel is 744// available. 745// 746if (psUSBDMAInst -> pui8Endpoint [ui32Channel ]== 0 ) { 747// 748// Save the endpoint for this DMA channel. 749// 750psUSBDMAInst -> pui8Endpoint [ui32Channel ]= ui8Endpoint ; 751 752// 753// Save the maximum packet size for the endpoint. 754// 755psUSBDMAInst -> pui32MaxPacketSize [ui32Channel ]= ui32MaxPacketSize ; 756 757// 758// Set the channel configuration based on the direction. 759// 760if (ui32Config & USB_DMA_EP_RX ) { 761psUSBDMAInst -> pui32Config [ui32Channel ]= 762UDMA_SIZE_8 |UDMA_SRC_INC_NONE |UDMA_DST_INC_8 | 763UDMA_ARB_64 ; 764 765// 766// If in device mode and Isochronous. 767// 768if (((ui32Config & USB_DMA_EP_HOST )== 0 )&& 769 ((ui32Config & USB_DMA_EP_TYPE_M )== 770USB_DMA_EP_TYPE_ISOC )) { 771// 772// USB_EP_AUTO_REQUEST is required for device 773// Isochronous endpoints. 774// 775psUSBDMAInst -> pui32EPDMAMode0 [ui32Channel ]= 776USB_EP_DMA_MODE_0 |USB_EP_AUTO_REQUEST | 777USB_EP_HOST_IN ; 778 }else { 779psUSBDMAInst -> pui32EPDMAMode0 [ui32Channel ]= 780USB_EP_DMA_MODE_0 |USB_EP_AUTO_CLEAR |USB_EP_HOST_IN ; 781 } 782 783// 784// Do not set auto request in device mode unless it is an 785// isochronous endpoint. 786// 787if (((ui32Config & USB_DMA_EP_HOST )== 0 )&& 788 ((ui32Config & USB_DMA_EP_TYPE_M )!= 789USB_DMA_EP_TYPE_ISOC )) { 790psUSBDMAInst -> pui32EPDMAMode1 [ui32Channel ]= 791USB_EP_DMA_MODE_1 |USB_EP_HOST_IN |USB_EP_AUTO_CLEAR ; 792 }else { 793psUSBDMAInst -> pui32EPDMAMode1 [ui32Channel ]= 794USB_EP_DMA_MODE_1 |USB_EP_HOST_IN | 795USB_EP_AUTO_REQUEST |USB_EP_AUTO_CLEAR ; 796 } 797 }else { 798psUSBDMAInst -> pui32Config [ui32Channel ]= 799UDMA_SIZE_8 |UDMA_SRC_INC_8 |UDMA_DST_INC_NONE | 800UDMA_ARB_64 ; 801 802psUSBDMAInst -> pui32EPDMAMode0 [ui32Channel ]= 803USB_EP_DMA_MODE_0 |USB_EP_HOST_OUT ; 804psUSBDMAInst -> pui32EPDMAMode1 [ui32Channel ]= 805USB_EP_DMA_MODE_1 |USB_EP_HOST_OUT |USB_EP_AUTO_SET ; 806 } 807 808// 809// Map the uDMA channel to the given endpoint. 810// 811MAP_USBEndpointDMAChannel (psUSBDMAInst -> ui32Base ,ui8Endpoint , 812ui32Channel ); 813 814// 815// Clear out the attributes on this channel. 816// 817MAP_uDMAChannelAttributeDisable (ui32Channel ,UDMA_ATTR_ALL ); 818 819// 820// Configure the uDMA channel for the pipe 821// 822MAP_uDMAChannelControlSet (ui32Channel , 823psUSBDMAInst -> pui32Config [ui32Channel ]); 824 825if (ui32Config & USB_DMA_EP_RX ) { 826MAP_USBEndpointDMADisable (psUSBDMAInst -> ui32Base ,ui8Endpoint , 827USB_EP_DEV_OUT ); 828 }else { 829MAP_USBEndpointDMADisable (psUSBDMAInst -> ui32Base ,ui8Endpoint , 830USB_EP_DEV_IN ); 831 } 832 833// 834// Outside of this function all channels are 1 based as 835// zero is not a valid channel. 836// 837return (ui32Channel + 1 ); 838 } 839 } 840return (0 ); 841} 842 843//***************************************************************************** 844// 845// USBLibDMAChannelAllocate() for USB controllers with an integrated DMA 846// controller. 847// 848//***************************************************************************** 849static uint32_t iDMAUSBChannelAllocate (tUSBDMAInstance * psUSBDMAInst , 850uint8_t ui8Endpoint , 851uint32_t ui32MaxPacketSize , 852uint32_t ui32Config ) { 853uint32_t ui32Channel ; 854 855// 856// Search for an available DMA channel to use. 857// 858for (ui32Channel = 0 ;ui32Channel < USB_MAX_DMA_CHANNELS_0 ;ui32Channel ++ ) { 859// 860// If the current endpoint value is zero then this channel is 861// available. 862// 863if (psUSBDMAInst -> pui8Endpoint [ui32Channel ]== 0 ) { 864// 865// Clear out the attributes on this channel. 866// 867USBDMAChannelDisable (psUSBDMAInst -> ui32Base ,ui32Channel ); 868 869// 870// Save the endpoint for this DMA channel. 871// 872psUSBDMAInst -> pui8Endpoint [ui32Channel ]= ui8Endpoint ; 873 874// 875// Save the maximum packet size for the endpoint. 876// 877psUSBDMAInst -> pui32MaxPacketSize [ui32Channel ]= ui32MaxPacketSize ; 878 879// 880// Assign the endpoint to the channel and set the direction. 881// 882if (ui32Config & USB_DMA_EP_RX ) { 883psUSBDMAInst -> pui32Config [ui32Channel ]= 884USB_DMA_CFG_DIR_RX |USB_DMA_CFG_BURST_NONE | 885USB_DMA_CFG_INT_EN ; 886 887// 888// If in device mode and Isochronous. 889// 890if (((ui32Config & USB_DMA_EP_HOST )== 0 )&& 891 ((ui32Config & USB_DMA_EP_TYPE_M )== 892USB_DMA_EP_TYPE_ISOC )) { 893// 894// USB_EP_AUTO_REQUEST is required for device 895// Isochronous endpoints. 896// 897psUSBDMAInst -> pui32EPDMAMode0 [ui32Channel ]= 898USB_EP_DMA_MODE_0 |USB_EP_AUTO_REQUEST | 899USB_EP_HOST_IN ; 900 }else { 901psUSBDMAInst -> pui32EPDMAMode0 [ui32Channel ]= 902USB_EP_DMA_MODE_0 |USB_EP_AUTO_CLEAR |USB_EP_HOST_IN ; 903 } 904 905// 906// Do not set auto request in device mode unless it is an 907// isochronous endpoint. 908// 909if (((ui32Config & USB_DMA_EP_HOST )== 0 )&& 910 ((ui32Config & USB_DMA_EP_TYPE_M )!= 911USB_DMA_EP_TYPE_ISOC )) { 912psUSBDMAInst -> pui32EPDMAMode1 [ui32Channel ]= 913USB_EP_DMA_MODE_1 |USB_EP_HOST_IN |USB_EP_AUTO_CLEAR ; 914 }else { 915psUSBDMAInst -> pui32EPDMAMode1 [ui32Channel ]= 916USB_EP_DMA_MODE_1 |USB_EP_HOST_IN | 917USB_EP_AUTO_REQUEST |USB_EP_AUTO_CLEAR ; 918 } 919 }else { 920psUSBDMAInst -> pui32Config [ui32Channel ]= 921USB_DMA_CFG_DIR_TX |USB_DMA_CFG_BURST_NONE | 922USB_DMA_CFG_INT_EN ; 923 924psUSBDMAInst -> pui32EPDMAMode0 [ui32Channel ]= 925USB_EP_DMA_MODE_0 |USB_EP_HOST_OUT ; 926psUSBDMAInst -> pui32EPDMAMode1 [ui32Channel ]= 927USB_EP_DMA_MODE_1 |USB_EP_HOST_OUT |USB_EP_AUTO_SET ; 928 } 929 930// 931// Outside of this function all channels are 1 based as 932// zero is not a valid channel. 933// 934return (ui32Channel + 1 ); 935 } 936 } 937return (0 ); 938} 939 940//***************************************************************************** 941// 942// USBLibDMAChannelRelease() for USB controllers that use uDMA for DMA. 943// 944//***************************************************************************** 945static void uDMAUSBChannelRelease (tUSBDMAInstance * psUSBDMAInst , 946uint8_t ui32Channel ) { 947ASSERT (ui32Channel < USB_MAX_DMA_CHANNELS_0 ); 948 949// 950// Clear out the attributes on this channel. 951// 952MAP_uDMAChannelAttributeDisable (ui32Channel - 1 ,UDMA_ATTR_ALL ); 953 954if (psUSBDMAInst -> pui8Endpoint [ui32Channel ]& USB_DMA_EP_RX ) { 955MAP_USBEndpointDMADisable ( 956psUSBDMAInst -> ui32Base , 957 (psUSBDMAInst -> pui8Endpoint [ui32Channel ]& ~USB_DMA_EP_RX ), 958USB_EP_DEV_OUT ); 959 }else { 960MAP_USBEndpointDMADisable ( 961psUSBDMAInst -> ui32Base , 962 (psUSBDMAInst -> pui8Endpoint [ui32Channel ]& ~USB_DMA_EP_RX ), 963USB_EP_DEV_IN ); 964 } 965 966// 967// Clear out the state for this endpoint. 968// 969psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ]= 0 ; 970psUSBDMAInst -> pui32Config [ui32Channel - 1 ]= 0 ; 971psUSBDMAInst -> ui32Pending &= ~(1 << (ui32Channel - 1 )); 972psUSBDMAInst -> ui32Complete &= ~(1 << (ui32Channel - 1 )); 973psUSBDMAInst -> pui32MaxPacketSize [ui32Channel - 1 ]= 0 ; 974} 975 976//***************************************************************************** 977// 978// DMAChannelRelease() for USB controllers with an integrated DMA controller. 979// 980//***************************************************************************** 981static void iDMAUSBChannelRelease (tUSBDMAInstance * psUSBDMAInst , 982uint8_t ui32Channel ) { 983ASSERT (ui32Channel < USB_MAX_DMA_CHANNELS ); 984 985// 986// Clear out the attributes on this channel. 987// 988USBDMAChannelDisable (psUSBDMAInst -> ui32Base ,ui32Channel ); 989 990// 991// Clear out the state for this endpoint. 992// 993psUSBDMAInst -> pui8Endpoint [ui32Channel - 1 ]= 0 ; 994psUSBDMAInst -> pui32Config [ui32Channel - 1 ]= 0 ; 995psUSBDMAInst -> ui32Pending &= ~(1 << (ui32Channel - 1 )); 996psUSBDMAInst -> ui32Complete &= ~(1 << (ui32Channel - 1 )); 997psUSBDMAInst -> pui32MaxPacketSize [ui32Channel - 1 ]= 0 ; 998} 999 1000//***************************************************************************** 1001// 1002// USBLibDMAUnitSizeSet() for USB controllers that use uDMA for DMA. 1003// 1004//***************************************************************************** 1005static void uDMAUSBUnitSizeSet (tUSBDMAInstance * psUSBDMAInst , 1006uint32_t ui32Channel ,uint32_t ui32BitSize ) { 1007uint32_t ui32Value ; 1008 1009ASSERT ((ui32BitSize == 8 )|| (ui32BitSize == 16 )|| (ui32BitSize == 32 )); 1010 1011ASSERT (ui32Channel < USB_MAX_DMA_CHANNELS_0 ); 1012 1013if (ui32BitSize == 8 ) { 1014ui32Value = UDMA_SIZE_8 ; 1015 1016if (UDMAConfigIsRx (psUSBDMAInst -> pui32Config [ui32Channel - 1 ])) { 1017// 1018// Receive increments destination and not source. 1019// 1020ui32Value |=UDMA_DST_INC_8 |UDMA_SRC_INC_NONE ; 1021 }else { 1022// 1023// Transmit increments source and not destination. 1024// 1025ui32Value |=UDMA_SRC_INC_8 |UDMA_DST_INC_NONE ; 1026 } 1027 }else if (ui32BitSize == 16 ) { 1028ui32Value = UDMA_SIZE_16 ; 1029 1030if (UDMAConfigIsRx (psUSBDMAInst -> pui32Config [ui32Channel - 1 ])) { 1031// 1032// Receive increments destination and not source. 1033// 1034ui32Value |=UDMA_DST_INC_16 |UDMA_SRC_INC_NONE ; 1035 }else { 1036// 1037// Transmit increments source and not destination. 1038// 1039ui32Value |=UDMA_SRC_INC_16 |UDMA_DST_INC_NONE ; 1040 } 1041 }else { 1042ui32Value = UDMA_SIZE_32 ; 1043 1044if (UDMAConfigIsRx (psUSBDMAInst -> pui32Config [ui32Channel - 1 ])) { 1045// 1046// Receive increments destination and not source. 1047// 1048ui32Value |= (UDMA_DST_INC_32 |UDMA_SRC_INC_NONE ); 1049 }else { 1050// 1051// Transmit increments source and not destination. 1052// 1053ui32Value |= (UDMA_SRC_INC_32 |UDMA_DST_INC_NONE ); 1054 } 1055 } 1056 1057// 1058// Keep the current arbitration size and or in the size. 1059// 1060psUSBDMAInst -> pui32Config [ui32Channel - 1 ] &=0x00ffffff ; 1061psUSBDMAInst -> pui32Config [ui32Channel - 1 ] |=ui32Value ; 1062MAP_uDMAChannelControlSet (ui32Channel - 1 , 1063psUSBDMAInst -> pui32Config [ui32Channel - 1 ]); 1064} 1065 1066//***************************************************************************** 1067// 1068// USBLibDMAUnitSizeSet() for USB controllers that have an integrated DMA 1069// controller. 1070// 1071//***************************************************************************** 1072static void iDMAUSBUnitSizeSet (tUSBDMAInstance * psUSBDMAInst , 1073uint32_t ui32Channel ,uint32_t ui32BitSize ) {} 1074 1075//***************************************************************************** 1076// 1077// USBLibDMAArbSizeSet() for USB controllers that use uDMA for DMA. 1078// 1079//***************************************************************************** 1080static void uDMAUSBArbSizeSet (tUSBDMAInstance * psUSBDMAInst , 1081uint32_t ui32Channel ,uint32_t ui32ArbSize ) { 1082uint32_t ui32Value ; 1083 1084ASSERT (ui32Channel < USB_MAX_DMA_CHANNELS_0 ); 1085 1086// 1087// Get the arbitration size value. 1088// 1089if (ui32ArbSize == 2 ) { 1090ui32Value = UDMA_ARB_2 ; 1091 }else if (ui32ArbSize == 4 ) { 1092ui32Value = UDMA_ARB_4 ; 1093 }else if (ui32ArbSize == 8 ) { 1094ui32Value = UDMA_ARB_8 ; 1095 }else if (ui32ArbSize == 16 ) { 1096ui32Value = UDMA_ARB_16 ; 1097 }else if (ui32ArbSize == 32 ) { 1098ui32Value = UDMA_ARB_32 ; 1099 }else if (ui32ArbSize == 64 ) { 1100ui32Value = UDMA_ARB_64 ; 1101 }else if (ui32ArbSize == 128 ) { 1102ui32Value = UDMA_ARB_128 ; 1103 }else if (ui32ArbSize == 256 ) { 1104ui32Value = UDMA_ARB_256 ; 1105 }else { 1106// 1107// Default to arbitration size of 1. 1108// 1109ui32Value = UDMA_ARB_1 ; 1110 } 1111 1112// 1113// Keep the current size and or in the new arbitration size. 1114// 1115psUSBDMAInst -> pui32Config [ui32Channel - 1 ] &=0xff000000 ; 1116psUSBDMAInst -> pui32Config [ui32Channel - 1 ] |=ui32Value ; 1117 1118// 1119// Set the uDMA channel control, remember its channel starts at 0 and 1120// not 1. 1121// 1122MAP_uDMAChannelControlSet (ui32Channel - 1 , 1123psUSBDMAInst -> pui32Config [ui32Channel - 1 ]); 1124} 1125 1126//***************************************************************************** 1127// 1128// USBLibDMAArbSizeSet() for USB controllers that have an integrated DMA 1129// controller. 1130// 1131//***************************************************************************** 1132static void iDMAUSBArbSizeSet (tUSBDMAInstance * psUSBDMAInst , 1133uint32_t ui32Channel ,uint32_t ui32ArbSize ) {} 1134 1135//***************************************************************************** 1136// 1137// USBLibDMAStatus() for USB controllers that use uDMA for DMA or have an 1138// integrated DMA controller. 1139// 1140//***************************************************************************** 1141static uint32_t DMAUSBStatus (tUSBDMAInstance * psUSBDMAInst ) { 1142return (0 ); 1143} 1144 1145//***************************************************************************** 1146// 1147//! This function is used to return the current DMA pointer for a given 1148//! DMA channel. 1149//! 1150//! \param psUSBDMAInst is a generic instance pointer that can be used to 1151//! distinguish between different hardware instances. 1152//! \param ui32Channel is the DMA channel number for this request. 1153//! 1154//! This function returns the address that is in use by the DMA channel passed 1155//! in via the \e ui32Channel parameter. This is not the real-time pointer, 1156//! but the starting address of the DMA transfer for this DMA channel. 1157//! 1158//! \return The current DMA address for the given DMA channel. 1159// 1160//***************************************************************************** 1161void * USBLibDMAAddrGet (tUSBDMAInstance * psUSBDMAInst ,uint32_t ui32Channel ) { 1162return (psUSBDMAInst -> ppui32Data [ui32Channel - 1 ]); 1163} 1164 1165//***************************************************************************** 1166// 1167//! This function is used to return the current DMA transfer size for a given 1168//! DMA channel. 1169//! 1170//! \param psUSBDMAInst is a generic instance pointer that can be used to 1171//! distinguish between different hardware instances. 1172//! \param ui32Channel is the DMA channel number for this request. 1173//! 1174//! This function returns the DMA transfer size that is in use by the DMA 1175//! channel passed in via the \e ui32Channel parameter. 1176//! 1177//! \return The current DMA transfer size for the given DMA channel. 1178// 1179//***************************************************************************** 1180uint32_t USBLibDMASizeGet (tUSBDMAInstance * psUSBDMAInst ,uint32_t ui32Channel ) { 1181return (psUSBDMAInst -> pui32Count [ui32Channel - 1 ]); 1182} 1183 1184//***************************************************************************** 1185// 1186//! This function is used to initialize the DMA interface for a USB instance. 1187//! 1188//! \param ui32Index is the index of the USB controller for this instance. 1189//! 1190//! This function performs any initialization and configuration of the DMA 1191//! portions of the USB controller. This function returns a pointer that 1192//! is used with the remaining USBLibDMA APIs or the function returns zero 1193//! if the requested controller cannot support DMA. If this function is called 1194//! when already initialized it will not reinitialize the DMA controller and 1195//! will instead return the previously initialized DMA instance. 1196//! 1197//! \return A pointer to use with USBLibDMA APIs. 1198// 1199//***************************************************************************** 1200tUSBDMAInstance * USBLibDMAInit (uint32_t ui32Index ) { 1201uint32_t ui32Channel ; 1202 1203ASSERT (ui32Index == 0 ); 1204 1205// 1206// Make sure that the DMA has not already been initialized. 1207// 1208if (g_psUSBDMAInst [0 ].ui32Base == USB0_BASE ) { 1209return (& g_psUSBDMAInst [0 ]); 1210 } 1211 1212// 1213// Save the base address of the USB controller. 1214// 1215g_psUSBDMAInst [0 ].ui32Base = USB0_BASE ; 1216 1217// 1218// Save the interrupt number for the USB controller. 1219// 1220g_psUSBDMAInst [0 ].ui32IntNum = INT_USB0_TM4C123 ; 1221 1222// 1223// Initialize the function pointers. 1224// 1225g_psUSBDMAInst [0 ].pfnArbSizeSet = uDMAUSBArbSizeSet ; 1226g_psUSBDMAInst [0 ].pfnChannelAllocate = uDMAUSBChannelAllocate ; 1227g_psUSBDMAInst [0 ].pfnChannelDisable = uDMAUSBChannelDisable ; 1228g_psUSBDMAInst [0 ].pfnChannelEnable = uDMAUSBChannelEnable ; 1229g_psUSBDMAInst [0 ].pfnChannelIntEnable = uDMAUSBChannelIntEnable ; 1230g_psUSBDMAInst [0 ].pfnChannelIntDisable = uDMAUSBChannelIntDisable ; 1231g_psUSBDMAInst [0 ].pfnChannelRelease = uDMAUSBChannelRelease ; 1232g_psUSBDMAInst [0 ].pfnChannelStatus = uDMAUSBChannelStatus ; 1233g_psUSBDMAInst [0 ].pfnIntHandler = DMAUSBIntHandler ; 1234g_psUSBDMAInst [0 ].pfnIntStatus = uDMAUSBIntStatus ; 1235g_psUSBDMAInst [0 ].pfnIntStatusClear = DMAUSBIntStatusClear ; 1236g_psUSBDMAInst [0 ].pfnStatus = DMAUSBStatus ; 1237g_psUSBDMAInst [0 ].pfnTransfer = uDMAUSBTransfer ; 1238g_psUSBDMAInst [0 ].pfnUnitSizeSet = uDMAUSBUnitSizeSet ; 1239 1240// 1241// These devices have a different USB interrupt number. 1242// 1243if (CLASS_IS_TM4C129 ) { 1244g_psUSBDMAInst [0 ].ui32IntNum = INT_USB0_TM4C129 ; 1245 } 1246 1247// 1248// Initialize the function pointers for the integrated USB DMA controller. 1249// 1250if (USBControllerVersion (g_psUSBDMAInst [0 ].ui32Base )== 1251USB_CONTROLLER_VER_1 ) { 1252g_psUSBDMAInst [0 ].pfnArbSizeSet = iDMAUSBArbSizeSet ; 1253g_psUSBDMAInst [0 ].pfnChannelAllocate = iDMAUSBChannelAllocate ; 1254g_psUSBDMAInst [0 ].pfnChannelStatus = iDMAUSBChannelStatus ; 1255g_psUSBDMAInst [0 ].pfnIntStatus = iDMAUSBIntStatus ; 1256g_psUSBDMAInst [0 ].pfnChannelIntEnable = iDMAUSBChannelIntEnable ; 1257g_psUSBDMAInst [0 ].pfnChannelIntDisable = iDMAUSBChannelIntDisable ; 1258g_psUSBDMAInst [0 ].pfnTransfer = iDMAUSBTransfer ; 1259g_psUSBDMAInst [0 ].pfnChannelRelease = iDMAUSBChannelRelease ; 1260g_psUSBDMAInst [0 ].pfnChannelEnable = iDMAUSBChannelEnable ; 1261g_psUSBDMAInst [0 ].pfnChannelDisable = iDMAUSBChannelDisable ; 1262g_psUSBDMAInst [0 ].pfnUnitSizeSet = iDMAUSBUnitSizeSet ; 1263 } 1264 1265// 1266// Clear out the endpoint and the current configuration. 1267// 1268for (ui32Channel = 0 ;ui32Channel < USB_MAX_DMA_CHANNELS ;ui32Channel ++ ) { 1269g_psUSBDMAInst [0 ].pui8Endpoint [ui32Channel ]= 0 ; 1270g_psUSBDMAInst [0 ].pui32Config [ui32Channel ]= 0 ; 1271g_psUSBDMAInst [0 ].ui32Pending = 0 ; 1272g_psUSBDMAInst [0 ].ui32Complete = 0 ; 1273 } 1274return (& g_psUSBDMAInst [0 ]); 1275} 1276 1277//***************************************************************************** 1278// 1279// Close the Doxygen group. 1280//! @} 1281// 1282//*****************************************************************************