nuttx: replace all ARRAY_SIZE()/ARRAYSIZE() to nitems()

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2023-02-02 20:31:22 +08:00
committed by Xiang Xiao
parent cf0769d613
commit 3a0fdb019d
95 changed files with 291 additions and 451 deletions
+2 -2
View File
@@ -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
+2 -1
View File
@@ -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)
/****************************************************************************
+3 -3
View File
@@ -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
+3 -3
View File
@@ -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 */
+1 -1
View File
@@ -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,
};
-4
View File
@@ -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 */
+1 -1
View File
@@ -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,
};
+1 -1
View File
@@ -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,
};
+1 -6
View File
@@ -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
****************************************************************************/
+2 -2
View File
@@ -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];

Some files were not shown because too many files have changed in this diff Show More