boards/: Within the OS, nxisg_usleep() should be used instead of usleep(). usleep() is a cancellation point and sets the errno value. Neither of which should be done inside the OS.

This commit is contained in:
Gregory Nutt 2019-11-29 17:47:03 -06:00
parent 244437257b
commit 03e41c6806
12 changed files with 61 additions and 47 deletions

View File

@ -47,6 +47,7 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/signal.h>
#include <arch/chip/audio.h>
#include "chip.h"
@ -297,13 +298,13 @@ int board_external_amp_mute_control(bool en)
/* Mute ON */
ret = board_power_control(POWER_AUDIO_MUTE, false);
usleep(MUTE_ON_DELAY);
nxsig_usleep(MUTE_ON_DELAY);
}
else
{
/* Mute OFF */
usleep(MUTE_OFF_DELAY);
nxsig_usleep(MUTE_OFF_DELAY);
ret = board_power_control(POWER_AUDIO_MUTE, true);
}

View File

@ -43,12 +43,14 @@
#include <debug.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/signal.h>
#include "cxd56_gpio.h"
#include "cxd56_pinconfig.h"
#include "cxd56_i2c.h"
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
/****************************************************************************
@ -111,8 +113,9 @@ int board_isx012_power_on(void)
break;
}
usleep(POWER_CHECK_TIME);
nxsig_usleep(POWER_CHECK_TIME);
}
return ret;
}
@ -144,7 +147,7 @@ int board_isx012_power_off(void)
break;
}
usleep(POWER_CHECK_TIME);
nxsig_usleep(POWER_CHECK_TIME);
}
return ret;
@ -167,20 +170,20 @@ void board_isx012_set_sleep(int kind)
{
/* PowerON -> sleep */
usleep(DEVICE_STARTUP_TIME);
nxsig_usleep(DEVICE_STARTUP_TIME);
}
else
{
/* active -> sleep */
usleep(STANDBY_TIME);
nxsig_usleep(STANDBY_TIME);
}
}
void board_isx012_release_sleep(void)
{
cxd56_gpio_write(IMAGER_SLEEP, true);
usleep(SLEEP_CANCEL_TIME);
nxsig_usleep(SLEEP_CANCEL_TIME);
}
int isx012_register(FAR struct i2c_master_s *i2c);

View File

@ -38,9 +38,13 @@
****************************************************************************/
#include <nuttx/config.h>
#include <time.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <time.h>
#include <nuttx/signal.h>
#include <arch/board/board.h>
#include <arch/chip/audio.h>
@ -107,7 +111,7 @@ static void wait_mic_boot_finish(void)
if (time < CXD56_AUDIO_MIC_BOOT_WAIT)
{
usleep((CXD56_AUDIO_MIC_BOOT_WAIT - time) * 1000);
nxsig_usleep((CXD56_AUDIO_MIC_BOOT_WAIT - time) * 1000);
}
}
}

View File

