Skip to content

Commit ce6313c

Browse files
author
nazar.palamar
committed
Addressed code review comments: 1. remove bt_power member from HCIDriver class; 2. set PullUp for bt_power in CyH4TransportDriver; 3. cleanup code: replace tabs to 4 spaces
1 parent aaa3acb commit ce6313c

File tree

3 files changed

+65
-71
lines changed

3 files changed

+65
-71
lines changed

connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ CyH4TransportDriver::CyH4TransportDriver(PinName tx, PinName rx, PinName cts, Pi
5555
cts(cts), rts(rts),
5656
bt_host_wake_name(bt_host_wake_name),
5757
bt_device_wake_name(bt_device_wake_name),
58-
bt_power(bt_power_name, PIN_OUTPUT, PullNone, 0),
58+
bt_power(bt_power_name, PIN_OUTPUT, PullUp, 0),
5959
bt_host_wake(bt_host_wake_name, PIN_INPUT, PullNone, 0),
6060
bt_device_wake(bt_device_wake_name, PIN_OUTPUT, PullNone, 1),
6161
host_wake_irq_event(host_wake_irq),

connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/CyH4TransportDriver.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ class CyH4TransportDriver : public CordioHCITransportDriver {
4646
* Initialize the transport driver.
4747
*
4848
*/
49-
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,
50-
uint8_t host_wake_irq = 0, uint8_t dev_wake_irq = 0);
51-
CyH4TransportDriver(PinName tx, PinName rx, PinName cts, PinName rts, PinName bt_power_name, int baud);
49+
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,
50+
uint8_t host_wake_irq = 0, uint8_t dev_wake_irq = 0);
51+
CyH4TransportDriver(PinName tx, PinName rx, PinName cts, PinName rts, PinName bt_power_name, int baud);
5252

