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
+3 -2
View File
@@ -47,6 +47,7 @@
#include <debug.h> #include <debug.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/signal.h>
#include <arch/chip/audio.h> #include <arch/chip/audio.h>
#include "chip.h" #include "chip.h"
@@ -297,13 +298,13 @@ int board_external_amp_mute_control(bool en)
/* Mute ON */ /* Mute ON */
ret = board_power_control(POWER_AUDIO_MUTE, false); ret = board_power_control(POWER_AUDIO_MUTE, false);
usleep(MUTE_ON_DELAY); nxsig_usleep(MUTE_ON_DELAY);
} }
else else
{ {
/* Mute OFF */ /* Mute OFF */
usleep(MUTE_OFF_DELAY); nxsig_usleep(MUTE_OFF_DELAY);
ret = board_power_control(POWER_AUDIO_MUTE, true); ret = board_power_control(POWER_AUDIO_MUTE, true);
} }
+10 -7
View File
@@ -43,12 +43,14 @@
#include <debug.h> #include <debug.h>
#include <errno.h> #include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/signal.h>
#include "cxd56_gpio.h" #include "cxd56_gpio.h"
#include "cxd56_pinconfig.h" #include "cxd56_pinconfig.h"
#include "cxd56_i2c.h" #include "cxd56_i2c.h"
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h> #include <arch/board/board.h>
/**************************************************************************** /****************************************************************************
@@ -111,8 +113,9 @@ int board_isx012_power_on(void)
break; break;
} }
usleep(POWER_CHECK_TIME); nxsig_usleep(POWER_CHECK_TIME);
} }
return ret; return ret;
} }
@@ -144,7 +147,7 @@ int board_isx012_power_off(void)
break; break;
} }
usleep(POWER_CHECK_TIME); nxsig_usleep(POWER_CHECK_TIME);
} }
return ret; return ret;
@@ -167,20 +170,20 @@ void board_isx012_set_sleep(int kind)
{ {
/* PowerON -> sleep */ /* PowerON -> sleep */
usleep(DEVICE_STARTUP_TIME); nxsig_usleep(DEVICE_STARTUP_TIME);
} }
else else
{ {
/* active -> sleep */ /* active -> sleep */
usleep(STANDBY_TIME); nxsig_usleep(STANDBY_TIME);
} }
} }
void board_isx012_release_sleep(void) void board_isx012_release_sleep(void)
{ {
cxd56_gpio_write(IMAGER_SLEEP, true); cxd56_gpio_write(IMAGER_SLEEP, true);
usleep(SLEEP_CANCEL_TIME); nxsig_usleep(SLEEP_CANCEL_TIME);
} }
int isx012_register(FAR struct i2c_master_s *i2c); int isx012_register(FAR struct i2c_master_s *i2c);
@@ -38,9 +38,13 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <time.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <time.h> #include <nuttx/signal.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include <arch/chip/audio.h> #include <arch/chip/audio.h>
@@ -107,7 +111,7 @@ static void wait_mic_boot_finish(void)
if (time < CXD56_AUDIO_MIC_BOOT_WAIT) if (time < CXD56_AUDIO_MIC_BOOT_WAIT)
{ {
usleep((CXD56_AUDIO_MIC_BOOT_WAIT - time) * 1000); nxsig_usleep((CXD56_AUDIO_MIC_BOOT_WAIT - time) * 1000);
} }
} }
} }
@@ -37,9 +37,11 @@
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <nuttx/arch.h>
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/signal.h>
#include "cxd56_audio_config.h" #include "cxd56_audio_config.h"
#include "cxd56_audio_ac_reg.h" #include "cxd56_audio_ac_reg.h"
#include "cxd56_audio_analog.h" #include "cxd56_audio_analog.h"
@@ -134,7 +136,7 @@ static CXD56_AUDIO_ECODE set_mute(cxd56_audio_volid_t id,
if (wait) if (wait)
{ {
usleep(waittime); nxsig_usleep(waittime);
} }
g_volparam[id].mute_bit |= type; g_volparam[id].mute_bit |= type;
@@ -200,7 +202,7 @@ static CXD56_AUDIO_ECODE set_unmute(cxd56_audio_volid_t id,
if (wait) if (wait)
{ {
usleep(waittime); nxsig_usleep(waittime);
} }
} }
@@ -39,10 +39,12 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <unistd.h> #include <unistd.h>
#include <nuttx/board.h>
#include <nuttx/signal.h>
#include <arch/board/board.h>
#include "chip.h" #include "chip.h"
#include "up_arch.h" #include "up_arch.h"
#include "up_internal.h" #include "up_internal.h"
@@ -69,9 +71,9 @@ void up_bt_enable(int enable)
if (enable) if (enable)
{ {
lc823450_gpio_write(BT_POWER, 0); lc823450_gpio_write(BT_POWER, 0);
usleep(100 * 1000); nxsig_usleep(100 * 1000);
lc823450_gpio_write(BT_POWER, 1); lc823450_gpio_write(BT_POWER, 1);
usleep(100 * 1000); nxsig_usleep(100 * 1000);
} }
else else
{ {
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* boards/arm/stm32/clicker2-stm32/src/stm32_appinit.c * 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> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -44,8 +44,9 @@
#include <unistd.h> #include <unistd.h>
#include <syslog.h> #include <syslog.h>
#include <nuttx/syslog/syslog.h>
#include <nuttx/board.h> #include <nuttx/board.h>
#include <nuttx/signal.h>
#include <nuttx/syslog/syslog.h>
#include "clicker2-stm32.h" #include "clicker2-stm32.h"
@@ -108,7 +109,7 @@ int board_app_initialize(uintptr_t arg)
* file syslog. * 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); ret = syslog_file_channel(CONFIG_CLICKER2_STM32_SYSLOG_FILE_PATH);
if (ret < 0) if (ret < 0)
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* boards/arm/stm32/nucleo-f302r8/src/stm32_highpri.c * 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> * Author: Mateusz Szafoni <raiden00@railab.me>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -46,14 +46,13 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/signal.h> #include <nuttx/signal.h>
#include <arch/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include <nuttx/timers/pwm.h> #include <nuttx/timers/pwm.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <nuttx/analog/ioctl.h> #include <nuttx/analog/ioctl.h>
#include <arch/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include "up_internal.h" #include "up_internal.h"
#include "ram_vectors.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); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
usleep(100); nxsig_usleep(100);
#endif #endif
#ifdef HIGHPRI_HAVE_INJECTED #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); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
usleep(100); nxsig_usleep(100);
#endif #endif
/* Lock global data */ /* Lock global data */
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* boards/arm/stm32/nucleo-f334r8/src/stm32_highpri.c * 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> * Author: Mateusz Szafoni <raiden00@railab.me>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -46,14 +46,13 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/signal.h> #include <nuttx/signal.h>
#include <arch/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include <nuttx/timers/pwm.h> #include <nuttx/timers/pwm.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <nuttx/analog/ioctl.h> #include <nuttx/analog/ioctl.h>
#include <arch/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include "up_internal.h" #include "up_internal.h"
#include "ram_vectors.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); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
usleep(100); nxsig_usleep(100);
#endif #endif
#ifdef HIGHPRI_HAVE_INJECTED #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); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
usleep(100); nxsig_usleep(100);
#endif #endif
/* Lock global data */ /* Lock global data */
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* boards/arm/stm32/stm32f429i-disco/src/stm32_highpri.c * 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> * Author: Mateusz Szafoni <raiden00@railab.me>
* *
* Redistribution and use in source and binary forms, with or without * 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); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
usleep(100); nxsig_usleep(100);
#endif #endif
#ifdef HIGHPRI_HAVE_INJECTED #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); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
usleep(100); nxsig_usleep(100);
#endif #endif
/* Lock global data */ /* Lock global data */
@@ -46,8 +46,9 @@
#include <debug.h> #include <debug.h>
#include <nuttx/board.h> #include <nuttx/board.h>
#include <arch/board/board.h> #include <nuttx/signal.h>
#include <nuttx/wireless/lpwan/sx127x.h> #include <nuttx/wireless/lpwan/sx127x.h>
#include <arch/board/board.h>
#include "stm32_gpio.h" #include "stm32_gpio.h"
#include "stm32_exti.h" #include "stm32_exti.h"
@@ -126,7 +127,7 @@ static void sx127x_chip_reset(void)
/* Wait 1 ms */ /* Wait 1 ms */
usleep(1000); nxsig_usleep(1000);
/* Configure reset as input */ /* Configure reset as input */
@@ -134,7 +135,7 @@ static void sx127x_chip_reset(void)
/* Wait 10 ms */ /* Wait 10 ms */
usleep(10000); nxsig_usleep(10000);
} }
/**************************************************************************** /****************************************************************************
@@ -47,8 +47,9 @@
#include <debug.h> #include <debug.h>
#include <nuttx/board.h> #include <nuttx/board.h>
#include <arch/board/board.h> #include <nuttx/signal.h>
#include <nuttx/wireless/lpwan/sx127x.h> #include <nuttx/wireless/lpwan/sx127x.h>
#include <arch/board/board.h>
#include "stm32_gpio.h" #include "stm32_gpio.h"
#include "stm32_exti.h" #include "stm32_exti.h"
@@ -125,7 +126,7 @@ static void sx127x_chip_reset(void)
/* Wait 1 ms */ /* Wait 1 ms */
usleep(1000); nxsig_usleep(1000);
/* Configure reset as input */ /* Configure reset as input */
@@ -133,7 +134,7 @@ static void sx127x_chip_reset(void)
/* Wait 10 ms */ /* Wait 10 ms */
usleep(10000); nxsig_usleep(10000);
} }
/**************************************************************************** /****************************************************************************
@@ -47,8 +47,9 @@
#include <debug.h> #include <debug.h>
#include <nuttx/board.h> #include <nuttx/board.h>
#include <arch/board/board.h> #include <nuttx/signal.h>
#include <nuttx/wireless/lpwan/sx127x.h> #include <nuttx/wireless/lpwan/sx127x.h>
#include <arch/board/board.h>
#include "stm32_gpio.h" #include "stm32_gpio.h"
#include "stm32_exti.h" #include "stm32_exti.h"
@@ -125,7 +126,7 @@ static void sx127x_chip_reset(void)
/* Wait 1 ms */ /* Wait 1 ms */
usleep(1000); nxsig_usleep(1000);
/* Configure reset as input */ /* Configure reset as input */
@@ -133,7 +134,7 @@ static void sx127x_chip_reset(void)
/* Wait 10 ms */ /* Wait 10 ms */
usleep(10000); nxsig_usleep(10000);
} }
/**************************************************************************** /****************************************************************************