summaryrefslogtreecommitdiff
path: root/nuttx/arch
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-06 19:58:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-06 19:58:14 +0000
commit7a21220ebd5cef442fb059c90e18ff90232d8dc9 (patch)
tree38277e8efa923112be23e9a0554313c0927f02e2 /nuttx/arch
parent4fc87116d818f5285403dbb37d2aa60d33e4203a (diff)
downloadpx4-nuttx-7a21220ebd5cef442fb059c90e18ff90232d8dc9.tar.gz
px4-nuttx-7a21220ebd5cef442fb059c90e18ff90232d8dc9.tar.bz2
px4-nuttx-7a21220ebd5cef442fb059c90e18ff90232d8dc9.zip
Verified basic client-side network functionalitynuttx-3.0
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@373 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch')
-rw-r--r--nuttx/arch/arm/src/common/up_udelay.c52
-rw-r--r--nuttx/arch/sim/src/up_uipdriver.c2
2 files changed, 25 insertions, 29 deletions
diff --git a/nuttx/arch/arm/src/common/up_udelay.c b/nuttx/arch/arm/src/common/up_udelay.c
index f7d10e459..40ec3ba75 100644
--- a/nuttx/arch/arm/src/common/up_udelay.c
+++ b/nuttx/arch/arm/src/common/up_udelay.c
@@ -44,8 +44,9 @@
* Definitions
****************************************************************************/
-#define CONFIG_BOARD_LOOPSPERUSEC ((CONFIG_BOARD_LOOPSPERMSEC+500)/1000)
-#define CONFIG_BOARD_LOOPSPER10USEC ((CONFIG_BOARD_LOOPSPERMSEC+50)/100)
+#define CONFIG_BOARD_LOOPSPER100USEC ((CONFIG_BOARD_LOOPSPERMSEC+5)/10)
+#define CONFIG_BOARD_LOOPSPER10USEC ((CONFIG_BOARD_LOOPSPERMSEC+50)/100)
+#define CONFIG_BOARD_LOOPSPERUSEC ((CONFIG_BOARD_LOOPSPERMSEC+500)/1000)
/****************************************************************************
* Private Types
@@ -85,48 +86,43 @@
void up_udelay(unsigned int microseconds)
{
- volatile int i;
- volatile int j;
- register uint32 loops;
+ volatile int i;
- /* The value of microseconds should be less than 1000. If not, then we
- * will perform millescond delays until it is.
+ /* We'll do this a little at a time because we expect that the
+ * CONFIG_BOARD_LOOPSPERUSEC is very inaccurate during to truncation in
+ * the divisions of its calculation. We'll use the largest values that
+ * we can in order to prevent significant error buildup in the loops.
*/
while (microseconds > 1000)
{
- for (j = 0; j < CONFIG_BOARD_LOOPSPERMSEC; j++)
+ for (i = 0; i < CONFIG_BOARD_LOOPSPERMSEC; i++)
{
}
microseconds -= 1000;
}
- /* The numerator of the 'loops' below will overflow if CONFIG_BOARD_LOOPSPERMSEC
- * is larger than (4*1024*1024*1024 - 500)/999 = 4,299,266.06
- */
-
-#if CONFIG_BOARD_LOOPSPERMSEC >= 4299266
- while (microseconds > 500)
+ while (microseconds > 100)
{
- for (j = 0; j < ((CONFIG_BOARD_LOOPSPERMSEC+1)/2); j++)
+ for (i = 0; i < CONFIG_BOARD_LOOPSPER100USEC; i++)
{
}
- microseconds -= 500;
+ microseconds -= 100;
}
-#endif
-
- /* The overflow could still occur if CONFIG_BOARD_LOOPSPERMSEC is larger than
- * (4*1024*1024*1024 - 500)/499 = 8,607,147.89
- */
-
-#if CONFIG_BOARD_LOOPSPERMSEC >= 8607147
-# warning "Overflow in loops calculation is possible"
-#endif
- /* Caculate the number of loops need to produce the required usec delay */
+ while (microseconds > 10)
+ {
+ for (i = 0; i < CONFIG_BOARD_LOOPSPER10USEC; i++)
+ {
+ }
+ microseconds -= 10;
+ }
- loops = (CONFIG_BOARD_LOOPSPERMSEC * microseconds + 500) / 1000;
- for (j = 0; j < loops; j++)
+ while (microseconds > 0)
{
+ for (i = 0; i < CONFIG_BOARD_LOOPSPERUSEC; i++)
+ {
+ }
+ microseconds--;
}
}
diff --git a/nuttx/arch/sim/src/up_uipdriver.c b/nuttx/arch/sim/src/up_uipdriver.c
index 3bd08c0b5..82e740bc0 100644
--- a/nuttx/arch/sim/src/up_uipdriver.c
+++ b/nuttx/arch/sim/src/up_uipdriver.c
@@ -201,7 +201,7 @@ void uipdriver_loop(void)
else if (timer_expired(&g_periodic_timer))
{
timer_reset(&g_periodic_timer);
- uip_poll(&g_sim_dev, sim_uiptxpoll, UIP_TIMER);
+ uip_poll(&g_sim_dev, sim_uiptxpoll, UIP_DRV_TIMER);
}
sched_unlock();
}