This commit adds a Bluetooth HCI UART lower half driver for the STM32

Squashed commit of the following:

    arch/arm/src/stm32:  Add Kconfig options needed by the HCI UART.  Various fixes to finally get a clean error free compile with no unexpected warnings.
    arch/arm/src/stm32:  In HCI UART, use spin_lock_irqsave() instead of enter_critical_section() whenever possible.
    arch/arm/src/stm32:  In HCI UART, fix up naming of configurations so that they are unique.  Still needs Kconfig settings.  Modify logic so that there can be multiple HCI UARTs, some supporting DMA and some not.
    arch/arm/src/stm32:  Integrate watermarks and software Rx flow control into the HCI UART driver.
    arch/arm/src/stm32:  Eliminate some HCI UART UART configuration options.  Per the HCI UART spec, the link will b 8 data bits, no parity, 1 stop bit... Always.
    arch/arm/src/stm32:  Trivial cleanup
    arch/arm/src/stm32:  Fixes most initial compilation issues STM32 HCI UART driver.  Still need to set up USART configuration parmeters for HCI UART
    arch/arm/src/stm32:  Completes first cut at STM32 HCI UART driver.
    arch/arm/src/stm32:  Completes most of read logic for HCI UART.  Still needs to be able to block if no read data is available.  Still missing write and flush logic.
    drivers/wireless:    Remove txenable from HCI UART methods.  arch/arm/src/stm32:  Reorganize some structures in HCI UART.
    arch/arm/src/stm32:  Still messaging the HCI uart driver.
    arch/arm/src/stm32:  Some trivial renaming.
    arch/arm/src/stm32:  A little more HCI-UART logic.
    arch/arm/src/stm32:  Initial setup to support HCI-UART.  Little more than the serial driver with some name changes and a few things removed.
