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

Fix and implement generic NTC and Voltage Divider drivers #1423

Open
wants to merge 458 commits into
base: main
Choose a base branch
from

Conversation

arnew
Copy link

@arnew arnew commented Dec 12, 2023

Hi!

Upstream Zephyr has fixed the generic NTC driver and included an implementation for the Voltage Divider, as defined in the already present dts bindings.

Are there any plans to include these changes soon?

Greetings,
Arne

HaavardRei and others added 30 commits October 20, 2023 13:37
Added offset to the model relation register for vendor
models to find correct model index
for Composition Data Page 1. The previous implementation used the
'mod_idx' from the 'bt_mesh_model' struct, which led to issues in the
model relation register due to SIG and vender models having the same
model index.
Modified existing functions related to the model relation
register to take in the offset.

Modified macros for determining if a model is a base- or
extending model.

Added check in 'add_items_to_page' to check whether the model relation
is an extension.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
(cherry picked from commit 3d40d91)
Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
(cherry picked from commit 8db1558)
…FU on DFD srv

The list of receives in the Firmware Distribution Server model and
and the Firmware Update Client model are 2 different lists.

In the Firmware Update Client model it is called the Update Receives
state and the Active Update Receivers state which is a subset of
receivers from the Update Receivers State. In the Firmware Distribution
Server model it is called the Distribution Receivers List state.

When Distribute Firmware procedure starts, in the Initiate step, the
Receivers List input (which is the input for the Update Receivers
state), is composed of the Distribution Receives List state. During DFU,
the Update Receivers state becomes the Active Update Receivers state
which keeps only active nodes. Timed out or failed nodes dropped out
from this list. The Distribution Receivers List state stays unchanged
and thus don't need to be populated again after every successfull and
failed DFU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
(cherry picked from commit 68365d5)
Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
(cherry picked from commit d6191e4)
…DU fragmentation

The CIS Central uses the algorithm described in BT Core 5.4 Vol 6,
Part G, Section 2.2 to calculate the Max_PDU value for framed mode.

However, HAP needs the Max_PDU to be calculated according to "Core
enhancement for ISOAL CR" coming with the "Atlanta" update. With this
update, the fragmentation is controlled via a parameter at CIG creation.

Enabling CONFIG_BT_CTLR_CONN_ISO_AVOID_SEGMENTATION will set the
ISO_Interval to 7.5 ms for a 10 ms framed CIG, and calculate Max_PDU to
45/65 for 16/24 kHz.

Signed-off-by: Morten Priess <mtpr@oticon.com>
(cherry picked from commit 79ab982)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 8687b84)
…C event

Use the HAL event clear function to clear the RTC EVENT
instead of accessing the register directly.

This allows using an updated version of the RTC HW models
which generate level interrupts (as the real HW) and in
which if the EVEN register is not properly cleared,
the interrupts are kept high, resulting in the interrupt
handler reentering immediately after exiting.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
(cherry picked from commit 7082222)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit cbd608b)
…ENTs

Use the HAL event clear functions to clear EVENTS
instead of accessing the registers directly.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
(cherry picked from commit bb811a1)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 99ed0b6)
…e-ordering

Fix some compiler instruction re-ordering. Mayfly code with
cpu_dmb() help avoid stalled memq_ull_rx processing when
rx_demux is to be executed using mayfly.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit f206953)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit eed5fba)
…tialization

Minor clean up of redundant initialization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit afd48e0)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit a11b48a)
Fix initialization of CIS lazy_active event count used when
first CIS event is active. Now initialization for first and
any subsequent CISes made active.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 1291e4b)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 4dd81a5)
…r Central ISO

Fix missing lazy calculation when using ticker interface
required for Central CIS create.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit d42d14e)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit a5bd816)
Convert the driver to a dt-based device. Also update Kconfig so that it
depends on the right compatible being enabled, initialize in POST_KERNEL
(APPLICATION should not be used for devices) and remove one redundant
include.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
(cherry picked from commit 4f80e50)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit a226209)
… original value

Revert back the EVENT_OVERHEAD_END_US value to original
value in initial commit 5c3709c ("bluetooth:
controller: Add def's re. update to slot reservation calc").

40 us is a sufficient margin considering ~30 us being the
worst case Rx chain delay for S8 Coded PHY on nRF5x SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit c986104)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 6e41294)
…r.h consistent

Make openisa and unit test hal ticker.h consistent with
nrf hal ticker.h.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 01314b2)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit ce4fd38)
… for ticks_slot

Use HAL_TICKER_US_TO_TICKS_CEIL for ticks_slot calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 333ff94)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 8412da5)
…seconds

Use defines for femto and pico seconds in HAL ticker
calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 34100cb)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit f1517bc)
…icker

Use DIV_ROUND_UP macro in HAL ticker.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 5daa864)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 96ebab1)
…d TX and RX bugfix

