[Xenomai-git] Alexis Berlemont : analogy: [pcimio] minor fix in log messages

2010-10-17 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 575ed70ee113c32c27a9537ebd503fb07085aca8
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=575ed70ee113c32c27a9537ebd503fb07085aca8

Author: Alexis Berlemont 
Date:   Sun Oct 17 16:00:42 2010 +0200

analogy: [pcimio] minor fix in log messages

---

 ksrc/drivers/analogy/national_instruments/mite.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ksrc/drivers/analogy/national_instruments/mite.c 
b/ksrc/drivers/analogy/national_instruments/mite.c
index 9b0394a..a093ee2 100644
--- a/ksrc/drivers/analogy/national_instruments/mite.c
+++ b/ksrc/drivers/analogy/national_instruments/mite.c
@@ -579,7 +579,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, 
a4l_subd_t *subd)
nbytes_ub = mite_bytes_written_to_memory_ub(mite_chan);
 
if(a4l_buf_prepare_absput(subd, nbytes_ub) != 0) {
-   __a4l_info("MITE: DMA overwrite of free area\n");
+   __a4l_err("MITE: DMA overwrite of free area\n");
return -EPIPE;
}



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


[Xenomai-git] Alexis Berlemont : analogy: fix the default size of the buffer

2010-10-17 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: a5bec5ab2b2a77b6120a59d1b8ba0ff4be5b413a
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=a5bec5ab2b2a77b6120a59d1b8ba0ff4be5b413a

Author: Alexis Berlemont 
Date:   Sun Oct 17 15:54:04 2010 +0200

analogy: fix the default size of the buffer

---

 include/analogy/types.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/analogy/types.h b/include/analogy/types.h
index eec4ad0..e3974eb 100644
--- a/include/analogy/types.h
+++ b/include/analogy/types.h
@@ -27,7 +27,7 @@
 
 /* --- Misc precompilation constants --- */
 
-#define A4L_DEFAULT_BFSIZE 0x1000
+#define A4L_DEFAULT_BFSIZE 0x1
 #define A4L_NAMELEN 20
 
 /* --- Common Analogy types --- */


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


[Xenomai-git] Alexis Berlemont : analogy: add first version of waveform generation

2010-10-17 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: debcfb2b698c75a1a0f2d99556595c0a296f9baa
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=debcfb2b698c75a1a0f2d99556595c0a296f9baa

Author: Alexis Berlemont 
Date:   Sat Oct 16 14:59:54 2010 +0200

analogy: add first version of waveform generation

This work is based on Daniele Nicolodi's work. Unfortunately, I could
not include the proprosal as is because it was limited for 16bits
acquisition devices.

So far, this work is not complete.

---

 src/utils/analogy/Makefile.am |6 ++
 src/utils/analogy/signal_generation.c |  157 +
 src/utils/analogy/signal_generation.h |   38 
 3 files changed, 201 insertions(+), 0 deletions(-)

diff --git a/src/utils/analogy/Makefile.am b/src/utils/analogy/Makefile.am
index f82942e..3d8cb5e 100644
--- a/src/utils/analogy/Makefile.am
+++ b/src/utils/analogy/Makefile.am
@@ -9,6 +9,12 @@ CPPFLAGS = \
 LDFLAGS = \
@XENO_USER_LDFLAGS@
 
+lib_LIBRARIES = libwaveform.a
+
+libwaveform_a_SOURCES = signal_generation.c
+
+noinst_HEADERS = signal_generation.h
+
 analogy_config_SOURCES = analogy_config.c
 analogy_config_LDADD = \
