Module: xenomai-abe
Branch: analogy
Commit: 2c8eb888d943bcbc2498bfc6d55771b139a4a4cd
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=2c8eb888d943bcbc2498bfc6d55771b139a4a4cd

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Tue Dec 15 15:25:54 2009 +0100

analogy: add a simple helper function 

The added function displays the size taken in memory for an element
acquired from (/ sent to) a specific channel.

---

 include/analogy/analogy.h  |    4 +++-
 src/drvlib/analogy/range.c |   34 +++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/include/analogy/analogy.h b/include/analogy/analogy.h
index 21c7e59..79bd69c 100644
--- a/include/analogy/analogy.h
+++ b/include/analogy/analogy.h
@@ -129,7 +129,9 @@ int a4l_sync_read(a4l_desc_t * dsc,
                  unsigned int idx_subd,
                  unsigned int chan_desc,
                  unsigned int delay, void *buf, size_t nbyte);
-       
+
+int a4l_sizeof_chan(a4l_chinfo_t * chan);
+
 int a4l_find_range(a4l_desc_t * dsc,
                   unsigned int idx_subd,
                   unsigned int idx_chan,
diff --git a/src/drvlib/analogy/range.c b/src/drvlib/analogy/range.c
index 1965e57..05615bd 100644
--- a/src/drvlib/analogy/range.c
+++ b/src/drvlib/analogy/range.c
@@ -66,6 +66,38 @@ void data8_set(void *dst, lsampl_t val)
  */
 
 /**
+ * @brief Get the size in memory of an acquired element
+ *
+ * According to the board, the channels have various acquisition
+ * widths. With values like 8, 16 or 32, there is no problem finding
+ * out the size in memory (1, 2, 4); however with widths like 12 or
+ * 24, this function might be helpful to guess the size needed in RAM
+ * for a single acquired element.
+ *
+ * @param[in] chan Channel descriptor
+ *
+ * @return the size in memory of an acquired element, otherwise a negative
+ * error code:
+ *
+ * - -EINVAL is returned if the argument chan is NULL
+ *
+ */
+int a4l_sizeof_chan(a4l_chinfo_t * chan)
+{
+       /* So far, it seems there is no 64 bit acquistion stuff */
+       int i = 0, sizes[3] = {8, 16, 32};
+
+       if (chan == NULL)
+               return -EINVAL;
+
+       while (i < 3 && sizes[i] < chan->nb_bits)
+               i++;
+
+       return (i == 3) ? -EINVAL : sizes[i] / 8;
+}
+
+
+/**
  * @brief Find the must suitable range
  *
  * @param[in] dsc Device descriptor filled by a4l_open() and
@@ -241,7 +273,7 @@ int a4l_from_phys(a4l_chinfo_t * chan,
  *
  */
 int a4l_to_phys(a4l_chinfo_t * chan,
-                 a4l_rnginfo_t * rng, void *dst, double *src, int cnt)
+               a4l_rnginfo_t * rng, void *dst, double *src, int cnt)
 {
        int i = 0, j = 0;
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to