Commit 12ee3842 authored by Jorge Machado's avatar Jorge Machado

Merge branch 'dio_extension' of https://ohwr.org/project/fmc-dio-5chttla into dio_extension

parents 52511df5 9b8d2bab
...@@ -47,8 +47,10 @@ static void send_to_file_log_device(log_device dev, const char *msg) ...@@ -47,8 +47,10 @@ static void send_to_file_log_device(log_device dev, const char *msg)
if(!check_file_log_priv(dev)) { if(!check_file_log_priv(dev)) {
priv = get_private_info(dev); priv = get_private_info(dev);
fputs(msg, priv->fp); if(priv && priv->fp) {
fputs("\n", priv->fp); fputs(msg, priv->fp);
fputs("\n", priv->fp);
}
} }
} }
...@@ -56,10 +58,14 @@ static void deinit_file_log_device(log_device dev) ...@@ -56,10 +58,14 @@ static void deinit_file_log_device(log_device dev)
{ {
struct file_log_private *priv; struct file_log_private *priv;
if(dev->private) { if(!check_file_log_priv(dev)) {
priv = get_private_info(dev); priv = get_private_info(dev);
fclose(priv->fp); if(priv) {
free(dev->private); if(priv->fp) {
fclose(priv->fp);
}
free(priv);
}
} }
} }
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "fmc-dio-device.h" #include "fmc-dio-device.h"
#include "fmc-dio-device-private.h" #include "fmc-dio-device-private.h"
#define FMC_DIO_FLUSH_SLEEP 5
fmc_dio_device create_fmc_dio_device(char *name) fmc_dio_device create_fmc_dio_device(char *name)
{ {
fmc_dio_device dev = calloc(1, sizeof(*dev)); fmc_dio_device dev = calloc(1, sizeof(*dev));
...@@ -298,10 +300,14 @@ void flush_fmc_dio_device_channel(fmc_dio_device dev, int ch) ...@@ -298,10 +300,14 @@ void flush_fmc_dio_device_channel(fmc_dio_device dev, int ch)
struct usr_timestamp *ts; struct usr_timestamp *ts;
unsigned int nts; unsigned int nts;
LOG(dev, "Flushing FMC DIO device, channel %d... ", ch);
sleep(FMC_DIO_FLUSH_SLEEP);
ret = get_hw_ts_from_fmc_dio_device(dev, ch, &ts, &nts); ret = get_hw_ts_from_fmc_dio_device(dev, ch, &ts, &nts);
if(ret == 0) { if(ret == 0) {
free(ts); free(ts);
} }
LOG(dev, "Ok!\n");
} }
static int get_kernel_leaps_info(fmc_dio_device dev) static int get_kernel_leaps_info(fmc_dio_device dev)
......
...@@ -121,13 +121,13 @@ int main(int argc, char *argv[]) ...@@ -121,13 +121,13 @@ int main(int argc, char *argv[])
/* Before starting IRQ demo, Interrupts should be properly configured: /* Before starting IRQ demo, Interrupts should be properly configured:
* 1) Disable all interrupts * 1) Disable all interrupts
* 2) Flush TEST_FMC_DIO_CH channel * 2) Enable the TEST_FMC_DIO_CH interrupt line
* 3) Enable the TEST_FMC_DIO_CH interrupt line * 3) Flush TEST_FMC_DIO_CH channel
* 4) Setup specific information for interrupt line (period from user arguments or default one) * 4) Setup specific information for interrupt line (period from user arguments or default one)
*/ */
disable_fmc_dio_device_all_irq(dev); disable_fmc_dio_device_all_irq(dev);
flush_fmc_dio_device_channel(dev, TEST_FMC_DIO_CH);
enable_fmc_dio_device_irq(dev, TEST_FMC_DIO_CH); enable_fmc_dio_device_irq(dev, TEST_FMC_DIO_CH);
flush_fmc_dio_device_channel(dev, TEST_FMC_DIO_CH);
setup_fmc_dio_device_irq(dev, user_arguments->irq_period, TEST_FMC_DIO_COUNT); setup_fmc_dio_device_irq(dev, user_arguments->irq_period, TEST_FMC_DIO_COUNT);
/* Configure stdin as non-blocking. It is required for the user check exit function */ /* Configure stdin as non-blocking. It is required for the user check exit function */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment