drivers: bluetooth: hci: add close function for Ambiq Apollo3x

This commit adds the bt_hci_driver.close function for Ambiq
Apollo3x SoC. Also update the hal_ambiq revision including
the necessary support.

Signed-off-by: Aaron Ye <aye@ambiq.com>
This commit is contained in:
Aaron Ye 2024-11-05 15:16:39 +08:00 committed by Anas Nashif
commit 0439cbc29c
4 changed files with 43 additions and 1 deletions

View file

@ -341,6 +341,25 @@ int bt_apollo_controller_init(spi_transmit_fun transmit)
return ret;
}
int bt_apollo_controller_deinit(void)
{
int ret = -ENOTSUP;
#if (CONFIG_SOC_SERIES_APOLLO3X)
irq_disable(DT_IRQN(SPI_DEV_NODE));
ret = am_apollo3_bt_controller_deinit();
if (ret == AM_HAL_STATUS_SUCCESS) {
LOG_INF("BT controller deinitialized");
} else {
ret = -EPERM;
LOG_ERR("BT controller deinitialization fails");
}
#endif /* CONFIG_SOC_SERIES_APOLLO3X */
return ret;
}
#if (CONFIG_SOC_SERIES_APOLLO4X)
static int bt_apollo_set_nvds(void)
{

View file

@ -81,6 +81,13 @@ int bt_apollo_spi_rcv(uint8_t *data, uint16_t *len, bt_spi_transceive_fun transc
*/
int bt_apollo_controller_init(spi_transmit_fun transmit);
/**
* @brief Deinitialize the BLE controller.
*
* @return 0 on success or negative error number on failure.
*/
int bt_apollo_controller_deinit(void);
/**
* @brief Vendor specific setup before general HCI command sequence for
* Bluetooth application.

View file

@ -396,6 +396,21 @@ static int bt_apollo_open(const struct device *dev, bt_hci_recv_t recv)
return ret;
}
static int bt_apollo_close(const struct device *dev)
{
int ret;
struct bt_apollo_data *hci = dev->data;
ret = bt_apollo_controller_deinit();
if (ret) {
return ret;
}
hci->recv = NULL;
return ret;
}
static int bt_apollo_setup(const struct device *dev, const struct bt_hci_setup_params *params)
{
ARG_UNUSED(params);
@ -409,6 +424,7 @@ static int bt_apollo_setup(const struct device *dev, const struct bt_hci_setup_p
static const struct bt_hci_driver_api drv = {
.open = bt_apollo_open,
.close = bt_apollo_close,
.send = bt_apollo_send,
.setup = bt_apollo_setup,
};

View file

@ -147,7 +147,7 @@ manifest:
groups:
- hal
- name: hal_ambiq
revision: d3092f9b82874a1791baa3ac41c3795d108fbbdb
revision: 87a188b91aca22ce3ce7deb4a1cbf7780d784673
path: modules/hal/ambiq
groups:
- hal