All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexis Berlemont <berlemont.hauw@domain.hid>
To: "Alessio Margan @ IIT" <alessio.margan@domain.hid>
Cc: Xenomai-core@domain.hid
Subject: Re: [Xenomai-core] [PATCH] Sensoray 526 analogy driver
Date: Thu, 07 Jan 2010 21:52:03 +0100	[thread overview]
Message-ID: <4B464973.5050608@domain.hid> (raw)
In-Reply-To: <4B4632D1.3020709@domain.hid>

Hi,

Alessio Margan @ IIT wrote:
> Hi,
> 
> I've got a doubt about s526 driver on reading analog input.
> 
> I read analog data in this way
> 
> sampl_t data;
> a4l_insn_t insn_tab = {
> .type = A4L_INSN_READ,
> .idx_subd = idx_subd,
> .chan_desc = CHAN(idx_chan),
> .data_size = sizeof(data),
> .data = &data};
> 
> /* Sends the read instruction to the Analogy layer */
> ret = a4l_snd_insn(&dsc, &insn_tab);
> 
> on driver side data_size is the number of samples not the nr of byte to 
> read,
> the driver expect data_size to be the number of samples and data to be a 
> vector of samples
You are right. There is a bug in the driver. The field data_size is not 
the acquisition count but the size of all the acquisitions in bytes.

So we should see:
for (n = 0; n < insn->data_size / sizeof(uint16_t); n++) {

I will fix it tonight.

> 
> uint16_t *data = (uint16_t *)insn->data;
> 
> /* convert n samples */
> for (n = 0; n < insn->data_size; n++) {
> /* trigger conversion */
> outw(value, ADDR_REG(REG_ADC));
> a4l_info(dev, "s526_ai_rinsn: Wrote 0x%04x to ADC\n", value);
> a4l_info(dev, "s526_ai_rinsn: ADC reg=0x%04x\n", inw(ADDR_REG(REG_ADC)));
> 
> #define TIMEOUT 100
> 
> /* wait for conversion to end */
> for (i = 0; i < TIMEOUT; i++) {
> status = inw(ADDR_REG(REG_ISR));
> if (status & ISR_ADC_DONE) {
> outw(ISR_ADC_DONE, ADDR_REG(REG_ISR));
> break;
> }
> }
> if (i == TIMEOUT) {
> a4l_warn(dev, "s526_ai_rinsn: ADC(0x%04x) timeout\n", 
> inw(ADDR_REG(REG_ISR)));
> return -ETIMEDOUT;
> }
> 
> /* read data */
> d = inw(ADDR_REG(REG_ADD));
> a4l_info(dev, "s526_ai_rinsn: AI[%d]=0x%04x\n", n, (unsigned short)(d & 
> 0xFFFF));
> 
> /* munge data */
> data[n] = d ^ 0x8000;
> }
> 
> TIA
> 
> Alessio
> 

Alexis.


  reply	other threads:[~2010-01-07 20:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-07 19:15 [Xenomai-core] [PATCH] Sensoray 526 analogy driver Alessio Margan @ IIT
2010-01-07 20:52 ` Alexis Berlemont [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-01-11 16:08 Alessio Margan @ IIT
2010-01-11 16:22 ` Alexis Berlemont
2009-12-26 14:54 Simon Boulay
2009-12-28 20:44 ` Alexis Berlemont
     [not found] ` <4B3917BF.5070600@domain.hid>
2009-12-29  1:40   ` Simon Boulay
2009-12-29  8:32     ` Alessio Margan @ IIT
2009-12-30 14:53       ` Alessio Margan @ IIT
2010-01-02 12:28         ` Simon Boulay
2010-01-04 16:03           ` Alessio Margan @ IIT
2010-01-04 23:10             ` Alexis Berlemont

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B464973.5050608@domain.hid \
    --to=berlemont.hauw@domain.hid \
    --cc=Xenomai-core@domain.hid \
    --cc=alessio.margan@domain.hid \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.