change(ldo): make ldo driver unit_id same as datasheet

Prior to this commit, we expect passing ldo_unit_t to esp_ldo driver
`ldo_unit` field. And ldo_unit_t will alias the LDO unit to values
starting from 0, e.g. LDO_UNIT_1 is actually value 0.

With this commit, esp_ldo driver `ldo_unit` field will start with 1,
which is aligned with the datasheet. So LDO_UNIT_1 is in value 1,
meanwhile setting 1 to `ldo_unit` will work as well.
This commit is contained in:
Armando
2024-01-08 10:52:01 +08:00
parent 86707a3af6
commit 1adea4ab66
6 changed files with 42 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -54,6 +54,17 @@ extern "C" {
*/
#define LDO_ID2UNIT(ldo_id) ((ldo_id) - 1)
/**
* @brief Check if a LDO ID is valid
*
* @return True for valid
*/
__attribute__((always_inline))
static inline bool ldo_ll_is_valid_ldo_id(int ldo_id)
{
return ((ldo_id > 0) && (ldo_id <= LDO_LL_UNIT_NUM));
}
/**
* @brief Enable a LDO
*