Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDSW, IBATT and NRF9160 examples #9

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
examples/target
examples/*/target
4 changes: 4 additions & 0 deletions .vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.cortex-debug.*.json
launch.json
tasks.json
*.cfg
11 changes: 11 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
33 changes: 33 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"[toml]": {
"editor.formatOnSave": false
},
"[markdown]": {
"editor.formatOnSave": false
},
"rust-analyzer.check.allTargets": false,
"rust-analyzer.check.noDefaultFeatures": true,
"rust-analyzer.cargo.noDefaultFeatures": true,
"rust-analyzer.showUnlinkedFileNotification": false,
// Uncomment the target of your chip.
//"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
//"rust-analyzer.cargo.target": "thumbv7m-none-eabi",
"rust-analyzer.cargo.target": "thumbv7em-none-eabi",
//"rust-analyzer.cargo.target": "thumbv7em-none-eabihf",
//"rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
"rust-analyzer.cargo.features": [
// Comment out these features when working on the examples. Most example crates do not have any cargo features.
//"stm32f446re",
//"time-driver-any",
//"unstable-pac",
//"exti",
//"rt",
],
"rust-analyzer.linkedProjects": [
// To work on the examples, comment the line above and all of the cargo.features lines,
// then uncomment ONE line below to select the chip you want to work on.
// This makes rust-analyzer work on the example crate and all its dependencies.
"examples/nrf9160/Cargo.toml",
//"examples/nrf52840/Cargo.toml",
],
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ This crate provides both low-level register access and a high-level API for mana
| SYSREG — System regulator | ✅ | ✅ |
| CHARGER — Battery charger | ✅ | ✅ |
| BUCK — Buck regulators | ✅ | ✅ |
| LOADSW/LDO — Load switches/LDO regulators | ❌ | ❌ |
| LOADSW — Load switches | ✅ | ✅ |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like many LOADSW configuration registers are not supported LDSW1GPISEL, LDSWCONFIG, LDSW1LDOSEL, LDSW1VOUTSEL, etc.
If that's really the case, I suggest making it explicit in the README and create an issue to add support for those registers.

| LDO — LDO regulators | ❌ | ❌ |
| LEDDRV — LED drivers | ✅ | ✅ |
| GPIO — General-purpose I/O | ✅ | ✅ |
| ADC - System Monitor | ✅ | ⚠️ |
Expand Down
117 changes: 115 additions & 2 deletions device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ ADC:
description: VSYS measurement result LSBs
ADCVBATBURSTRESULTMSB:
type: register
description: ADC VBAT (or VBUS) burst measurement result MSB
description: ADC VBAT (or VBUS) burst measurement result MSB or IBAT/vbat measurement
access: ReadOnly
address: 0x16
repeat:
Expand All @@ -1708,7 +1708,7 @@ ADC:
description: ADC VBAT (or VBUS) burst measurement result upper 8-bits
ADCGP1RESULTLSBS:
type: register
description: ADC result LSB's (VBAT burst 0, 1, 2 and 3)
description: ADC result LSB's (VBAT burst 0, 1, 2 and 3) or 2 IBAT/ 3 VBUS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that VBAT2RESULTLSB contains IBAT LSB and VBAT3RESULTLSB VBUS LSB?

access: ReadOnly
address: 0x1A
size_bits: 8
Expand Down Expand Up @@ -1749,6 +1749,14 @@ ADC:
start: 0
end: 1
description: Enable auto IBAT measurement after VBAT task
conversion:
name: IBATMEASENABLE
IBATOFF:
value: 0
description: IBAT measurement disabled
IBATON:
value: 1
description: IBAT measurement enabled

POF:
type: block
Expand Down Expand Up @@ -1989,3 +1997,108 @@ SHIP:
SHPHLDGPIO0:
value: 1
description: SHPHLD + GPIO0 buttons

LDSW:
type: block
description: LOADSW registers
address_offset: 0x0800
objects:
LDSWSET:
type: command
description: Enable LDSW
address: 0x00
repeat:
count: 2
stride: 2
size_bits_in: 1
fields_in:
TASKLDSWSET:
base: uint
start: 0
end: 1
description: LDSW Enable request SET
try_conversion: crate::common::Task
LDSWCLR:
type: command
description: Disable LDSW1
address: 0x01
size_bits_in: 1
repeat:
count: 2
stride: 2
fields_in:
TASKLDSWCLR:
base: uint
start: 0
end: 1
description: LDSW Disable request CLR
try_conversion: crate::common::Task
LDSWSTATUS:
type: register
description: Load Switch Status
access: RO
address: 0x04
size_bits: 8
reset_value: 0x00
fields:
LDSW1PWRUPLDSW:
base: uint
start: 0
end: 1
description: Current status of LDSW1
access: ReadOnly
conversion:
name: LDSW1PWRUPLDSW
LDSWDISABLED:
value: 0
description: LDSW powered off
LDSWPOWERED:
value: 1
description: LDSW powered on
LDSW1PWRUPLDO:
base: uint
start: 1
end: 2
description: Current status of LDO1
access: ReadOnly
conversion:
name: LDSW1PWRUPLDO
LDODISABLED:
value: 0
description: LDO powered off
LDOPOWERED:
value: 1
description: LDO powered on
LDSW2PWRUPLDSW:
base: uint
start: 2
end: 3
description: Current status of LDSW2
access: ReadOnly
conversion:
name: LDSW2PWRUPLDSW
LDSWDISABLED:
value: 0
description: LDSW powered off
LDSWPOWERED:
value: 1
description: LDSW powered on
LDSW2PWRUPLDO:
base: uint
start: 3
end: 4
description: Current status of LDO2
access: ReadOnly
conversion:
name: LDSW2PWRUPLDO
LDODISABLED:
value: 0
description: LDO powered off
LDOPOWERED:
value: 1
description: LDO powered on
LDSWENABLE:
base: uint
start: 4
end: 5
description: Status of LDSW[n] and LDO[n]
File renamed without changes.
21 changes: 10 additions & 11 deletions examples/Cargo.lock → examples/nrf52840/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/Cargo.toml → examples/nrf52840/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }

npm1300-rs = { path = "../", features = ["defmt-03"] }
npm1300-rs = { path = "../../", features = ["defmt-03"] }

[patch.crates-io]
embassy-nrf = { git = "https://github.com/embassy-rs/embassy.git", rev = "796f6c034a148e1fedb3196a2c73a155f5d0545f" }
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions examples/nrf9160/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# runner = "probe-rs run --chip nRF9160_xxAA"
runner = [ "probe-rs", "run", "--chip=nRF9160_xxAA", "--always-print-stacktrace", "--log-format={t} {[{L}]%bold} {s} {{c} {ff}:{l:1}%dimmed}" ]

[build]
target = "thumbv8m.main-none-eabihf"

[env]
DEFMT_LOG = "trace"
Loading