@@ -75,16 +75,13 @@ class HCIDriver : public CordioHCIDriver {
7575public:
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