Module: xenomai-2.5
Branch: master
Commit: 85f7babb313f3132300a35f0115ea7f294aa40db
URL:    
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=85f7babb313f3132300a35f0115ea7f294aa40db

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Mon Jan 18 00:13:08 2010 +0100

analogy: add the function a4l_sync_dio

---

 include/analogy/analogy.h |    3 ++
 src/drvlib/analogy/sync.c |   62 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/include/analogy/analogy.h b/include/analogy/analogy.h
index 987b083..ca05d60 100644
--- a/include/analogy/analogy.h
+++ b/include/analogy/analogy.h
@@ -130,6 +130,9 @@ int a4l_sync_read(a4l_desc_t * dsc,
                  unsigned int chan_desc,
                  unsigned int delay, void *buf, size_t nbyte);
 
+int a4l_sync_dio(a4l_desc_t *dsc,
+                unsigned int idx_subd, void *mask, void *buf);
+
 int a4l_sizeof_chan(a4l_chinfo_t * chan);
 
 int a4l_sizeof_subd(a4l_sbinfo_t *subd);
diff --git a/src/drvlib/analogy/sync.c b/src/drvlib/analogy/sync.c
index 66a6c00..69e31c3 100644
--- a/src/drvlib/analogy/sync.c
+++ b/src/drvlib/analogy/sync.c
@@ -255,6 +255,68 @@ int a4l_sync_read(a4l_desc_t * dsc,
 }
 
 /**
+ * @brief Perform a synchronous acquisition digital acquisition
+ *
+ * @param[in] dsc Device descriptor filled by a4l_open() (and
+ * optionally a4l_fill_desc())
+ * @param[in] idx_subd Index of the concerned subdevice
+ * @param[in] mask Write mask which indicates which bit(s) must be
+ * modified
+ * @param[in,out] buf Input / output buffer
+ *
+ * @return Number of bytes read, otherwise negative error code:
+ *
+ * - -EINVAL is returned if some argument is missing or wrong (Please,
+ *    type "dmesg" for more info)
+ * - -EFAULT is returned if a user <-> kernel transfer went wrong
+ * - -ENOMEM is returned if the system is out of memory
+ * - -ENOSYS is returned if the driver does not provide any handler
+ *    "instruction bits"
+ *
+ */
+int a4l_sync_dio(a4l_desc_t *dsc,
+                unsigned int idx_subd, void *mask, void *buf)
+{
+       unsigned char values[16];       
+       a4l_insn_t insn = {
+               .type = A4L_INSN_BITS,
+               .idx_subd = idx_subd,
+               .data = values,
+       };
+
+       int ret;
+       a4l_sbinfo_t *subd;
+
+       /* Get the subdevice descriptor */
+       ret = a4l_get_subdinfo(dsc, idx_subd, &subd);
+       if (ret < 0)
+               return ret;
+
+       /* Get the size in memory of a DIO acquisition */
+       switch(a4l_sizeof_subd(subd)) {
+       case 4:
+               ((uint32_t *)values)[0] = *((uint32_t *)mask);
+               ((uint32_t *)values)[1] = *((uint32_t *)buf);
+               break;
+       case 2: 
+               ((uint16_t *)values)[0] = *((uint16_t *)mask);
+               ((uint16_t *)values)[1] = *((uint16_t *)buf);
+               break;
+       case 1: 
+               ((uint8_t *)values)[0] = *((uint8_t *)mask);
+               ((uint8_t *)values)[1] = *((uint8_t *)buf);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /* Send the config instruction */
+       ret = a4l_snd_insn(dsc, &insn);
+       
+       return ret;
+}
+
+/**
  * @brief Configure a subdevice
  *
  * a4l_config_subd() takes a variable count of arguments. According to


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

Reply via email to