@@ -59,12 +59,36 @@ CyH4TransportDriver::~CyH4TransportDriver()
59
59
}
60
60
}
61
61
62
- void CyH4TransportDriver::bt_host_wake_irq_handler (void )
62
+ void CyH4TransportDriver::bt_host_wake_rise_irq_handler (void )
63
+ {
64
+ if (host_wake_irq_event == WAKE_EVENT_ACTIVE_LOW) {
65
+ if (bt_host_wake_active == true )
66
+ {
67
+ /* lock PSoC 6 DeepSleep entry as long as host_wake is asserted */
68
+ sleep_manager_unlock_deep_sleep ();
69
+ bt_host_wake_active = false ;
70
+ }
71
+ } else {
72
+ /* lock PSoC 6 DeepSleep entry as long as host_wake is asserted */
73
+ sleep_manager_lock_deep_sleep ();
74
+ bt_host_wake_active = true ;
75
+ }
76
+ }
77
+
78
+ void CyH4TransportDriver::bt_host_wake_fall_irq_handler (void )
63
79
{
64
- uart.attach (
65
- callback (this , &CyH4TransportDriver::on_controller_irq),
66
- SerialBase::RxIrq
67
- );
80
+ if (host_wake_irq_event == WAKE_EVENT_ACTIVE_LOW) {
81
+ /* lock PSoC 6 DeepSleep entry as long as host_wake is asserted */
82
+ sleep_manager_lock_deep_sleep ();
83
+ bt_host_wake_active = true ;
84
+ } else {
85
+ if (bt_host_wake_active == true )
86
+ {
87
+ /* lock PSoC 6 DeepSleep entry as long as host_wake is asserted */
88
+ sleep_manager_unlock_deep_sleep ();
89
+ bt_host_wake_active = false ;
90
+ }
91
+ }
68
92
}
69
93
70
94
void CyH4TransportDriver::initialize ()
@@ -92,17 +116,15 @@ void CyH4TransportDriver::initialize()
92
116
SerialBase::RxIrq
93
117
);
94
118
119
+ sleep_manager_unlock_deep_sleep ();
120
+
95
121
#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
96
122
if (bt_host_wake_name != NC) {
97
123
// Register IRQ for Host WAKE
98
124
host_wake_pin = new InterruptIn (bt_host_wake_name);
99
- if (host_wake_irq_event == WAKE_EVENT_ACTIVE_LOW) {
100
- host_wake_pin->fall (callback (this , &CyH4TransportDriver::bt_host_wake_irq_handler));
101
- } else {
102
- host_wake_pin->rise (callback (this , &CyH4TransportDriver::bt_host_wake_irq_handler));
103
- }
125
+ host_wake_pin->fall (callback (this , &CyH4TransportDriver::bt_host_wake_fall_irq_handler));
126
+ host_wake_pin->rise (callback (this , &CyH4TransportDriver::bt_host_wake_rise_irq_handler));
104
127
}
105
-
106
128
#endif
107
129
if (dev_wake_irq_event == WAKE_EVENT_ACTIVE_LOW) {
108
130
if (bt_device_wake_name != NC)
@@ -136,26 +158,15 @@ uint16_t CyH4TransportDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
136
158
return len;
137
159
}
138
160
139
- #if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
140
- void CyH4TransportDriver::on_host_stack_inactivity ()
141
- {
142
- if (enabled_powersave) {
143
- uart.attach (NULL , SerialBase::RxIrq);
144
- }
145
- }
146
- #endif
147
-
148
161
void CyH4TransportDriver::on_controller_irq ()
149
162
{
150
163
sleep_manager_lock_deep_sleep ();
151
- assert_bt_dev_wake ();
152
164
153
165
while (uart.readable ()) {
154
166
uint8_t char_received = uart.getc ();
155
167
on_data_received (&char_received, 1 );
156
168
}
157
169
158
- deassert_bt_dev_wake ();
159
170
sleep_manager_unlock_deep_sleep ();
160
171
}
161
172
0 commit comments