-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b77adb
commit 9342371
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) 2023 Nordic Semiconductor ASA. | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
|
||
if (CONFIG_BOARD_NRF9131EK_NRF9131 OR CONFIG_BOARD_NRF9131EK_NRF9131_NS) | ||
zephyr_library() | ||
zephyr_library_sources(npm1300.c) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Thingy:91 nRF9161 board configuration | ||
# | ||
# Copyright (c) 2019 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
|
||
if BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS | ||
|
||
config BOARD_INIT_PRIORITY | ||
int "Initialization priority for board configuration" | ||
default 80 | ||
|
||
endif # BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS | ||
|
||
module=BOARD | ||
module-dep=LOG | ||
module-str=Log level for board | ||
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/init.h> | ||
#include <zephyr/logging/log.h> | ||
#include <zephyr/device.h> | ||
#include <zephyr/drivers/i2c.h> | ||
|
||
LOG_MODULE_REGISTER(board_secure, CONFIG_BOARD_LOG_LEVEL); | ||
|
||
#define CHECKERR if (err) {LOG_ERR("I2C error: %d", err); return err;} | ||
|
||
static const struct i2c_dt_spec pmic = I2C_DT_SPEC_GET(DT_NODELABEL(pmic_main)); | ||
|
||
static int pmic_write_reg(uint16_t address, uint8_t value) | ||
{ | ||
uint8_t buf[] = { | ||
address >> 8, | ||
address & 0xFF, | ||
value, | ||
}; | ||
|
||
return i2c_write_dt(&pmic, buf, ARRAY_SIZE(buf)); | ||
} | ||
|
||
static int thingy91x_board_init(void) | ||
{ | ||
int err = 0; | ||
|
||
if (!device_is_ready(pmic.bus)) { | ||
LOG_ERR("cannot reach PMIC!"); | ||
return -ENODEV; | ||
} | ||
|
||
// disable charger for config | ||
err = pmic_write_reg(0x0305, 0x03); CHECKERR; | ||
|
||
// set VBUS current limit 500mA | ||
Check failure on line 42 in boards/arm/nrf9131ek_nrf9131/npm1300.c GitHub Actions / Run compliance checks on patch series (PR)TRAILING_WHITESPACE
|
||
err = pmic_write_reg(0x0201, 0x00); CHECKERR; | ||
err = pmic_write_reg(0x0202, 0x00); CHECKERR; | ||
err = pmic_write_reg(0x0200, 0x01); CHECKERR; | ||
|
||
// enable charger | ||
err = pmic_write_reg(0x0304, 0x03); CHECKERR; | ||
|
||
return err; | ||
} | ||
|
||
SYS_INIT(thingy91x_board_init, POST_KERNEL, CONFIG_BOARD_INIT_PRIORITY); |