../../drvlib/analogy/libanalogy.la \
diff --git a/src/utils/analogy/signal_generation.c 
b/src/utils/analogy/signal_generation.c
new file mode 100644
index 000..2f443c5
--- /dev/null
+++ b/src/utils/analogy/signal_generation.c
@@ -0,0 +1,157 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "signal_generation.h"
+
+#ifndef PI
+#define PI 3.14159265358979323846
+#endif
+
+void a4l_sg_init_sine(struct waveform_config *config, double *values)
+{
+   int i;
+
+   double ratio = config->wf_frequency / config->spl_frequency;
+
+   for (i = 0; i < config->spl_count; i++) {
+
+   values[i] = config->wf_offset -
+   config->wf_amplitude / 2 + 
+   0.5 * config->wf_amplitude * cos(i * 2 * PI * ratio);
+   }
+}
+
+void a4l_sg_init_sawtooth(struct waveform_config *config, double *values)
+{
+   int i;
+
+   double ratio = config->wf_frequency / config->spl_frequency;
+
+   for (i = 0; i < config->spl_count; i++) {
+   
+   int period_idx = (int)floor(i * ratio);
+
+   values[i] = config->wf_offset -
+   config->wf_amplitude / 2 -
+   period_idx * config->wf_amplitude +
+   i * ratio * config->wf_amplitude;
+   }
+}
+
+void a4l_sg_init_triangular(struct waveform_config *config, double *values)
+{
+   int i;
+
+   double ratio = config->wf_frequency / config->spl_frequency;
+
+   for (i = 0; i < config->spl_count; i++) {
+
+   int period_idx = (int)floor(i * ratio);
+   int half_period_idx = (int)floor(i * 2 * ratio);
+   int rise = ((half_period_idx % 2) == 0) ? 1 : 0;
+
+   if (rise) {
+   values[i] = config->wf_offset - 
+   config->wf_amplitude / 2 -
+   2 * period_idx * config->wf_amplitude +
+   2 * i * ratio * config->wf_amplitude;
+   } else {
+   values[i] = config->wf_offset -
+   config->wf_amplitude / 2 +
+   2 * (period_idx + 1) * config->wf_amplitude - 
+   2 * i * ratio * config->wf_amplitude;
+   }
+   }
+}
+
+void a4l_sg_init_steps(struct waveform_config *config, double *values)
+{
+   int i;
+   
+   double ratio = config->wf_frequency / config->spl_frequency;
+   
+   for (i = 0; i < config->spl_count; i++) {
+   int half_period_idx = (int)floor(i * 2 * ratio);
+   int even = (half_period_idx % 2 == 0);
+   
+   values[i] = config->wf_offset - 
+   config->wf_amplitude / 2 + even * config->wf_amplitude;
+   }
+}
+
+void a4l_sg_set_sample_count(struct waveform_config *config)
+{
+   int sample_count = MIN_SAMPLE_COUNT;
+   int best_count = MIN_SAMPLE_COUNT;
+   double lowest_diff = INFINITY;
+
+   while (sample_count < MAX_SAMPLE_COUNT) {
+
+   double ratio = (double)sample_count * 
+   (config->wf_frequency / config->spl_frequency);
+   int ceiling = ceil(ratio);
+   double diff = (double)ceiling - ratio;
+
+   assert(diff >= 0);
+
+   if (diff < lowest_diff) {
+   lowest_diff = diff;
+   best_count = sample_count;
+   }
+
+   if (diff == 0)
+   break;
+
+   sample_count++;
+   }
+
+   if (lowest_diff != 0) {
+   printf("Warning: unable to create a contiguous signal\n");
+   printf("Warning: an approximation is performed\n

[Xenomai-git] Alexis Berlemont : analogy: [pcimio] minor fix in log messages

2010-10-17 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 4f6f53acadd15f712ec238f676d20a8f407dfef0
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=4f6f53acadd15f712ec238f676d20a8f407dfef0

Author: Alexis Berlemont 
Date:   Sun Oct 17 16:00:42 2010 +0200

analogy: [pcimio] minor fix in log messages

---

 ksrc/drivers/analogy/national_instruments/mite.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ksrc/drivers/analogy/national_instruments/mite.c 
b/ksrc/drivers/analogy/national_instruments/mite.c
index 9b0394a..a093ee2 100644
--- a/ksrc/drivers/analogy/national_instruments/mite.c
+++ b/ksrc/drivers/analogy/national_instruments/mite.c
@@ -579,7 +579,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, 
a4l_subd_t *subd)
nbytes_ub = mite_bytes_written_to_memory_ub(mite_chan);
 
if(a4l_buf_prepare_absput(subd, nbytes_ub) != 0) {
-   __a4l_info("MITE: DMA overwrite of free area\n");
+   __a4l_err("MITE: DMA overwrite of free area\n");
return -EPIPE;
}



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


[Xenomai-git] Alexis Berlemont : analogy: fix the default size of the buffer

2010-10-17 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 1b8708a6d8cba5777c33d29e2b0da4c870186706
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=1b8708a6d8cba5777c33d29e2b0da4c870186706

Author: Alexis Berlemont 
Date:   Sun Oct 17 15:54:04 2010 +0200

analogy: fix the default size of the buffer

---

 include/analogy/types.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/analogy/types.h b/include/analogy/types.h
index eec4ad0..e3974eb 100644
--- a/include/analogy/types.h
+++ b/include/analogy/types.h
@@ -27,7 +27,7 @@
 
 /* --- Misc precompilation constants --- */
 
-#define A4L_DEFAULT_BFSIZE 0x1000
+#define A4L_DEFAULT_BFSIZE 0x1
 #define A4L_NAMELEN 20
 
 /* --- Common Analogy types --- */


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


[Xenomai-git] Alexis Berlemont : analogy: add first version of waveform generation

2010-10-17 Thread GIT version control
Module: xenomai-abe
Branch: analogy
Commit: 1c8f7dfbae13d89c6b7474ddd6b94a1711e2f919
URL:
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=1c8f7dfbae13d89c6b7474ddd6b94a1711e2f919

Author: Alexis Berlemont 
Date:   Sat Oct 16 14:59:54 2010 +0200

analogy: add first version of waveform generation

This work is based on Daniele Nicolodi's work. Unfortunately, I could
not include the proprosal as is because it was limited for 16bits
acquisition devices.

So far, this work is not complete.

---

 src/utils/analogy/Makefile.am |6 ++
 src/utils/analogy/signal_generation.c |  157 +
 src/utils/analogy/signal_generation.h |   38 
 3 files changed, 201 insertions(+), 0 deletions(-)

diff --git a/src/utils/analogy/Makefile.am b/src/utils/analogy/Makefile.am
index f82942e..3d8cb5e 100644
--- a/src/utils/analogy/Makefile.am
+++ b/src/utils/analogy/Makefile.am
@@ -9,6 +9,12 @@ CPPFLAGS = \
 LDFLAGS = \
@XENO_USER_LDFLAGS@
 
+lib_LIBRARIES = libwaveform.a
+
+libwaveform_a_SOURCES = signal_generation.c
+
+noinst_HEADERS = signal_generation.h
+
 analogy_config_SOURCES = analogy_config.c
 analogy_config_LDADD = \
../../drvlib/analogy/libanalogy.la \
diff --git a/src/utils/analogy/signal_generation.c 
b/src/utils/analogy/signal_generation.c
new file mode 100644
index 000..2f443c5
--- /dev/null
+++ b/src/utils/analogy/signal_generation.c
@@ -0,0 +1,157 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "signal_generation.h"
+
+#ifndef PI
+#define PI 3.14159265358979323846
+#endif
+
+void a4l_sg_init_sine(struct waveform_config *config, double *values)
+{
+   int i;
+
+   double ratio = config->wf_frequency / config->spl_frequency;
+
+   for (i = 0; i < config->spl_count; i++) {
+
+   values[i] = config->wf_offset -
+   config->wf_amplitude / 2 + 
+   0.5 * config->wf_amplitude * cos(i * 2 * PI * ratio);
+   }
+}
+
+void a4l_sg_init_sawtooth(struct waveform_config *config, double *values)
+{
+   int i;
+
+   double ratio = config->wf_frequency / config->spl_frequency;
+
+   for (i = 0; i < config->spl_count; i++) {
+   
+   int period_idx = (int)floor(i * ratio);
+
+   values[i] = config->wf_offset -
+   config->wf_amplitude / 2 -
+   period_idx * config->wf_amplitude +
+   i * ratio * config->wf_amplitude;
+   }
+}
+
+void a4l_sg_init_triangular(struct waveform_config *config, double *values)
+{
+   int i;
+
+   double ratio = config->wf_frequency / config->spl_frequency;
+
+   for (i = 0; i < config->spl_count; i++) {
+
+   int period_idx = (int)floor(i * ratio);
+   int half_period_idx = (int)floor(i * 2 * ratio);
+   int rise = ((half_period_idx % 2) == 0) ? 1 : 0;
+
+   if (rise) {
+   values[i] = config->wf_offset - 
+   config->wf_amplitude / 2 -
+   2 * period_idx * config->wf_amplitude +
+   2 * i * ratio * config->wf_amplitude;
+   } else {
+   values[i] = config->wf_offset -
+   config->wf_amplitude / 2 +
+   2 * (period_idx + 1) * config->wf_amplitude - 
+   2 * i * ratio * config->wf_amplitude;
+   }
+   }
+}
+
+void a4l_sg_init_steps(struct waveform_config *config, double *values)
+{
+   int i;
+   
+   double ratio = config->wf_frequency / config->spl_frequency;
+   
+   for (i = 0; i < config->spl_count; i++) {
+   int half_period_idx = (int)floor(i * 2 * ratio);
+   int even = (half_period_idx % 2 == 0);
+   
+   values[i] = config->wf_offset - 
+   config->wf_amplitude / 2 + even * config->wf_amplitude;
+   }
+}
+
+void a4l_sg_set_sample_count(struct waveform_config *config)
+{
+   int sample_count = MIN_SAMPLE_COUNT;
+   int best_count = MIN_SAMPLE_COUNT;
+   double lowest_diff = INFINITY;
+
+   while (sample_count < MAX_SAMPLE_COUNT) {
+
+   double ratio = (double)sample_count * 
+   (config->wf_frequency / config->spl_frequency);
+   int ceiling = ceil(ratio);
+   double diff = (double)ceiling - ratio;
+
+   assert(diff >= 0);
+
+   if (diff < lowest_diff) {
+   lowest_diff = diff;
+   best_count = sample_count;
+   }
+
+   if (diff == 0)
+   break;
+
+   sample_count++;
+   }
+
+   if (lowest_diff != 0) {
+   printf("Warning: unable to create a contiguous signal\n");
+   printf("Warning: an approximation is performed\n