davids5 commented on a change in pull request #3795:
URL: https://github.com/apache/incubator-nuttx/pull/3795#discussion_r640535534



##########
File path: arch/arm/src/s32k1xx/s32k1xx_lpspi.c
##########
@@ -1294,42 +1387,130 @@ static void s32k1xx_lpspi_exchange_nodma(FAR struct 
spi_dev_s *dev,
 {
   FAR struct s32k1xx_lpspidev_s *priv = (FAR struct s32k1xx_lpspidev_s *)dev;
   DEBUGASSERT(priv && priv->spibase);
+  uint16_t framesize;

Review comment:
       Coding standard:The variables need to be declared prior to any code 
execution.  Move this line above the DEBUGASSERT

##########
File path: arch/arm/src/s32k1xx/s32k1xx_lpspi.c
##########
@@ -1294,42 +1387,130 @@ static void s32k1xx_lpspi_exchange_nodma(FAR struct 
spi_dev_s *dev,
 {
   FAR struct s32k1xx_lpspidev_s *priv = (FAR struct s32k1xx_lpspidev_s *)dev;
   DEBUGASSERT(priv && priv->spibase);
+  uint16_t framesize;
 
   spiinfo("txbuffer=%p rxbuffer=%p nwords=%d\n", txbuffer, rxbuffer, nwords);
 
-  /* 8- or 16-bit mode? */
+  /* bit mode? */
 
-  if (s32k1xx_lpspi_9to16bitmode(priv))
+  framesize = s32k1xx_lpspi_9to16bitmode(priv);
+  if (framesize > 8)
     {
-      /* 16-bit mode */
+      /* 16-bit, 32-bit or 40-bit mode
+       * take care of big endian mode of hardware !!
+       */
 
-      const uint16_t *src = (const uint16_t *)txbuffer;
-      uint16_t *dest = (uint16_t *) rxbuffer;
-      uint16_t word;
+      const uint8_t *src = (const uint8_t *)txbuffer;
+      uint8_t *dest = (uint8_t *) rxbuffer;
+      uint32_t word = 0x0;
+#ifdef CONFIG_S32K1XX_LPSPI_DWORD
+      uint32_t word1 = 0x0;
+      uint32_t rword1;
+      bool     dwords = false;
+#endif
 
       while (nwords-- > 0)
         {
           /* Get the next word to write.  Is there a source buffer? */
 
           if (src)
             {
-              word = *src++;
+              /* read the required number of bytes */

Review comment:
       Performance will suffer with switching per nwords. It would be better to 
make the size determination once then have separate loops.  IIRC I did this in 
the stm32F4.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to