Difference between revisions of "Current debugging"
From Wiki at Neela Nurseries
m (Examples from Zephyr 3.2.0 of device structure pointer assignments) |
m (→^ Device Tree syntax and Undocumented DTS) |
||
Line 50: | Line 50: | ||
+ | Excerpt from Nordic sample source code: | ||
+ | <pre> | ||
+ | 1 /* | ||
+ | 2 * Copyright (c) 2019 Nordic Semiconductor ASA. | ||
+ | 3 * | ||
+ | 4 * SPDX-License-Identifier: Apache-2.0 | ||
+ | 5 */ | ||
+ | 6 | ||
+ | 7 #include <zephyr/drivers/gpio.h> | ||
+ | 8 #include <zephyr/drivers/uart.h> | ||
+ | 9 #include <zephyr/device.h> | ||
+ | 10 #include <zephyr/devicetree.h> | ||
+ | 11 | ||
+ | 12 #define RESET_NODE DT_NODELABEL(nrf52840_reset) | ||
+ | 13 | ||
+ | 14 #if DT_NODE_HAS_STATUS(RESET_NODE, okay) | ||
+ | 15 | ||
+ | 16 #define RESET_GPIO_CTRL DT_GPIO_CTLR(RESET_NODE, gpios) | ||
+ | 17 #define RESET_GPIO_PIN DT_GPIO_PIN(RESET_NODE, gpios) | ||
+ | 18 #define RESET_GPIO_FLAGS DT_GPIO_FLAGS(RESET_NODE, gpios) | ||
+ | 19 | ||
+ | 20 int bt_hci_transport_setup(const struct device *h4) | ||
+ | 21 { | ||
+ | 22 int err; | ||
+ | 23 char c; | ||
+ | 24 const struct device *const port = DEVICE_DT_GET(RESET_GPIO_CTRL); | ||
+ | 25 | ||
+ | 26 if (!device_is_ready(port)) { | ||
+ | 27 return -EIO; | ||
+ | 28 } | ||
+ | 29 | ||
+ | 30 /* Configure pin as output and initialize it to inactive state. */ | ||
+ | 31 err = gpio_pin_configure(port, RESET_GPIO_PIN, | ||
+ | 32 RESET_GPIO_FLAGS | GPIO_OUTPUT_INACTIVE); | ||
+ | 33 if (err) { | ||
+ | 34 return err; | ||
+ | 35 } | ||
+ | 36 | ||
+ | 37 /* Reset the nRF52840 and let it wait until the pin is inactive again | ||
+ | 38 * before running to main to ensure that it won't send any data until | ||
+ | 39 * the H4 device is setup and ready to receive. | ||
+ | 40 */ | ||
+ | 41 err = gpio_pin_set(port, RESET_GPIO_PIN, 1); | ||
+ | 42 if (err) { | ||
+ | 43 return err; | ||
+ | 44 } | ||
+ | 45 | ||
+ | 46 /* Wait for the nRF52840 peripheral to stop sending data. | ||
+ | "./boards/arm/nrf9160dk_nrf9160/nrf52840_reset.c" 67L, 1609C | ||
+ | </pre> | ||
<!-- comentario --> | <!-- comentario --> |
Revision as of 19:35, 10 November 2022
2022-11-05 SAT
[00:00:00.009,000] <err> IIS2DH: iis2dh@18: device ������rF����� is not ready [00:00:00.017,000] <err> IIS2DH: Failed to initialize interrupts *** Booting Zephyr OS build zephyr-v3.2.0 *** - scoreboard - in setter function test val holds 0, - scoreboard - setting test val to 5, - DEV 1028 - symbol ST_IIS2DH got assigned 'DT_N_S_soc_S_peripheral_50000000_S_flexcomm_8a000_S_iis2dh_18' - kd_thread_iis2dh - Success finding iis2dh device, - kd_thread_iis2dh - WARNING - sensor device 'iis2dh@18' is not ready! - kd_thread_iis2dh - INFO: device name (Zephyr compile time setting) found to be 'iis2dh@18' - kd_thread_iis2dh - INFO: boot time Zephyr init result value holds 5, - DEV 1101 - WHO_AM_I register 0x0F holds 0x33 - DEV 1101 - config register 0x22 holds 0x10 - FIFO control reg holds 0x4f - updating this value to set watermark at 16 data entries . . . - write_register() returns status of 0,./tests/subsys/pm/device_power_domains/src/main.c:14: const struct device *const reg_0 = DEVICE_DT_GET(DT_NODELABEL(test_reg_0)); ./tests/subsys/pm/device_power_domains/src/main.c:15: const struct device *const reg_1 = DEVICE_DT_GET(DT_NODELABEL(test_reg_1)); ./tests/subsys/pm/device_power_domains/src/main.c:16: const struct device *const reg_chained = DEVICE_DT_GET(DT_NODELABEL(test_reg_chained)); - following update, FIFO control reg holds 0x4f - updating FIFO ctrl register to enable FIFO mode . . . - reading back vale . . . - FIFO ctrl register now holds 0x4F. - kd_thread_iis2dh - unconditionally attempting to configure data ready (drdy-gpios) interrupt, Waiting for triggers - whoami register, ODR register, and ctrl reg 5 hold 0x33, 0x57, 0x40 - whoami register, ODR register, and ctrl reg 5 hold 0x33, 0x57, 0x40 - whoami register, ODR register, and ctrl reg 5 hold 0x33, 0x57, 0x40
^ Device Tree syntax and Undocumented DTS
Examples from Zephyr 3.2.0 of device structure pointer assignments:
./tests/subsys/pm/device_power_domains/src/main.c:14: const struct device *const reg_0 = DEVICE_DT_GET(DT_NODELABEL(test_reg_0)); ./tests/subsys/pm/device_power_domains/src/main.c:15: const struct device *const reg_1 = DEVICE_DT_GET(DT_NODELABEL(test_reg_1)); ./tests/subsys/pm/device_power_domains/src/main.c:16: const struct device *const reg_chained = DEVICE_DT_GET(DT_NODELABEL(test_reg_chained));
Excerpt from Nordic sample source code:
1 /* 2 * Copyright (c) 2019 Nordic Semiconductor ASA. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/drivers/gpio.h> 8 #include <zephyr/drivers/uart.h> 9 #include <zephyr/device.h> 10 #include <zephyr/devicetree.h> 11 12 #define RESET_NODE DT_NODELABEL(nrf52840_reset) 13 14 #if DT_NODE_HAS_STATUS(RESET_NODE, okay) 15 16 #define RESET_GPIO_CTRL DT_GPIO_CTLR(RESET_NODE, gpios) 17 #define RESET_GPIO_PIN DT_GPIO_PIN(RESET_NODE, gpios) 18 #define RESET_GPIO_FLAGS DT_GPIO_FLAGS(RESET_NODE, gpios) 19 20 int bt_hci_transport_setup(const struct device *h4) 21 { 22 int err; 23 char c; 24 const struct device *const port = DEVICE_DT_GET(RESET_GPIO_CTRL); 25 26 if (!device_is_ready(port)) { 27 return -EIO; 28 } 29 30 /* Configure pin as output and initialize it to inactive state. */ 31 err = gpio_pin_configure(port, RESET_GPIO_PIN, 32 RESET_GPIO_FLAGS | GPIO_OUTPUT_INACTIVE); 33 if (err) { 34 return err; 35 } 36 37 /* Reset the nRF52840 and let it wait until the pin is inactive again 38 * before running to main to ensure that it won't send any data until 39 * the H4 device is setup and ready to receive. 40 */ 41 err = gpio_pin_set(port, RESET_GPIO_PIN, 1); 42 if (err) { 43 return err; 44 } 45 46 /* Wait for the nRF52840 peripheral to stop sending data. "./boards/arm/nrf9160dk_nrf9160/nrf52840_reset.c" 67L, 1609C