This commit is contained in:
Gregory Nutt
2018-04-13 10:36:23 -06:00
parent e8832be8f1
commit d25549ac54
11 changed files with 2915 additions and 46 deletions
File diff suppressed because it is too large Load Diff
+4
View File
@@ -240,6 +240,10 @@ ifeq ($(CONFIG_STM32_1WIREDRIVER),y)
CHIP_CSRCS += stm32_1wire.c
endif
ifeq ($(CONFIG_STM32_HCIUART),y)
CHIP_CSRCS += stm32_hciuart.c
endif
ifeq ($(CONFIG_STM32_RNG),y)
CHIP_CSRCS += stm32_rng.c
endif
File diff suppressed because it is too large Load Diff
+15 -9
View File
@@ -247,7 +247,7 @@
# define GPIO_CAN2_TX GPIO_CAN2_TX_1
#endif
/* UART2:
/* USART2:
*
* The STM32F4 Discovery has no on-board serial devices, but the console is
* brought out to PA2 (TX) and PA3 (RX) for connection to an external serial
@@ -257,23 +257,29 @@
*/
#ifndef CONFIG_STM32F4DISBB
# define GPIO_USART2_RX GPIO_USART2_RX_1
# define GPIO_USART2_TX GPIO_USART2_TX_1
# define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */
# define GPIO_USART2_TX GPIO_USART2_TX_1 /* PA2 */
#endif
/* UART3: (Used in pseudoterm configuration) */
/* USART3:
*
* Used in pseudoterm configuration and also with the BT860 HCI UART.
* RTS/CTS Flow control support is need by the HCI UART.
*/
#define GPIO_USART3_TX GPIO_USART3_TX_1
#define GPIO_USART3_RX GPIO_USART3_RX_1
#define GPIO_USART3_TX GPIO_USART3_TX_1 /* PB10 */
#define GPIO_USART3_RX GPIO_USART3_RX_1 /* PB11 */
#define GPIO_USART3_CTS GPIO_USART3_CTS_1 /* PB13 */
#define GPIO_USART3_RTS GPIO_USART3_RTS_1 /* PB14 */
/* UART6:
/* USART6:
*
* The STM32F4DIS-BB base board provides RS-232 drivers and a DB9 connector
* for USART6. This is the preferred serial console for use with the STM32F4DIS-BB.
*/
#define GPIO_USART6_RX GPIO_USART6_RX_1
#define GPIO_USART6_TX GPIO_USART6_TX_1
#define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */
#define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */
/* PWM
*
+5 -6
View File
@@ -198,8 +198,8 @@ static FAR struct bt_buf_s *btuart_acl_recv(FAR struct btuart_upperhalf_s *upper
return buf;
}
static void btuart_interrupt(FAR const struct btuart_lowerhalf_s *lower,
FAR void *arg)
static void btuart_rxcallback(FAR const struct btuart_lowerhalf_s *lower,
FAR void *arg)
{
FAR struct btuart_upperhalf_s *upper;
static FAR struct bt_buf_s *buf;
@@ -343,16 +343,15 @@ static int btuart_open(FAR const struct bt_driver_s *dev)
DEBUGASSERT(upper != NULL && upper->lower != NULL);
lower = upper->lower;
/* Disable Tx and Rx interrupts */
/* Disable Rx callbacks */
lower->txenable(lower, false);
lower->rxenable(lower, false);
/* Drain any cached Rx data */
(void)lower->rxdrain(lower);
/* Enable Rx interrupts */
/* Re-enable Rx callbacks */
lower->rxenable(lower, true);
return OK;
@@ -405,7 +404,7 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
/* Attach the interrupt handler */
lower->attach(lower, btuart_interrupt, upper);
lower->rxattach(lower, btuart_rxcallback, upper);
/* And register the driver with the Bluetooth stack */
+2 -1
View File
@@ -46,6 +46,7 @@
* Included Files
****************************************************************************/
#include <nuttx/wireless/wireless.h>
#include <nuttx/wireless/bt_core.h>
#include <nuttx/wireless/bt_hci.h>
@@ -58,7 +59,7 @@
/* Bluetooth network device IOCTL commands. */
#ifndef WL_BLUETOOTHCMDS != 16
#if !defined(WL_BLUETOOTHCMDS) || WL_BLUETOOTHCMDS != 16
# error Incorrect setting for number of Bluetooth IOCTL commands
#endif
+27 -11
View File
@@ -55,11 +55,11 @@
****************************************************************************/
/* This is the type of the Bluetooth UART upper-half driver interrupt
* handler used with the struct btuart_lowerhalf_s attach() method.
* callback used with the struct btuart_lowerhalf_s attach() method.
*/
struct btuart_lowerhalf_s;
typedef CODE void (*btuart_handler_t)
typedef CODE void (*btuart_rxcallback_t)
(FAR const struct btuart_lowerhalf_s *lower, FAR void *arg);
/* The Bluetooth UART driver is a two-part driver:
@@ -77,19 +77,35 @@ typedef CODE void (*btuart_handler_t)
struct btuart_lowerhalf_s
{
/* Attach the upper half interrupt handler */
CODE void (*attach)(FAR const struct btuart_lowerhalf_s *lower,
btuart_handler_t handler, FAR void *arg);
/* Enable/disable RX/TX interrupts from the UART. */
/* Attach/enable the upper half Rx interrupt callback.
*
* rxattach() allows the upper half logic to attach a callback function
* that will be used to inform the upper half that an Rx frame is
* available. This callback will, most likely, be invoked in the
* context of an interrupt callback. The receive() method should then
* be invoked in order to receive the obtain the Rx frame data.
* rxenable() may be used to enable or disable callback events. This
* probably translates to enabling and disabled Rx interrupts at
* the UART. NOTE: Rx event notification should be done sparingly:
* Rx data overrun may occur when Rx events are disabled!
*/
CODE void (*rxattach)(FAR const struct btuart_lowerhalf_s *lower,
btuart_rxcallback_t callback, FAR void *arg);
CODE void (*rxenable)(FAR const struct btuart_lowerhalf_s *lower,
bool enable);
CODE void (*txenable)(FAR const struct btuart_lowerhalf_s *lower,
bool enable);
/* Read/write UART data */
/* Read/write UART frames
*
* read() after receipt of a callback notifying the upper half of the
* availability of Rx frame, the upper half may call the receive()
* method in order to obtain the buffered Rx frame data.
* write() will add the outgoing frame to the Tx buffer and will return
* immediately. This function may block only in the event that there
* is insufficient buffer space to hold the Tx frame data. In that
* case the lower half will block until there is sufficient to buffer
* the entire outgoing packet.
*/
CODE ssize_t (*read)(FAR const struct btuart_lowerhalf_s *lower,
FAR void *buffer, size_t buflen);
-3
View File
@@ -53,8 +53,6 @@
#include <net/if.h>
#include <nuttx/fs/ioctl.h>
#ifdef CONFIG_DRIVERS_WIRELESS
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
@@ -564,5 +562,4 @@ struct iw_scan_req
struct iw_freq channel_list[IW_MAX_FREQUENCIES];
};
#endif /* CONFIG_DRIVERS_WIRELESS */
#endif /* __INCLUDE_NUTTX_WIRELESS_WIRELESS_H */
+1
View File
@@ -565,6 +565,7 @@ void bt_conn_set_state(FAR struct bt_conn_s *conn,
CONFIG_BLUETOOTH_TXCONN_STACKSIZE,
conn_tx_kthread, NULL);
DEBUGASSERT(pid > 0);
UNUSED(pid);
/* Take the semaphore again. This will force us to wait with the
* sem_count at -1. It will be zero again when we continue.
+3 -1
View File
@@ -316,12 +316,14 @@ static void hci_num_completed_packets(FAR struct bt_buf_s *buf)
for (i = 0; i < num_handles; i++)
{
uint16_t handle, count;
uint16_t handle;
uint16_t count;
handle = BT_LE162HOST(evt->h[i].handle);
count = BT_LE162HOST(evt->h[i].count);
wlinfo("handle %u count %u\n", handle, count);
UNUSED(handle);
while (count--)
{
+1
View File
@@ -938,6 +938,7 @@ static int btnet_req_data(FAR struct radio_driver_s *netdev,
NETDEV_TXDONE(&priv->bd_dev.r_dev);
}
UNUSED(priv);
return OK;
}