5353
/**
5454
* Destructor

connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp

Lines changed: 61 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,13 @@ class HCIDriver : public CordioHCIDriver {
7575
public:
7676
HCIDriver(
7777
ble::vendor::cypress_ble::CyH4TransportDriver& transport_driver,
78-
PinName bt_power_name,
79-
bool ps_enabled,
80-
uint8_t host_wake_irq,
81-
uint8_t dev_wake_irq
78+
bool ps_enabled,
79+
uint8_t host_wake_irq,
80+
uint8_t dev_wake_irq
8281
) : CordioHCIDriver(transport_driver),
83-
bt_power_name(bt_power_name),
84-
bt_power(bt_power_name, PIN_OUTPUT, PullUp, 0),
85-
is_powersave_enabled(ps_enabled),
86-
host_wake_irq(host_wake_irq),
87-
dev_wake_irq(dev_wake_irq),
82+
is_powersave_enabled(ps_enabled),
83+
host_wake_irq(host_wake_irq),
84+
dev_wake_irq(dev_wake_irq),
8885
service_pack_index(0),
8986
service_pack_ptr(0),
9087
service_pack_length(0),
@@ -419,68 +416,68 @@ class HCIDriver : public CordioHCIDriver {
419416

420417
void set_sleep_mode()
421418
{
422-
uint8_t *pBuf;
423-
if ((pBuf = hciCmdAlloc(HCI_VS_CMD_SET_SLEEP_MODE, 12)) != NULL)
424-
{
425-
if (is_powersave_on()) {
426-
pBuf[HCI_CMD_HDR_LEN] = 0x01; // sleep
427-
} else {
428-
pBuf[HCI_CMD_HDR_LEN] = 0x00; // no sleep
429-
}
430-
pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // no idle threshold host (N/A)
431-
if (is_powersave_on()) {
432-
pBuf[HCI_CMD_HDR_LEN + 2] = 0x05; // no idle threshold HC (N/A)
433-
} else {
434-
pBuf[HCI_CMD_HDR_LEN + 2] = 0x00; // no idle threshold HC (N/A)
435-
}
436-
if (is_powersave_on()) {
437-
pBuf[HCI_CMD_HDR_LEN + 3] = dev_wake_irq; // BT WAKE
438-
} else {
439-
pBuf[HCI_CMD_HDR_LEN + 3] = 0x00; // BT WAKE
440-
}
441-
if (is_powersave_on()) {
442-
pBuf[HCI_CMD_HDR_LEN + 4] = host_wake_irq; // HOST WAKE
443-
} else {
444-
pBuf[HCI_CMD_HDR_LEN + 4] = 0x00; // HOST WAKE
445-
}
446-
pBuf[HCI_CMD_HDR_LEN + 5] = 0x00; // Sleep during SCO
447-
pBuf[HCI_CMD_HDR_LEN + 6] = 0x00; // Combining sleep mode and SCM
448-
pBuf[HCI_CMD_HDR_LEN + 7] = 0x00; // Tristate TX
449-
pBuf[HCI_CMD_HDR_LEN + 8] = 0x00; // Active connection handling on suspend
450-
pBuf[HCI_CMD_HDR_LEN + 9] = 0x00; // resume timeout
451-
pBuf[HCI_CMD_HDR_LEN + 10] = 0x00; // break to host
452-
pBuf[HCI_CMD_HDR_LEN + 11] = 0x00; // Pulsed host wake
453-
hciCmdSend(pBuf);
419+
uint8_t *pBuf;
420+
if ((pBuf = hciCmdAlloc(HCI_VS_CMD_SET_SLEEP_MODE, 12)) != NULL)
421+
{
422+
if (is_powersave_on()) {
423+
pBuf[HCI_CMD_HDR_LEN] = 0x01; // sleep
424+
} else {
425+
pBuf[HCI_CMD_HDR_LEN] = 0x00; // no sleep
426+
}
427+
pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // no idle threshold host (N/A)
428+
if (is_powersave_on()) {
429+
pBuf[HCI_CMD_HDR_LEN + 2] = 0x05; // no idle threshold HC (N/A)
430+
} else {
431+
pBuf[HCI_CMD_HDR_LEN + 2] = 0x00; // no idle threshold HC (N/A)
432+
}
433+
if (is_powersave_on()) {
434+
pBuf[HCI_CMD_HDR_LEN + 3] = dev_wake_irq; // BT WAKE
435+
} else {
436+
pBuf[HCI_CMD_HDR_LEN + 3] = 0x00; // no BT WAKE
437+
}
438+
if (is_powersave_on()) {
439+
pBuf[HCI_CMD_HDR_LEN + 4] = host_wake_irq; // HOST WAKE
440+
} else {
441+
pBuf[HCI_CMD_HDR_LEN + 4] = 0x00; // no HOST WAKE
454442
}
443+
pBuf[HCI_CMD_HDR_LEN + 5] = 0x00; // Sleep during SCO
444+
pBuf[HCI_CMD_HDR_LEN + 6] = 0x00; // Combining sleep mode and SCM
445+
pBuf[HCI_CMD_HDR_LEN + 7] = 0x00; // Tristate TX
446+
pBuf[HCI_CMD_HDR_LEN + 8] = 0x00; // Active connection handling on suspend
447+
pBuf[HCI_CMD_HDR_LEN + 9] = 0x00; // resume timeout
448+
pBuf[HCI_CMD_HDR_LEN + 10] = 0x00; // break to host
449+
pBuf[HCI_CMD_HDR_LEN + 11] = 0x00; // Pulsed host wake
450+
hciCmdSend(pBuf);
451+
}
455452
}
456453

457454
// 0x18, 0xFC, 0x06, 0x00, 0x00, 0xC0, 0xC6, 0x2D, 0x00, //update uart baudrate 3 mbp
458455
void HciUpdateUartBaudRate()
459456
{
460-
uint8_t *pBuf;
461-
if ((pBuf = hciCmdAlloc(HCI_VS_CMD_UPDATE_UART_BAUD_RATE, 6)) != NULL)
462-
{
463-
pBuf[HCI_CMD_HDR_LEN] = 0x00; // encoded_baud_rate
464-
pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // use_encoded_form
465-
pBuf[HCI_CMD_HDR_LEN + 2] = 0xC0; // explicit baud rate bit 0-7
466-
pBuf[HCI_CMD_HDR_LEN + 3] = 0xC6; // explicit baud rate bit 8-15
467-
pBuf[HCI_CMD_HDR_LEN + 4] = 0x2D; // explicit baud rate bit 16-23
468-
pBuf[HCI_CMD_HDR_LEN + 5] = 0x00; // explicit baud rate bit 24-31
469-
hciCmdSend(pBuf);
470-
}
457+
uint8_t *pBuf;
458+
if ((pBuf = hciCmdAlloc(HCI_VS_CMD_UPDATE_UART_BAUD_RATE, 6)) != NULL)
459+
{
460+
pBuf[HCI_CMD_HDR_LEN] = 0x00; // encoded_baud_rate
461+
pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // use_encoded_form
462+
pBuf[HCI_CMD_HDR_LEN + 2] = 0xC0; // explicit baud rate bit 0-7
463+
pBuf[HCI_CMD_HDR_LEN + 3] = 0xC6; // explicit baud rate bit 8-15
464+
pBuf[HCI_CMD_HDR_LEN + 4] = 0x2D; // explicit baud rate bit 16-23
465+
pBuf[HCI_CMD_HDR_LEN + 5] = 0x00; // explicit baud rate bit 24-31
466+
hciCmdSend(pBuf);
467+
}
471468
}
472469

473470
static const uint16_t HCI_OPCODE_WRITE_LE_HOST_SUPPORT = 0x0C6D;
474471

475472
void HciWriteLeHostSupport()
476473
{
477-
uint8_t *pBuf;
478-
if ((pBuf = hciCmdAlloc(HCI_OPCODE_WRITE_LE_HOST_SUPPORT, 2)) != NULL)
479-
{
480-
pBuf[HCI_CMD_HDR_LEN] = 0x01;
481-
pBuf[HCI_CMD_HDR_LEN + 1] = 0x00;
482-
hciCmdSend(pBuf);
483-
}
474+
uint8_t *pBuf;
475+
if ((pBuf = hciCmdAlloc(HCI_OPCODE_WRITE_LE_HOST_SUPPORT, 2)) != NULL)
476+
{
477+
pBuf[HCI_CMD_HDR_LEN] = 0x01;
478+
pBuf[HCI_CMD_HDR_LEN + 1] = 0x00;
479+
hciCmdSend(pBuf);
480+
}
484481
}
485482

486483
void hciCoreReadResolvingListSize(void)
@@ -503,7 +500,7 @@ class HCIDriver : public CordioHCIDriver {
503500

504501
void hciCoreReadMaxDataLen(void)
505502
{
506-
/* if LE Data Packet Length Extensions is supported by Controller and included */
503+
/* if LE Data Packet Length Extensions is supported by Controller and included */
507504
if ((hciCoreCb.leSupFeat & HCI_LE_SUP_FEAT_DATA_LEN_EXT) &&
508505
(hciLeSupFeatCfg & HCI_LE_SUP_FEAT_DATA_LEN_EXT))
509506
{
@@ -522,9 +519,6 @@ class HCIDriver : public CordioHCIDriver {
522519
return (is_powersave_enabled);
523520
}
524521

525-
PinName bt_power_name;
526-
mbed::DigitalInOut bt_power;
527-
528522
bool is_powersave_enabled;
529523
uint8_t host_wake_irq;
530524
uint8_t dev_wake_irq;
@@ -546,12 +540,12 @@ ble::CordioHCIDriver& ble_cordio_get_hci_driver()
546540
{
547541
static ble::vendor::cypress_ble::CyH4TransportDriver& transport_driver =
548542
ble_cordio_get_h4_transport_driver();
543+
549544
static ble::vendor::cypress::HCIDriver hci_driver(
550545
transport_driver,
551-
/* bt_power */ CYBSP_BT_POWER,
552-
transport_driver.get_enabled_powersave(),
553-
transport_driver.get_host_wake_irq_event(),
554-
transport_driver.get_dev_wake_irq_event()
546+
transport_driver.get_enabled_powersave(),
547+
transport_driver.get_host_wake_irq_event(),
548+
transport_driver.get_dev_wake_irq_event()
555549
);
556550
return hci_driver;
557551
}

0 commit comments

Comments
 (0)