@@ -143,7 +143,7 @@ static void *USB_EhciGetBase(uint8_t controllerId, uint32_t *baseArray, uint8_t
143143 return NULL ;
144144 }
145145
146- return (void * )(uint8_t * )baseArray [controllerId ];
146+ return (void * )(uint8_t * )( uintptr_t ) baseArray [controllerId ];
147147}
148148#endif
149149
@@ -166,8 +166,8 @@ static void USB_DeviceEhciSetDefaultState(usb_device_ehci_state_struct_t *ehciSt
166166 p = ehciState -> dtdFree ;
167167 for (uint32_t i = 1U ; i < USB_DEVICE_CONFIG_EHCI_MAX_DTD ; i ++ )
168168 {
169- p -> nextDtdPointer = (uint32_t )& ehciState -> dtd [i ];
170- p = (usb_device_ehci_dtd_struct_t * )p -> nextDtdPointer ;
169+ p -> nextDtdPointer = (uint32_t )( uintptr_t ) & ehciState -> dtd [i ];
170+ p = (usb_device_ehci_dtd_struct_t * )( uintptr_t ) p -> nextDtdPointer ;
171171 }
172172 p -> nextDtdPointer = 0U ;
173173 ehciState -> dtdCount = USB_DEVICE_CONFIG_EHCI_MAX_DTD ;
@@ -201,7 +201,7 @@ static void USB_DeviceEhciSetDefaultState(usb_device_ehci_state_struct_t *ehciSt
201201 ehciState -> registerBase -> EPLISTADDR = (uint32_t )USB_DEV_MEMORY_CPU_2_DMA (ehciState -> qh );
202202#else
203203 /* Add QH buffer address to USBHS_EPLISTADDR_REG */
204- ehciState -> registerBase -> EPLISTADDR = (uint32_t )ehciState -> qh ;
204+ ehciState -> registerBase -> EPLISTADDR = (uint32_t )( uintptr_t ) ehciState -> qh ;
205205#endif
206206
207207 /* Clear device address */
@@ -532,7 +532,7 @@ static void USB_DeviceEhciCancelControlPipe(usb_device_ehci_state_struct_t *ehci
532532 message .length = 0U ;
533533 /* Get the dtd of the control pipe */
534534 currentDtd =
535- (usb_device_ehci_dtd_struct_t * )((uint32_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
535+ (usb_device_ehci_dtd_struct_t * )((uintptr_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
536536 while (NULL != currentDtd )
537537 {
538538 /* Pass the transfer buffer address */
@@ -543,7 +543,7 @@ static void USB_DeviceEhciCancelControlPipe(usb_device_ehci_state_struct_t *ehci
543543#else
544544 uint32_t bufferAddress = currentDtd -> bufferPointerPage [0 ];
545545#endif
546- message .buffer = (uint8_t * )((bufferAddress & USB_DEVICE_ECHI_DTD_PAGE_MASK ) |
546+ message .buffer = (uint8_t * )(uintptr_t )( (bufferAddress & USB_DEVICE_ECHI_DTD_PAGE_MASK ) |
547547 (currentDtd -> reservedUnion .originalBufferInfo .originalBufferOffest ));
548548 }
549549 /* If the dtd is active, set the message length to USB_CANCELLED_TRANSFER_LENGTH. Or set the length by using
@@ -595,13 +595,13 @@ static void USB_DeviceEhciCancelControlPipe(usb_device_ehci_state_struct_t *ehci
595595 ehciState -> dtdHard [index ] =
596596 (usb_device_ehci_dtd_struct_t * )USB_DEV_MEMORY_DMA_2_CPU (ehciState -> dtdHard [index ]-> nextDtdPointer );
597597#else
598- ehciState -> dtdHard [index ] = (usb_device_ehci_dtd_struct_t * )ehciState -> dtdHard [index ]-> nextDtdPointer ;
598+ ehciState -> dtdHard [index ] = (usb_device_ehci_dtd_struct_t * )( uintptr_t ) ehciState -> dtdHard [index ]-> nextDtdPointer ;
599599#endif
600600 }
601601
602602 /* When the ioc is set or the dtd queue is empty, the up layer will be notified. */
603603 if ((0U != currentDtd -> dtdTokenUnion .dtdTokenBitmap .ioc ) ||
604- (0U == ((uint32_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK )))
604+ (0U == ((uintptr_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK )))
605605 {
606606 message .code = endpoint | (uint8_t )((uint32_t )direction << 0x07U );
607607 message .isSetup = 0U ;
@@ -613,13 +613,13 @@ static void USB_DeviceEhciCancelControlPipe(usb_device_ehci_state_struct_t *ehci
613613 /* Clear the token field of the dtd. */
614614 currentDtd -> dtdTokenUnion .dtdToken = 0U ;
615615 /* Add the dtd to the free dtd queue. */
616- currentDtd -> nextDtdPointer = (uint32_t )ehciState -> dtdFree ;
616+ currentDtd -> nextDtdPointer = (uint32_t )( uintptr_t ) ehciState -> dtdFree ;
617617 ehciState -> dtdFree = currentDtd ;
618618 ehciState -> dtdCount ++ ;
619619
620620 /* Get the next in-used dtd. */
621621 currentDtd =
622- (usb_device_ehci_dtd_struct_t * )((uint32_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
622+ (usb_device_ehci_dtd_struct_t * )((uintptr_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
623623 }
624624}
625625
@@ -717,13 +717,13 @@ static void USB_DeviceEhciInterruptTokenDone(usb_device_ehci_state_struct_t *ehc
717717 }
718718 }
719719 /* Get the in-used dtd of the specified endpoint. */
720- currentDtd = (usb_device_ehci_dtd_struct_t * )(( uint32_t )ehciState -> dtdHard [index ] &
720+ currentDtd = (usb_device_ehci_dtd_struct_t * )(uintptr_t )(( uintptr_t )ehciState -> dtdHard [index ] &
721721 USB_DEVICE_ECHI_DTD_POINTER_MASK );
722722 while (NULL != currentDtd )
723723 {
724724 uint8_t isTokenDone = 0 ;
725725 /* Get the in-used dtd of the specified endpoint. */
726- currentDtd = (usb_device_ehci_dtd_struct_t * )(( uint32_t )ehciState -> dtdHard [index ] &
726+ currentDtd = (usb_device_ehci_dtd_struct_t * )(uintptr_t )(( uintptr_t )ehciState -> dtdHard [index ] &
727727 USB_DEVICE_ECHI_DTD_POINTER_MASK );
728728
729729 while (NULL != currentDtd )
@@ -744,7 +744,7 @@ static void USB_DeviceEhciInterruptTokenDone(usb_device_ehci_state_struct_t *ehc
744744 }
745745 break ;
746746 }
747- currentDtd = (usb_device_ehci_dtd_struct_t * )(currentDtd -> nextDtdPointer &
747+ currentDtd = (usb_device_ehci_dtd_struct_t * )(uintptr_t )( currentDtd -> nextDtdPointer &
748748 USB_DEVICE_ECHI_DTD_POINTER_MASK );
749749 }
750750
@@ -754,7 +754,7 @@ static void USB_DeviceEhciInterruptTokenDone(usb_device_ehci_state_struct_t *ehc
754754 }
755755
756756 /* Get the in-used dtd of the specified endpoint. */
757- currentDtd = (usb_device_ehci_dtd_struct_t * )(( uint32_t )ehciState -> dtdHard [index ] &
757+ currentDtd = (usb_device_ehci_dtd_struct_t * )(uintptr_t )(( uintptr_t )ehciState -> dtdHard [index ] &
758758 USB_DEVICE_ECHI_DTD_POINTER_MASK );
759759 while (NULL != currentDtd )
760760 {
@@ -771,7 +771,7 @@ static void USB_DeviceEhciInterruptTokenDone(usb_device_ehci_state_struct_t *ehc
771771 if (NULL == message .buffer )
772772 {
773773 message .buffer =
774- (uint8_t * )((currentDtd -> bufferPointerPage [0 ] & USB_DEVICE_ECHI_DTD_PAGE_MASK ) |
774+ (uint8_t * )(uintptr_t )( (currentDtd -> bufferPointerPage [0 ] & USB_DEVICE_ECHI_DTD_PAGE_MASK ) |
775775 (currentDtd -> reservedUnion .originalBufferInfo .originalBufferOffest ));
776776#if defined FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
777777 message .buffer = (uint8_t * )USB_DEV_MEMORY_DMA_2_CPU (message .buffer );
@@ -800,13 +800,13 @@ static void USB_DeviceEhciInterruptTokenDone(usb_device_ehci_state_struct_t *ehc
800800 (uint8_t * )ehciState -> dtdHard [index ]-> nextDtdPointer );
801801#else
802802 ehciState -> dtdHard [index ] =
803- (usb_device_ehci_dtd_struct_t * )ehciState -> dtdHard [index ]-> nextDtdPointer ;
803+ (usb_device_ehci_dtd_struct_t * )( uintptr_t ) ehciState -> dtdHard [index ]-> nextDtdPointer ;
804804#endif
805805 }
806806
807807 /* When the ioc is set or the dtd queue is empty, the up layer will be notified. */
808808 if ((0U != currentDtd -> dtdTokenUnion .dtdTokenBitmap .ioc ) ||
809- (0U == ((uint32_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK )))
809+ (0U == ((uintptr_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK )))
810810 {
811811 message .code = endpoint | (uint8_t )((uint32_t )direction << 0x07U );
812812 message .isSetup = 0U ;
@@ -816,11 +816,11 @@ static void USB_DeviceEhciInterruptTokenDone(usb_device_ehci_state_struct_t *ehc
816816 }
817817 /* Clear the token field of the dtd */
818818 currentDtd -> dtdTokenUnion .dtdToken = 0U ;
819- currentDtd -> nextDtdPointer = (uint32_t )ehciState -> dtdFree ;
819+ currentDtd -> nextDtdPointer = (uint32_t )( uintptr_t ) ehciState -> dtdFree ;
820820 ehciState -> dtdFree = currentDtd ;
821821 ehciState -> dtdCount ++ ;
822822 /* Get the next in-used dtd */
823- currentDtd = (usb_device_ehci_dtd_struct_t * )(( uint32_t )ehciState -> dtdHard [index ] &
823+ currentDtd = (usb_device_ehci_dtd_struct_t * )(uintptr_t )(( uintptr_t )ehciState -> dtdHard [index ] &
824824 USB_DEVICE_ECHI_DTD_POINTER_MASK );
825825#if defined FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
826826 currentDtd = (usb_device_ehci_dtd_struct_t * )USB_DEV_MEMORY_DMA_2_CPU ((uint8_t * )currentDtd );
@@ -850,7 +850,7 @@ static void USB_DeviceEhciInterruptTokenDone(usb_device_ehci_state_struct_t *ehc
850850 (usb_device_ehci_dtd_struct_t * )USB_DEV_MEMORY_CPU_2_DMA ((uint8_t * )currentDtd );
851851#endif
852852 /* Prime next dtd and prime the transfer */
853- ehciState -> qh [index ].nextDtdPointer = (uint32_t )currentDtd ;
853+ ehciState -> qh [index ].nextDtdPointer = (uint32_t )( uintptr_t ) currentDtd ;
854854 ehciState -> qh [index ].dtdTokenUnion .dtdToken = 0U ;
855855 ehciState -> registerBase -> EPPRIME = primeBit ;
856856 }
@@ -1139,7 +1139,7 @@ static usb_status_t USB_DeviceEhciTransfer(usb_device_ehci_state_struct_t *ehciS
11391139 /* Get a free dtd */
11401140 dtd = ehciState -> dtdFree ;
11411141
1142- ehciState -> dtdFree = (usb_device_ehci_dtd_struct_t * )dtd -> nextDtdPointer ;
1142+ ehciState -> dtdFree = (usb_device_ehci_dtd_struct_t * )( uintptr_t ) dtd -> nextDtdPointer ;
11431143 ehciState -> dtdCount -- ;
11441144
11451145 /* Save the dtd head when current active buffer offset is zero. */
@@ -1154,7 +1154,7 @@ static usb_status_t USB_DeviceEhciTransfer(usb_device_ehci_state_struct_t *ehciS
11541154#if defined FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
11551155 dtd -> bufferPointerPage [0 ] = (uint32_t )USB_DEV_MEMORY_CPU_2_DMA ((buffer + currentIndex ));
11561156#else
1157- dtd -> bufferPointerPage [0 ] = (uint32_t )(buffer + currentIndex );
1157+ dtd -> bufferPointerPage [0 ] = (uint32_t )(uintptr_t )( buffer + currentIndex );
11581158#endif
11591159 dtd -> bufferPointerPage [1 ] =
11601160 (dtd -> bufferPointerPage [0 ] + USB_DEVICE_ECHI_DTD_PAGE_BLOCK ) & USB_DEVICE_ECHI_DTD_PAGE_MASK ;
@@ -1192,9 +1192,9 @@ static usb_status_t USB_DeviceEhciTransfer(usb_device_ehci_state_struct_t *ehciS
11921192 if (NULL != (ehciState -> dtdTail [index ]))
11931193 {
11941194#if defined FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
1195- ehciState -> dtdTail [index ]-> nextDtdPointer = (uint32_t )USB_DEV_MEMORY_CPU_2_DMA (dtd );
1195+ ehciState -> dtdTail [index ]-> nextDtdPointer = (uint32_t )( uintptr_t ) USB_DEV_MEMORY_CPU_2_DMA (dtd );
11961196#else
1197- ehciState -> dtdTail [index ]-> nextDtdPointer = (uint32_t )dtd ;
1197+ ehciState -> dtdTail [index ]-> nextDtdPointer = (uint32_t )( uintptr_t ) dtd ;
11981198#endif
11991199 ehciState -> dtdTail [index ] = dtd ;
12001200 }
@@ -1260,9 +1260,9 @@ static usb_status_t USB_DeviceEhciTransfer(usb_device_ehci_state_struct_t *ehciS
12601260 if ((0U != qhIdle ) || (0U == (epStatus & primeBit )))
12611261 {
12621262#if defined FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
1263- ehciState -> qh [index ].nextDtdPointer = (uint32_t )USB_DEV_MEMORY_CPU_2_DMA (dtdHard );
1263+ ehciState -> qh [index ].nextDtdPointer = (uint32_t )( uintptr_t ) USB_DEV_MEMORY_CPU_2_DMA (dtdHard );
12641264#else
1265- ehciState -> qh [index ].nextDtdPointer = (uint32_t )dtdHard ;
1265+ ehciState -> qh [index ].nextDtdPointer = (uint32_t )( uintptr_t ) dtdHard ;
12661266#endif
12671267 ehciState -> qh [index ].dtdTokenUnion .dtdToken = 0U ;
12681268 /*make sure dtd is linked to dqh*/
@@ -1504,7 +1504,7 @@ usb_status_t USB_DeviceEhciInit(uint8_t controllerId,
15041504
15051505 ehciState -> controllerId = controllerId ;
15061506
1507- ehciState -> registerBase = (USBHS_Type * )ehci_base [controllerId - (uint8_t )kUSB_ControllerEhci0 ];
1507+ ehciState -> registerBase = (USBHS_Type * )( uintptr_t ) ehci_base [controllerId - (uint8_t )kUSB_ControllerEhci0 ];
15081508#if (defined(USB_DEVICE_CONFIG_LOW_POWER_MODE ) && (USB_DEVICE_CONFIG_LOW_POWER_MODE > 0U ))
15091509#if ((defined FSL_FEATURE_SOC_USBPHY_COUNT ) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U ))
15101510#if defined(FSL_FEATURE_USBHS_SUPPORT_EUSBn )
@@ -1796,7 +1796,7 @@ usb_status_t USB_DeviceEhciCancel(usb_device_controller_handle ehciHandle, uint8
17961796
17971797 /* Get the first dtd */
17981798 currentDtd =
1799- (usb_device_ehci_dtd_struct_t * )((uint32_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
1799+ (usb_device_ehci_dtd_struct_t * )((uintptr_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
18001800
18011801 /* In the next loop, USB_DeviceNotificationTrigger function may trigger a new transfer and the context always
18021802 * keep in the critical section, so the Dtd sequence would still keep non-empty and the loop would be endless.
@@ -1810,13 +1810,13 @@ usb_status_t USB_DeviceEhciCancel(usb_device_controller_handle ehciHandle, uint8
18101810 currentDtd = (usb_device_ehci_dtd_struct_t * )USB_DEV_MEMORY_DMA_2_CPU (currentDtd -> nextDtdPointer &
18111811 USB_DEVICE_ECHI_DTD_POINTER_MASK );
18121812#else
1813- currentDtd = (usb_device_ehci_dtd_struct_t * )(currentDtd -> nextDtdPointer & USB_DEVICE_ECHI_DTD_POINTER_MASK );
1813+ currentDtd = (usb_device_ehci_dtd_struct_t * )(uintptr_t )( currentDtd -> nextDtdPointer & USB_DEVICE_ECHI_DTD_POINTER_MASK );
18141814#endif
18151815 }
18161816
18171817 /* Get the first dtd */
18181818 currentDtd =
1819- (usb_device_ehci_dtd_struct_t * )((uint32_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
1819+ (usb_device_ehci_dtd_struct_t * )((uintptr_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
18201820 while (NULL != currentDtd )
18211821 {
18221822 /* this if statement is used with the previous while loop to avoid the endless loop */
@@ -1851,10 +1851,10 @@ usb_status_t USB_DeviceEhciCancel(usb_device_controller_handle ehciHandle, uint8
18511851 {
18521852#if defined FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
18531853 convert_addr = (uint32_t )USB_DEV_MEMORY_DMA_2_CPU (currentDtd -> bufferPointerPage [0 ]);
1854- message .buffer = (uint8_t * )((convert_addr & USB_DEVICE_ECHI_DTD_PAGE_MASK ) |
1854+ message .buffer = (uint8_t * )(uintptr_t )( (convert_addr & USB_DEVICE_ECHI_DTD_PAGE_MASK ) |
18551855 (currentDtd -> reservedUnion .originalBufferInfo .originalBufferOffest ));
18561856#else
1857- message .buffer = (uint8_t * )((currentDtd -> bufferPointerPage [0 ] & USB_DEVICE_ECHI_DTD_PAGE_MASK ) |
1857+ message .buffer = (uint8_t * )(uintptr_t )( (currentDtd -> bufferPointerPage [0 ] & USB_DEVICE_ECHI_DTD_PAGE_MASK ) |
18581858 (currentDtd -> reservedUnion .originalBufferInfo .originalBufferOffest ));
18591859#endif
18601860 }
@@ -1871,26 +1871,26 @@ usb_status_t USB_DeviceEhciCancel(usb_device_controller_handle ehciHandle, uint8
18711871 ehciState -> dtdHard [index ] =
18721872 (usb_device_ehci_dtd_struct_t * )USB_DEV_MEMORY_DMA_2_CPU (ehciState -> dtdHard [index ]-> nextDtdPointer );
18731873#else
1874- ehciState -> dtdHard [index ] = (usb_device_ehci_dtd_struct_t * )ehciState -> dtdHard [index ]-> nextDtdPointer ;
1874+ ehciState -> dtdHard [index ] = (usb_device_ehci_dtd_struct_t * )( uintptr_t ) ehciState -> dtdHard [index ]-> nextDtdPointer ;
18751875#endif
18761876 }
18771877
18781878 /* When the ioc is set or the dtd queue is empty, the up layer will be notified. */
18791879 if ((0U != currentDtd -> dtdTokenUnion .dtdTokenBitmap .ioc ) ||
1880- (0U == ((uint32_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK )))
1880+ (0U == ((uintptr_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK )))
18811881 {
18821882 flag = 1 ;
18831883 }
18841884 /* Clear the token field. */
18851885 currentDtd -> dtdTokenUnion .dtdToken = 0U ;
18861886 /* Save the dtd to the free queue. */
1887- currentDtd -> nextDtdPointer = (uint32_t )ehciState -> dtdFree ;
1887+ currentDtd -> nextDtdPointer = (uint32_t )( uintptr_t ) ehciState -> dtdFree ;
18881888 ehciState -> dtdFree = currentDtd ;
18891889 ehciState -> dtdCount ++ ;
18901890 }
18911891 /* Get the next dtd. */
18921892 currentDtd =
1893- (usb_device_ehci_dtd_struct_t * )((uint32_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
1893+ (usb_device_ehci_dtd_struct_t * )((uintptr_t )ehciState -> dtdHard [index ] & USB_DEVICE_ECHI_DTD_POINTER_MASK );
18941894 }
18951895 if (NULL == currentDtd )
18961896 {
0 commit comments