tests: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h DT_INST macro APIs. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
36049b1657
commit
a5375ead0c
|
@ -65,7 +65,7 @@ static int powerup_adv7513(struct device *i2c_dev)
|
|||
|
||||
static int test_i2c_adv7513(void)
|
||||
{
|
||||
struct device *i2c_dev = device_get_binding(DT_INST_0_NIOS2_I2C_LABEL);
|
||||
struct device *i2c_dev = device_get_binding(DT_LABEL(DT_INST(0, nios2_i2c)));
|
||||
u32_t i2c_cfg = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_MASTER;
|
||||
u8_t data;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define GPIO_OUT_PIN 23
|
||||
#define GPIO_INT_PIN 24
|
||||
#define GPIO_NAME "GPIO_"
|
||||
#define GPIO_DRV_NAME DT_INST_0_SNPS_DESIGNWARE_GPIO_LABEL
|
||||
#define GPIO_DRV_NAME DT_LABEL(DT_INST(0, snps_designware_gpio))
|
||||
|
||||
/* size of stack area used by each thread */
|
||||
#define STACKSIZE 1024
|
||||
|
|
|
@ -56,7 +56,7 @@ void test_flash(void)
|
|||
u32_t magic[4];
|
||||
int i;
|
||||
|
||||
flash_dev = device_get_binding(DT_INST_0_JEDEC_SPI_NOR_LABEL);
|
||||
flash_dev = device_get_binding(DT_LABEL(DT_INST(0, jedec_spi_nor)));
|
||||
|
||||
if (!flash_dev) {
|
||||
LOG_ERR("SPI flash driver was not found!\n");
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
|
||||
#elif defined(CONFIG_SOC_FAMILY_SAM0)
|
||||
#include <soc.h>
|
||||
#define ADC_DEVICE_NAME DT_INST_0_ATMEL_SAM0_ADC_LABEL
|
||||
#define ADC_DEVICE_NAME DT_LABEL(DT_INST(0, atmel_sam0_adc))
|
||||
#define ADC_RESOLUTION 12
|
||||
#define ADC_GAIN ADC_GAIN_1
|
||||
#define ADC_REFERENCE ADC_REF_INTERNAL
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <logging/log.h>
|
||||
LOG_MODULE_REGISTER(test);
|
||||
|
||||
#ifdef DT_INST_0_NORDIC_NRF_CLOCK_LABEL
|
||||
#if DT_HAS_NODE(DT_INST(0, nordic_nrf_clock))
|
||||
#include <drivers/clock_control/nrf_clock_control.h>
|
||||
#endif
|
||||
|
||||
|
@ -24,9 +24,9 @@ struct device_data {
|
|||
};
|
||||
|
||||
static const struct device_data devices[] = {
|
||||
#ifdef DT_INST_0_NORDIC_NRF_CLOCK_LABEL
|
||||
#if DT_HAS_NODE(DT_INST(0, nordic_nrf_clock))
|
||||
{
|
||||
.name = DT_INST_0_NORDIC_NRF_CLOCK_LABEL,
|
||||
.name = DT_LABEL(DT_INST(0, nordic_nrf_clock)),
|
||||
.subsys_data = (const struct device_subsys_data[]){
|
||||
{
|
||||
.subsys = CLOCK_CONTROL_NRF_SUBSYS_HF,
|
||||
|
|
|
@ -44,7 +44,7 @@ static const struct sensor_driver_api mock_temp_nrf5_driver_api = {
|
|||
};
|
||||
|
||||
DEVICE_AND_API_INIT(mock_temp_nrf5,
|
||||
DT_INST_0_NORDIC_NRF_TEMP_LABEL,
|
||||
DT_LABEL(DT_INST(0, nordic_nrf_temp)),
|
||||
mock_temp_nrf5_init,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -99,7 +99,7 @@ static void test_basic_clock_calibration(void)
|
|||
static void test_calibration_after_enabling_lfclk(void)
|
||||
{
|
||||
struct device *clk_dev =
|
||||
device_get_binding(DT_INST_0_NORDIC_NRF_CLOCK_LABEL);
|
||||
device_get_binding(DT_LABEL(DT_INST(0, nordic_nrf_clock)));
|
||||
struct sensor_value value = { .val1 = 0, .val2 = 0 };
|
||||
|
||||
mock_temp_nrf5_value_set(&value);
|
||||
|
|
|
@ -57,14 +57,14 @@ static const char * const devices[] = {
|
|||
#ifdef CONFIG_COUNTER_IMX_EPIT_2
|
||||
DT_COUNTER_IMX_EPIT_2_LABEL,
|
||||
#endif
|
||||
#ifdef DT_INST_0_ARM_CMSDK_TIMER_LABEL
|
||||
DT_INST_0_ARM_CMSDK_TIMER_LABEL,
|
||||
#if DT_HAS_NODE(DT_INST(0, arm_cmsdk_timer))
|
||||
DT_LABEL(DT_INST(0, arm_cmsdk_timer)),
|
||||
#endif
|
||||
#ifdef DT_INST_1_ARM_CMSDK_TIMER_LABEL
|
||||
DT_INST_1_ARM_CMSDK_TIMER_LABEL,
|
||||
#if DT_HAS_NODE(DT_INST(1, arm_cmsdk_timer))
|
||||
DT_LABEL(DT_INST(1, arm_cmsdk_timer)),
|
||||
#endif
|
||||
#ifdef DT_INST_0_ARM_CMSDK_DTIMER_LABEL
|
||||
DT_INST_0_ARM_CMSDK_DTIMER_LABEL,
|
||||
#if DT_HAS_NODE(DT_INST(0, arm_cmsdk_dtimer))
|
||||
DT_LABEL(DT_INST(0, arm_cmsdk_dtimer)),
|
||||
#endif
|
||||
#ifdef DT_RTC_0_NAME
|
||||
DT_RTC_0_NAME,
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
|
||||
static void board_setup(void)
|
||||
{
|
||||
#ifdef DT_INST_0_TEST_GPIO_BASIC_API
|
||||
#if DT_HAS_NODE(DT_INST(0, test_gpio_basic_api))
|
||||
/* PIN_IN and PIN_OUT must be on same controller. */
|
||||
if (strcmp(DT_INST_0_TEST_GPIO_BASIC_API_OUT_GPIOS_CONTROLLER,
|
||||
DT_INST_0_TEST_GPIO_BASIC_API_IN_GPIOS_CONTROLLER) != 0) {
|
||||
if (strcmp(DT_GPIO_LABEL(DT_INST(0, test_gpio_basic_api), out_gpios),
|
||||
DT_GPIO_LABEL(DT_INST(0, test_gpio_basic_api), in_gpios)) != 0) {
|
||||
printk("FATAL: output controller %s != input controller %s\n",
|
||||
DT_INST_0_TEST_GPIO_BASIC_API_OUT_GPIOS_CONTROLLER,
|
||||
DT_INST_0_TEST_GPIO_BASIC_API_IN_GPIOS_CONTROLLER);
|
||||
DT_GPIO_LABEL(DT_INST(0, test_gpio_basic_api), out_gpios),
|
||||
DT_GPIO_LABEL(DT_INST(0, test_gpio_basic_api), in_gpios));
|
||||
k_panic();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <sys/util.h>
|
||||
#include <ztest.h>
|
||||
|
||||
#ifdef DT_INST_0_TEST_GPIO_BASIC_API
|
||||
#if DT_HAS_NODE(DT_INST(0, test_gpio_basic_api))
|
||||
|
||||
/* Execution of the test requires hardware configuration described in
|
||||
* devicetree. See the test,gpio_basic_api binding local to this test
|
||||
|
@ -21,9 +21,9 @@
|
|||
* If this is not present devices that have gpio-0, gpio-1, or gpio-2
|
||||
* aliases are supported for build-only tests.
|
||||
*/
|
||||
#define DEV_NAME DT_INST_0_TEST_GPIO_BASIC_API_OUT_GPIOS_CONTROLLER
|
||||
#define PIN_OUT DT_INST_0_TEST_GPIO_BASIC_API_OUT_GPIOS_PIN
|
||||
#define PIN_IN DT_INST_0_TEST_GPIO_BASIC_API_IN_GPIOS_PIN
|
||||
#define DEV_NAME DT_GPIO_LABEL(DT_INST(0, test_gpio_basic_api), out_gpios)
|
||||
#define PIN_OUT DT_GPIO_PIN(DT_INST(0, test_gpio_basic_api), out_gpios)
|
||||
#define PIN_IN DT_GPIO_PIN(DT_INST(0, test_gpio_basic_api), in_gpios)
|
||||
|
||||
#elif defined(DT_ALIAS_GPIO_0_LABEL)
|
||||
#define DEV_NAME DT_ALIAS_GPIO_0_LABEL
|
||||
|
|
|
@ -139,30 +139,30 @@ void test_eeprom_slave(void)
|
|||
|
||||
|
||||
i2c_0 = device_get_binding(
|
||||
DT_INST_0_ATMEL_AT24_BUS_NAME);
|
||||
DT_BUS_LABEL(DT_INST(0, atmel_at24)));
|
||||
zassert_not_null(i2c_0, "I2C device %s not found",
|
||||
DT_INST_0_ATMEL_AT24_BUS_NAME);
|
||||
DT_BUS_LABEL(DT_INST(0, atmel_at24)));
|
||||
|
||||
LOG_INF("Found I2C Master device %s",
|
||||
DT_INST_0_ATMEL_AT24_BUS_NAME);
|
||||
DT_BUS_LABEL(DT_INST(0, atmel_at24)));
|
||||
|
||||
i2c_1 = device_get_binding(
|
||||
DT_INST_1_ATMEL_AT24_BUS_NAME);
|
||||
DT_BUS_LABEL(DT_INST(1, atmel_at24)));
|
||||
zassert_not_null(i2c_1, "I2C device %s not found",
|
||||
DT_INST_1_ATMEL_AT24_BUS_NAME);
|
||||
DT_BUS_LABEL(DT_INST(1, atmel_at24)));
|
||||
|
||||
LOG_INF("Found I2C Master device %s",
|
||||
DT_INST_1_ATMEL_AT24_BUS_NAME);
|
||||
DT_BUS_LABEL(DT_INST(1, atmel_at24)));
|
||||
|
||||
/*
|
||||
* Normal applications would interact with an EEPROM
|
||||
* identified by the string literal used in the binding node
|
||||
* label property ("EEPROM_SLAVE_0") rather than the generated
|
||||
* macro DT_INST_0_ATMEL_AT24_LABEL. There is no guarantee that
|
||||
* macro DT_LABEL(DT_INST(0, atmel_at24)). There is no guarantee that
|
||||
* the index for the compatible is persistent across builds;
|
||||
* for example DT_INST_0_ATMEL_AT24 might refer to "EEPROM_SLAVE_1"
|
||||
* if the order of the node declarations were changed in the
|
||||
* overlay file.
|
||||
* for example DT_LABEL(DT_INST(0, atmel_at24)) might refer to
|
||||
* "EEPROM_SLAVE_1" * if the order of the node declarations were changed
|
||||
* in the overlay file.
|
||||
*
|
||||
* The label string cannot be directly used to determine the
|
||||
* correct parent bus and device index for whitebox testing in
|
||||
|
@ -171,61 +171,61 @@ void test_eeprom_slave(void)
|
|||
* using the generated macro.
|
||||
*/
|
||||
|
||||
eeprom_0 = device_get_binding(DT_INST_0_ATMEL_AT24_LABEL);
|
||||
eeprom_0 = device_get_binding(DT_LABEL(DT_INST(0, atmel_at24)));
|
||||
zassert_not_null(eeprom_0, "EEPROM device %s not found",
|
||||
DT_INST_0_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(0, atmel_at24)));
|
||||
|
||||
LOG_INF("Found EEPROM device %s", DT_INST_0_ATMEL_AT24_LABEL);
|
||||
LOG_INF("Found EEPROM device %s", DT_LABEL(DT_INST(0, atmel_at24)));
|
||||
|
||||
eeprom_1 = device_get_binding(DT_INST_1_ATMEL_AT24_LABEL);
|
||||
eeprom_1 = device_get_binding(DT_LABEL(DT_INST(1, atmel_at24)));
|
||||
zassert_not_null(eeprom_1, "EEPROM device %s not found",
|
||||
DT_INST_1_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(1, atmel_at24)));
|
||||
|
||||
LOG_INF("Found EEPROM device %s", DT_INST_1_ATMEL_AT24_LABEL);
|
||||
LOG_INF("Found EEPROM device %s", DT_LABEL(DT_INST(1, atmel_at24)));
|
||||
|
||||
/* Program dummy bytes */
|
||||
ret = eeprom_slave_program(eeprom_0, eeprom_0_data, TEST_DATA_SIZE);
|
||||
zassert_equal(ret, 0, "Failed to program EEPROM %s",
|
||||
DT_INST_0_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(0, atmel_at24)));
|
||||
|
||||
ret = eeprom_slave_program(eeprom_1, eeprom_1_data, TEST_DATA_SIZE);
|
||||
zassert_equal(ret, 0, "Failed to program EEPROM %s",
|
||||
DT_INST_1_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(1, atmel_at24)));
|
||||
|
||||
/* Attach EEPROM */
|
||||
ret = i2c_slave_driver_register(eeprom_0);
|
||||
zassert_equal(ret, 0, "Failed to register EEPROM %s",
|
||||
DT_INST_0_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(0, atmel_at24)));
|
||||
|
||||
LOG_INF("EEPROM %s Attached !", DT_INST_0_ATMEL_AT24_LABEL);
|
||||
LOG_INF("EEPROM %s Attached !", DT_LABEL(DT_INST(0, atmel_at24)));
|
||||
|
||||
ret = i2c_slave_driver_register(eeprom_1);
|
||||
zassert_equal(ret, 0, "Failed to register EEPROM %s",
|
||||
DT_INST_1_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(1, atmel_at24)));
|
||||
|
||||
LOG_INF("EEPROM %s Attached !", DT_INST_1_ATMEL_AT24_LABEL);
|
||||
LOG_INF("EEPROM %s Attached !", DT_LABEL(DT_INST(1, atmel_at24)));
|
||||
|
||||
/* Run Tests without bus access conflicts */
|
||||
run_full_read(i2c_0, DT_INST_1_ATMEL_AT24_BASE_ADDRESS, eeprom_1_data);
|
||||
run_full_read(i2c_1, DT_INST_0_ATMEL_AT24_BASE_ADDRESS, eeprom_0_data);
|
||||
run_full_read(i2c_0, DT_REG_ADDR(DT_INST(1, atmel_at24)), eeprom_1_data);
|
||||
run_full_read(i2c_1, DT_REG_ADDR(DT_INST(0, atmel_at24)), eeprom_0_data);
|
||||
|
||||
for (offset = 0 ; offset < TEST_DATA_SIZE-1 ; ++offset) {
|
||||
run_partial_read(i2c_0, DT_INST_1_ATMEL_AT24_BASE_ADDRESS,
|
||||
run_partial_read(i2c_0, DT_REG_ADDR(DT_INST(1, atmel_at24)),
|
||||
eeprom_1_data, offset);
|
||||
}
|
||||
|
||||
for (offset = 0 ; offset < TEST_DATA_SIZE-1 ; ++offset) {
|
||||
run_partial_read(i2c_1, DT_INST_0_ATMEL_AT24_BASE_ADDRESS,
|
||||
run_partial_read(i2c_1, DT_REG_ADDR(DT_INST(0, atmel_at24)),
|
||||
eeprom_0_data, offset);
|
||||
}
|
||||
|
||||
for (offset = 0 ; offset < TEST_DATA_SIZE-1 ; ++offset) {
|
||||
run_program_read(i2c_0, DT_INST_1_ATMEL_AT24_BASE_ADDRESS,
|
||||
run_program_read(i2c_0, DT_REG_ADDR(DT_INST(1, atmel_at24)),
|
||||
offset);
|
||||
}
|
||||
|
||||
for (offset = 0 ; offset < TEST_DATA_SIZE-1 ; ++offset) {
|
||||
run_program_read(i2c_1, DT_INST_0_ATMEL_AT24_BASE_ADDRESS,
|
||||
run_program_read(i2c_1, DT_REG_ADDR(DT_INST(0, atmel_at24)),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
@ -234,17 +234,17 @@ void test_eeprom_slave(void)
|
|||
/* Detach EEPROM */
|
||||
ret = i2c_slave_driver_unregister(eeprom_0);
|
||||
zassert_equal(ret, 0, "Failed to unregister EEPROM %s",
|
||||
DT_INST_0_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(0, atmel_at24)));
|
||||
|
||||
LOG_INF("EEPROM %s Detached !",
|
||||
DT_INST_0_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(0, atmel_at24)));
|
||||
|
||||
ret = i2c_slave_driver_unregister(eeprom_1);
|
||||
zassert_equal(ret, 0, "Failed to unregister EEPROM %s",
|
||||
DT_INST_1_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(1, atmel_at24)));
|
||||
|
||||
LOG_INF("EEPROM %s Detached !",
|
||||
DT_INST_1_ATMEL_AT24_LABEL);
|
||||
DT_LABEL(DT_INST(1, atmel_at24)));
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
#define WDT_DEV_NAME DT_ALIAS_WATCHDOG0_LABEL
|
||||
#else
|
||||
#ifdef CONFIG_WWDG_STM32
|
||||
#define WDT_DEV_NAME DT_INST_0_ST_STM32_WINDOW_WATCHDOG_LABEL
|
||||
#define WDT_DEV_NAME DT_LABEL(DT_INST(0, st_stm32_window_watchdog))
|
||||
#else
|
||||
#define WDT_DEV_NAME DT_WDT_0_NAME
|
||||
#endif
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
* is not defined in platform, generate an error
|
||||
*/
|
||||
#if defined(CONFIG_HPET_TIMER)
|
||||
#define TICK_IRQ DT_INST_0_INTEL_HPET_IRQ_0
|
||||
#define TICK_IRQ DT_IRQN(DT_INST(0, intel_hpet))
|
||||
#elif defined(CONFIG_ARM_ARCH_TIMER)
|
||||
#define TICK_IRQ ARM_ARCH_TIMER_IRQ
|
||||
#elif defined(CONFIG_APIC_TIMER)
|
||||
|
@ -70,7 +70,7 @@
|
|||
#elif defined(CONFIG_RV32M1_LPTMR_TIMER)
|
||||
#define TICK_IRQ DT_OPENISA_RV32M1_LPTMR_SYSTEM_LPTMR_IRQ_0
|
||||
#elif defined(CONFIG_XLNX_PSTTC_TIMER)
|
||||
#define TICK_IRQ DT_INST_0_XLNX_TTCPS_IRQ_0
|
||||
#define TICK_IRQ DT_IRQN(DT_INST(0, xlnx_ttcps))
|
||||
#elif defined(CONFIG_CPU_CORTEX_M)
|
||||
/*
|
||||
* The Cortex-M use the SYSTICK exception for the system timer, which is
|
||||
|
|
Loading…
Reference in a new issue