|
20 | 20 |
|
21 | 21 | #define SCROLL_SPEED 300
|
22 | 22 |
|
23 |
| -#define BUZZER_PWM_CHANNEL 0 |
24 |
| -#define BEEP_DURATION K_MSEC(60) |
25 |
| - |
26 | 23 | #define SEQ_PER_BIT 976
|
27 | 24 | #define SEQ_PAGE (NRF_FICR->CODEPAGESIZE * (NRF_FICR->CODESIZE - 1))
|
28 | 25 | #define SEQ_MAX (NRF_FICR->CODEPAGESIZE * 8 * SEQ_PER_BIT)
|
29 | 26 |
|
30 | 27 | static const struct gpio_dt_spec button_a =
|
31 |
| - GPIO_DT_SPEC_GET(DT_NODELABEL(buttona), gpios); |
| 28 | + GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios); |
32 | 29 | static const struct gpio_dt_spec button_b =
|
33 |
| - GPIO_DT_SPEC_GET(DT_NODELABEL(buttonb), gpios); |
34 |
| -static const struct device *const nvm = |
35 |
| - DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)); |
36 |
| -static const struct device *const pwm = |
37 |
| - DEVICE_DT_GET_ANY(nordic_nrf_sw_pwm); |
| 30 | + GPIO_DT_SPEC_GET(DT_ALIAS(sw1), gpios); |
38 | 31 |
|
39 | 32 | static struct k_work button_work;
|
40 | 33 |
|
@@ -64,6 +57,13 @@ static void button_pressed(const struct device *dev, struct gpio_callback *cb,
|
64 | 57 | }
|
65 | 58 | }
|
66 | 59 |
|
| 60 | +#if defined(CONFIG_PWM) |
| 61 | +#define BUZZER_PWM_CHANNEL 0 |
| 62 | +#define BEEP_DURATION K_MSEC(60) |
| 63 | + |
| 64 | +static const struct device *const pwm = |
| 65 | + DEVICE_DT_GET_ANY(nordic_nrf_sw_pwm); |
| 66 | + |
67 | 67 | static const struct {
|
68 | 68 | char note;
|
69 | 69 | uint32_t period;
|
@@ -139,6 +139,11 @@ void board_play_tune(const char *str)
|
139 | 139 | pwm_set(pwm, BUZZER_PWM_CHANNEL, 0, 0, 0);
|
140 | 140 | }
|
141 | 141 | }
|
| 142 | +#else |
| 143 | +void board_play_tune(const char *str) |
| 144 | +{ |
| 145 | +} |
| 146 | +#endif /* CONFIG_PWM */ |
142 | 147 |
|
143 | 148 | void board_heartbeat(uint8_t hops, uint16_t feat)
|
144 | 149 | {
|
@@ -267,13 +272,6 @@ int board_init(uint16_t *addr)
|
267 | 272 | {
|
268 | 273 | struct mb_display *disp = mb_display_get();
|
269 | 274 |
|
270 |
| - if (!(device_is_ready(nvm) && device_is_ready(pwm) && |
271 |
| - gpio_is_ready_dt(&button_a) && |
272 |
| - gpio_is_ready_dt(&button_b))) { |
273 |
| - printk("One or more devices are not ready\n"); |
274 |
| - return -ENODEV; |
275 |
| - } |
276 |
| - |
277 | 275 | *addr = NRF_UICR->CUSTOMER[0];
|
278 | 276 | if (!*addr || *addr == 0xffff) {
|
279 | 277 | #if defined(NODE_ADDR)
|
|
0 commit comments