@ -37,9 +37,11 @@
* Included Files
****************************************************************************/
#include <nuttx/arch.h>
#include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/signal.h>
#include "cxd56_audio_config.h"
#include "cxd56_audio_ac_reg.h"
#include "cxd56_audio_analog.h"
@ -134,7 +136,7 @@ static CXD56_AUDIO_ECODE set_mute(cxd56_audio_volid_t id,
if (wait)
{
usleep(waittime);
nxsig_usleep(waittime);
}
g_volparam[id].mute_bit |= type;
@ -200,7 +202,7 @@ static CXD56_AUDIO_ECODE set_unmute(cxd56_audio_volid_t id,
if (wait)
{
usleep(waittime);
nxsig_usleep(waittime);
}
}

View File

@ -39,10 +39,12 @@
#include <nuttx/config.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <unistd.h>
#include <nuttx/board.h>
#include <nuttx/signal.h>
#include <arch/board/board.h>
#include "chip.h"
#include "up_arch.h"
#include "up_internal.h"
@ -69,9 +71,9 @@ void up_bt_enable(int enable)
if (enable)
{
lc823450_gpio_write(BT_POWER, 0);
usleep(100 * 1000);
nxsig_usleep(100 * 1000);
lc823450_gpio_write(BT_POWER, 1);
usleep(100 * 1000);
nxsig_usleep(100 * 1000);
}
else
{

View File

@ -1,7 +1,7 @@
/****************************************************************************
* boards/arm/stm32/clicker2-stm32/src/stm32_appinit.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2017, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,8 +44,9 @@
#include <unistd.h>
#include <syslog.h>
#include <nuttx/syslog/syslog.h>
#include <nuttx/board.h>
#include <nuttx/signal.h>
#include <nuttx/syslog/syslog.h>
#include "clicker2-stm32.h"
@ -108,7 +109,7 @@ int board_app_initialize(uintptr_t arg)
* file syslog.
*/
usleep(CONFIG_CLICKER2_STM32_SYSLOG_FILE_DELAY * 1000);
nxsig_usleep(CONFIG_CLICKER2_STM32_SYSLOG_FILE_DELAY * 1000);
ret = syslog_file_channel(CONFIG_CLICKER2_STM32_SYSLOG_FILE_PATH);
if (ret < 0)

View File

@ -1,7 +1,7 @@
/****************************************************************************
* boards/arm/stm32/nucleo-f302r8/src/stm32_highpri.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Copyright (C) 2018, 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* Redistribution and use in source and binary forms, with or without
@ -46,14 +46,13 @@
#include <nuttx/arch.h>
#include <nuttx/signal.h>
#include <arch/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include <nuttx/timers/pwm.h>
#include <nuttx/analog/adc.h>
#include <nuttx/analog/ioctl.h>
#include <arch/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include "up_internal.h"
#include "ram_vectors.h"
@ -505,7 +504,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
usleep(100);
nxsig_usleep(100);
#endif
#ifdef HIGHPRI_HAVE_INJECTED
@ -513,7 +512,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
usleep(100);
nxsig_usleep(100);
#endif
/* Lock global data */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* boards/arm/stm32/nucleo-f334r8/src/stm32_highpri.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Copyright (C) 2018, 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* Redistribution and use in source and binary forms, with or without
@ -46,14 +46,13 @@
#include <nuttx/arch.h>
#include <nuttx/signal.h>
#include <arch/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include <nuttx/timers/pwm.h>
#include <nuttx/analog/adc.h>
#include <nuttx/analog/ioctl.h>
#include <arch/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include "up_internal.h"
#include "ram_vectors.h"
@ -547,7 +546,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
usleep(100);
nxsig_usleep(100);
#endif
#ifdef HIGHPRI_HAVE_INJECTED
@ -555,7 +554,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
usleep(100);
nxsig_usleep(100);
#endif
/* Lock global data */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* boards/arm/stm32/stm32f429i-disco/src/stm32_highpri.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Copyright (C) 2018, 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* Redistribution and use in source and binary forms, with or without
@ -495,7 +495,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
usleep(100);
nxsig_usleep(100);
#endif
#ifdef HIGHPRI_HAVE_INJECTED
@ -503,7 +503,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
usleep(100);
nxsig_usleep(100);
#endif
/* Lock global data */

View File

@ -46,8 +46,9 @@
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <nuttx/signal.h>
#include <nuttx/wireless/lpwan/sx127x.h>
#include <arch/board/board.h>
#include "stm32_gpio.h"
#include "stm32_exti.h"
@ -126,7 +127,7 @@ static void sx127x_chip_reset(void)
/* Wait 1 ms */
usleep(1000);
nxsig_usleep(1000);
/* Configure reset as input */
@ -134,7 +135,7 @@ static void sx127x_chip_reset(void)
/* Wait 10 ms */
usleep(10000);
nxsig_usleep(10000);
}
/****************************************************************************

View File

@ -47,8 +47,9 @@
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <nuttx/signal.h>
#include <nuttx/wireless/lpwan/sx127x.h>
#include <arch/board/board.h>
#include "stm32_gpio.h"
#include "stm32_exti.h"
@ -125,7 +126,7 @@ static void sx127x_chip_reset(void)
/* Wait 1 ms */
usleep(1000);
nxsig_usleep(1000);
/* Configure reset as input */
@ -133,7 +134,7 @@ static void sx127x_chip_reset(void)
/* Wait 10 ms */
usleep(10000);
nxsig_usleep(10000);
}
/****************************************************************************

View File

@ -47,8 +47,9 @@
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <nuttx/signal.h>
#include <nuttx/wireless/lpwan/sx127x.h>
#include <arch/board/board.h>
#include "stm32_gpio.h"
#include "stm32_exti.h"
@ -125,7 +126,7 @@ static void sx127x_chip_reset(void)
/* Wait 1 ms */
usleep(1000);
nxsig_usleep(1000);
/* Configure reset as input */
@ -133,7 +134,7 @@ static void sx127x_chip_reset(void)
/* Wait 10 ms */
usleep(10000);
nxsig_usleep(10000);
}
/****************************************************************************