Changes:
-- Disregards target event after segmenting the first TX SDU and instead
   decide event based on the next payload and feasibility to fragment
   for that event (time-offset > 0)
-- Corrected error SDU release logic when an error occurs while
   expecting the start of a new SDU, to avoid releasing an SDU which
   could be received in the next payload or event
-- Included additional debug logging

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
(cherry picked from commit e318a30)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 40fdecb)
…nness

Changes:
-- Corrected reading and writing time offset in framed segment header to
   account for endianness
-- Corrected bit positioning of time offset bit field in the segment
   header structure definition
-- Fixed upstream Zephyr BSIM test build failure due to debug logging
   39-bit variable

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
(cherry picked from commit 31df0ef)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit e0122d7)
… of TX time stamps

Intent is to pass Ellisys ISOAL quality tests for framed TX scenarios
where the TX SDU includes a time stamp that is not based on the
controller's clock.

Changes:
-- Include controller's reception time as a separate field in the TX SDU
   information
-- Include decision on whether SDU time stamp is valid and based on the
   controller's clock
-- Arbitrate and select / compute time stamp for the SDU

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
(cherry picked from commit d414cab)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 9c58cfc)
…rror

In case of unframed iso rx, length field cannot be trusted in case of
PDU error.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
(cherry picked from commit 365a56c)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit aff4981)
…gging

Included kconfigs to set the ISO-AL logging level and control debug
logging verbosity.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
(cherry picked from commit b964362)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 5951daa)
…e started

Fix ticker implementation to prefer to keep ticker node
started in case of race condition to start and stop.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit f4e05e3)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 31efdfb)
…quested flag

Fix the order of setting the flag that indicates that
preempt timeout has been successfully requested versus
the request is waiting to be scheduled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 4cefcb6)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 4393623)
…valid status

Fix HCI LE Set Extended Advertising Parameter Command
invalid status reason.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 879c611)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit ae5d8e2)
… for skipped events"

These change are reverted as part of fixing regression
failure in LL/DDI/SCN/BV-21-C and LL/DDI/SCN/BV-25-C.

This reverts commit 0d54ca8.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 9178130)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 69d2075)
…pare pipeline

Use the state/role context parameter in prepare pipeline
to identify the preempt timeout that was setup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit dacadf2)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 3494cea)
…eck short prepare

Use ticker_ticks_diff_get consistently when calculating
difference between ticker ticks when determining short
prepare requests.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 67a2fc4)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 0d3ec77)
…server

Fix ticks_slot_window use in Observer, do not use for
unreserved continuous scanning, and do not use when scanning
on both 1M and Coded PHY simultaneously.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 377e2a1)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 13b4224)
…ueued in pipeline

Fix short prepare handling when more than one event is
enqueued in the pipeline and the short prepare is placed at
the end of the prepare pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 7f388bb)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit f200aa6)
…ion code

Refactor/rename prepare dequeue iteration code and reuse it.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit c1042df)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 0a00dd7)
…on Extended Scan

Reduce number of successive calls to ticker_job() by
disabling mayflies in the ULL_HIGH priority, enqueue
ticker_yield_abs() and ticker_start() before re-enabling
so that single ticker_job() handles both yield and start.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 02b1c76)
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 1902bae)
Paweł Anikiel and others added 8 commits December 12, 2023 10:17
Fix the flipped condition inside this if statement.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
The pullup resistance was assumed to be the maximum ADC value. This is
incorrect when the reference ADC voltage and the thermistor pullup
voltage differ. Use the pullup_uv property from DT instead.

The equations for the thermistor resistance are also wrong. The correct
equations are (see https://en.wikipedia.org/wiki/Voltage_divider):
R1 = R2 * (Vin / Vout - 1)
for the positive-connected resistor, and
R2 = R1 * (Vin / Vout - 1)^-1
for the negative-connected resistor. These were transformed so that
they can be computed using integer math.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
The value of n_comp is wrong for ntc-thermistor-generic. Introduce a
helper macro to compute n_comp correctly for both thermistor types.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
bsearch() tries to find the exact match for the key, otherwise it
returns NULL. However, here we want to find two elements our key lies
in-between. This requires some rather complicated logic that pretends
it found the exact match even if it didn't. Replace this with a simple
implementation of binary search.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
Remove the r25-ohm property. It is not used by the driver, and it is
not present in linux.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
Add murata,ncp15wb473 property together with a compensation table. The
table can be found on the vendor's website
(Resistance VS. Temperature tab):
https://www.murata.com/en-us/products/productdetail?partno=NCP15WB473F03RC

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
Add support for runtime power management.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
Adds compensation table and bindings for NTCG103JF103FT1 thermistor

Signed-off-by: Maxmillion McLaughlin <github@maxmclau.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.