@@ -542,10 +542,12 @@ static int xfer_packet(struct mspi_xfer_packet *packet, uint32_t timeout)
542542 xfer_packet -> num_bytes = packet -> num_bytes ;
543543
544544#ifdef CONFIG_MSPI_NRFE_IPC_NO_COPY
545- /* Check for alignlemt problems. */
545+ /* Check for alignment problems. */
546546 if (((uint32_t )packet -> data_buf ) % sizeof (uint32_t ) != 0 ) {
547- memcpy ((void * )(buffer + sizeof (nrfe_mspi_xfer_packet_msg_t )),
548- (void * )packet -> data_buf , packet -> num_bytes );
547+ if (packet -> dir == MSPI_TX ) {
548+ memcpy ((void * )(buffer + sizeof (nrfe_mspi_xfer_packet_msg_t )),
549+ (void * )packet -> data_buf , packet -> num_bytes );
550+ }
549551 xfer_packet -> data = buffer + sizeof (nrfe_mspi_xfer_packet_msg_t );
550552 } else {
551553 xfer_packet -> data = packet -> data_buf ;
@@ -557,20 +559,32 @@ static int xfer_packet(struct mspi_xfer_packet *packet, uint32_t timeout)
557559 rc = send_data (xfer_packet -> opcode , xfer_packet , len );
558560
559561 /* Wait for the transfer to complete and receive data. */
560- if ((packet -> dir == MSPI_RX ) && (ipc_receive_buffer != NULL ) && (ipc_received > 0 )) {
561- /*
562- * It is not possible to check whether received data is valid, so packet->num_bytes
563- * should always be equal to ipc_received. If it is not, then something went wrong.
564- */
565- if (packet -> num_bytes != ipc_received ) {
566- rc = - EIO ;
567- } else {
568- memcpy ((void * )packet -> data_buf , (void * )ipc_receive_buffer , ipc_received );
562+ if (packet -> dir == MSPI_RX ) {
563+ #ifdef CONFIG_MSPI_NRFE_IPC_NO_COPY
564+ /* Not aligned buffer. */
565+ if (((uint32_t )packet -> data_buf ) % sizeof (uint32_t ) != 0 ) {
566+ memcpy ((void * )packet -> data_buf , (void * )xfer_packet -> data ,
567+ packet -> num_bytes );
569568 }
569+ #else
570+ if ((ipc_receive_buffer != NULL ) && (ipc_received > 0 )) {
571+ /*
572+ * It is not possible to check whether received data is valid, so
573+ * packet->num_bytes should always be equal to ipc_received. If it is not,
574+ * then something went wrong.
575+ */
576+ if (packet -> num_bytes != ipc_received ) {
577+ rc = - EIO ;
578+ } else {
579+ memcpy ((void * )packet -> data_buf , (void * )ipc_receive_buffer ,
580+ ipc_received );
581+ }
570582
571- /* Clear the receive buffer pointer and size */
572- ipc_receive_buffer = NULL ;
573- ipc_received = 0 ;
583+ /* Clear the receive buffer pointer and size */
584+ ipc_receive_buffer = NULL ;
585+ ipc_received = 0 ;
586+ }
587+ #endif
574588 }
575589
576590 return rc ;
@@ -731,7 +745,7 @@ static int nrfe_mspi_init(const struct device *dev)
731745 .callback = flpr_fault_handler ,
732746 .user_data = NULL ,
733747 .flags = 0 ,
734- .ticks = counter_us_to_ticks (flpr_fault_timer , CONFIG_MSPI_NRFE_FAULT_TIMEOUT )
748+ .ticks = counter_us_to_ticks (flpr_fault_timer , CONFIG_MSPI_NRFE_FAULT_TIMEOUT ),
735749 };
736750#endif
737751
0 commit comments