diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.cpp b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.cpp index af3e34dbeb2..66e9fd9a0e1 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.cpp @@ -55,7 +55,7 @@ CyH4TransportDriver::CyH4TransportDriver(PinName tx, PinName rx, PinName cts, Pi cts(cts), rts(rts), bt_host_wake_name(bt_host_wake_name), bt_device_wake_name(bt_device_wake_name), - bt_power(bt_power_name, PIN_OUTPUT, PullNone, 0), + bt_power(bt_power_name, PIN_OUTPUT, PullUp, 0), bt_host_wake(bt_host_wake_name, PIN_INPUT, PullNone, 0), bt_device_wake(bt_device_wake_name, PIN_OUTPUT, PullNone, 1), host_wake_irq_event(host_wake_irq), diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.h b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.h index 8babd0abec4..1538372d066 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.h +++ b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.h @@ -46,9 +46,9 @@ class CyH4TransportDriver : public CordioHCITransportDriver { * Initialize the transport driver. * */ - CyH4TransportDriver(PinName tx, PinName rx, PinName cts, PinName rts, PinName bt_power_name, int baud, PinName bt_host_wake_name, PinName bt_device_wake_name, - uint8_t host_wake_irq = 0, uint8_t dev_wake_irq = 0); - CyH4TransportDriver(PinName tx, PinName rx, PinName cts, PinName rts, PinName bt_power_name, int baud); + CyH4TransportDriver(PinName tx, PinName rx, PinName cts, PinName rts, PinName bt_power_name, int baud, PinName bt_host_wake_name, PinName bt_device_wake_name, + uint8_t host_wake_irq = 0, uint8_t dev_wake_irq = 0); + CyH4TransportDriver(PinName tx, PinName rx, PinName cts, PinName rts, PinName bt_power_name, int baud); /** * Destructor diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp index 49fb0f4f072..6c781cfbaee 100644 --- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp +++ b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp @@ -75,16 +75,13 @@ class HCIDriver : public CordioHCIDriver { public: HCIDriver( ble::vendor::cypress_ble::CyH4TransportDriver& transport_driver, - PinName bt_power_name, - bool ps_enabled, - uint8_t host_wake_irq, - uint8_t dev_wake_irq + bool ps_enabled, + uint8_t host_wake_irq, + uint8_t dev_wake_irq ) : CordioHCIDriver(transport_driver), - bt_power_name(bt_power_name), - bt_power(bt_power_name, PIN_OUTPUT, PullUp, 0), - is_powersave_enabled(ps_enabled), - host_wake_irq(host_wake_irq), - dev_wake_irq(dev_wake_irq), + is_powersave_enabled(ps_enabled), + host_wake_irq(host_wake_irq), + dev_wake_irq(dev_wake_irq), service_pack_index(0), service_pack_ptr(0), service_pack_length(0), @@ -419,68 +416,68 @@ class HCIDriver : public CordioHCIDriver { void set_sleep_mode() { - uint8_t *pBuf; - if ((pBuf = hciCmdAlloc(HCI_VS_CMD_SET_SLEEP_MODE, 12)) != NULL) - { - if (is_powersave_on()) { - pBuf[HCI_CMD_HDR_LEN] = 0x01; // sleep - } else { - pBuf[HCI_CMD_HDR_LEN] = 0x00; // no sleep - } - pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // no idle threshold host (N/A) - if (is_powersave_on()) { - pBuf[HCI_CMD_HDR_LEN + 2] = 0x05; // no idle threshold HC (N/A) - } else { - pBuf[HCI_CMD_HDR_LEN + 2] = 0x00; // no idle threshold HC (N/A) - } - if (is_powersave_on()) { - pBuf[HCI_CMD_HDR_LEN + 3] = dev_wake_irq; // BT WAKE - } else { - pBuf[HCI_CMD_HDR_LEN + 3] = 0x00; // BT WAKE - } - if (is_powersave_on()) { - pBuf[HCI_CMD_HDR_LEN + 4] = host_wake_irq; // HOST WAKE - } else { - pBuf[HCI_CMD_HDR_LEN + 4] = 0x00; // HOST WAKE - } - pBuf[HCI_CMD_HDR_LEN + 5] = 0x00; // Sleep during SCO - pBuf[HCI_CMD_HDR_LEN + 6] = 0x00; // Combining sleep mode and SCM - pBuf[HCI_CMD_HDR_LEN + 7] = 0x00; // Tristate TX - pBuf[HCI_CMD_HDR_LEN + 8] = 0x00; // Active connection handling on suspend - pBuf[HCI_CMD_HDR_LEN + 9] = 0x00; // resume timeout - pBuf[HCI_CMD_HDR_LEN + 10] = 0x00; // break to host - pBuf[HCI_CMD_HDR_LEN + 11] = 0x00; // Pulsed host wake - hciCmdSend(pBuf); + uint8_t *pBuf; + if ((pBuf = hciCmdAlloc(HCI_VS_CMD_SET_SLEEP_MODE, 12)) != NULL) + { + if (is_powersave_on()) { + pBuf[HCI_CMD_HDR_LEN] = 0x01; // sleep + } else { + pBuf[HCI_CMD_HDR_LEN] = 0x00; // no sleep + } + pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // no idle threshold host (N/A) + if (is_powersave_on()) { + pBuf[HCI_CMD_HDR_LEN + 2] = 0x05; // no idle threshold HC (N/A) + } else { + pBuf[HCI_CMD_HDR_LEN + 2] = 0x00; // no idle threshold HC (N/A) + } + if (is_powersave_on()) { + pBuf[HCI_CMD_HDR_LEN + 3] = dev_wake_irq; // BT WAKE + } else { + pBuf[HCI_CMD_HDR_LEN + 3] = 0x00; // no BT WAKE + } + if (is_powersave_on()) { + pBuf[HCI_CMD_HDR_LEN + 4] = host_wake_irq; // HOST WAKE + } else { + pBuf[HCI_CMD_HDR_LEN + 4] = 0x00; // no HOST WAKE } + pBuf[HCI_CMD_HDR_LEN + 5] = 0x00; // Sleep during SCO + pBuf[HCI_CMD_HDR_LEN + 6] = 0x00; // Combining sleep mode and SCM + pBuf[HCI_CMD_HDR_LEN + 7] = 0x00; // Tristate TX + pBuf[HCI_CMD_HDR_LEN + 8] = 0x00; // Active connection handling on suspend + pBuf[HCI_CMD_HDR_LEN + 9] = 0x00; // resume timeout + pBuf[HCI_CMD_HDR_LEN + 10] = 0x00; // break to host + pBuf[HCI_CMD_HDR_LEN + 11] = 0x00; // Pulsed host wake + hciCmdSend(pBuf); + } } // 0x18, 0xFC, 0x06, 0x00, 0x00, 0xC0, 0xC6, 0x2D, 0x00, //update uart baudrate 3 mbp void HciUpdateUartBaudRate() { - uint8_t *pBuf; - if ((pBuf = hciCmdAlloc(HCI_VS_CMD_UPDATE_UART_BAUD_RATE, 6)) != NULL) - { - pBuf[HCI_CMD_HDR_LEN] = 0x00; // encoded_baud_rate - pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // use_encoded_form - pBuf[HCI_CMD_HDR_LEN + 2] = 0xC0; // explicit baud rate bit 0-7 - pBuf[HCI_CMD_HDR_LEN + 3] = 0xC6; // explicit baud rate bit 8-15 - pBuf[HCI_CMD_HDR_LEN + 4] = 0x2D; // explicit baud rate bit 16-23 - pBuf[HCI_CMD_HDR_LEN + 5] = 0x00; // explicit baud rate bit 24-31 - hciCmdSend(pBuf); - } + uint8_t *pBuf; + if ((pBuf = hciCmdAlloc(HCI_VS_CMD_UPDATE_UART_BAUD_RATE, 6)) != NULL) + { + pBuf[HCI_CMD_HDR_LEN] = 0x00; // encoded_baud_rate + pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // use_encoded_form + pBuf[HCI_CMD_HDR_LEN + 2] = 0xC0; // explicit baud rate bit 0-7 + pBuf[HCI_CMD_HDR_LEN + 3] = 0xC6; // explicit baud rate bit 8-15 + pBuf[HCI_CMD_HDR_LEN + 4] = 0x2D; // explicit baud rate bit 16-23 + pBuf[HCI_CMD_HDR_LEN + 5] = 0x00; // explicit baud rate bit 24-31 + hciCmdSend(pBuf); + } } static const uint16_t HCI_OPCODE_WRITE_LE_HOST_SUPPORT = 0x0C6D; void HciWriteLeHostSupport() { - uint8_t *pBuf; - if ((pBuf = hciCmdAlloc(HCI_OPCODE_WRITE_LE_HOST_SUPPORT, 2)) != NULL) - { - pBuf[HCI_CMD_HDR_LEN] = 0x01; - pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; - hciCmdSend(pBuf); - } + uint8_t *pBuf; + if ((pBuf = hciCmdAlloc(HCI_OPCODE_WRITE_LE_HOST_SUPPORT, 2)) != NULL) + { + pBuf[HCI_CMD_HDR_LEN] = 0x01; + pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; + hciCmdSend(pBuf); + } } void hciCoreReadResolvingListSize(void) @@ -503,7 +500,7 @@ class HCIDriver : public CordioHCIDriver { void hciCoreReadMaxDataLen(void) { - /* if LE Data Packet Length Extensions is supported by Controller and included */ + /* if LE Data Packet Length Extensions is supported by Controller and included */ if ((hciCoreCb.leSupFeat & HCI_LE_SUP_FEAT_DATA_LEN_EXT) && (hciLeSupFeatCfg & HCI_LE_SUP_FEAT_DATA_LEN_EXT)) { @@ -522,9 +519,6 @@ class HCIDriver : public CordioHCIDriver { return (is_powersave_enabled); } - PinName bt_power_name; - mbed::DigitalInOut bt_power; - bool is_powersave_enabled; uint8_t host_wake_irq; uint8_t dev_wake_irq; @@ -546,12 +540,12 @@ ble::CordioHCIDriver& ble_cordio_get_hci_driver() { static ble::vendor::cypress_ble::CyH4TransportDriver& transport_driver = ble_cordio_get_h4_transport_driver(); + static ble::vendor::cypress::HCIDriver hci_driver( transport_driver, - /* bt_power */ CYBSP_BT_POWER, - transport_driver.get_enabled_powersave(), - transport_driver.get_host_wake_irq_event(), - transport_driver.get_dev_wake_irq_event() + transport_driver.get_enabled_powersave(), + transport_driver.get_host_wake_irq_event(), + transport_driver.get_dev_wake_irq_event() ); return hci_driver; }