device: Add DT_INST versions of DEVICE_DT_DECLARE and DEVICE_DT_DEFINE

Add convenience macros versions of DEVICE_DT_DECLARE and
DEVICE_DT_DEFINE that take a DT_INST number instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-12-02 11:21:46 -06:00 committed by Kumar Gala
commit 3a83f0ec69

View file

@ -172,6 +172,19 @@ extern "C" {
pm_control_fn, \
data_ptr, cfg_ptr, level, prio, api_ptr)
/**
* @def DEVICE_DT_INST_DEFINE
*
* @brief Like DEVICE_DT_DEFINE for an instance of a DT_DRV_COMPAT compatible
*
* @param inst instance number. This is replaced by
* <tt>DT_DRV_COMPAT(inst)</tt> in the call to DEVICE_DT_DEFINE.
*
* @param ... other parameters as expected by DEVICE_DT_DEFINE.
*/
#define DEVICE_DT_INST_DEFINE(inst, ...) \
DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
/**
* @def DEVICE_DT_NAME_GET
*
@ -209,6 +222,15 @@ extern "C" {
*/
#define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
/** @def DEVICE_DT_INST_GET
*
* @brief Obtain a pointer to a device object for an instance of a
* DT_DRV_COMPAT compatible
*
* @param inst instance number
*/
#define DEVICE_DT_INST_GET(inst) DEVICE_DT_GET(DT_DRV_INST(inst))
/** @def DEVICE_DT_DECLARE
*
* @brief Declare a device object associated with @p node_id
@ -236,6 +258,15 @@ extern "C" {
#define DEVICE_DT_DECLARE(node_id) \
extern const struct device DEVICE_DT_NAME_GET(node_id)
/** @def DEVICE_DT_INST_DECLARE
*
* @brief Declare a device object associated for an instance of a
* DT_DRV_COMPAT compatible
*
* @param inst instance number
*/
#define DEVICE_DT_INST_DECLARE(inst) DEVICE_DT_DECLARE(DT_DRV_INST(inst))
/**
* @def DEVICE_GET
*