devicetree: add DT_INST_NUM_IRQS()

Add `DT_INST_NUM_IRQS()` to get the number of interrupt lines
of the current `DT_DRV_COMPAT`

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
Yong Cong Sin 2024-08-29 22:36:45 +08:00 committed by Alberto Escolar
parent 707844ca56
commit ee08ebd9ca
2 changed files with 11 additions and 0 deletions

View file

@ -4234,6 +4234,14 @@
*/
#define DT_INST_REG_SIZE(inst) DT_INST_REG_SIZE_BY_IDX(inst, 0)
/**
* @brief Get a `DT_DRV_COMPAT`'s number of interrupts
*
* @param inst instance number
* @return number of interrupts
*/
#define DT_INST_NUM_IRQS(inst) DT_NUM_IRQS(DT_DRV_INST(inst))
/**
* @brief Get a `DT_DRV_COMPAT` interrupt level
*

View file

@ -751,6 +751,9 @@ ZTEST(devicetree_api, test_irq)
/* DT_INST */
zassert_equal(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT), 1, "");
/* DT_INST_NUM_IRQS */
zassert_equal(DT_INST_NUM_IRQS(0), 3);
/* DT_INST_IRQ_HAS_IDX */
zassert_equal(DT_INST_IRQ_HAS_IDX(0, 0), 1, "");
zassert_equal(DT_INST_IRQ_HAS_IDX(0, 1), 1, "");