diff --git a/arch/arm/src/efm32/efm32_usbhost.c b/arch/arm/src/efm32/efm32_usbhost.c index 7d9cb4de29d..cce11725fdd 100644 --- a/arch/arm/src/efm32/efm32_usbhost.c +++ b/arch/arm/src/efm32/efm32_usbhost.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -2251,7 +2252,7 @@ static ssize_t efm32_out_transfer(FAR struct efm32_usbhost_s *priv, int chidx, * using the same buffer pointer and length. */ - usleep(20*1000); + nxsig_usleep(20*1000); } else { @@ -3915,7 +3916,7 @@ static int efm32_rh_enumerate(FAR struct efm32_usbhost_s *priv, /* USB 2.0 spec says at least 50ms delay before port reset. We wait 100ms. */ - usleep(100*1000); + nxsig_usleep(100*1000); /* Reset the host port */ diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 76e12a9b058..8f51cc6a7b8 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -1679,8 +1680,9 @@ static inline int kinetis_initphy(struct kinetis_driver_s *priv) retries = 0; do { - usleep(LINK_WAITUS); - ninfo("%s: Read PHYID1, retries=%d\n", BOARD_PHY_NAME, retries + 1); + nxsig_usleep(LINK_WAITUS); + ninfo("%s: Read PHYID1, retries=%d\n", + BOARD_PHY_NAME, retries + 1); phydata = 0xffff; ret = kinetis_readmii(priv, phyaddr, MII_PHYID1, &phydata); } @@ -1758,7 +1760,7 @@ static inline int kinetis_initphy(struct kinetis_driver_s *priv) break; } - usleep(LINK_WAITUS); + nxsig_usleep(LINK_WAITUS); } if (phydata & MII_MSR_ANEGCOMPLETE) diff --git a/arch/arm/src/lc823450/lc823450_i2c.c b/arch/arm/src/lc823450/lc823450_i2c.c index fdda0e46903..4b9c26451e5 100644 --- a/arch/arm/src/lc823450/lc823450_i2c.c +++ b/arch/arm/src/lc823450/lc823450_i2c.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -1043,7 +1044,7 @@ static int lc823450_i2c_transfer(FAR struct i2c_master_s *dev, * transaction, STOP condition for write transaction */ - usleep(10 * 1000); + nxsig_usleep(10 * 1000); } else { diff --git a/arch/arm/src/lc823450/lc823450_sddrv_dep.c b/arch/arm/src/lc823450/lc823450_sddrv_dep.c index 986b98c28e7..9e3806d7076 100644 --- a/arch/arm/src/lc823450/lc823450_sddrv_dep.c +++ b/arch/arm/src/lc823450/lc823450_sddrv_dep.c @@ -40,16 +40,18 @@ * Included Files ****************************************************************************/ -#include #include -#include -#include -#include #include #include #include #include +#include + +#include +#include +#include +#include #include "up_arch.h" #include "lc823450_sddrv_type.h" @@ -193,7 +195,7 @@ SINT_T sddep1_hw_init(struct SdDrCfg_s *cfg) /* wait 15ms */ - usleep(15000); + nxsig_usleep(15000); irqstate_t flags = enter_critical_section(); @@ -286,7 +288,7 @@ void sddep_voltage_switch(struct SdDrCfg_s *cfg) lc823450_gpio_config(GPIO_PORT0 | GPIO_PIN6 | GPIO_MODE_OUTPUT | GPIO_VALUE_ONE); - usleep(200 * 1000); + nxsig_usleep(200 * 1000); #endif } @@ -345,7 +347,7 @@ SINT_T sddep_wait(UI_32 ms, struct SdDrCfg_s *cfg) } else { - usleep(ms * 1000); + nxsig_usleep(ms * 1000); } #endif diff --git a/arch/arm/src/lc823450/lc823450_usbdev.c b/arch/arm/src/lc823450/lc823450_usbdev.c index b348c1ff82d..f8c0a09787c 100644 --- a/arch/arm/src/lc823450/lc823450_usbdev.c +++ b/arch/arm/src/lc823450/lc823450_usbdev.c @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -1560,7 +1561,7 @@ int usbdev_register(struct usbdevclass_driver_s *driver) putreg32(~USB_DEVS_SOF, USB_DEVS); - usleep(100000); + nxsig_usleep(100000); /* SOF is not arrived & D+/D- is HIGH */ diff --git a/arch/arm/src/lpc17xx/lpc17_usbhost.c b/arch/arm/src/lpc17xx/lpc17_usbhost.c index 9a613faf801..fd51d9df2c4 100644 --- a/arch/arm/src/lpc17xx/lpc17_usbhost.c +++ b/arch/arm/src/lpc17xx/lpc17_usbhost.c @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -2057,7 +2058,7 @@ static int lpc17_rh_enumerate(struct usbhost_connection_s *conn, /* USB 2.0 spec says at least 50ms delay before port reset */ - (void)usleep(100*1000); + (void)nxsig_usleep(100*1000); /* Put RH port 1 in reset (the LPC176x supports only a single downstream port) */ @@ -2070,7 +2071,7 @@ static int lpc17_rh_enumerate(struct usbhost_connection_s *conn, /* Release RH port 1 from reset and wait a bit */ lpc17_putreg(OHCI_RHPORTST_PRSC, LPC17_USBHOST_RHPORTST1); - (void)usleep(200*1000); + (void)nxsig_usleep(200*1000); return OK; } diff --git a/arch/arm/src/lpc31xx/lpc31_ehci.c b/arch/arm/src/lpc31xx/lpc31_ehci.c index b816bc11be3..26772ea81a5 100644 --- a/arch/arm/src/lpc31xx/lpc31_ehci.c +++ b/arch/arm/src/lpc31xx/lpc31_ehci.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -3569,7 +3570,7 @@ static int lpc31_rh_enumerate(FAR struct usbhost_connection_s *conn, * reset for 50Msec, not wait 50Msec before resetting. */ - usleep(100*1000); + nxsig_usleep(100*1000); /* Paragraph 2.3.9: * @@ -3672,7 +3673,7 @@ static int lpc31_rh_enumerate(FAR struct usbhost_connection_s *conn, * 50 ms." */ - usleep(50*1000); + nxsig_usleep(50*1000); regval = lpc31_getreg(regaddr); regval &= ~EHCI_PORTSC_RESET; @@ -3693,7 +3694,7 @@ static int lpc31_rh_enumerate(FAR struct usbhost_connection_s *conn, */ while ((lpc31_getreg(regaddr) & EHCI_PORTSC_RESET) != 0); - usleep(200*1000); + nxsig_usleep(200*1000); /* EHCI Paragraph 4.2.2: * diff --git a/arch/arm/src/lpc43xx/lpc43_ehci.c b/arch/arm/src/lpc43xx/lpc43_ehci.c index a3b0813d89f..3b24b4f282e 100644 --- a/arch/arm/src/lpc43xx/lpc43_ehci.c +++ b/arch/arm/src/lpc43xx/lpc43_ehci.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -3406,7 +3407,7 @@ static int lpc43_rh_enumerate(FAR struct usbhost_connection_s *conn, * reset for 50Msec, not wait 50Msec before resetting. */ - usleep(100*1000); + nxsig_usleep(100*1000); /* Paragraph 2.3.9: * @@ -3509,7 +3510,7 @@ static int lpc43_rh_enumerate(FAR struct usbhost_connection_s *conn, * 50 ms." */ - usleep(50*1000); + nxsig_usleep(50*1000); regval = lpc43_getreg(regaddr); regval &= ~EHCI_PORTSC_RESET; @@ -3530,7 +3531,7 @@ static int lpc43_rh_enumerate(FAR struct usbhost_connection_s *conn, */ while ((lpc43_getreg(regaddr) & EHCI_PORTSC_RESET) != 0); - usleep(200*1000); + nxsig_usleep(200*1000); /* EHCI Paragraph 4.2.2: * diff --git a/arch/arm/src/sam34/sam_udp.c b/arch/arm/src/sam34/sam_udp.c index 839a7bfdbad..908716ebb08 100644 --- a/arch/arm/src/sam34/sam_udp.c +++ b/arch/arm/src/sam34/sam_udp.c @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -3523,7 +3524,7 @@ static int sam_wakeup(struct usbdev_s *dev) /* Wait 5msec in case we just entered the resume state */ - usleep(5*1000); + nxsig_usleep(5*1000); /* Set the ESR bit to send the remote resume */ diff --git a/arch/arm/src/sama5/sam_ehci.c b/arch/arm/src/sama5/sam_ehci.c index d6538ced752..9b25316272f 100644 --- a/arch/arm/src/sama5/sam_ehci.c +++ b/arch/arm/src/sama5/sam_ehci.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -3406,7 +3407,7 @@ static int sam_rh_enumerate(FAR struct usbhost_connection_s *conn, * reset for 50Msec, not wait 50Msec before resetting. */ - usleep(100*1000); + nxsig_usleep(100*1000); /* Paragraph 2.3.9: * @@ -3512,7 +3513,7 @@ static int sam_rh_enumerate(FAR struct usbhost_connection_s *conn, * 50 ms." */ - usleep(50*1000); + nxsig_usleep(50*1000); regval = sam_getreg(regaddr); regval &= ~EHCI_PORTSC_RESET; @@ -3533,7 +3534,7 @@ static int sam_rh_enumerate(FAR struct usbhost_connection_s *conn, */ while ((sam_getreg(regaddr) & EHCI_PORTSC_RESET) != 0); - usleep(200*1000); + nxsig_usleep(200*1000); /* Paragraph 4.2.2: * diff --git a/arch/arm/src/stm32/stm32_otgfshost.c b/arch/arm/src/stm32/stm32_otgfshost.c index 7f1af4b40b0..8a6382d345b 100644 --- a/arch/arm/src/stm32/stm32_otgfshost.c +++ b/arch/arm/src/stm32/stm32_otgfshost.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -1964,7 +1965,7 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx, * * Small delays could require more resolution than is provided * by the system timer. For example, if the system timer - * resolution is 10MS, then usleep(1000) will actually request + * resolution is 10MS, then nxsig_usleep(1000) will actually request * a delay 20MS (due to both quantization and rounding). * * REVISIT: So which is better? To ignore tiny delays and @@ -1974,7 +1975,7 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx, if (delay > CONFIG_USEC_PER_TICK) { - usleep(delay - CONFIG_USEC_PER_TICK); + nxsig_usleep(delay - CONFIG_USEC_PER_TICK); } } } @@ -2276,7 +2277,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, * using the same buffer pointer and length. */ - usleep(20*1000); + nxsig_usleep(20*1000); } else { @@ -3942,9 +3943,11 @@ static int stm32_rh_enumerate(FAR struct stm32_usbhost_s *priv, DEBUGASSERT(priv->smstate == SMSTATE_ATTACHED); - /* USB 2.0 spec says at least 50ms delay before port reset. We wait 100ms. */ + /* USB 2.0 spec says at least 50ms delay before port reset. We wait + * 100ms. + */ - usleep(100*1000); + nxsig_usleep(100*1000); /* Reset the host port */ diff --git a/arch/arm/src/stm32/stm32_otghshost.c b/arch/arm/src/stm32/stm32_otghshost.c index 55bda259227..ad1091d02f7 100644 --- a/arch/arm/src/stm32/stm32_otghshost.c +++ b/arch/arm/src/stm32/stm32_otghshost.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -1969,7 +1970,7 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx, * * Small delays could require more resolution than is provided * by the system timer. For example, if the system timer - * resolution is 10MS, then usleep(1000) will actually request + * resolution is 10MS, then nxsig_usleep(1000) will actually request * a delay 20MS (due to both quantization and rounding). * * REVISIT: So which is better? To ignore tiny delays and @@ -1979,7 +1980,7 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx, if (delay > CONFIG_USEC_PER_TICK) { - usleep(delay - CONFIG_USEC_PER_TICK); + nxsig_usleep(delay - CONFIG_USEC_PER_TICK); } } } @@ -2281,7 +2282,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, * using the same buffer pointer and length. */ - usleep(20*1000); + nxsig_usleep(20*1000); } else { @@ -3947,9 +3948,11 @@ static int stm32_rh_enumerate(FAR struct stm32_usbhost_s *priv, DEBUGASSERT(priv->smstate == SMSTATE_ATTACHED); - /* USB 2.0 spec says at least 50ms delay before port reset. We wait 100ms. */ + /* USB 2.0 spec says at least 50ms delay before port reset. We wait + * 100ms. + */ - usleep(100*1000); + nxsig_usleep(100*1000); /* Reset the host port */ diff --git a/arch/arm/src/stm32f7/stm32_otghost.c b/arch/arm/src/stm32f7/stm32_otghost.c index a8a3511d13f..548a6f393de 100644 --- a/arch/arm/src/stm32f7/stm32_otghost.c +++ b/arch/arm/src/stm32f7/stm32_otghost.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -1964,7 +1965,7 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx, * * Small delays could require more resolution than is provided * by the system timer. For example, if the system timer - * resolution is 10MS, then usleep(1000) will actually request + * resolution is 10MS, then nxsig_usleep(1000) will actually request * a delay 20MS (due to both quantization and rounding). * * REVISIT: So which is better? To ignore tiny delays and @@ -1974,7 +1975,7 @@ static ssize_t stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx, if (delay > CONFIG_USEC_PER_TICK) { - usleep(delay - CONFIG_USEC_PER_TICK); + nxsig_usleep(delay - CONFIG_USEC_PER_TICK); } } } @@ -2276,7 +2277,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, * using the same buffer pointer and length. */ - usleep(20*1000); + nxsig_usleep(20*1000); } else { @@ -3941,9 +3942,11 @@ static int stm32_rh_enumerate(FAR struct stm32_usbhost_s *priv, DEBUGASSERT(priv->smstate == SMSTATE_ATTACHED); - /* USB 2.0 spec says at least 50ms delay before port reset. We wait 100ms. */ + /* USB 2.0 spec says at least 50ms delay before port reset. We wait + * 100ms. + */ - usleep(100*1000); + nxsig_usleep(100*1000); /* Reset the host port */ diff --git a/arch/arm/src/stm32l4/stm32l4_otgfshost.c b/arch/arm/src/stm32l4/stm32l4_otgfshost.c index 77b7b1aaefd..b7e952d2317 100644 --- a/arch/arm/src/stm32l4/stm32l4_otgfshost.c +++ b/arch/arm/src/stm32l4/stm32l4_otgfshost.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -1968,7 +1969,7 @@ static ssize_t stm32l4_in_transfer(FAR struct stm32l4_usbhost_s *priv, * * Small delays could require more resolution than is provided * by the system timer. For example, if the system timer - * resolution is 10MS, then usleep(1000) will actually request + * resolution is 10MS, then nxsig_usleep(1000) will actually request * a delay 20MS (due to both quantization and rounding). * * REVISIT: So which is better? To ignore tiny delays and @@ -1978,7 +1979,7 @@ static ssize_t stm32l4_in_transfer(FAR struct stm32l4_usbhost_s *priv, if (delay > CONFIG_USEC_PER_TICK) { - usleep(delay - CONFIG_USEC_PER_TICK); + nxsig_usleep(delay - CONFIG_USEC_PER_TICK); } } } @@ -2281,7 +2282,7 @@ static ssize_t stm32l4_out_transfer(FAR struct stm32l4_usbhost_s *priv, * using the same buffer pointer and length. */ - usleep(20*1000); + nxsig_usleep(20*1000); } else { @@ -3947,9 +3948,11 @@ static int stm32l4_rh_enumerate(FAR struct stm32l4_usbhost_s *priv, DEBUGASSERT(priv->smstate == SMSTATE_ATTACHED); - /* USB 2.0 spec says at least 50ms delay before port reset. We wait 100ms. */ + /* USB 2.0 spec says at least 50ms delay before port reset. We wait + * 100ms. + */ - usleep(100*1000); + nxsig_usleep(100*1000); /* Reset the host port */ diff --git a/arch/arm/src/tiva/tiva_adclow.c b/arch/arm/src/tiva/tiva_adclow.c index 5519c180392..577a430d2f5 100644 --- a/arch/arm/src/tiva/tiva_adclow.c +++ b/arch/arm/src/tiva/tiva_adclow.c @@ -71,6 +71,7 @@ #include #include +#include #include #include @@ -577,7 +578,7 @@ static int tiva_adc_ioctl(struct adc_dev_s *dev, int cmd, unsigned long arg) tiva_adc_proc_trig(priv->devno, (uint8_t)SSE_PROC_TRIG(sse)); while (!tiva_adc_sse_int_status(priv->devno, sse)) { - usleep(100); + nxsig_usleep(100); } tiva_adc_sse_clear_int(priv->devno, sse); diff --git a/configs/b-l475e-iot01a/src/stm32_spirit.c b/configs/b-l475e-iot01a/src/stm32_spirit.c index 4aadd015a9b..9cce60a8a76 100644 --- a/configs/b-l475e-iot01a/src/stm32_spirit.c +++ b/configs/b-l475e-iot01a/src/stm32_spirit.c @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -147,7 +148,7 @@ static int stm32l4_reset(FAR const struct spirit_lower_s *lower) /* Wait minimum 1.5 ms to allow Spirit a proper boot-up sequence */ - usleep(1500); + nxsig_usleep(1500); return OK; } diff --git a/configs/cloudctrl/src/stm32_relays.c b/configs/cloudctrl/src/stm32_relays.c index b0da0f8976a..470441db43d 100644 --- a/configs/cloudctrl/src/stm32_relays.c +++ b/configs/cloudctrl/src/stm32_relays.c @@ -1,7 +1,7 @@ /**************************************************************************** * configs/cloudctrl/src/stm32_relays.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * Darcy Gong * @@ -45,6 +45,7 @@ #include #include +#include #include #include "cloudctrl.h" @@ -244,11 +245,11 @@ void relays_onoff(int relays, uint32_t mdelay) if (relays_getstat(relays)) { relays_setstat(relays, false); - usleep(RELAYS_MIN_RESET_TIME*1000*1000); + nxsig_usleep(RELAYS_MIN_RESET_TIME*1000*1000); } relays_setstat(relays,true); - usleep(mdelay*100*1000); + nxsig_usleep(mdelay*100*1000); relays_setstat(relays, false); } } diff --git a/configs/photon/src/stm32_wdt.c b/configs/photon/src/stm32_wdt.c index 8ea352925c5..3f2c4fd4f57 100644 --- a/configs/photon/src/stm32_wdt.c +++ b/configs/photon/src/stm32_wdt.c @@ -47,6 +47,7 @@ #include #include +#include #include #include @@ -88,7 +89,7 @@ static int wdog_daemon(int argc, char *argv[]) while(1) { - usleep((CONFIG_PHOTON_WDG_THREAD_INTERVAL)*1000); + nxsig_usleep((CONFIG_PHOTON_WDG_THREAD_INTERVAL)*1000); /* Send keep alive ioctl */ diff --git a/configs/sam4s-xplained-pro/src/sam_wdt.c b/configs/sam4s-xplained-pro/src/sam_wdt.c index fd3e01fe440..180d69de905 100644 --- a/configs/sam4s-xplained-pro/src/sam_wdt.c +++ b/configs/sam4s-xplained-pro/src/sam_wdt.c @@ -1,7 +1,7 @@ /************************************************************************************ * configs/sam4s-xplained-pro/src/up_wdt.c * - * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2016-2017 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * Bob Doiron * @@ -48,6 +48,7 @@ #include #include +#include #include #include @@ -114,10 +115,10 @@ static int wdog_daemon(int argc, char *argv[]) goto errout_with_dev; } - usleep(200); + nxsig_usleep(200); while(1) { - usleep((CONFIG_WDT_THREAD_INTERVAL)*1000); + nxsig_usleep((CONFIG_WDT_THREAD_INTERVAL)*1000); wdinfo("ping\n"); ret = ioctl(fd, WDIOC_KEEPALIVE, 0); diff --git a/configs/same70-xplained/src/sam_xbee.c b/configs/same70-xplained/src/sam_xbee.c index 9f2d8b8d9fb..b8ff4329ac0 100644 --- a/configs/same70-xplained/src/sam_xbee.c +++ b/configs/same70-xplained/src/sam_xbee.c @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -154,7 +155,7 @@ static int sam_reset(FAR const struct xbee_lower_s *lower) /* Wait minimum 1.5 ms to allow Xbee a proper boot-up sequence */ /* TODO: Update time according to datasheet */ - usleep(1500); + nxsig_usleep(1500); return OK; } diff --git a/configs/shenzhou/src/stm32_relays.c b/configs/shenzhou/src/stm32_relays.c index a9acd03a562..770beb0c11c 100644 --- a/configs/shenzhou/src/stm32_relays.c +++ b/configs/shenzhou/src/stm32_relays.c @@ -1,7 +1,7 @@ /**************************************************************************** * configs/shenzhou/src/stm32_relays.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * Darcy Gong * @@ -45,6 +45,7 @@ #include #include +#include #include #include "shenzhou.h" @@ -244,11 +245,11 @@ void relays_onoff(int relays, uint32_t mdelay) if (relays_getstat(relays)) { relays_setstat(relays, false); - usleep(RELAYS_MIN_RESET_TIME*1000*1000); + nxsig_usleep(RELAYS_MIN_RESET_TIME*1000*1000); } relays_setstat(relays,true); - usleep(mdelay*100*1000); + nxsig_usleep(mdelay*100*1000); relays_setstat(relays, false); } } diff --git a/configs/stm32butterfly2/src/stm32_mmcsd.c b/configs/stm32butterfly2/src/stm32_mmcsd.c index fb425b1dc4b..6ff41c3917f 100644 --- a/configs/stm32butterfly2/src/stm32_mmcsd.c +++ b/configs/stm32butterfly2/src/stm32_mmcsd.c @@ -36,15 +36,18 @@ * Included Files ****************************************************************************/ -#include #include -#include -#include + #include #include #include #include #include +#include + +#include +#include +#include #include "stm32.h" #include "stm32_butterfly2.h" @@ -109,7 +112,7 @@ static void *stm32_cd_thread(void *arg) * rest for a millsecond or so. */ - usleep(1 * 1000); + nxsig_usleep(1 * 1000); g_chmediaclbk(g_chmediaarg); } } diff --git a/configs/u-blox-c027/src/lpc17_ubxmdm.c b/configs/u-blox-c027/src/lpc17_ubxmdm.c index 183e076ec40..bd165b96d22 100644 --- a/configs/u-blox-c027/src/lpc17_ubxmdm.c +++ b/configs/u-blox-c027/src/lpc17_ubxmdm.c @@ -46,9 +46,10 @@ #include #include -#include #include #include +#include +#include #include #include @@ -182,7 +183,7 @@ static int lpc17_poweron(FAR struct ubxmdm_lower* lower) lpc17_configgpio(priv->pins->reset_n | GPIO_VALUE_ONE); /* Modem not in reset */ lpc17_configgpio(priv->pins->power_on_n | GPIO_VALUE_ZERO); /* Switch closed to GND */ - usleep(10 * 1000); /* Min. time for power_on_n being low is 5 ms */ + nxsig_usleep(10 * 1000); /* Min. time for power_on_n being low is 5 ms */ if (priv->usb_used) { @@ -196,7 +197,7 @@ static int lpc17_poweron(FAR struct ubxmdm_lower* lower) lpc17_configgpio(priv->pins->usb_detect | usb_detect_val); lpc17_configgpio(priv->pins->ldo_enable | GPIO_VALUE_ONE); /* LDO enabled */ - usleep(1 * 1000); /* Delay to obtain correct voltage on shifters */ + nxsig_usleep(1 * 1000); /* Delay to obtain correct voltage on shifters */ lpc17_configgpio(priv->pins->shifter_en_n | GPIO_VALUE_ZERO); /* UART shifter enabled */ /* lpc17_configgpio(priv->pins->power_on_n | GPIO_VALUE_ONE); * Stop current through switch */ @@ -224,7 +225,7 @@ static int lpc17_reset(FAR struct ubxmdm_lower* lower) (FAR struct lpc17_ubxmdm_lower*) lower; lpc17_configgpio(priv->pins->reset_n | GPIO_VALUE_ZERO); /* Modem in reset */ - usleep(75 * 1000); /* The minimum reset_n low time is 50 ms */ + nxsig_usleep(75 * 1000); /* The minimum reset_n low time is 50 ms */ lpc17_configgpio(priv->pins->reset_n | GPIO_VALUE_ONE); /* Modem not in reset */ return OK; diff --git a/configs/viewtool-stm32f107/src/stm32_highpri.c b/configs/viewtool-stm32f107/src/stm32_highpri.c index ad9677469ed..92ad5e9adbd 100644 --- a/configs/viewtool-stm32f107/src/stm32_highpri.c +++ b/configs/viewtool-stm32f107/src/stm32_highpri.c @@ -1,7 +1,7 @@ /**************************************************************************** * configs/viewtool-stm32f107/src/stm32_highpri.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -226,7 +227,7 @@ int highpri_main(int argc, char *argv[]) /* Flush stdout and wait a bit */ fflush(stdout); - sleep(1); + nxsig_sleep(1); seconds++; /* Sample counts so that they are not volatile. Missing a count now diff --git a/drivers/analog/ads1255.c b/drivers/analog/ads1255.c index 94b278de096..408dd92a29b 100644 --- a/drivers/analog/ads1255.c +++ b/drivers/analog/ads1255.c @@ -56,6 +56,7 @@ #include #include +#include #include #include @@ -281,7 +282,7 @@ static void adc_reset(FAR struct adc_dev_s *dev) spi = priv->spi; adc_lock(spi); - usleep(1000); + nxsig_usleep(1000); SPI_SELECT(spi, priv->devno, true); SPI_SEND(spi, ADS125X_WREG + 0x03); /* WRITE SPS REG */ @@ -332,7 +333,7 @@ static int adc_setup(FAR struct adc_dev_s *dev) SPI_SEND(spi, priv->mux[0]); SPI_SEND(spi, priv->pga); /* REG2 ADCON PGA=2 */ SPI_SEND(spi, getspsreg(priv->sps)); - usleep(1000); + nxsig_usleep(1000); SPI_SEND(spi, ADS125X_SELFCAL); SPI_SELECT(spi, priv->devno, false); diff --git a/drivers/analog/dac.c b/drivers/analog/dac.c index af57f5a3c77..7e028e26f5e 100644 --- a/drivers/analog/dac.c +++ b/drivers/analog/dac.c @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -204,7 +205,7 @@ static int dac_close(FAR struct file *filep) while (dev->ad_xmit.af_head != dev->ad_xmit.af_tail) { #ifndef CONFIG_DISABLE_SIGNALS - usleep(HALF_SECOND_USEC); + nxsig_usleep(HALF_SECOND_USEC); #else up_mdelay(HALF_SECOND_MSEC); #endif diff --git a/drivers/audio/vs1053.c b/drivers/audio/vs1053.c index d0387a10faf..5660101db9b 100644 --- a/drivers/audio/vs1053.c +++ b/drivers/audio/vs1053.c @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -342,7 +343,7 @@ static void vs1053_writereg(FAR struct vs1053_struct_s *dev, uint8_t reg, uint16 /* Short delay after a write for VS1053 processing time */ - usleep(10); + nxsig_usleep(10); } /**************************************************************************** @@ -417,7 +418,7 @@ static int vs1053_setfrequency(FAR struct vs1053_struct_s *dev, uint32_t freq) timeout = 200; while (!dev->hw_lower->read_dreq(dev->hw_lower) && timeout) { - usleep(1000); + nxsig_usleep(1000); timeout--; } @@ -896,9 +897,9 @@ static int vs1053_hardreset(FAR struct vs1053_struct_s *dev) { dev->hw_lower->disable(dev->hw_lower); /* Disable the DREQ interrupt */ dev->hw_lower->reset(dev->hw_lower, false); - usleep(10); + nxsig_usleep(10); dev->hw_lower->reset(dev->hw_lower, true); - usleep(VS1053_RST_USECS); + nxsig_usleep(VS1053_RST_USECS); vs1053_setfrequency(dev, CONFIG_VS1053_XTALI); /* Slow speed at first */ return OK; @@ -1269,7 +1270,7 @@ static void *vs1053_workerthread(pthread_addr_t pvarg) timeout = 200; while (!dev->hw_lower->read_dreq(dev->hw_lower) && timeout) { - usleep(100); + nxsig_usleep(100); timeout--; } @@ -1305,7 +1306,7 @@ static void *vs1053_workerthread(pthread_addr_t pvarg) /* The ISR has requested more data */ case AUDIO_MSG_DATA_REQUEST: - usleep(500); + nxsig_usleep(500); vs1053_feeddata(dev); /* Feed more data to the VS1053 FIFO */ break; @@ -1315,7 +1316,7 @@ static void *vs1053_workerthread(pthread_addr_t pvarg) case AUDIO_MSG_STOP: if (!dev->hw_lower->read_dreq(dev->hw_lower)) { - usleep(300); + nxsig_usleep(300); } /* Send CANCEL message to VS1053 */ diff --git a/drivers/audio/wm8904.c b/drivers/audio/wm8904.c index 80403731191..f2b35261c55 100644 --- a/drivers/audio/wm8904.c +++ b/drivers/audio/wm8904.c @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -923,7 +924,7 @@ static void wm8904_setbitrate(FAR struct wm8904_dev_s *priv) retries = 5; do { - usleep(5*5000); + nxsig_usleep(5*5000); } while (priv->locked == false && --retries > 0); @@ -946,7 +947,7 @@ static void wm8904_setbitrate(FAR struct wm8904_dev_s *priv) retries = 5; do { - usleep(5*5000); + nxsig_usleep(5*5000); } while ((wm8904_readreg(priv, WM8904_INT_STATUS) & WM8904_FLL_LOCK_INT) != 0 || --retries > 0); diff --git a/drivers/can/can.c b/drivers/can/can.c index bfde490de43..7a590d5a73b 100644 --- a/drivers/can/can.c +++ b/drivers/can/can.c @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -520,7 +521,7 @@ static int can_close(FAR struct file *filep) while (dev->cd_xmit.tx_head != dev->cd_xmit.tx_tail) { #ifndef CONFIG_DISABLE_SIGNALS - usleep(HALF_SECOND_USEC); + nxsig_usleep(HALF_SECOND_USEC); #else up_mdelay(HALF_SECOND_MSEC); #endif @@ -531,7 +532,7 @@ static int can_close(FAR struct file *filep) while (!dev_txempty(dev)) { #ifndef CONFIG_DISABLE_SIGNALS - usleep(HALF_SECOND_USEC); + nxsig_usleep(HALF_SECOND_USEC); #else up_mdelay(HALF_SECOND_MSEC); #endif diff --git a/drivers/can/mcp2515.c b/drivers/can/mcp2515.c index a7c9ac9163e..59699037f00 100644 --- a/drivers/can/mcp2515.c +++ b/drivers/can/mcp2515.c @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -1135,7 +1136,7 @@ static void mcp2515_reset_lowlevel(FAR struct mcp2515_can_s *priv) /* Wait 1ms to let MCP2515 restart */ - usleep(1000); + nxsig_usleep(1000); /* Make sure that all buffers are released. * @@ -2434,7 +2435,7 @@ static int mcp2515_hw_initialize(struct mcp2515_can_s *priv) regval = (regval & ~CANCTRL_REQOP_MASK) | (CANCTRL_REQOP_NORMAL); mcp2515_writeregs(priv, MCP2515_CANCTRL, ®val, 1); - usleep(100); + nxsig_usleep(100); /* Read the CANINTF */ diff --git a/drivers/contactless/mfrc522.c b/drivers/contactless/mfrc522.c index bf87bc31de8..849f759b67c 100644 --- a/drivers/contactless/mfrc522.c +++ b/drivers/contactless/mfrc522.c @@ -50,6 +50,7 @@ #include #include +#include #include #include "mfrc522.h" @@ -1107,7 +1108,7 @@ void mfrc522_softreset(FAR struct mfrc522_dev_s *dev) /* Wait the internal state machine to initialize */ - usleep(50000); + nxsig_usleep(50000); /* Wait for the PowerDown bit in COMMAND_REG to be cleared */ @@ -1381,7 +1382,7 @@ static int mfrc522_open(FAR struct file *filep) mfrc522_configspi(dev->spi); - usleep(10000); + nxsig_usleep(10000); mfrc522_getfwversion(dev); diff --git a/drivers/contactless/pn532.c b/drivers/contactless/pn532.c index fe8dbd7061e..6f1d8fb5314 100644 --- a/drivers/contactless/pn532.c +++ b/drivers/contactless/pn532.c @@ -48,6 +48,7 @@ #include #include +#include #include "pn532.h" @@ -340,7 +341,7 @@ static int pn532_wait_rx_ready(struct pn532_dev_s *dev, int timeout) return -ETIMEDOUT; } - usleep(1000); + nxsig_usleep(1000); } dev->state = PN532_STATE_DATA_READY; @@ -370,7 +371,7 @@ static void pn532_writecommand(struct pn532_dev_s *dev, uint8_t cmd) pn532_lock(dev->spi); pn532_select(dev); - usleep(10000); + nxsig_usleep(10000); SPI_SEND(dev->spi, PN532_SPI_DATAWRITE); SPI_SNDBLOCK(dev->spi, f, FRAME_SIZE(f)); @@ -478,7 +479,7 @@ int pn532_write_frame(struct pn532_dev_s *dev, struct pn532_frame *f) pn532_lock(dev->spi); pn532_select(dev); - usleep(2000); + nxsig_usleep(2000); SPI_SEND(dev->spi, PN532_SPI_DATAWRITE); SPI_SNDBLOCK(dev->spi, f, FRAME_SIZE(f)); @@ -879,7 +880,7 @@ static int _open(FAR struct file *filep) pn532_configspi(dev->spi); dev->config->reset(1); - usleep(10000); + nxsig_usleep(10000); pn532_sam_config(dev, NULL); pn532_get_fw_version(dev, NULL); diff --git a/drivers/eeprom/spi_xx25xx.c b/drivers/eeprom/spi_xx25xx.c index f2efa86ebff..65c48c194c3 100644 --- a/drivers/eeprom/spi_xx25xx.c +++ b/drivers/eeprom/spi_xx25xx.c @@ -122,6 +122,7 @@ #include #include +#include #include /**************************************************************************** @@ -382,7 +383,7 @@ static void ee25xx_waitwritecomplete(struct ee25xx_dev_s *priv) if ((status & EE25XX_SR_WIP) != 0) { ee25xx_unlock(priv->spi); - usleep(1000); + nxsig_usleep(1000); ee25xx_lock(priv->spi); } } diff --git a/drivers/input/cypress_mbr3108.c b/drivers/input/cypress_mbr3108.c index 36ab4c678df..e91701e4db6 100644 --- a/drivers/input/cypress_mbr3108.c +++ b/drivers/input/cypress_mbr3108.c @@ -47,8 +47,9 @@ #include #include -#include #include +#include +#include #include @@ -424,7 +425,7 @@ static int mbr3108_save_check_crc(FAR struct mbr3108_dev_s *dev) return ret; } - usleep(MBR3108_CMD_MSECS_CHECK_CONFIG_CRC * 1000); + nxsig_usleep(MBR3108_CMD_MSECS_CHECK_CONFIG_CRC * 1000); ret = mbr3108_check_cmd_status(dev); if (ret != 0) @@ -448,7 +449,7 @@ static int mbr3108_software_reset(FAR struct mbr3108_dev_s *dev) return ret; } - usleep(MBR3108_CMD_MSECS_SOFTWARE_RESET * 1000); + nxsig_usleep(MBR3108_CMD_MSECS_SOFTWARE_RESET * 1000); ret = mbr3108_check_cmd_status(dev); if (ret != 0) @@ -492,7 +493,7 @@ static int mbr3108_clear_latched(FAR struct mbr3108_dev_s *dev) return ret; } - usleep(MBR3108_CMD_MSECS_CLEAR_LATCHED * 1000); + nxsig_usleep(MBR3108_CMD_MSECS_CLEAR_LATCHED * 1000); ret = mbr3108_check_cmd_status(dev); if (ret != 0) @@ -906,7 +907,7 @@ static int mbr3108_open(FAR struct file *filep) /* Let chip to power up before probing */ - usleep(100 * 1000); + nxsig_usleep(100 * 1000); /* Check that device exists on I2C. */ diff --git a/drivers/input/mxt.c b/drivers/input/mxt.c index 98f42373681..af0f3bff985 100644 --- a/drivers/input/mxt.c +++ b/drivers/input/mxt.c @@ -66,6 +66,7 @@ #include #include +#include #include #include #include @@ -1794,7 +1795,7 @@ static int mxt_hwinitialize(FAR struct mxt_dev_s *priv) goto errout_with_objtab; } - usleep(MXT_RESET_TIME); + nxsig_usleep(MXT_RESET_TIME); /* Update matrix size in the info structure */ diff --git a/drivers/input/stmpe811_adc.c b/drivers/input/stmpe811_adc.c index cd174213842..e14e96c3d77 100644 --- a/drivers/input/stmpe811_adc.c +++ b/drivers/input/stmpe811_adc.c @@ -49,6 +49,7 @@ #include #include +#include #include #include "stmpe811.h" @@ -236,12 +237,12 @@ uint16_t stmpe811_adcread(STMPE811_HANDLE handle, int pin) for (i = 0; i < 3; i++) { /* The worst case ADC conversion time is (nominally) 56.4 uS. The - * following usleep() looks nice but in reality, the usleep() - * does not have that kind of precision (it will probably end up - * waiting 10 MS). + * following nxsig_usleep() looks nice but in reality, nxsig_usleep() + * normal does not have that kind of precision (it will probably end + * up waiting 10 MS). */ - usleep(57); + nxsig_usleep(57); /* Check if the conversion is complete */ diff --git a/drivers/input/stmpe811_base.c b/drivers/input/stmpe811_base.c index ecf7ee32578..b1857286050 100644 --- a/drivers/input/stmpe811_base.c +++ b/drivers/input/stmpe811_base.c @@ -48,6 +48,7 @@ #include #include +#include #include #include "stmpe811.h" @@ -234,7 +235,7 @@ static void stmpe811_reset(FAR struct stmpe811_dev_s *priv) /* Wait a bit */ - usleep(20*1000); + nxsig_usleep(20*1000); /* Then power on again. All registers will be in their reset state. */ diff --git a/drivers/input/tsc2007.c b/drivers/input/tsc2007.c index a2f63338bca..edf07764f7f 100644 --- a/drivers/input/tsc2007.c +++ b/drivers/input/tsc2007.c @@ -70,6 +70,7 @@ #include #include +#include #include #include @@ -515,7 +516,7 @@ static int tsc2007_transfer(FAR struct tsc2007_dev_s *priv, uint8_t cmd) * least 10ms before attempting to read data from the TSC2007... */ - usleep(10*1000); + nxsig_usleep(10*1000); /* "Data access begins with the master issuing a START condition followed * by the address byte ... with R/W = 1. diff --git a/drivers/lcd/pcf8574_lcd_backpack.c b/drivers/lcd/pcf8574_lcd_backpack.c index 44578f9a7fc..b16f2bb9301 100644 --- a/drivers/lcd/pcf8574_lcd_backpack.c +++ b/drivers/lcd/pcf8574_lcd_backpack.c @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -551,7 +552,7 @@ static void lcd_init(FAR struct pcf8574_lcd_dev_s *priv) { /* Wait for more than 15 ms after Vcc for the LCD to stabilize */ - usleep(50000); + nxsig_usleep(50000); /* Perform the init sequence. This sequence of commands is constructed so * that it will get the device into nybble mode irrespective of what state @@ -564,22 +565,22 @@ static void lcd_init(FAR struct pcf8574_lcd_dev_s *priv) /* Send Command 0x30, set 8-bit mode, and wait > 4.1 ms */ latch_nybble(priv, 0x30>>4, false); - usleep(5000); + nxsig_usleep(5000); /* Send Command 0x30, set 8-bit mode, and wait > 100 us */ latch_nybble(priv, 0x30>>4, false); - usleep(5000); + nxsig_usleep(5000); /* Send Command 0x30, set 8-bit mode */ latch_nybble(priv, 0x30>>4, false); - usleep(200); + nxsig_usleep(200); /* now Function set: Set interface to be 4 bits long (only 1 cycle write for the first time). */ latch_nybble(priv, 0x20>>4, false); - usleep(5000); + nxsig_usleep(5000); /* Function set: DL=0;Interface is 4 bits, N=1 (2 Lines), F=0 (5x8 dots font) */ diff --git a/drivers/leds/ncp5623c.c b/drivers/leds/ncp5623c.c index 7fb96a7bdc9..c1b1ea6a750 100644 --- a/drivers/leds/ncp5623c.c +++ b/drivers/leds/ncp5623c.c @@ -42,8 +42,9 @@ #include #include -#include #include +#include +#include #include #if defined(CONFIG_I2C) && defined(CONFIG_NCP5623C) @@ -170,7 +171,7 @@ static int ncp5623c_open(FAR struct file *filep) /* Let the chip settle a bit */ - usleep(1); + nxsig_usleep(1); return OK; } diff --git a/drivers/leds/pca9635pw.c b/drivers/leds/pca9635pw.c index 8d703982968..0ae92dd30df 100644 --- a/drivers/leds/pca9635pw.c +++ b/drivers/leds/pca9635pw.c @@ -42,8 +42,9 @@ #include #include -#include #include +#include +#include #include #if defined(CONFIG_I2C) && defined(CONFIG_PCA9635PW) @@ -212,7 +213,7 @@ static int pca9635pw_open(FAR struct file *filep) * left. */ - usleep(500); + nxsig_usleep(500); /* Turn all led drivers to mode 2 in which the led brightness is controlled * by the indiviual pwm registers. diff --git a/drivers/mtd/at24xx.c b/drivers/mtd/at24xx.c index 8ad9ff852a9..f08cec9d618 100644 --- a/drivers/mtd/at24xx.c +++ b/drivers/mtd/at24xx.c @@ -58,6 +58,7 @@ #include #include +#include #include #include #include @@ -283,7 +284,7 @@ static int at24c_eraseall(FAR struct at24c_dev_s *priv) return -ETIMEDOUT; } - usleep(1000); + nxsig_usleep(1000); } at24c_i2c_write(priv, at24addr, buf, AT24XX_PAGESIZE + AT24XX_ADDRSIZE); @@ -349,7 +350,7 @@ static ssize_t at24c_read_internal(FAR struct at24c_dev_s *priv, off_t offset, return -ETIMEDOUT; } - usleep(1000); + nxsig_usleep(1000); } /* Then transfer the following bytes */ @@ -472,7 +473,7 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t return -ETIMEDOUT; } - usleep(1000); + nxsig_usleep(1000); } memcpy(&buf[AT24XX_ADDRSIZE], buffer, priv->pagesize); diff --git a/drivers/mtd/at25.c b/drivers/mtd/at25.c index 042734593db..783f060181e 100644 --- a/drivers/mtd/at25.c +++ b/drivers/mtd/at25.c @@ -50,6 +50,7 @@ #include #include +#include #include #include #include @@ -284,7 +285,7 @@ static void at25_waitwritecomplete(struct at25_dev_s *priv) if ((status & AT25_SR_BUSY) != 0) { at25_unlock(priv->dev); - usleep(10000); + nxsig_usleep(10000); at25_lock(priv->dev); } } diff --git a/drivers/mtd/is25xp.c b/drivers/mtd/is25xp.c index 5ea9e8ae1a7..b7f4df66573 100644 --- a/drivers/mtd/is25xp.c +++ b/drivers/mtd/is25xp.c @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -374,7 +375,7 @@ static void is25xp_waitwritecomplete(struct is25xp_dev_s *priv) if ((status & IS25_SR_WIP) != 0) { is25xp_unlock(priv->dev); - usleep(1000); + nxsig_usleep(1000); is25xp_lock(priv->dev); } } diff --git a/drivers/mtd/m25px.c b/drivers/mtd/m25px.c index c3cf4febba1..fab4d196792 100644 --- a/drivers/mtd/m25px.c +++ b/drivers/mtd/m25px.c @@ -50,6 +50,7 @@ #include #include +#include #include #include #include @@ -492,7 +493,7 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv) if ((status & M25P_SR_WIP) != 0) { m25p_unlock(priv->dev); - usleep(1000); + nxsig_usleep(1000); m25p_lock(priv->dev); } } diff --git a/drivers/mtd/mx25lx.c b/drivers/mtd/mx25lx.c index 8eb4fc5407b..d7c9f079d5a 100644 --- a/drivers/mtd/mx25lx.c +++ b/drivers/mtd/mx25lx.c @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -396,7 +397,7 @@ static void mx25l_waitwritecomplete(FAR struct mx25l_dev_s *priv) if ((status & MX25L_SR_WIP) != 0) { mx25l_unlock(priv->dev); - usleep(1000); + nxsig_usleep(1000); mx25l_lock(priv->dev); } } diff --git a/drivers/mtd/mx25rxx.c b/drivers/mtd/mx25rxx.c index 7d9b732fc06..785999601f4 100644 --- a/drivers/mtd/mx25rxx.c +++ b/drivers/mtd/mx25rxx.c @@ -47,6 +47,8 @@ #include #include +#include +#include #include #include #include @@ -397,7 +399,7 @@ int mx25rxx_erase_sector(struct mx25rxx_dev_s *priv, off_t sector) do { - usleep(50*1000); + nxsig_usleep(50*1000); mx25rxx_read_status(priv); status = priv->cmdbuf[0]; } @@ -421,7 +423,7 @@ int mx25rxx_erase_block(struct mx25rxx_dev_s *priv, off_t block) do { - usleep(300*1000); + nxsig_usleep(300*1000); mx25rxx_read_status(priv); status = priv->cmdbuf[0]; } @@ -446,7 +448,7 @@ int mx25rxx_erase_chip(struct mx25rxx_dev_s *priv) while ((status & MX25R_SR_WIP) != 0) { - sleep(2); + nxsig_sleep(2); mx25rxx_read_status(priv); status = priv->cmdbuf[0]; } diff --git a/drivers/mtd/n25qxxx.c b/drivers/mtd/n25qxxx.c index 3ed07ac8083..cd66ea27630 100644 --- a/drivers/mtd/n25qxxx.c +++ b/drivers/mtd/n25qxxx.c @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -855,7 +856,7 @@ static int n25qxxx_erase_chip(struct n25qxxx_dev_s *priv) status = n25qxxx_read_status(priv); while ((status & STATUS_BUSY_MASK) != 0) { - usleep(200*1000); + nxsig_usleep(200*1000); status = n25qxxx_read_status(priv); } diff --git a/drivers/mtd/s25fl1.c b/drivers/mtd/s25fl1.c index f513b683631..d238e603578 100644 --- a/drivers/mtd/s25fl1.c +++ b/drivers/mtd/s25fl1.c @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -890,7 +891,7 @@ static int s25fl1_erase_chip(struct s25fl1_dev_s *priv) status = sf25fl1_read_status1(priv); while ((status & STATUS1_BUSY_MASK) != 0) { - usleep(200*1000); + nxsig_usleep(200*1000); status = sf25fl1_read_status1(priv); } @@ -1511,7 +1512,7 @@ FAR struct mtd_dev_s *s25fl1_initialize(FAR struct qspi_dev_s *qspi, bool unprot priv->cmdbuf[1] |= STATUS2_QUAD_ENABLE; s25fl1_write_status(priv); priv->cmdbuf[1] = sf25fl1_read_status2(priv); - usleep(50*1000); + nxsig_usleep(50*1000); } /* Unprotect FLASH sectors if so requested. */ diff --git a/drivers/mtd/sst25.c b/drivers/mtd/sst25.c index 7e4b3435e8a..46f80461707 100644 --- a/drivers/mtd/sst25.c +++ b/drivers/mtd/sst25.c @@ -57,6 +57,7 @@ #include #include +#include #include #include #include @@ -425,7 +426,7 @@ static uint8_t sst25_waitwritecomplete(struct sst25_dev_s *priv) if ((status & SST25_SR_BUSY) != 0) { sst25_unlock(priv->dev); - usleep(1000); + nxsig_usleep(1000); sst25_lock(priv->dev); } #endif diff --git a/drivers/mtd/sst25xx.c b/drivers/mtd/sst25xx.c index efd53859165..fc3d0556d3e 100644 --- a/drivers/mtd/sst25xx.c +++ b/drivers/mtd/sst25xx.c @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -348,7 +349,7 @@ static void sst25xx_waitwritecomplete(struct sst25xx_dev_s *priv) if ((status & SST25_SR_WIP) != 0) { sst25xx_unlock(priv->dev); - usleep(1000); + nxsig_usleep(1000); sst25xx_lock(priv->dev); } } diff --git a/drivers/mtd/sst26.c b/drivers/mtd/sst26.c index a0bfc9dbab2..d7e642b93dc 100644 --- a/drivers/mtd/sst26.c +++ b/drivers/mtd/sst26.c @@ -60,6 +60,7 @@ #include #include +#include #include #include #include @@ -407,7 +408,7 @@ static void sst26_waitwritecomplete(struct sst26_dev_s *priv) if ((status & SST26_SR_WIP) != 0) { sst26_unlock(priv->dev); - usleep(1000); + nxsig_usleep(1000); sst26_lock(priv->dev); } } diff --git a/drivers/mtd/sst39vf.c b/drivers/mtd/sst39vf.c index 93295088452..ad57d42405a 100644 --- a/drivers/mtd/sst39vf.c +++ b/drivers/mtd/sst39vf.c @@ -50,6 +50,7 @@ #include #include +#include #include #include @@ -454,12 +455,12 @@ static int sst39vf_chiperase(FAR struct sst39vf_dev_s *priv) /* No, wait one system clock tick */ - usleep(USEC_PER_TICK); + nxsig_usleep(USEC_PER_TICK); } #else /* Delay the maximum amount of time for the chip erase to complete. */ - usleep(SST39VF_TSCE_MSEC * USEC_PER_MSEC); + nxsig_usleep(SST39VF_TSCE_MSEC * USEC_PER_MSEC); #endif return OK; @@ -530,12 +531,12 @@ static int sst39vf_sectorerase(FAR struct sst39vf_dev_s *priv, /* No, wait one system clock tick */ - usleep(USEC_PER_TICK); + nxsig_usleep(USEC_PER_TICK); } #else /* Delay the maximum amount of time for the sector erase to complete. */ - usleep(SST39VF_TSE_MSEC * USEC_PER_MSEC); + nxsig_usleep(SST39VF_TSE_MSEC * USEC_PER_MSEC); #endif return OK; diff --git a/drivers/mtd/w25.c b/drivers/mtd/w25.c index 25f263f0ac5..d98364266ec 100644 --- a/drivers/mtd/w25.c +++ b/drivers/mtd/w25.c @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -521,7 +522,7 @@ static uint8_t w25_waitwritecomplete(struct w25_dev_s *priv) if (priv->prev_instr != W25_PP && (status & W25_SR_BUSY) != 0) { w25_unlock(priv->spi); - usleep(1000); + nxsig_usleep(1000); w25_lock(priv->spi); } } diff --git a/drivers/net/slip.c b/drivers/net/slip.c index bbd4cd357cc..db7ea97b6e5 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -134,7 +135,7 @@ struct slip_driver_s { volatile bool bifup; /* true:ifup false:ifdown */ - bool txnodelay; /* True: usleep() not needed */ + bool txnodelay; /* True: nxsig_usleep() not needed */ int16_t fd; /* TTY file descriptor */ uint16_t rxlen; /* The number of bytes in rxbuf */ pid_t rxpid; /* Receiver thread ID */ @@ -456,7 +457,7 @@ static void slip_txtask(int argc, FAR char *argv[]) if (!priv->txnodelay) { slip_semgive(priv); - usleep(SLIP_WDDELAY); + nxsig_usleep(SLIP_WDDELAY); } else { diff --git a/drivers/power/bq2425x.c b/drivers/power/bq2425x.c index a93116b46f9..5039ad9ea92 100644 --- a/drivers/power/bq2425x.c +++ b/drivers/power/bq2425x.c @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -294,7 +295,7 @@ static inline int bq2425x_reset(FAR struct bq2425x_dev_s *priv) /* Wait a little bit to clear registers */ - usleep(500); + nxsig_usleep(500); /* There is a BUG in BQ2425X the RESET bit is always read as 1 */ diff --git a/drivers/power/bq2429x.c b/drivers/power/bq2429x.c index 7aa91eab8ef..46bc65ebbb6 100644 --- a/drivers/power/bq2429x.c +++ b/drivers/power/bq2429x.c @@ -76,6 +76,7 @@ #include #include +#include #include #include #include @@ -344,7 +345,7 @@ static int bq2429x_reset(FAR struct bq2429x_dev_s *priv) /* Wait a little bit to clear registers */ - usleep(500); + nxsig_usleep(500); #if 0 /* There is a BUG in BQ2429X the RESET bit is always read as 1 */ diff --git a/drivers/sensors/adxl345_base.c b/drivers/sensors/adxl345_base.c index da09bb353af..33079ed9c58 100644 --- a/drivers/sensors/adxl345_base.c +++ b/drivers/sensors/adxl345_base.c @@ -47,8 +47,9 @@ #include #include -#include +#include #include +#include #include "adxl345.h" @@ -359,7 +360,7 @@ static void adxl345_reset(FAR struct adxl345_dev_s *priv) /* Wait a bit to make the GOD of TIME happy */ - usleep(20*1000); + nxsig_usleep(20*1000); } /**************************************************************************** diff --git a/drivers/sensors/bmp180.c b/drivers/sensors/bmp180.c index e3301979572..d18d14e9ab2 100644 --- a/drivers/sensors/bmp180.c +++ b/drivers/sensors/bmp180.c @@ -50,6 +50,7 @@ #include #include +#include #include #include #include @@ -402,7 +403,7 @@ static void bmp180_read_press_temp(FAR struct bmp180_dev_s *priv) /* Wait 5ms */ - usleep(5000); + nxsig_usleep(5000); /* Read temperature */ @@ -414,7 +415,7 @@ static void bmp180_read_press_temp(FAR struct bmp180_dev_s *priv) /* Delay 25.5ms (to OverSampling 8X) */ - usleep(25500); + nxsig_usleep(25500); /* Read pressure */ diff --git a/drivers/sensors/hc_sr04.c b/drivers/sensors/hc_sr04.c index 0a3dfa8e1a1..9865da7dbf4 100644 --- a/drivers/sensors/hc_sr04.c +++ b/drivers/sensors/hc_sr04.c @@ -43,11 +43,12 @@ #include #include #include + #include #include #include +#include #include - #include /**************************************************************************** @@ -144,7 +145,7 @@ static int hcsr04_start_measuring(FAR struct hcsr04_dev_s *priv) /* Send to 10uS trigger pulse */ priv->config->set_trigger(priv->config, true); - usleep(10); + nxsig_usleep(10); priv->config->set_trigger(priv->config, false); return 0; diff --git a/drivers/sensors/kxtj9.c b/drivers/sensors/kxtj9.c index 8f08f048059..ed50d6260fa 100644 --- a/drivers/sensors/kxtj9.c +++ b/drivers/sensors/kxtj9.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -303,7 +304,7 @@ static void kxtj9_soft_reset(FAR struct kxtj9_dev_s *priv) /* Delay 10ms for the accel parts to re-initialize */ - usleep(10000); + nxsig_usleep(10000); } /**************************************************************************** diff --git a/drivers/sensors/lis2dh.c b/drivers/sensors/lis2dh.c index 0fe8f1cb891..c42935dec87 100644 --- a/drivers/sensors/lis2dh.c +++ b/drivers/sensors/lis2dh.c @@ -49,9 +49,10 @@ #include #include -#include #include +#include #include +#include #include @@ -1121,7 +1122,7 @@ static int lis2dh_handle_selftest(FAR struct lis2dh_dev_s *priv) goto out; } - usleep(20000); + nxsig_usleep(20000); /* Now INT1 should have been latched high and INT2 should be still low */ @@ -1150,7 +1151,7 @@ static int lis2dh_handle_selftest(FAR struct lis2dh_dev_s *priv) goto out; } - usleep(20000); + nxsig_usleep(20000); if (priv->config->read_int2_pin() != 1) { @@ -1256,7 +1257,7 @@ static FAR const struct lis2dh_vector_s * while (--retries_left > 0) { - usleep(20000); + nxsig_usleep(20000); if (lis2dh_data_available(dev)) { if (lis2dh_access(dev, ST_LIS2DH_OUT_X_L_REG, retval, @@ -1692,7 +1693,7 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev) return -ETIMEDOUT; } - usleep(1); + nxsig_usleep(1); } while (true); diff --git a/drivers/sensors/mpl115a.c b/drivers/sensors/mpl115a.c index 0e5ad6a971a..c4ea87de60e 100644 --- a/drivers/sensors/mpl115a.c +++ b/drivers/sensors/mpl115a.c @@ -47,10 +47,11 @@ #include #include +#include +#include #include #include #include -#include #if defined(CONFIG_SPI) && defined(CONFIG_SENSORS_MPL115A) @@ -215,7 +216,7 @@ static void mpl115a_read_press_temp(FAR struct mpl115a_dev_s *priv) /* Delay 5ms */ - usleep(5000); + nxsig_usleep(5000); priv->mpl115a_pressure = mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_PADC_MSB << 1)) << 8; priv->mpl115a_pressure |= mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_PADC_LSB << 1)); diff --git a/drivers/sensors/veml6070.c b/drivers/sensors/veml6070.c index 215a23c0d5d..2255f0618a9 100644 --- a/drivers/sensors/veml6070.c +++ b/drivers/sensors/veml6070.c @@ -45,10 +45,11 @@ #include #include +#include +#include #include #include #include -#include #if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_VEML6070) @@ -248,7 +249,7 @@ static ssize_t veml6070_read(FAR struct file *filep, FAR char *buffer, /* 1T for Rset 270Kohms is 125ms */ - usleep(125000); + nxsig_usleep(125000); /* Read the MSB first */ diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 69ea5420a57..98ad621ab8b 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -452,7 +453,7 @@ static int uart_tcdrain(FAR uart_dev_t *dev) while (!uart_txempty(dev)) { #ifndef CONFIG_DISABLE_SIGNALS - usleep(HALF_SECOND_USEC); + nxsig_usleep(HALF_SECOND_USEC); #else up_mdelay(HALF_SECOND_MSEC); #endif diff --git a/drivers/spi/spi_transfer.c b/drivers/spi/spi_transfer.c index b92819c86a8..5a5a54d0e99 100644 --- a/drivers/spi/spi_transfer.c +++ b/drivers/spi/spi_transfer.c @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -148,7 +149,7 @@ int spi_transfer(FAR struct spi_dev_s *spi, FAR struct spi_sequence_s *seq) if (trans->delay > 0) { - usleep(trans->delay); + nxsig_usleep(trans->delay); } } diff --git a/drivers/usbhost/usbhost_enumerate.c b/drivers/usbhost/usbhost_enumerate.c index 01062d077be..a6cbddc9ed6 100644 --- a/drivers/usbhost/usbhost_enumerate.c +++ b/drivers/usbhost/usbhost_enumerate.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/usbhost/usbhost_enumerate.c * - * Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2015, 2017 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -433,7 +434,7 @@ int usbhost_enumerate(FAR struct usbhost_hubport_s *hport, goto errout; } - usleep(2*1000); + nxsig_usleep(2*1000); /* Assign the function address to the port */ @@ -531,7 +532,7 @@ int usbhost_enumerate(FAR struct usbhost_hubport_s *hport, /* Some devices may require some delay before initialization */ - usleep(100*1000); + nxsig_usleep(100*1000); #ifdef CONFIG_USBHOST_COMPOSITE /* Check if the device attached to the downstream port if a USB composite diff --git a/drivers/usbhost/usbhost_hidkbd.c b/drivers/usbhost/usbhost_hidkbd.c index eb329b75b12..2987effce88 100644 --- a/drivers/usbhost/usbhost_hidkbd.c +++ b/drivers/usbhost/usbhost_hidkbd.c @@ -57,10 +57,11 @@ #include #include #include -#include #include #include +#include #include +#include #include #include @@ -96,7 +97,7 @@ # warning "Worker thread support is required (CONFIG_SCHED_WORKQUEUE)" #endif -/* Signals must not be disabled as they are needed by usleep. Need to have +/* Signals must not be disabled as they are needed by nxsig_usleep. Need to have * CONFIG_DISABLE_SIGNALS=n */ @@ -1039,7 +1040,7 @@ static int usbhost_kbdpoll(int argc, char *argv[]) priv->polling = true; usbhost_givesem(&g_syncsem); - sleep(1); + nxsig_sleep(1); /* Loop here until the device is disconnected */ @@ -1250,7 +1251,7 @@ static int usbhost_kbdpoll(int argc, char *argv[]) delay = CONFIG_HIDKBD_POLLUSEC; } - usleep(delay); + nxsig_usleep(delay); } /* We get here when the driver is removed.. or when too many errors have diff --git a/drivers/usbhost/usbhost_hidmouse.c b/drivers/usbhost/usbhost_hidmouse.c index 72ec7f52a18..3c0afef7e19 100644 --- a/drivers/usbhost/usbhost_hidmouse.c +++ b/drivers/usbhost/usbhost_hidmouse.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -1076,7 +1077,7 @@ static int usbhost_mouse_poll(int argc, char *argv[]) priv->polling = true; usbhost_givesem(&g_syncsem); - sleep(1); + nxsig_sleep(1); /* Loop here until the device is disconnected */ diff --git a/drivers/usbhost/usbhost_hub.c b/drivers/usbhost/usbhost_hub.c index f040332b030..58d7c64a2dd 100644 --- a/drivers/usbhost/usbhost_hub.c +++ b/drivers/usbhost/usbhost_hub.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/usbhost/usbhost_hub.c * - * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. * Author: Kaushal Parikh * Gregory Nutt * @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -834,7 +835,7 @@ static void usbhost_hub_event(FAR void *arg) } debouncetime += 25; - usleep(25*1000); + nxsig_usleep(25*1000); } if (ret < 0 || debouncetime >= 1500) @@ -862,7 +863,7 @@ static void usbhost_hub_event(FAR void *arg) continue; } - usleep(100*1000); + nxsig_usleep(100*1000); ctrlreq->type = USB_REQ_DIR_IN | USBHUB_REQ_TYPE_PORT; ctrlreq->req = USBHUB_REQ_GETSTATUS; diff --git a/drivers/usbhost/usbhost_storage.c b/drivers/usbhost/usbhost_storage.c index 71f8c951b12..f78a58ce545 100644 --- a/drivers/usbhost/usbhost_storage.c +++ b/drivers/usbhost/usbhost_storage.c @@ -50,10 +50,11 @@ #include #include -#include +#include #include #include #include +#include #include #include @@ -1248,7 +1249,7 @@ static inline int usbhost_initvolume(FAR struct usbhost_state_s *priv) /* Wait just a bit */ - usleep(USBHOST_RETRY_USEC); + nxsig_usleep(USBHOST_RETRY_USEC); /* Send TESTUNITREADY to see if the unit is ready. The most likely error * error that can occur here is a a stall which simply means that the diff --git a/drivers/usbhost/usbhost_xboxcontroller.c b/drivers/usbhost/usbhost_xboxcontroller.c index 01e1ec808ef..ff0132b6efc 100644 --- a/drivers/usbhost/usbhost_xboxcontroller.c +++ b/drivers/usbhost/usbhost_xboxcontroller.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -618,7 +619,7 @@ static int usbhost_xboxcontroller_poll(int argc, char *argv[]) priv->polling = true; usbhost_givesem(&g_syncsem); - sleep(1); + nxsig_sleep(1); /* Loop here until the device is disconnected */ diff --git a/drivers/usbmonitor/usbmonitor.c b/drivers/usbmonitor/usbmonitor.c index 913ceeb1108..17068372806 100644 --- a/drivers/usbmonitor/usbmonitor.c +++ b/drivers/usbmonitor/usbmonitor.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/usbmonitor/usbmonitor.c * - * Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -166,7 +167,7 @@ static int usbmonitor_daemon(int argc, char **argv) while (!g_usbmonitor.stop) { - sleep(CONFIG_USBMONITOR_INTERVAL); + nxsig_sleep(CONFIG_USBMONITOR_INTERVAL); #ifdef CONFIG_USBDEV_TRACE (void)usbtrace_enumerate(usbmonitor_tracecallback, NULL); #endif diff --git a/drivers/wireless/cc3000/cc3000.c b/drivers/wireless/cc3000/cc3000.c index 162d8b5794e..6fb4f52ee5c 100644 --- a/drivers/wireless/cc3000/cc3000.c +++ b/drivers/wireless/cc3000/cc3000.c @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -1264,9 +1265,9 @@ static ssize_t cc3000_write(FAR struct file *filep, FAR const char *usrbuffer, s if (priv->state == eSPI_STATE_INITIALIZED) { cc3000_lock_and_select(priv->spi); /* Assert CS */ - usleep(55); + nxsig_usleep(55); SPI_SNDBLOCK(priv->spi, buffer, 4); - usleep(55); + nxsig_usleep(55); SPI_SNDBLOCK(priv->spi, buffer+4, tx_len-4); } else diff --git a/drivers/wireless/cc3000/socket_imp.c b/drivers/wireless/cc3000/socket_imp.c index 2ec41d92e1b..e3f7c862075 100644 --- a/drivers/wireless/cc3000/socket_imp.c +++ b/drivers/wireless/cc3000/socket_imp.c @@ -47,11 +47,13 @@ #include #include +#include #include -#include "cc3000_socket.h" #include #include +#include "cc3000_socket.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -154,7 +156,7 @@ int HostFlowControlConsumeBuff(int sd) if (0 == tSLInformation.usNumberOfFreeBuffers) { - usleep(100000); + nxsig_usleep(100000); } } while (0 == tSLInformation.usNumberOfFreeBuffers); diff --git a/drivers/wireless/nrf24l01.c b/drivers/wireless/nrf24l01.c index a9d435ebcea..dcd14652cb4 100644 --- a/drivers/wireless/nrf24l01.c +++ b/drivers/wireless/nrf24l01.c @@ -60,6 +60,7 @@ #include #include +#include #ifdef CONFIG_WL_NRF24L01_RXSUPPORT # include @@ -792,7 +793,7 @@ static void nrf24l01_tostate(struct nrf24l01_dev_s *dev, /* Leaving power down (note: new state cannot be power down here) */ nrf24l01_setregbit(dev, NRF24L01_CONFIG, NRF24L01_PWR_UP, true); - usleep(NRF24L01_TPD2STBY_DELAY); + nxsig_usleep(NRF24L01_TPD2STBY_DELAY); } /* Entering new state */ diff --git a/drivers/wireless/spirit/lib/spirit_radio.c b/drivers/wireless/spirit/lib/spirit_radio.c index b5dc649d9c9..edb6ee1544c 100644 --- a/drivers/wireless/spirit/lib/spirit_radio.c +++ b/drivers/wireless/spirit/lib/spirit_radio.c @@ -47,6 +47,8 @@ #include #include +#include + #include "spirit_config.h" #include "spirit_types.h" #include "spirit_management.h" @@ -225,7 +227,7 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit, /* Delay for state transition */ - usleep(100); + nxsig_usleep(100); /* Wait for the device to enter STANDBY */ @@ -262,7 +264,7 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit, /* Delay for state transition */ - usleep(100); + nxsig_usleep(100); /* Make sure that the device becomes READY */ diff --git a/graphics/nxmu/nx_start.c b/graphics/nxmu/nx_start.c index a262b28a91a..646cb561ba3 100644 --- a/graphics/nxmu/nx_start.c +++ b/graphics/nxmu/nx_start.c @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxmu/nx_start.c * - * Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,7 @@ #include #include +#include #include #include @@ -204,7 +205,7 @@ int nx_start(void) * this operation cannot be done from the IDLE thread! */ - usleep(50*1000); + nxsig_usleep(50*1000); } return OK; diff --git a/include/nuttx/signal.h b/include/nuttx/signal.h index 57f8f2d6651..999bebbe17f 100644 --- a/include/nuttx/signal.h +++ b/include/nuttx/signal.h @@ -171,6 +171,70 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info, int nxsig_nanosleep(FAR const struct timespec *rqtp, FAR struct timespec *rmtp); +/**************************************************************************** + * Name: nxsig_sleep + * + * Description: + * The nxsig_sleep() function will cause the calling thread to be + * suspended from execution until either the number of real-time seconds + * specified by the argument 'seconds' has elapsed or a signal is + * delivered to the calling thread. + * + * This is an internal OS interface. It is functionally equivalent to + * the standard sleep() application interface except that: + * + * - It is not a cancellaction point, and + * - There is no check that the action of the signal is to invoke a + * signal-catching function or to terminate the process. + * + * See the description of sleep() for additional information that is not + * duplicated here. + * + * Parameters: + * seconds - The number of seconds to sleep + * + * Returned Value: + * If nxsig_sleep() returns because the requested time has elapsed, the + * value returned will be zero (OK). If nxsig_sleep() returns because of + * premature arousal due to delivery of a signal, the return value will + * be the "unslept" amount (the requested time minus the time actually + * slept) in seconds. + * + ****************************************************************************/ + +unsigned int nxsig_sleep(unsigned int seconds); + +/**************************************************************************** + * Name: nxsig_usleep + * + * Description: + * The nxsig_usleep() function will cause the calling thread to be + * suspended from execution until either the number of real-time + * microseconds specified by the argument 'usec' has elapsed or a signal + * is delivered to the calling thread. The suspension time may be longer + * than requested due to the scheduling of other activity by the system. + * + * This is an internal OS interface. It is functionally equivalent to + * the standard nxsig_usleep() application interface except that: + * + * - It is not a cancellaction point, and + * - It does not modify the errno value. + * + * See the description of usleep() for additional information that is not + * duplicated here. + * + * Parameters: + * usec - the number of microseconds to wait. + * + * Returned Value: + * This is an internal OS interface and should not be used by applications. + * It follows the NuttX internal error return policy: Zero (OK) is + * returned on success. A negated errno value is returned on failure. + * + ****************************************************************************/ + +int nxsig_usleep(useconds_t usec); + /**************************************************************************** * Name: nxsig_notification * diff --git a/libc/unistd/lib_sleep.c b/libc/unistd/lib_sleep.c index 70f763f0ce5..cb188a9329a 100644 --- a/libc/unistd/lib_sleep.c +++ b/libc/unistd/lib_sleep.c @@ -94,7 +94,7 @@ * are unspecified. * * Parameters: - * seconds + * seconds - The number of seconds to sleep * * Returned Value: * If sleep() returns because the requested time has elapsed, the value @@ -115,7 +115,7 @@ unsigned int sleep(unsigned int seconds) /* Don't sleep if seconds == 0 */ - if (seconds) + if (seconds > 0) { /* Let nanosleep() do all of the work. */ diff --git a/sched/paging/pg_worker.c b/sched/paging/pg_worker.c index 8fd125812af..4c52e549cf3 100644 --- a/sched/paging/pg_worker.c +++ b/sched/paging/pg_worker.c @@ -49,6 +49,7 @@ #include #include +#include #include #include @@ -538,15 +539,14 @@ int pg_worker(int argc, char *argv[]) { /* Wait awhile. We will wait here until either the configurable timeout * elapses or until we are awakened by a signal (which terminates the - * usleep with an EINTR error). Note that interrupts will be re-enabled - * while this task sleeps. + * nxsig_usleep with an EINTR error). Note that interrupts will be re- * enabled while this task sleeps. * * The timeout is a failsafe that will handle any cases where a single * is lost (that would really be a bug and shouldn't happen!) and also * supports timeouts for case of non-blocking, asynchronous fills. */ - usleep(CONFIG_PAGING_WORKPERIOD); + nxsig_usleep(CONFIG_PAGING_WORKPERIOD); /* The page fill worker thread will be awakened on one of three conditions: * diff --git a/sched/signal/Make.defs b/sched/signal/Make.defs index 7104fd18203..f752a0b74cd 100644 --- a/sched/signal/Make.defs +++ b/sched/signal/Make.defs @@ -42,7 +42,7 @@ CSRCS += sig_findaction.c sig_allocpendingsigaction.c CSRCS += sig_releasependingsigaction.c sig_unmaskpendingsignal.c CSRCS += sig_removependingsignal.c sig_releasependingsignal.c sig_lowest.c CSRCS += sig_mqnotempty.c sig_cleanup.c sig_dispatch.c sig_deliver.c -CSRCS += sig_pause.c sig_nanosleep.c +CSRCS += sig_pause.c sig_nanosleep.c sig_usleep.c sig_sleep.c ifeq ($(CONFIG_SIG_EVTHREAD),y) CSRCS += sig_notification.c diff --git a/sched/signal/sig_sleep.c b/sched/signal/sig_sleep.c new file mode 100644 index 00000000000..7c3c8998585 --- /dev/null +++ b/sched/signal/sig_sleep.c @@ -0,0 +1,121 @@ +/**************************************************************************** + * sched/signal/sig_sleep.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxsig_sleep + * + * Description: + * The nxsig_sleep() function will cause the calling thread to be + * suspended from execution until either the number of real-time seconds + * specified by the argument 'seconds' has elapsed or a signal is + * delivered to the calling thread. + * + * This is an internal OS interface. It is functionally equivalent to + * the standard sleep() application interface except that: + * + * - It is not a cancellaction point, and + * - There is no check that the action of the signal is to invoke a + * signal-catching function or to terminate the process. + * + * See the description of sleep() for additional information that is not + * duplicated here. + * + * Parameters: + * seconds - The number of seconds to sleep + * + * Returned Value: + * If nxsig_sleep() returns because the requested time has elapsed, the + * value returned will be zero (OK). If nxsig_sleep() returns because of + * premature arousal due to delivery of a signal, the return value will + * be the "unslept" amount (the requested time minus the time actually + * slept) in seconds. + * + ****************************************************************************/ + +unsigned int nxsig_sleep(unsigned int seconds) +{ + struct timespec rqtp; + struct timespec rmtp; + unsigned int remaining = 0; + int ret; + + /* Don't sleep if seconds == 0 */ + + if (seconds > 0) + { + /* Let nxsig_nanosleep() do all of the work. */ + + rqtp.tv_sec = seconds; + rqtp.tv_nsec = 0; + + ret = nxsig_nanosleep(&rqtp, &rmtp); + + /* nanosleep() should only fail if it was interrupted by a signal, + * but we treat all errors the same, + */ + + if (ret < 0) + { + remaining = rmtp.tv_sec; + if (remaining < seconds && rmtp.tv_nsec >= 500000000) + { + /* Round up */ + + remaining++; + } + } + + return remaining; + } + + return 0; +} diff --git a/sched/signal/sig_usleep.c b/sched/signal/sig_usleep.c new file mode 100644 index 00000000000..9bce046df03 --- /dev/null +++ b/sched/signal/sig_usleep.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * sched/sig_usleep.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxsig_usleep + * + * Description: + * The nxsig_usleep() function will cause the calling thread to be + * suspended from execution until either the number of real-time + * microseconds specified by the argument 'usec' has elapsed or a signal + * is delivered to the calling thread. The suspension time may be longer + * than requested due to the scheduling of other activity by the system. + * + * This is an internal OS interface. It is functionally equivalent to + * the standard nxsig_usleep() application interface except that: + * + * - It is not a cancellaction point, and + * - It does not modify the errno value. + * + * See the description of usleep() for additional information that is not + * duplicated here. + * + * Parameters: + * usec - the number of microseconds to wait. + * + * Returned Value: + * This is an internal OS interface and should not be used by applications. + * It follows the NuttX internal error return policy: Zero (OK) is + * returned on success. A negated errno value is returned on failure. + * + ****************************************************************************/ + +int nxsig_usleep(useconds_t usec) +{ + struct timespec rqtp; + time_t sec; + int ret = 0; + + if (usec) + { + /* Let nxsig_nanosleep() do all of the work. */ + + sec = usec / 1000000; + rqtp.tv_sec = sec; + rqtp.tv_nsec = (usec - (sec * 1000000)) * 1000; + + ret = nxsig_nanosleep(&rqtp, NULL); + } + + return ret; +} diff --git a/sched/wqueue/kwork_process.c b/sched/wqueue/kwork_process.c index 58ecd47eef2..80c7befca29 100644 --- a/sched/wqueue/kwork_process.c +++ b/sched/wqueue/kwork_process.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/wqueue/work_process.c * - * Copyright (C) 2009-2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2014, 2016-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,7 @@ #include #include +#include #include #include "wqueue/wqueue.h" @@ -258,7 +259,7 @@ void work_process(FAR struct kwork_wqueue_s *wqueue, systime_t period, int wndx) */ wqueue->worker[wndx].busy = false; - usleep(next * USEC_PER_TICK); + nxsig_usleep(next * USEC_PER_TICK); wqueue->worker[wndx].busy = true; } }