diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-09-06 21:00:48 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-09-06 21:00:48 +0000 |
commit | f8523254d0c4584e1a56d835ab0af9e8a8625c4b (patch) | |
tree | 765ebc200ed841447879eaeb06f8ad02706c5428 | |
parent | ca6a50135e04d530ddf75b38f7fff1081ced6de4 (diff) | |
download | px4-nuttx-f8523254d0c4584e1a56d835ab0af9e8a8625c4b.tar.gz px4-nuttx-f8523254d0c4584e1a56d835ab0af9e8a8625c4b.tar.bz2 px4-nuttx-f8523254d0c4584e1a56d835ab0af9e8a8625c4b.zip |
Fix a error the the STM32 I2C timeout logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3940 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | apps/system/i2c/i2c_common.c | 2 | ||||
-rw-r--r-- | apps/system/i2c/i2c_main.c | 4 | ||||
-rw-r--r-- | apps/system/i2c/i2ctool.h | 5 | ||||
-rw-r--r-- | nuttx/ChangeLog | 5 | ||||
-rw-r--r-- | nuttx/Documentation/NuttShell.html | 2 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_i2c.c | 2 | ||||
-rw-r--r-- | nuttx/drivers/pm/pm_checkstate.c | 2 | ||||
-rw-r--r-- | nuttx/include/nuttx/pm.h | 17 |
8 files changed, 31 insertions, 8 deletions
diff --git a/apps/system/i2c/i2c_common.c b/apps/system/i2c/i2c_common.c index a04f7769a..6d5396346 100644 --- a/apps/system/i2c/i2c_common.c +++ b/apps/system/i2c/i2c_common.c @@ -187,7 +187,7 @@ int arg_decimal(FAR char **arg, FAR long *value) { FAR char *string; int ret; - + ret = arg_string(arg, &string); *value = strtol(string, NULL, 10); return ret; diff --git a/apps/system/i2c/i2c_main.c b/apps/system/i2c/i2c_main.c index 85ad90365..7e4a0c91b 100644 --- a/apps/system/i2c/i2c_main.c +++ b/apps/system/i2c/i2c_main.c @@ -253,7 +253,7 @@ FAR char *i2c_argument(FAR struct i2ctool_s *i2ctool, int argc, char *argv[], in int i2c_parse(FAR struct i2ctool_s *i2ctool, int argc, char *argv[]) { - FAR char *newargs[MAX_ARGUMENTS+1]; + FAR char *newargs[MAX_ARGUMENTS+2]; FAR char *cmd; int nargs; int index; @@ -278,7 +278,7 @@ int i2c_parse(FAR struct i2ctool_s *i2ctool, int argc, char *argv[]) /* Parse all of the arguments following the command name. */ newargs[0] = cmd; - for (nargs = 1; nargs < MAX_ARGUMENTS; nargs++) + for (nargs = 1; nargs <= MAX_ARGUMENTS; nargs++) { newargs[nargs] = i2c_argument(i2ctool, argc, argv, &index); if (!newargs[nargs]) diff --git a/apps/system/i2c/i2ctool.h b/apps/system/i2c/i2ctool.h index 5abd731aa..81b7c0682 100644 --- a/apps/system/i2c/i2ctool.h +++ b/apps/system/i2c/i2ctool.h @@ -91,10 +91,11 @@ #endif /* This is the maximum number of arguments that will be accepted for a - * command + * command. The only real limit is in the OS configuration that limits + * the number of parameters passed to a task. */ -#define MAX_ARGUMENTS 6 +#define MAX_ARGUMENTS (CONFIG_MAX_TASK_ARGS-1) /* Maximum size of one command line */ diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index a5743d55e..32522415b 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2052,3 +2052,8 @@ * lib/time/lib_gmtimer.c: Correct several calculations that could lead to errors in dates. * drivers/pm: Add the beginnings of a NuttX power management sub-system. + * arch/arm/src/stm32/stm32_irq.c: Fix a error introduced in 6.8. + Timeout calculation uses clock_settime() instead of clock_gettime(). + Pretty gross error, but actually it works with the side effect of setting + a bad time. + diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 693105166..73bb1bf65 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -1497,7 +1497,7 @@ ping [-c <count>] [-i <interval>] <ip-address> Test the network communication with a remote peer. Example, </p> <ul><pre> -nsh> 10.0.0.1 +nsh> ping 10.0.0.1 PING 10.0.0.1 56 bytes of data 56 bytes from 10.0.0.1: icmp_seq=1 time=0 ms 56 bytes from 10.0.0.1: icmp_seq=2 time=0 ms diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c.c b/nuttx/arch/arm/src/stm32/stm32_i2c.c index 605719246..09f61c05c 100644 --- a/nuttx/arch/arm/src/stm32/stm32_i2c.c +++ b/nuttx/arch/arm/src/stm32/stm32_i2c.c @@ -200,7 +200,7 @@ int inline stm32_i2c_sem_waitisr(FAR struct i2c_dev_s *dev) flags = irqsave(); do { - (void)clock_settime(CLOCK_REALTIME, &abstime); + (void)clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000; if (abstime.tv_nsec > 1000 * 1000 * 1000) { diff --git a/nuttx/drivers/pm/pm_checkstate.c b/nuttx/drivers/pm/pm_checkstate.c index 93f19a502..9ecff862e 100644 --- a/nuttx/drivers/pm/pm_checkstate.c +++ b/nuttx/drivers/pm/pm_checkstate.c @@ -129,7 +129,7 @@ enum pm_state_e pm_checkstate(void) now = clock_systimer(); if (now - g_pmglobals.stime >= TIME_SLICE_TICKS) { - int16_t accum; + int16_t accum; /* Sample the count, reset the time and count, and assess the PM * state. This is an atomic operation because interrupts are diff --git a/nuttx/include/nuttx/pm.h b/nuttx/include/nuttx/pm.h index 898a82b88..520348ca6 100644 --- a/nuttx/include/nuttx/pm.h +++ b/nuttx/include/nuttx/pm.h @@ -458,5 +458,22 @@ EXTERN int pm_changestate(enum pm_state_e newstate); #endif #endif /* __ASSEMBLY__ */ + +/**************************************************************************** + * Stubs + ****************************************************************************/ + +#else /* CONFIG_PM */ + +/* Stubbed out versions of all of PM interface functions that may be used to + * avoid so much conditional compilation in driver code when PM is disabled: + */ + +# define pm_initialize() +# define pm_register(cb) (0) +# define pm_activity(prio) +# define pm_checkstate() (0) +# define pm_changestate(state) + #endif /* CONFIG_PM */ #endif /* __INCLUDE_NUTTX_PM_H */ |