You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/05/05 19:23:10 UTC

[nuttx-apps] branch master updated: spitool: add support for 32-bit SPI BUS width

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new be55ea786 spitool: add support for 32-bit SPI BUS width
be55ea786 is described below

commit be55ea7869daa1a2ebbe3015e8a812261c7440af
Author: Radek Pesina <ra...@motec.com.au>
AuthorDate: Fri May 5 10:23:32 2023 +1000

    spitool: add support for 32-bit SPI BUS width
    
    Link: https://git.motec.com.au/id/I62920d28ab9804d52d25af3bcdd0f1ceb87be93f
---
 system/spi/spi_common.c |  2 +-
 system/spi/spi_exch.c   | 12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/system/spi/spi_common.c b/system/spi/spi_common.c
index 0f9cc4dba..906b4d1f0 100644
--- a/system/spi/spi_common.c
+++ b/system/spi/spi_common.c
@@ -192,7 +192,7 @@ int spitool_common_args(FAR struct spitool_s *spitool, FAR char **arg)
 
       case 'w':
         ret = arg_decimal(arg, &value);
-        if (value != 8 && value != 16)
+        if (value != 8 && value != 16 && value != 32)
           {
             goto out_of_range;
           }
diff --git a/system/spi/spi_exch.c b/system/spi/spi_exch.c
index 4d8d10c8f..31db5d83e 100644
--- a/system/spi/spi_exch.c
+++ b/system/spi/spi_exch.c
@@ -124,10 +124,14 @@ int spicmd_exch(FAR struct spitool_s *spitool, int argc, FAR char **argv)
         {
           spitool_printf(spitool, "%02X ", txdata[d]);
         }
-      else
+      else if (spitool->width <= 16)
         {
           spitool_printf(spitool, "%04X ", ((uint16_t *)txdata)[d]);
         }
+      else
+        {
+          spitool_printf(spitool, "%08" PRIX32 " ", ((uint32_t *)txdata)[d]);
+        }
     }
 
   spitool_printf(spitool, "\n");
@@ -175,10 +179,14 @@ int spicmd_exch(FAR struct spitool_s *spitool, int argc, FAR char **argv)
         {
           spitool_printf(spitool, "%02X ", rxdata[d]);
         }
-      else
+      else if (spitool->width <= 16)
         {
           spitool_printf(spitool, "%04X ", ((uint16_t *)rxdata)[d]);
         }
+      else
+        {
+          spitool_printf(spitool, "%08" PRIX32 " ", ((uint32_t *)rxdata)[d]);
+        }
     }
 
   spitool_printf(spitool, "\n");