nuttx: replace all ARRAY_SIZE()/ARRAYSIZE() to nitems()
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
parent
cf0769d613
commit
3a0fdb019d
@ -29,6 +29,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
/****************************************************************************
|
||||
@ -54,8 +56,6 @@
|
||||
#define CONFIG_USTACK_SIZE (CRASHLOG_LEFTOVER / NUMBER_STACKS / \
|
||||
sizeof(stack_word_t))
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof((a))/sizeof(a[0]))
|
||||
|
||||
/* For Assert keep this much of the file name */
|
||||
|
||||
#define MAX_FILE_PATH_LENGTH 40
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -119,7 +120,7 @@
|
||||
|
||||
#define CXD56_PIN_CONFIGS(pin) do { \
|
||||
uint32_t p[] = pin; \
|
||||
cxd56_pin_configs((p), sizeof(p) / sizeof((p)[0])); \
|
||||
cxd56_pin_configs((p), nitems(p)); \
|
||||
} while (0)
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -29,15 +29,15 @@
|
||||
# include <stdint.h>
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <arch/chip/chip.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
/* If the common ARMv7-M vector handling logic is used,
|
||||
* then it expects the following
|
||||
* definition in this file that provides the number of
|
||||
|
@ -31,11 +31,11 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* To use FMC, you must first enable it in configuration:
|
||||
*
|
||||
@ -265,7 +265,7 @@ void stm32_fmc_init(void)
|
||||
|
||||
/* Set up FMC GPIOs */
|
||||
|
||||
for (regval = 0; regval < ARRAY_SIZE(fmc_gpios); regval++)
|
||||
for (regval = 0; regval < nitems(fmc_gpios); regval++)
|
||||
stm32_configgpio(fmc_gpios[regval]);
|
||||
|
||||
/* Set up FMC registers */
|
||||
|
@ -62,7 +62,7 @@ static const struct arm_mmu_region mmu_regions[] =
|
||||
|
||||
const struct arm_mmu_config mmu_config =
|
||||
{
|
||||
.num_regions = ARRAY_SIZE(mmu_regions),
|
||||
.num_regions = nitems(mmu_regions),
|
||||
.mmu_regions = mmu_regions,
|
||||
};
|
||||
|
||||
|
@ -145,10 +145,6 @@
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define GET_EL(mode) (((mode) >> MODE_EL_SHIFT) & MODE_EL_MASK)
|
||||
|
||||
/* MPIDR_EL1, Multiprocessor Affinity Register */
|
||||
|
@ -186,7 +186,7 @@ static const struct arm_mmu_region mmu_nxrt_regions[] =
|
||||
|
||||
static const struct arm_mmu_config mmu_nxrt_config =
|
||||
{
|
||||
.num_regions = ARRAY_SIZE(mmu_nxrt_regions),
|
||||
.num_regions = nitems(mmu_nxrt_regions),
|
||||
.mmu_regions = mmu_nxrt_regions,
|
||||
};
|
||||
|
||||
|
@ -62,7 +62,7 @@ static const struct arm_mmu_region mmu_regions[] =
|
||||
|
||||
const struct arm_mmu_config mmu_config =
|
||||
{
|
||||
.num_regions = ARRAY_SIZE(mmu_regions),
|
||||
.num_regions = nitems(mmu_regions),
|
||||
.mmu_regions = mmu_regions,
|
||||
};
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@ -39,12 +40,6 @@
|
||||
|
||||
#include "sim_hostusrsock.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@ -44,7 +45,6 @@
|
||||
|
||||
#define ELF_PAGESIZE 4096
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define ROUNDUP(x, y) ((x + (y - 1)) / (y)) * (y)
|
||||
|
||||
/****************************************************************************
|
||||
@ -244,7 +244,7 @@ static void elf_emit_note_info(FAR struct elf_dumpinfo_s *cinfo)
|
||||
|
||||
status.pr_pid = tcb->pid;
|
||||
|
||||
for (j = 0; j < ARRAY_SIZE(status.pr_regs); j++)
|
||||
for (j = 0; j < nitems(status.pr_regs); j++)
|
||||
{
|
||||
status.pr_regs[j] = *(uintptr_t *)((uint8_t *)tcb +
|
||||
g_tcbinfo.reg_off.p[j]);
|
||||
|
@ -200,8 +200,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
if ((pdump->info.flags & INTSTACK_PRESENT) != 0)
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.interrupt.sp;
|
||||
copy_reverse(pdump->istack, &ps[ARRAYSIZE(pdump->istack) / 2],
|
||||
ARRAYSIZE(pdump->istack));
|
||||
copy_reverse(pdump->istack, &ps[nitems(pdump->istack) / 2],
|
||||
nitems(pdump->istack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
@ -221,8 +221,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
if ((pdump->info.flags & USERSTACK_PRESENT) != 0)
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.user.sp;
|
||||
copy_reverse(pdump->ustack, &ps[ARRAYSIZE(pdump->ustack) / 2],
|
||||
ARRAYSIZE(pdump->ustack));
|
||||
copy_reverse(pdump->ustack, &ps[nitems(pdump->ustack) / 2],
|
||||
nitems(pdump->ustack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -34,12 +36,6 @@
|
||||
#include "gd32f450z_eval.h"
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -87,7 +83,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LED GPIO for output. */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_led_map); i++)
|
||||
for (i = 0; i < nitems(g_led_map); i++)
|
||||
{
|
||||
gd32_gpio_config(g_led_map[i]);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -100,7 +96,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure the LED GPIO for output. */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_led_map); i++)
|
||||
for (i = 0; i < nitems(g_led_map); i++)
|
||||
{
|
||||
gd32_gpio_config(g_led_map[i]);
|
||||
}
|
||||
@ -120,7 +116,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_led_map))
|
||||
if ((unsigned)led < nitems(g_led_map))
|
||||
{
|
||||
gd32_gpio_write(g_led_map[led], ledon);
|
||||
}
|
||||
@ -144,7 +140,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_led_map); i++)
|
||||
for (i = 0; i < nitems(g_led_map); i++)
|
||||
{
|
||||
gd32_gpio_write(g_led_map[i], (ledset & g_led_setmap[i]) != 0);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@ -72,8 +73,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#define NSECTORS(n) \
|
||||
(((n)+CONFIG_SAME70QMTECH_ROMFS_ROMDISK_SECTSIZE-1) / \
|
||||
CONFIG_SAME70QMTECH_ROMFS_ROMDISK_SECTSIZE)
|
||||
@ -103,7 +102,7 @@ static struct mtd_partition_s g_mtd_partition_table[] =
|
||||
};
|
||||
|
||||
static const size_t g_mtd_partition_table_size =
|
||||
ARRAY_SIZE(g_mtd_partition_table);
|
||||
nitems(g_mtd_partition_table);
|
||||
#else
|
||||
# define g_mtd_partition_table NULL
|
||||
# define g_mtd_partition_table_size 0
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@ -65,8 +66,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#define NSECTORS(n) \
|
||||
(((n)+CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_SECTSIZE-1) / \
|
||||
CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_SECTSIZE)
|
||||
@ -96,7 +95,7 @@ static struct mtd_partition_s g_mtd_partition_table[] =
|
||||
};
|
||||
|
||||
static const size_t g_mtd_partition_table_size =
|
||||
ARRAY_SIZE(g_mtd_partition_table);
|
||||
nitems(g_mtd_partition_table);
|
||||
#else
|
||||
# define g_mtd_partition_table NULL
|
||||
# define g_mtd_partition_table_size 0
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@ -90,8 +91,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#define NSECTORS(n) \
|
||||
(((n)+CONFIG_SAMV71XULT_ROMFS_ROMDISK_SECTSIZE-1) / \
|
||||
CONFIG_SAMV71XULT_ROMFS_ROMDISK_SECTSIZE)
|
||||
@ -121,7 +120,7 @@ static struct mtd_partition_s g_mtd_partition_table[] =
|
||||
};
|
||||
|
||||
static const size_t g_mtd_partition_table_size =
|
||||
ARRAY_SIZE(g_mtd_partition_table);
|
||||
nitems(g_mtd_partition_table);
|
||||
#else
|
||||
# define g_mtd_partition_table NULL
|
||||
# define g_mtd_partition_table_size 0
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -81,7 +77,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1 GPIO for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -77,7 +73,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -97,7 +93,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
@ -120,7 +116,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -81,7 +77,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1 GPIO for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -77,7 +73,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -97,7 +93,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
@ -120,7 +116,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -34,12 +36,6 @@
|
||||
#include "nucleo-144.h"
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -80,7 +76,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1 GPIO for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include <debug.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
|
||||
#include "arm_internal.h"
|
||||
@ -102,15 +104,13 @@
|
||||
0 \
|
||||
}
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof((a))/sizeof(a[0]))
|
||||
|
||||
/* For Assert keep this much of the file name */
|
||||
|
||||
#define MAX_FILE_PATH_LENGTH 40
|
||||
|
||||
#define HEADER_TIME_FMT "%Y-%m-%d-%H:%M:%S"
|
||||
#define HEADER_TIME_FMT_NUM (2+ 0+ 0+ 0+ 0+ 0)
|
||||
#define HEADER_TIME_FMT_LEN (((ARRAYSIZE(HEADER_TIME_FMT)-1) + \
|
||||
#define HEADER_TIME_FMT_LEN (((nitems(HEADER_TIME_FMT)-1) + \
|
||||
HEADER_TIME_FMT_NUM))
|
||||
|
||||
/****************************************************************************
|
||||
@ -465,8 +465,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
if ((pdump->info.flags & INTSTACK_PRESENT) != 0)
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.interrupt.sp;
|
||||
copy_reverse(pdump->istack, &ps[ARRAYSIZE(pdump->istack) / 2],
|
||||
ARRAYSIZE(pdump->istack));
|
||||
copy_reverse(pdump->istack, &ps[nitems(pdump->istack) / 2],
|
||||
nitems(pdump->istack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
@ -487,8 +487,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
if ((pdump->info.flags & USERSTACK_PRESENT) != 0)
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.user.sp;
|
||||
copy_reverse(pdump->ustack, &ps[ARRAYSIZE(pdump->ustack) / 2],
|
||||
ARRAYSIZE(pdump->ustack));
|
||||
copy_reverse(pdump->ustack, &ps[nitems(pdump->ustack) / 2],
|
||||
nitems(pdump->ustack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -45,8 +47,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
#if defined(CONFIG_NUCLEO_SPI1_TEST)
|
||||
# if defined(CONFIG_NUCLEO_SPI1_TEST_MODE0)
|
||||
# define CONFIG_NUCLEO_SPI1_TEST_MODE SPIDEV_MODE0
|
||||
@ -200,7 +200,7 @@ void weak_function stm32_spidev_initialize(void)
|
||||
/* Configure SPI CS GPIO for output */
|
||||
|
||||
#if defined(CONFIG_STM32F4_SPI1)
|
||||
for (int i = 0; i < ARRAYSIZE(g_spi1gpio); i++)
|
||||
for (int i = 0; i < nitems(g_spi1gpio); i++)
|
||||
{
|
||||
if (g_spi1gpio[i] != 0)
|
||||
{
|
||||
@ -210,7 +210,7 @@ void weak_function stm32_spidev_initialize(void)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32F4_SPI2)
|
||||
for (int i = 0; i < ARRAYSIZE(g_spi2gpio); i++)
|
||||
for (int i = 0; i < nitems(g_spi2gpio); i++)
|
||||
{
|
||||
if (g_spi2gpio[i] != 0)
|
||||
{
|
||||
@ -220,7 +220,7 @@ void weak_function stm32_spidev_initialize(void)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32F4_SPI3)
|
||||
for (int i = 0; i < ARRAYSIZE(g_spi3gpio); i++)
|
||||
for (int i = 0; i < nitems(g_spi3gpio); i++)
|
||||
{
|
||||
if (g_spi3gpio[i] != 0)
|
||||
{
|
||||
@ -451,7 +451,7 @@ int stm32_spidev_bus_test(void)
|
||||
SPI_SETFREQUENCY(spi1, CONFIG_NUCLEO_SPI1_TEST_FREQ);
|
||||
SPI_SETBITS(spi1, CONFIG_NUCLEO_SPI1_TEST_BITS);
|
||||
SPI_SETMODE(spi1, CONFIG_NUCLEO_SPI1_TEST_MODE);
|
||||
SPI_EXCHANGE(spi1, tx, NULL, ARRAYSIZE(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
SPI_EXCHANGE(spi1, tx, NULL, nitems(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NUCLEO_SPI2_TEST)
|
||||
@ -468,7 +468,7 @@ int stm32_spidev_bus_test(void)
|
||||
SPI_SETFREQUENCY(spi2, CONFIG_NUCLEO_SPI2_TEST_FREQ);
|
||||
SPI_SETBITS(spi2, CONFIG_NUCLEO_SPI2_TEST_BITS);
|
||||
SPI_SETMODE(spi2, CONFIG_NUCLEO_SPI2_TEST_MODE);
|
||||
SPI_EXCHANGE(spi2, tx, NULL, ARRAYSIZE(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
SPI_EXCHANGE(spi2, tx, NULL, nitems(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NUCLEO_SPI3_TEST)
|
||||
@ -485,7 +485,7 @@ int stm32_spidev_bus_test(void)
|
||||
SPI_SETFREQUENCY(spi3, CONFIG_NUCLEO_SPI3_TEST_FREQ);
|
||||
SPI_SETBITS(spi3, CONFIG_NUCLEO_SPI3_TEST_BITS);
|
||||
SPI_SETMODE(spi3, CONFIG_NUCLEO_SPI3_TEST_MODE);
|
||||
SPI_EXCHANGE(spi3, tx, NULL, ARRAYSIZE(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
SPI_EXCHANGE(spi3, tx, NULL, nitems(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -77,7 +73,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -97,7 +93,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
@ -121,7 +117,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -34,12 +36,6 @@
|
||||
#include "nucleo-144.h"
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -80,7 +76,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1 GPIO for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include <debug.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
|
||||
#include "arm_internal.h"
|
||||
@ -102,15 +104,13 @@
|
||||
0 \
|
||||
}
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof((a))/sizeof(a[0]))
|
||||
|
||||
/* For Assert keep this much of the file name */
|
||||
|
||||
#define MAX_FILE_PATH_LENGTH 40
|
||||
|
||||
#define HEADER_TIME_FMT "%Y-%m-%d-%H:%M:%S"
|
||||
#define HEADER_TIME_FMT_NUM (2+ 0+ 0+ 0+ 0+ 0)
|
||||
#define HEADER_TIME_FMT_LEN (((ARRAYSIZE(HEADER_TIME_FMT)-1) + \
|
||||
#define HEADER_TIME_FMT_LEN (((nitems(HEADER_TIME_FMT)-1) + \
|
||||
HEADER_TIME_FMT_NUM))
|
||||
|
||||
/****************************************************************************
|
||||
@ -465,8 +465,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
if ((pdump->info.flags & INTSTACK_PRESENT) != 0)
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.interrupt.sp;
|
||||
copy_reverse(pdump->istack, &ps[ARRAYSIZE(pdump->istack) / 2],
|
||||
ARRAYSIZE(pdump->istack));
|
||||
copy_reverse(pdump->istack, &ps[nitems(pdump->istack) / 2],
|
||||
nitems(pdump->istack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
@ -487,8 +487,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
if ((pdump->info.flags & USERSTACK_PRESENT) != 0)
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.user.sp;
|
||||
copy_reverse(pdump->ustack, &ps[ARRAYSIZE(pdump->ustack) / 2],
|
||||
ARRAYSIZE(pdump->ustack));
|
||||
copy_reverse(pdump->ustack, &ps[nitems(pdump->ustack) / 2],
|
||||
nitems(pdump->ustack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -45,8 +47,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
#if defined(CONFIG_NUCLEO_SPI1_TEST)
|
||||
# if defined(CONFIG_NUCLEO_SPI1_TEST_MODE0)
|
||||
# define CONFIG_NUCLEO_SPI1_TEST_MODE SPIDEV_MODE0
|
||||
@ -200,7 +200,7 @@ void weak_function stm32_spidev_initialize(void)
|
||||
/* Configure SPI CS GPIO for output */
|
||||
|
||||
#if defined(CONFIG_STM32F7_SPI1)
|
||||
for (int i = 0; i < ARRAYSIZE(g_spi1gpio); i++)
|
||||
for (int i = 0; i < nitems(g_spi1gpio); i++)
|
||||
{
|
||||
if (g_spi1gpio[i] != 0)
|
||||
{
|
||||
@ -210,7 +210,7 @@ void weak_function stm32_spidev_initialize(void)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32F7_SPI2)
|
||||
for (int i = 0; i < ARRAYSIZE(g_spi2gpio); i++)
|
||||
for (int i = 0; i < nitems(g_spi2gpio); i++)
|
||||
{
|
||||
if (g_spi2gpio[i] != 0)
|
||||
{
|
||||
@ -220,7 +220,7 @@ void weak_function stm32_spidev_initialize(void)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32F7_SPI3)
|
||||
for (int i = 0; i < ARRAYSIZE(g_spi3gpio); i++)
|
||||
for (int i = 0; i < nitems(g_spi3gpio); i++)
|
||||
{
|
||||
if (g_spi3gpio[i] != 0)
|
||||
{
|
||||
@ -451,7 +451,7 @@ int stm32_spidev_bus_test(void)
|
||||
SPI_SETFREQUENCY(spi1, CONFIG_NUCLEO_SPI1_TEST_FREQ);
|
||||
SPI_SETBITS(spi1, CONFIG_NUCLEO_SPI1_TEST_BITS);
|
||||
SPI_SETMODE(spi1, CONFIG_NUCLEO_SPI1_TEST_MODE);
|
||||
SPI_EXCHANGE(spi1, tx, NULL, ARRAYSIZE(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
SPI_EXCHANGE(spi1, tx, NULL, nitems(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NUCLEO_SPI2_TEST)
|
||||
@ -468,7 +468,7 @@ int stm32_spidev_bus_test(void)
|
||||
SPI_SETFREQUENCY(spi2, CONFIG_NUCLEO_SPI2_TEST_FREQ);
|
||||
SPI_SETBITS(spi2, CONFIG_NUCLEO_SPI2_TEST_BITS);
|
||||
SPI_SETMODE(spi2, CONFIG_NUCLEO_SPI2_TEST_MODE);
|
||||
SPI_EXCHANGE(spi2, tx, NULL, ARRAYSIZE(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
SPI_EXCHANGE(spi2, tx, NULL, nitems(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NUCLEO_SPI3_TEST)
|
||||
@ -485,7 +485,7 @@ int stm32_spidev_bus_test(void)
|
||||
SPI_SETFREQUENCY(spi3, CONFIG_NUCLEO_SPI3_TEST_FREQ);
|
||||
SPI_SETBITS(spi3, CONFIG_NUCLEO_SPI3_TEST_BITS);
|
||||
SPI_SETMODE(spi3, CONFIG_NUCLEO_SPI3_TEST_MODE);
|
||||
SPI_EXCHANGE(spi3, tx, NULL, ARRAYSIZE(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
SPI_EXCHANGE(spi3, tx, NULL, nitems(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -77,7 +73,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -97,7 +93,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
@ -120,7 +116,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -81,7 +77,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1 GPIO for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledmap[i]);
|
||||
phy_set_led(i, false);
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -81,7 +77,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1 GPIO for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
@ -52,8 +53,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
#define PARTITION_LABEL_LEN 16
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
@ -183,7 +182,7 @@ static int init_ota_partitions(void)
|
||||
int ret = 0;
|
||||
char path[PARTITION_LABEL_LEN + 1];
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ota_partition_table); ++i)
|
||||
for (i = 0; i < nitems(g_ota_partition_table); ++i)
|
||||
{
|
||||
const struct ota_partition_s *part = &g_ota_partition_table[i];
|
||||
mtd = progmem_alloc_mtdpart(part->offset, part->size);
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -77,7 +73,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -97,7 +93,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
@ -120,7 +116,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -81,7 +77,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1 GPIO for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -77,7 +73,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -97,7 +93,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
@ -120,7 +116,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -82,7 +78,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1 GPIO for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -78,7 +74,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -100,7 +96,7 @@ void board_userled(int led, bool ledon)
|
||||
{
|
||||
/* Active Low */
|
||||
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[led], !ledon);
|
||||
}
|
||||
@ -123,7 +119,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) == 0);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -34,12 +36,6 @@
|
||||
#include "nucleo-144.h"
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -80,7 +76,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1 GPIO for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32l4_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -45,8 +47,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
#if defined(CONFIG_NUCLEO_SPI1_TEST)
|
||||
# if defined(CONFIG_NUCLEO_SPI1_TEST_MODE0)
|
||||
# define CONFIG_NUCLEO_SPI1_TEST_MODE SPIDEV_MODE0
|
||||
@ -200,7 +200,7 @@ void weak_function stm32_spidev_initialize(void)
|
||||
/* Configure SPI CS GPIO for output */
|
||||
|
||||
#if defined(CONFIG_STM32L4_SPI1)
|
||||
for (int i = 0; i < ARRAYSIZE(g_spi1gpio); i++)
|
||||
for (int i = 0; i < nitems(g_spi1gpio); i++)
|
||||
{
|
||||
if (g_spi1gpio[i] != 0)
|
||||
{
|
||||
@ -210,7 +210,7 @@ void weak_function stm32_spidev_initialize(void)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32L4_SPI2)
|
||||
for (int i = 0; i < ARRAYSIZE(g_spi2gpio); i++)
|
||||
for (int i = 0; i < nitems(g_spi2gpio); i++)
|
||||
{
|
||||
if (g_spi2gpio[i] != 0)
|
||||
{
|
||||
@ -220,7 +220,7 @@ void weak_function stm32_spidev_initialize(void)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32L4_SPI3)
|
||||
for (int i = 0; i < ARRAYSIZE(g_spi3gpio); i++)
|
||||
for (int i = 0; i < nitems(g_spi3gpio); i++)
|
||||
{
|
||||
if (g_spi3gpio[i] != 0)
|
||||
{
|
||||
@ -387,7 +387,7 @@ int stm32_spidev_bus_test(void)
|
||||
SPI_SETFREQUENCY(spi1, CONFIG_NUCLEO_SPI1_TEST_FREQ);
|
||||
SPI_SETBITS(spi1, CONFIG_NUCLEO_SPI1_TEST_BITS);
|
||||
SPI_SETMODE(spi1, CONFIG_NUCLEO_SPI1_TEST_MODE);
|
||||
SPI_EXCHANGE(spi1, tx, NULL, ARRAYSIZE(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
SPI_EXCHANGE(spi1, tx, NULL, nitems(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NUCLEO_SPI2_TEST)
|
||||
@ -404,7 +404,7 @@ int stm32_spidev_bus_test(void)
|
||||
SPI_SETFREQUENCY(spi2, CONFIG_NUCLEO_SPI2_TEST_FREQ);
|
||||
SPI_SETBITS(spi2, CONFIG_NUCLEO_SPI2_TEST_BITS);
|
||||
SPI_SETMODE(spi2, CONFIG_NUCLEO_SPI2_TEST_MODE);
|
||||
SPI_EXCHANGE(spi2, tx, NULL, ARRAYSIZE(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
SPI_EXCHANGE(spi2, tx, NULL, nitems(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NUCLEO_SPI3_TEST)
|
||||
@ -421,7 +421,7 @@ int stm32_spidev_bus_test(void)
|
||||
SPI_SETFREQUENCY(spi3, CONFIG_NUCLEO_SPI3_TEST_FREQ);
|
||||
SPI_SETBITS(spi3, CONFIG_NUCLEO_SPI3_TEST_BITS);
|
||||
SPI_SETMODE(spi3, CONFIG_NUCLEO_SPI3_TEST_MODE);
|
||||
SPI_EXCHANGE(spi3, tx, NULL, ARRAYSIZE(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
SPI_EXCHANGE(spi3, tx, NULL, nitems(CONFIG_NUCLEO_SPI_TEST_MESSAGE));
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -77,7 +73,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32l4_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -97,7 +93,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32l4_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
@ -120,7 +116,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32l4_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
@ -39,12 +41,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -83,7 +79,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD1, LD2 and LD3 GPIOs for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32l5_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -77,7 +73,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32l5_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -97,7 +93,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32l5_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
@ -119,7 +115,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32l5_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
@ -39,12 +41,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -82,7 +78,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LD9 and LD10 GPIOs for output. Initial state is OFF */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
|
||||
for (i = 0; i < nitems(g_ledmap); i++)
|
||||
{
|
||||
stm32l5_configgpio(g_ledmap[i]);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -35,12 +37,6 @@
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -76,7 +72,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure LED1-2 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32l5_configgpio(g_ledcfg[i]);
|
||||
}
|
||||
@ -96,7 +92,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
|
||||
if ((unsigned)led < nitems(g_ledcfg))
|
||||
{
|
||||
stm32l5_gpiowrite(g_ledcfg[led], !ledon);
|
||||
}
|
||||
@ -118,7 +114,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-2 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32l5_gpiowrite(g_ledcfg[i], !(ledset & (1 << i)));
|
||||
}
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -37,12 +39,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -116,7 +112,7 @@ void board_autoled_initialize(void)
|
||||
|
||||
/* Configure the LED GPIO for output. */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_led_map); i++)
|
||||
for (i = 0; i < nitems(g_led_map); i++)
|
||||
{
|
||||
ret = a64_pio_config(g_led_map[i]);
|
||||
DEBUGASSERT(ret == OK);
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@ -37,12 +39,6 @@
|
||||
|
||||
#ifdef CONFIG_USERLED
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -102,7 +98,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
/* Configure the LED GPIO for output. */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_led_map); i++)
|
||||
for (i = 0; i < nitems(g_led_map); i++)
|
||||
{
|
||||
ret = a64_pio_config(g_led_map[i]);
|
||||
DEBUGASSERT(ret == OK);
|
||||
@ -142,7 +138,7 @@ uint32_t board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < ARRAYSIZE(g_led_map))
|
||||
if ((unsigned)led < nitems(g_led_map))
|
||||
{
|
||||
a64_pio_write(g_led_map[led], ledon);
|
||||
}
|
||||
@ -182,7 +178,7 @@ void board_userled_all(uint32_t ledset)
|
||||
|
||||
/* Configure LED1-3 GPIOs for output */
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(g_led_map); i++)
|
||||
for (i = 0; i < nitems(g_led_map); i++)
|
||||
{
|
||||
a64_pio_write(g_led_map[i], (ledset & g_led_setmap[i]) != 0);
|
||||
}
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include <debug.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include "renesas_internal.h"
|
||||
@ -101,15 +103,13 @@
|
||||
0 \
|
||||
}
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof((a))/sizeof(a[0]))
|
||||
|
||||
/* For Assert keep this much of the file name */
|
||||
|
||||
#define MAX_FILE_PATH_LENGTH 40
|
||||
|
||||
#define HEADER_TIME_FMT "%Y-%m-%d-%H:%M:%S"
|
||||
#define HEADER_TIME_FMT_NUM (2+ 0+ 0+ 0+ 0+ 0)
|
||||
#define HEADER_TIME_FMT_LEN (((ARRAYSIZE(HEADER_TIME_FMT)-1) + \
|
||||
#define HEADER_TIME_FMT_LEN (((nitems(HEADER_TIME_FMT)-1) + \
|
||||
HEADER_TIME_FMT_NUM))
|
||||
|
||||
/****************************************************************************
|
||||
@ -420,8 +420,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.interrupt.sp;
|
||||
copy_reverse((stack_word_t *)pdump->istack,
|
||||
&ps[ARRAYSIZE(pdump->istack) / 2],
|
||||
ARRAYSIZE(pdump->istack));
|
||||
&ps[nitems(pdump->istack) / 2],
|
||||
nitems(pdump->istack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
@ -443,8 +443,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.user.sp;
|
||||
copy_reverse((stack_word_t *)pdump->ustack,
|
||||
&ps[ARRAYSIZE(pdump->ustack) / 2],
|
||||
ARRAYSIZE(pdump->ustack));
|
||||
&ps[nitems(pdump->ustack) / 2],
|
||||
nitems(pdump->ustack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include <debug.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include "renesas_internal.h"
|
||||
@ -101,15 +103,13 @@
|
||||
0 \
|
||||
}
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof((a))/sizeof(a[0]))
|
||||
|
||||
/* For Assert keep this much of the file name */
|
||||
|
||||
#define MAX_FILE_PATH_LENGTH 40
|
||||
|
||||
#define HEADER_TIME_FMT "%Y-%m-%d-%H:%M:%S"
|
||||
#define HEADER_TIME_FMT_NUM (2+ 0+ 0+ 0+ 0+ 0)
|
||||
#define HEADER_TIME_FMT_LEN (((ARRAYSIZE(HEADER_TIME_FMT)-1) + \
|
||||
#define HEADER_TIME_FMT_LEN (((nitems(HEADER_TIME_FMT)-1) + \
|
||||
HEADER_TIME_FMT_NUM))
|
||||
|
||||
/****************************************************************************
|
||||
@ -418,8 +418,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.interrupt.sp;
|
||||
copy_reverse((stack_word_t *)pdump->istack,
|
||||
&ps[ARRAYSIZE(pdump->istack) / 2],
|
||||
ARRAYSIZE(pdump->istack));
|
||||
&ps[nitems(pdump->istack) / 2],
|
||||
nitems(pdump->istack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
@ -440,8 +440,8 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
|
||||
{
|
||||
stack_word_t *ps = (stack_word_t *) pdump->info.stacks.user.sp;
|
||||
copy_reverse((stack_word_t *)pdump->ustack,
|
||||
&ps[ARRAYSIZE(pdump->ustack) / 2],
|
||||
ARRAYSIZE(pdump->ustack));
|
||||
&ps[nitems(pdump->ustack) / 2],
|
||||
nitems(pdump->ustack));
|
||||
}
|
||||
|
||||
/* Is it Invalid? */
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
@ -52,8 +54,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
#ifdef CONFIG_ESP32C3_OTA_PARTITION_ENCRYPT
|
||||
# define OTA_ENCRYPT true
|
||||
#else
|
||||
@ -147,7 +147,7 @@ static int init_ota_partitions(void)
|
||||
#endif
|
||||
int ret = OK;
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(g_ota_partition_table); ++i)
|
||||
for (int i = 0; i < nitems(g_ota_partition_table); ++i)
|
||||
{
|
||||
const struct ota_partition_s *part = &g_ota_partition_table[i];
|
||||
mtd = esp32c3_spiflash_alloc_mtdpart(part->offset, part->size,
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
@ -49,8 +51,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
#ifdef CONFIG_ESP32_OTA_PARTITION_ENCRYPT
|
||||
# define OTA_ENCRYPT true
|
||||
#else
|
||||
@ -128,7 +128,7 @@ static int init_ota_partitions(void)
|
||||
#endif
|
||||
int ret = OK;
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(g_ota_partition_table); ++i)
|
||||
for (int i = 0; i < nitems(g_ota_partition_table); ++i)
|
||||
{
|
||||
const struct ota_partition_s *part = &g_ota_partition_table[i];
|
||||
mtd = esp32_spiflash_alloc_mtdpart(part->offset, part->size,
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/board/board.h>
|
||||
#include <nuttx/board.h>
|
||||
@ -45,10 +47,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define TOUCHPAD_REFH (TOUCH_HVOLT_2V7)
|
||||
#define TOUCHPAD_REFL (TOUCH_LVOLT_0V5)
|
||||
#define TOUCHPAD_ATTEN (TOUCH_HVOLT_ATTEN_1V)
|
||||
@ -190,7 +188,7 @@ uint32_t board_buttons(void)
|
||||
bool b1;
|
||||
int n;
|
||||
|
||||
for (uint8_t btn_id = 0; btn_id < ARRAY_SIZE(g_buttons); btn_id++)
|
||||
for (uint8_t btn_id = 0; btn_id < nitems(g_buttons); btn_id++)
|
||||
{
|
||||
iinfo("Reading button %d\n", btn_id);
|
||||
|
||||
@ -265,7 +263,7 @@ uint32_t board_buttons(void)
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
int board_button_irq(int id, xcpt_t irqhandler, void *arg)
|
||||
{
|
||||
DEBUGASSERT(id < ARRAY_SIZE(g_buttons));
|
||||
DEBUGASSERT(id < nitems(g_buttons));
|
||||
|
||||
int ret;
|
||||
button_type_t button_info = g_buttons[id];
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/crypto/crypto.h>
|
||||
@ -43,10 +45,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_CRYPTO_AES)
|
||||
|
||||
/****************************************************************************
|
||||
@ -94,14 +92,14 @@ static int test_aes(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
AES_CYPHER_TEST(AES_MODE_ECB, "ECB", ARRAY_SIZE(aes_enc_tv_template),
|
||||
ARRAY_SIZE(aes_dec_tv_template), aes_enc_tv_template,
|
||||
AES_CYPHER_TEST(AES_MODE_ECB, "ECB", nitems(aes_enc_tv_template),
|
||||
nitems(aes_dec_tv_template), aes_enc_tv_template,
|
||||
aes_dec_tv_template)
|
||||
AES_CYPHER_TEST(AES_MODE_CBC, "CBC", ARRAY_SIZE(aes_cbc_enc_tv_template),
|
||||
ARRAY_SIZE(aes_cbc_dec_tv_template),
|
||||
AES_CYPHER_TEST(AES_MODE_CBC, "CBC", nitems(aes_cbc_enc_tv_template),
|
||||
nitems(aes_cbc_dec_tv_template),
|
||||
aes_cbc_enc_tv_template, aes_cbc_dec_tv_template)
|
||||
AES_CYPHER_TEST(AES_MODE_CTR, "CTR", ARRAY_SIZE(aes_ctr_enc_tv_template),
|
||||
ARRAY_SIZE(aes_ctr_dec_tv_template),
|
||||
AES_CYPHER_TEST(AES_MODE_CTR, "CTR", nitems(aes_ctr_enc_tv_template),
|
||||
nitems(aes_ctr_dec_tv_template),
|
||||
aes_ctr_enc_tv_template, aes_ctr_dec_tv_template)
|
||||
|
||||
return OK;
|
||||
|
@ -247,7 +247,7 @@ static int cs4344_setmclkfrequency(FAR struct cs4344_dev_s *priv)
|
||||
|
||||
priv->mclk_freq = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mclk_rate); i++)
|
||||
for (i = 0; i < nitems(mclk_rate); i++)
|
||||
{
|
||||
if (mclk_rate[i].sample_rate == priv->samprate)
|
||||
{
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <pthread.h>
|
||||
#include <mqueue.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/mutex.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
@ -41,10 +43,6 @@
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define CS4344_DEFAULT_SAMPRATE 11025 /* Initial sample rate */
|
||||
#define CS4344_DEFAULT_NCHANNELS 1 /* Initial number of channels */
|
||||
#define CS4344_DEFAULT_BPSAMP 16 /* Initial bits per sample */
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <debug.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/mqueue.h>
|
||||
#include <nuttx/queue.h>
|
||||
@ -53,14 +55,6 @@
|
||||
|
||||
#include "es8388.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
@ -465,7 +459,7 @@ static void es8388_setmclkfrequency(FAR struct es8388_dev_s *priv)
|
||||
{
|
||||
priv->mclk = 0;
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(es8388_mclk_rate); i++)
|
||||
for (int i = 0; i < nitems(es8388_mclk_rate); i++)
|
||||
{
|
||||
if (es8388_mclk_rate[i].sample_rate == priv->samprate)
|
||||
{
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/clk/clk.h>
|
||||
#include <nuttx/clk/clk_provider.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
@ -48,10 +50,6 @@
|
||||
#define CLK_RPMSG_ROUNDRATE 6
|
||||
#define CLK_RPMSG_ISENABLED 7
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -606,7 +604,7 @@ static int clk_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data,
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
else if (cmd < ARRAY_SIZE(g_clk_rpmsg_handler)
|
||||
else if (cmd < nitems(g_clk_rpmsg_handler)
|
||||
&& g_clk_rpmsg_handler[cmd])
|
||||
{
|
||||
hdr->response = 1;
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/ioexpander/ioe_rpmsg.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/nuttx.h>
|
||||
@ -37,10 +39,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define IOE_RPMSG_EPT_FORMAT "rpmsg-ioe-%s"
|
||||
|
||||
#define IOE_RPMSG_DIRECTION 0
|
||||
@ -596,7 +594,7 @@ static int ioe_rpmsg_server_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
FAR struct ioe_rpmsg_header_s *msg = data;
|
||||
uint32_t cmd = msg->command;
|
||||
|
||||
if (cmd < ARRAY_SIZE(g_ioe_rpmsg_handler) && g_ioe_rpmsg_handler[cmd])
|
||||
if (cmd < nitems(g_ioe_rpmsg_handler) && g_ioe_rpmsg_handler[cmd])
|
||||
{
|
||||
return g_ioe_rpmsg_handler[cmd](ept, data, len, src, priv_);
|
||||
}
|
||||
|
@ -986,7 +986,7 @@ static int rpmsgblk_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
FAR struct rpmsgblk_header_s *header = data;
|
||||
uint32_t command = header->command;
|
||||
|
||||
if (command < ARRAY_SIZE(g_rpmsgblk_handler))
|
||||
if (command < nitems(g_rpmsgblk_handler))
|
||||
{
|
||||
return g_rpmsgblk_handler[command](ept, data, len, src, priv);
|
||||
}
|
||||
|
@ -27,14 +27,12 @@
|
||||
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define RPMSGBLK_NAME_PREFIX "rpmsgblk-"
|
||||
#define RPMSGBLK_NAME_PREFIX_LEN 9
|
||||
|
||||
|
@ -365,7 +365,7 @@ static int rpmsgblk_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
FAR struct rpmsgblk_header_s *header = data;
|
||||
uint32_t command = header->command;
|
||||
|
||||
if (command < ARRAY_SIZE(g_rpmsgblk_handler))
|
||||
if (command < nitems(g_rpmsgblk_handler))
|
||||
{
|
||||
return g_rpmsgblk_handler[command](ept, data, len, src, priv);
|
||||
}
|
||||
|
@ -1109,7 +1109,7 @@ static int rpmsgdev_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
FAR struct rpmsgdev_header_s *header = data;
|
||||
uint32_t command = header->command;
|
||||
|
||||
if (command < ARRAY_SIZE(g_rpmsgdev_handler))
|
||||
if (command < nitems(g_rpmsgdev_handler))
|
||||
{
|
||||
return g_rpmsgdev_handler[command](ept, data, len, src, priv);
|
||||
}
|
||||
|
@ -27,14 +27,12 @@
|
||||
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define RPMSGDEV_NAME_PREFIX "rpmsgdev-"
|
||||
#define RPMSGDEV_NAME_PREFIX_LEN 9
|
||||
|
||||
|
@ -459,7 +459,7 @@ static int rpmsgdev_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
FAR struct rpmsgdev_header_s *header = data;
|
||||
uint32_t command = header->command;
|
||||
|
||||
if (command < ARRAY_SIZE(g_rpmsgdev_handler))
|
||||
if (command < nitems(g_rpmsgdev_handler))
|
||||
{
|
||||
return g_rpmsgdev_handler[command](ept, data, len, src, priv);
|
||||
}
|
||||
|
@ -995,7 +995,7 @@ static int rpmsgmtd_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
FAR struct rpmsgmtd_header_s *header = data;
|
||||
uint32_t command = header->command;
|
||||
|
||||
if (command < ARRAY_SIZE(g_rpmsgmtd_handler))
|
||||
if (command < nitems(g_rpmsgmtd_handler))
|
||||
{
|
||||
return g_rpmsgmtd_handler[command](ept, data, len, src, priv);
|
||||
}
|
||||
|
@ -27,15 +27,12 @@
|
||||
|
||||
#include <nuttx/compiler.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define RPMSGMTD_NAME_PREFIX "rpmsgmtd-"
|
||||
#define RPMSGMTD_NAME_PREFIX_LEN 9
|
||||
|
||||
|
@ -383,7 +383,7 @@ static int rpmsgmtd_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
FAR struct rpmsgmtd_header_s *header = data;
|
||||
uint32_t command = header->command;
|
||||
|
||||
if (command < ARRAY_SIZE(g_rpmsgmtd_handler))
|
||||
if (command < nitems(g_rpmsgmtd_handler))
|
||||
{
|
||||
return g_rpmsgmtd_handler[command](ept, data, len, src, priv);
|
||||
}
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/nuttx.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
@ -62,10 +64,6 @@
|
||||
|
||||
#define PM_LINELEN 128
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
typedef ssize_t (*pm_read_t)(FAR struct file *filep,
|
||||
FAR char *buffer, size_t buflen);
|
||||
|
||||
@ -193,7 +191,7 @@ static int pm_open(FAR struct file *filep, FAR const char *relpath,
|
||||
}
|
||||
|
||||
relpath += strlen("pm/");
|
||||
for (i = 0; i < ARRAY_SIZE(g_pm_files); i++)
|
||||
for (i = 0; i < nitems(g_pm_files); i++)
|
||||
{
|
||||
if (strncmp(relpath, g_pm_files[i].name,
|
||||
strlen(g_pm_files[i].name)) == 0)
|
||||
@ -462,7 +460,7 @@ static int pm_opendir(FAR const char *relpath, FAR struct fs_dirent_s **dir)
|
||||
/* Initialize base structure components */
|
||||
|
||||
level1->level = 1;
|
||||
level1->nentries = CONFIG_PM_NDOMAINS * ARRAY_SIZE(g_pm_files);
|
||||
level1->nentries = CONFIG_PM_NDOMAINS * nitems(g_pm_files);
|
||||
|
||||
*dir = (FAR struct fs_dirent_s *)level1;
|
||||
return OK;
|
||||
@ -511,8 +509,8 @@ static int pm_readdir(FAR struct fs_dirent_s *dir,
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
domain = index / ARRAY_SIZE(g_pm_files);
|
||||
fpos = index % ARRAY_SIZE(g_pm_files);
|
||||
domain = index / nitems(g_pm_files);
|
||||
fpos = index % nitems(g_pm_files);
|
||||
|
||||
entry->d_type = DTYPE_FILE;
|
||||
snprintf(entry->d_name, NAME_MAX + 1, "%s%d",
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/list.h>
|
||||
#include <nuttx/power/consumer.h>
|
||||
@ -38,10 +40,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define REGULATOR_RPMSG_EPT_NAME "rpmsg-regulator"
|
||||
|
||||
#define REGULATOR_RPMSG_ENABLE 0
|
||||
@ -400,7 +398,7 @@ static int regulator_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
nxsem_post(&cookie->sem);
|
||||
ret = 0;
|
||||
}
|
||||
else if (cmd < ARRAY_SIZE(g_regulator_rpmsg_handler)
|
||||
else if (cmd < nitems(g_regulator_rpmsg_handler)
|
||||
&& g_regulator_rpmsg_handler[cmd])
|
||||
{
|
||||
header->response = 1;
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <termios.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
@ -40,8 +42,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define WTGAHRS2_ARRAYSIZE(a) (sizeof((a))/sizeof(a[0]))
|
||||
|
||||
#define WTGAHRS2_ACCEL_IDX 0
|
||||
#define WTGAHRS2_GYRO_IDX 1
|
||||
#define WTGAHRS2_MAG_IDX 2
|
||||
@ -170,7 +170,7 @@ static int wtgahrs2_set_interval(FAR struct sensor_lowerhalf_s *lower,
|
||||
FAR struct wtgahrs2_sensor_s *dev = (FAR struct wtgahrs2_sensor_s *)lower;
|
||||
int idx = 0;
|
||||
|
||||
for (; idx < WTGAHRS2_ARRAYSIZE(g_wtgahrs2_interval) - 1; idx++)
|
||||
for (; idx < nitems(g_wtgahrs2_interval) - 1; idx++)
|
||||
{
|
||||
if (*interval >= g_wtgahrs2_interval[idx])
|
||||
{
|
||||
|
@ -436,7 +436,7 @@ static int usrsockdev_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
* slot for the poll structure reference
|
||||
*/
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dev->pollfds); i++)
|
||||
for (i = 0; i < nitems(dev->pollfds); i++)
|
||||
{
|
||||
/* Find an available slot */
|
||||
|
||||
@ -450,7 +450,7 @@ static int usrsockdev_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= ARRAY_SIZE(dev->pollfds))
|
||||
if (i >= nitems(dev->pollfds))
|
||||
{
|
||||
fds->priv = NULL;
|
||||
ret = -EBUSY;
|
||||
@ -470,7 +470,7 @@ static int usrsockdev_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
eventset |= POLLIN;
|
||||
}
|
||||
|
||||
poll_notify(dev->pollfds, ARRAY_SIZE(dev->pollfds), eventset);
|
||||
poll_notify(dev->pollfds, nitems(dev->pollfds), eventset);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -521,7 +521,7 @@ int usrsock_request(FAR struct iovec *iov, unsigned int iovcnt)
|
||||
|
||||
/* Notify daemon of new request. */
|
||||
|
||||
poll_notify(dev->pollfds, ARRAY_SIZE(dev->pollfds), POLLIN);
|
||||
poll_notify(dev->pollfds, nitems(dev->pollfds), POLLIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -28,15 +28,12 @@
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statfs.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define RPMSGFS_NAME_PREFIX "rpmsgfs-"
|
||||
|
||||
#define RPMSGFS_OPEN 1
|
||||
|
@ -323,7 +323,7 @@ static int rpmsgfs_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
FAR struct rpmsgfs_header_s *header = data;
|
||||
uint32_t command = header->command;
|
||||
|
||||
if (command < ARRAY_SIZE(g_rpmsgfs_handler))
|
||||
if (command < nitems(g_rpmsgfs_handler))
|
||||
{
|
||||
return g_rpmsgfs_handler[command](ept, data, len, src, priv);
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ static int rpmsgfs_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
struct rpmsgfs_header_s *header = data;
|
||||
uint32_t command = header->command;
|
||||
|
||||
if (command < ARRAY_SIZE(g_rpmsgfs_handler))
|
||||
if (command < nitems(g_rpmsgfs_handler))
|
||||
{
|
||||
return g_rpmsgfs_handler[command](ept, data, len, src, priv);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/net/netconfig.h>
|
||||
#include <nuttx/compiler.h>
|
||||
@ -38,10 +39,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
/* Event message flags */
|
||||
|
||||
#define USRSOCK_EVENT_ABORT (1 << 1)
|
||||
|
@ -328,7 +328,7 @@
|
||||
.user_data = (&(struct _bt_gatt_ccc_s) \
|
||||
{ \
|
||||
.cfg = _cfg, \
|
||||
.cfg_len = ARRAY_SIZE(_cfg), \
|
||||
.cfg_len = nitems(_cfg), \
|
||||
.value_handle = _value_handle, \
|
||||
.cfg_changed = _cfg_changed, \
|
||||
}),\
|
||||
|
@ -23,6 +23,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <termios.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
@ -34,8 +35,6 @@
|
||||
#define CBAUD 0010017 /* Baud speed mask (not in POSIX) */
|
||||
#define BOTHER 0010000 /* Magic token for custom baud rate */
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof((a))/sizeof(a[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Definitions
|
||||
****************************************************************************/
|
||||
@ -147,7 +146,7 @@ int cfsetspeed(FAR struct termios *termiosp, speed_t speed)
|
||||
size_t idx;
|
||||
|
||||
DEBUGASSERT(termiosp);
|
||||
for (idx = 0; idx < ARRAYSIZE(g_baud_table); idx++)
|
||||
for (idx = 0; idx < nitems(g_baud_table); idx++)
|
||||
{
|
||||
if (speed == g_baud_table[idx].mask)
|
||||
{
|
||||
@ -162,7 +161,7 @@ int cfsetspeed(FAR struct termios *termiosp, speed_t speed)
|
||||
}
|
||||
}
|
||||
|
||||
if (idx == ARRAYSIZE(g_baud_table))
|
||||
if (idx == nitems(g_baud_table))
|
||||
{
|
||||
termiosp->c_speed = speed;
|
||||
speed = BOTHER;
|
||||
|
@ -26,16 +26,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/time.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -82,8 +76,8 @@ FAR char *asctime_r(FAR const struct tm *tp, FAR char *buf)
|
||||
char tmp[128];
|
||||
|
||||
if (tp == NULL ||
|
||||
tp->tm_wday >= ARRAY_SIZE(g_wday_name) ||
|
||||
tp->tm_mon >= ARRAY_SIZE(g_mon_name))
|
||||
tp->tm_wday >= nitems(g_wday_name) ||
|
||||
tp->tm_mon >= nitems(g_mon_name))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "netfilter/iptables.h"
|
||||
@ -37,10 +39,6 @@
|
||||
|
||||
#define SWAP(a,b,t) do { t = a; a = b; b = t; } while (0)
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -116,7 +114,7 @@ static void ipt_table_init(FAR struct ipt_table_s *table)
|
||||
static FAR struct ipt_table_s *ipt_table(FAR const char *name)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ARRAY_SIZE(g_tables); i++)
|
||||
for (i = 0; i < nitems(g_tables); i++)
|
||||
{
|
||||
ipt_table_init(&g_tables[i]);
|
||||
if (g_tables[i].repl != NULL &&
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
@ -48,12 +50,6 @@
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
|
||||
!defined(CONFIG_FS_PROCFS_EXCLUDE_NET)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Definitions
|
||||
****************************************************************************/
|
||||
@ -214,7 +210,7 @@ static int netprocfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
|
||||
/* For each net entries */
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(g_net_entries); i++)
|
||||
for (i = 0; i < nitems(g_net_entries); i++)
|
||||
{
|
||||
if (strncmp(relpath + 4, g_net_entries[i].name,
|
||||
strlen(g_net_entries[i].name)))
|
||||
@ -230,7 +226,7 @@ static int netprocfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(g_net_entries) - 1)
|
||||
if (i == nitems(g_net_entries) - 1)
|
||||
{
|
||||
FAR char *devname;
|
||||
FAR char *copy;
|
||||
@ -395,7 +391,7 @@ static int netprocfs_opendir(FAR const char *relpath,
|
||||
|
||||
if (strlen(relpath) > 4)
|
||||
{
|
||||
for (i = 0; i < ARRAY_SIZE(g_net_entries); i++)
|
||||
for (i = 0; i < nitems(g_net_entries); i++)
|
||||
{
|
||||
if (strncmp(relpath + 4, g_net_entries[i].name,
|
||||
strlen(g_net_entries[i].name)))
|
||||
@ -439,7 +435,7 @@ static int netprocfs_opendir(FAR const char *relpath,
|
||||
|
||||
/* Add other enabled net components, except netdev */
|
||||
|
||||
level1->base.nentries += ARRAY_SIZE(g_net_entries) - 1;
|
||||
level1->base.nentries += nitems(g_net_entries) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -517,7 +513,7 @@ static int netprocfs_readdir(FAR struct fs_dirent_s *dir,
|
||||
|
||||
/* Process other enabled net components, except netdev */
|
||||
|
||||
if (index < ARRAY_SIZE(g_net_entries) - 1)
|
||||
if (index < nitems(g_net_entries) - 1)
|
||||
{
|
||||
entry->d_type = g_net_entries[index].type;
|
||||
strlcpy(entry->d_name,
|
||||
@ -558,7 +554,7 @@ static int netprocfs_readdir(FAR struct fs_dirent_s *dir,
|
||||
* entry of last g_net_entries(-1) and start the devidx from 1)
|
||||
*/
|
||||
|
||||
ifindex = index + 2 - ARRAY_SIZE(g_net_entries);
|
||||
ifindex = index + 2 - nitems(g_net_entries);
|
||||
#endif
|
||||
/* Find the device corresponding to this device index */
|
||||
|
||||
@ -637,7 +633,7 @@ static int netprocfs_stat(FAR const char *relpath, FAR struct stat *buf)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < ARRAY_SIZE(g_net_entries); i++)
|
||||
for (i = 0; i < nitems(g_net_entries); i++)
|
||||
{
|
||||
if (strcmp(relpath + 4, g_net_entries[i].name) == 0)
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ static int do_accept_request(FAR struct usrsock_conn_s *conn,
|
||||
bufs[0].iov_base = &req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -385,7 +385,7 @@ int usrsock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
inbufs[1].iov_base = &newconn->usockid;
|
||||
inbufs[1].iov_len = sizeof(newconn->usockid);
|
||||
|
||||
usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs));
|
||||
usrsock_setup_datain(conn, inbufs, nitems(inbufs));
|
||||
|
||||
/* We might start getting events for this socket right after
|
||||
* returning to daemon, so setup 'newconn' already here.
|
||||
|
@ -110,7 +110,7 @@ static int do_bind_request(FAR struct usrsock_conn_s *conn,
|
||||
bufs[1].iov_base = (FAR void *)addr;
|
||||
bufs[1].iov_len = req.addrlen;
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -106,7 +106,7 @@ static int do_close_request(FAR struct usrsock_conn_s *conn)
|
||||
bufs[0].iov_base = (FAR void *)&req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -112,7 +112,7 @@ static int do_connect_request(FAR struct usrsock_conn_s *conn,
|
||||
bufs[1].iov_base = (FAR void *)addr;
|
||||
bufs[1].iov_len = addrlen;
|
||||
|
||||
ret = usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
ret = usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
if (ret == -ENETDOWN)
|
||||
{
|
||||
ret = -ECONNABORTED;
|
||||
|
@ -123,7 +123,7 @@ static int do_getpeername_request(FAR struct usrsock_conn_s *conn,
|
||||
bufs[0].iov_base = (FAR void *)&req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -193,7 +193,7 @@ int usrsock_getpeername(FAR struct socket *psock,
|
||||
inbufs[0].iov_base = (FAR void *)addr;
|
||||
inbufs[0].iov_len = *addrlen;
|
||||
|
||||
usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs));
|
||||
usrsock_setup_datain(conn, inbufs, nitems(inbufs));
|
||||
|
||||
/* Request user-space daemon to close socket. */
|
||||
|
||||
|
@ -123,7 +123,7 @@ static int do_getsockname_request(FAR struct usrsock_conn_s *conn,
|
||||
bufs[0].iov_base = (FAR void *)&req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -193,7 +193,7 @@ int usrsock_getsockname(FAR struct socket *psock,
|
||||
inbufs[0].iov_base = (FAR void *)addr;
|
||||
inbufs[0].iov_len = *addrlen;
|
||||
|
||||
usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs));
|
||||
usrsock_setup_datain(conn, inbufs, nitems(inbufs));
|
||||
|
||||
/* Request user-space daemon to handle request. */
|
||||
|
||||
|
@ -134,7 +134,7 @@ static int do_getsockopt_request(FAR struct usrsock_conn_s *conn, int level,
|
||||
bufs[0].iov_base = (FAR void *)&req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -216,7 +216,7 @@ int usrsock_getsockopt(FAR struct socket *psock, int level, int option,
|
||||
inbufs[0].iov_base = (FAR void *)value;
|
||||
inbufs[0].iov_len = *value_len;
|
||||
|
||||
usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs));
|
||||
usrsock_setup_datain(conn, inbufs, nitems(inbufs));
|
||||
|
||||
/* Request user-space daemon to handle request. */
|
||||
|
||||
|
@ -139,7 +139,7 @@ static int do_ioctl_request(FAR struct usrsock_conn_s *conn, int cmd,
|
||||
}
|
||||
#endif
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -227,7 +227,7 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, unsigned long arg_)
|
||||
}
|
||||
#endif
|
||||
|
||||
usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs));
|
||||
usrsock_setup_datain(conn, inbufs, nitems(inbufs));
|
||||
|
||||
/* Request user-space daemon to handle ioctl. */
|
||||
|
||||
|
@ -106,7 +106,7 @@ static int do_listen_request(FAR struct usrsock_conn_s *conn, int backlog)
|
||||
bufs[0].iov_base = &req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -175,7 +175,7 @@ static int do_recvfrom_request(FAR struct usrsock_conn_s *conn,
|
||||
bufs[0].iov_base = (FAR void *)&req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -385,7 +385,7 @@ ssize_t usrsock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
||||
inbufs[1].iov_base = (FAR void *)buf;
|
||||
inbufs[1].iov_len = len;
|
||||
|
||||
usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs));
|
||||
usrsock_setup_datain(conn, inbufs, nitems(inbufs));
|
||||
|
||||
/* MSG_DONTWAIT is only use in usrsock. */
|
||||
|
||||
|
@ -172,7 +172,7 @@ static int do_sendto_request(FAR struct usrsock_conn_s *conn,
|
||||
|
||||
memcpy(&bufs[2], msg->msg_iov, sizeof(struct iovec) * msg->msg_iovlen);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -128,7 +128,7 @@ static int do_setsockopt_request(FAR struct usrsock_conn_s *conn,
|
||||
bufs[1].iov_base = (FAR void *)value;
|
||||
bufs[1].iov_len = req.valuelen;
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -106,7 +106,7 @@ static int do_shutdown_request(FAR struct usrsock_conn_s *conn, int how)
|
||||
bufs[0].iov_base = (FAR void *)&req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -137,7 +137,7 @@ static int do_socket_request(FAR struct usrsock_conn_s *conn, int domain,
|
||||
bufs[0].iov_base = (FAR void *)&req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
|
||||
return usrsock_do_request(conn, bufs, ARRAY_SIZE(bufs));
|
||||
return usrsock_do_request(conn, bufs, nitems(bufs));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -29,16 +29,14 @@
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/net/snoop.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define SNOOP_VERSION_1 1
|
||||
#define SNOOP_VERSION_2 2
|
||||
|
||||
@ -336,7 +334,7 @@ int snoop_open(FAR struct snoop_s *snoop, FAR const char *filename,
|
||||
's', 'n', 'o', 'o', 'p', '\0', '\0', '\0'
|
||||
};
|
||||
|
||||
memcpy(header.magic, snoop_magic, ARRAY_SIZE(snoop_magic));
|
||||
memcpy(header.magic, snoop_magic, nitems(snoop_magic));
|
||||
header.version = htobe32(SNOOP_VERSION_2);
|
||||
break;
|
||||
};
|
||||
@ -351,7 +349,7 @@ int snoop_open(FAR struct snoop_s *snoop, FAR const char *filename,
|
||||
'b', 't', 's', 'n', 'o', 'o', 'p', '\0'
|
||||
};
|
||||
|
||||
memcpy(header.magic, btsnoop_magic, ARRAY_SIZE(btsnoop_magic));
|
||||
memcpy(header.magic, btsnoop_magic, nitems(btsnoop_magic));
|
||||
header.version = htobe32(SNOOP_VERSION_1);
|
||||
break;
|
||||
}
|
||||
|
@ -50,6 +50,8 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
@ -69,8 +71,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
/* Wait up to 2.5 seconds for a response. This delay is arbitrary and
|
||||
* intended only to avoid hangs while waiting for a response. It may need
|
||||
* to be adjusted.
|
||||
@ -2139,7 +2139,7 @@ FAR const char *bt_addr_str(FAR const bt_addr_t *addr)
|
||||
FAR char *str;
|
||||
|
||||
str = bufs[cur++];
|
||||
cur %= ARRAY_SIZE(bufs);
|
||||
cur %= nitems(bufs);
|
||||
bt_addr_to_str(addr, str, sizeof(bufs[cur]));
|
||||
|
||||
return str;
|
||||
@ -2152,7 +2152,7 @@ FAR const char *bt_addr_le_str(FAR const bt_addr_le_t *addr)
|
||||
FAR char *str;
|
||||
|
||||
str = bufs[cur++];
|
||||
cur %= ARRAY_SIZE(bufs);
|
||||
cur %= nitems(bufs);
|
||||
bt_addr_le_to_str(addr, str, sizeof(bufs[cur]));
|
||||
|
||||
return str;
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/wireless/bluetooth/bt_hci.h>
|
||||
#include <nuttx/wireless/bluetooth/bt_core.h>
|
||||
|
||||
@ -61,8 +63,6 @@
|
||||
#define RECV_KEYS (BT_SMP_DIST_ID_KEY | BT_SMP_DIST_ENC_KEY)
|
||||
#define SEND_KEYS (BT_SMP_DIST_ENC_KEY)
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -326,7 +326,7 @@ static const char *h(FAR const void *buf, size_t len)
|
||||
int i;
|
||||
|
||||
str = hexbufs[curbuf++];
|
||||
curbuf %= ARRAY_SIZE(hexbufs);
|
||||
curbuf %= nitems(hexbufs);
|
||||
|
||||
maxlen = (sizeof(hexbufs[0]) - 1) / 2;
|
||||
if (len > maxlen)
|
||||
|
Loading…
Reference in New Issue
Block a user