Skip to content

Commit b245445

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 c2f7a95 commit b245445

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),
@@ -416,68 +413,68 @@ class HCIDriver : public CordioHCIDriver {
416413

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

454451
// 0x18, 0xFC, 0x06, 0x00, 0x00, 0xC0, 0xC6, 0x2D, 0x00, //update uart baudrate 3 mbp
455452
void HciUpdateUartBaudRate()
456453
{
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-
}
454+
uint8_t *pBuf;
455+
if ((pBuf = hciCmdAlloc(HCI_VS_CMD_UPDATE_UART_BAUD_RATE, 6)) != NULL)
456+
{
457+
pBuf[HCI_CMD_HDR_LEN] = 0x00; // encoded_baud_rate
458+
pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // use_encoded_form
459+
pBuf[HCI_CMD_HDR_LEN + 2] = 0xC0; // explicit baud rate bit 0-7
460+
pBuf[HCI_CMD_HDR_LEN + 3] = 0xC6; // explicit baud rate bit 8-15
461+
pBuf[HCI_CMD_HDR_LEN + 4] = 0x2D; // explicit baud rate bit 16-23
462+
pBuf[HCI_CMD_HDR_LEN + 5] = 0x00; // explicit baud rate bit 24-31
463+
hciCmdSend(pBuf);
464+
}
468465
}
469466

470467
static const uint16_t HCI_OPCODE_WRITE_LE_HOST_SUPPORT = 0x0C6D;
471468

472469
void HciWriteLeHostSupport()
473470
{
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-
}
471+
uint8_t *pBuf;
472+
if ((pBuf = hciCmdAlloc(HCI_OPCODE_WRITE_LE_HOST_SUPPORT, 2)) != NULL)
473+
{
474+
pBuf[HCI_CMD_HDR_LEN] = 0x01;
475+
pBuf[HCI_CMD_HDR_LEN + 1] = 0x00;
476+
hciCmdSend(pBuf);
477+
}
481478
}
482479

483480
void hciCoreReadResolvingListSize(void)
@@ -500,7 +497,7 @@ class HCIDriver : public CordioHCIDriver {
500497

501498
void hciCoreReadMaxDataLen(void)
502499
{
503-
/* if LE Data Packet Length Extensions is supported by Controller and included */
500+
/* if LE Data Packet Length Extensions is supported by Controller and included */
504501
if ((hciCoreCb.leSupFeat & HCI_LE_SUP_FEAT_DATA_LEN_EXT) &&
505502
(hciLeSupFeatCfg & HCI_LE_SUP_FEAT_DATA_LEN_EXT))
506503
{
@@ -519,9 +516,6 @@ class HCIDriver : public CordioHCIDriver {
519516
return (is_powersave_enabled);
520517
}
521518

522-
PinName bt_power_name;
523-
mbed::DigitalInOut bt_power;
524-
525519
bool is_powersave_enabled;
526520
uint8_t host_wake_irq;
527521
uint8_t dev_wake_irq;
@@ -543,12 +537,12 @@ ble::CordioHCIDriver& ble_cordio_get_hci_driver()
543537
{
544538
static ble::vendor::cypress_ble::CyH4TransportDriver& transport_driver =
545539
ble_cordio_get_h4_transport_driver();
540+
546541
static ble::vendor::cypress::HCIDriver hci_driver(
547542
transport_driver,
548-
/* bt_power */ CYBSP_BT_POWER,
549-
transport_driver.get_enabled_powersave(),
550-
transport_driver.get_host_wake_irq_event(),
551-
transport_driver.get_dev_wake_irq_event()
543+
transport_driver.get_enabled_powersave(),
544+
transport_driver.get_host_wake_irq_event(),
545+
transport_driver.get_dev_wake_irq_event()
552546
);
553547
return hci_driver;
554548
}

0 commit comments

Comments
 (0)