`bt_recv` is invoked from the BT long work queue, which is preemptible.
The host uses cooperative scheduling to ensure thread safety.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Provide support for reading events longer than 127 bytes in
ST SPI protocol v1 by splitting them into several SPI transactions.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
This config selects a variant of the HCI driver interface that spills
out host internals unto the drivers and even the Zephyr controller. It
will now be removed in favor of driver interfaces that hide the
internals of the host.
The new default is `CONFIG_BT_RECV_WORKQ_BT`.
Any references to the removed kconfig are refactored out.
Any out-of-tree driver using the removed interface can be easily adapted
by copying the following implementations into the driver as private
functions:
- `hci_driver.h:BT_HCI_EVT_FLAG_RECV_PRIO`
- `hci_driver.h:BT_HCI_EVT_FLAG_RECV`
- `hci_driver.h:bt_hci_evt_get_flags`
- `hci_raw.c:bt_recv_prio`
In combination these symbols function as a interface adapter. These
symbols will be removed in this PR in subsequent commits.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Use SPI_LOCK_ON to lock configuration for multiple transaction while CS is
kept low.
Change control of CS line from direct GPIO manipulation to SPI driver API.
Signed-off-by: Michele Sardo <msmttchr@gmail.com>
Use the nrf_reset_network_force_off() function to release and set the
force-off signal.This ensures that the workaround for errata 161 is
applied.
Signed-off-by: Vidar Berg <vidar.berg@nordicsemi.no>
Exclude devices based on ST SPI protocol v2 from special handling of
hci_reset opcode as it is redundant.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
Add raw mode in ST HCI SPI BT driver to support host-less configuration.
Remove compilation dependency for BT_QUIRK_NO_RESET as it applies to all
configurations.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
In the case that there are no more ISO buffers left,
"No available ISO buffers" is logged. However, given the
nature of ISO where we are (very) likely to get additional ISO
very soon after (typically every 7.5 or 10ms for audio),
this will get logged a lot, and the logging may in some
cases actually prevent the application from handling and
freeing existng buffers due to the immense logging,
which may make this (minor) issue into a blocking issue.
This is fixed by reducing the logging to the first
occurence, and then only every 100 afterwards, which has
shown to reduce the risk of this effectively blocking
the application.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A payload size of 0xFF is valid and should not be a reason to keep
looping for more headers. The complete reqiurement is now:
```
header_slave[STATUS_HEADER_READY] == READY_NOW &&
header_slave[STATUS_HEADER_TOREAD] > 0
```
This fixes events being dropped when the payload size is 255.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Provide multiple write transaction support for BlueNRG-MS, st_hci_spi_v1
protocol. Since by default, BlueNRG-MS write buffer supports up to 127
bytes; however, it is possible to have consecutive write transactions
so as to send data more than 127 bytes.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
This change renames the RX message buffer from g_hciRxMsg to rxmsg,
as it does not follow the Zephyr coding style.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
This change relocates the tx/rx message buffer from the .bss section
to the .noinit section. This adjustment is aimed at reducing boot time by
lowering the size of the .bss section, without impacting the operational
functionality of the buffer.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Fix issue #66806, caused by PR #65172.
Return -EINVAL from bt_spi_get_header if op is neither SPI_READ nor
SPI_WRITE.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
This commits create the dts binding for Ambiq BT HCI instance.
And create the SPI based common HCI driver for Ambiq Apollox
Blue SoC and the extended soc driver for HCI.
Signed-off-by: Aaron Ye <aye@ambiq.com>
Remove BT_SPI_BLUENRG Kconfig parameter as it is redundant according to
the new changes introduced by ST SPI protocol V1 and V2.
Remove "config BT_SPI_BLUENRG" from the boards that were using it.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
Introduce STMicroelectronics SPI protocol V2 which is used in BlueNRG-1
and successor devices.
Change the size of the variable "size" to 16 bits as it is necessary for ST
BlueNRG-1 and successor devices.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
Replace the header acquisition scope in bt_spi_send with bt_spi_get_header.
Add WRITE_DATA_CONDITION in order not to retransmit data without reading
the header as it is meaningless for ST BlueNRG devices.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
Update structure of spi.c to have a better and cleaner separation
between STMicroelectronics and Zephyr SPI protocol.
Introduce bt_spi_get_header to separate algorithms well for
header acquisition in different protocols.
Remove header acquisition from bt_spi_rx_thread to make it simpler.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
Enforcing the peer's behavior is not strictly necessary. All the host
should do is make sure it is resilient to a spec-violating peer.
Moreover, a growing number of platforms were disabling the check, as the
spec allows "batching" HCI num complete packets events, stalling ATT RX.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
If no public address was set, it should just do nothing instead of
erroring. The function should also be static and there's no need to copy
the address struct.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
STM32CubeWB v1.18.0 replaces Master with Central & Slave with Peripheral
in the file app_conf.h (modified in the commit updating lib/stm32wb)
Signed-off-by: Abderrahmane Jarmouni <abderrahmane.jarmouni-ext@st.com>
Make sure that events flagged as high priority are handled when
CONFIG_BT_RECV_BLOCKING is not defined.
Fix for #65892.
Signed-off-by: Michele Sardo <msmttchr@gmail.com>
The zephyr bluetooth stack expects the controller to know its public
address, if any. At least for BlueNRG, the public address is forgotten with
every reset/power cycle, so there needs to be a way to set it from within
zephyr. This is accomplished using the `Aci_Hal_Write_Config_Data` HCI
command, as described in PM0237.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
"LL only" is not the only config option of potential interest, e.g. the
public address is also important.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
This allows HCI drivers to expose vendor-specific functions to set the
public address.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
Increase the SPI RX driver stack size by 128 bytes. Overflows have
previously been observed on real hardware at the default stack size of
512.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The HCI receive path has a delay between reading the header and payload
from the controller to give the controller time to setup the SPI
peripheral for the next transaction. Add the same delay on the transmit
path for the same reasons.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add log output when the HCI interface is forced to retransmit a packet
because the controller is not ready.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Modify SPI configuration to match the features introduced in PR #63437.
Set the property "controller-data-delay-us" to zero for boards
which are using BlueNRG-MS.
Fix Chip Select configuration for stm32l562e_dk board.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
The existing driver and sample:
- drivers/bluetooth/hci/rpmsg
- samples/bluetooth/hci_rpmsg
are no longer correctly named, since they now use the IPC subsystem to
send and receive data. The IPC subsystem can use RPMsg as a transport,
but that is one of several selectable backends.
I initially wanted to deprecated both the BT_RPMSG Kconfig option as
well as the zephyr,bt-hci-rpmsg-ipc chosen node in Devicetree. However,
this proved to be undoable in the case of the Kconfig option. This is
because it's a choice option, and those have special behavior. In
particular, the only practical way to deprecate would've been to keep
the old Kconfig option outside the choice (much like it's done in this
commit) but then also add a 'depends on !BT_RPMSG' on each of the
remaining choice symbols *except* on the new BT_HCI_IPC one. This, however,
only works correctly for .conf files. If a board instead sets the
default BT_HCI_BUS_TYPE in the Kconfig.defconfig file then the Kconfig
tree parsing would fail, because it'd try to set it to a value
(BT_RPMSG) that is no longer part of the choice.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>