Bluetooth: Enable and disable BLE chip sleep mode dynamically

For power consumption matter, UART between quark and BLE chip shall
be disabled in absence of messages. GPIO NBLE_BTWAKE_PIN is used
from Quark to notify BLE chip payload is coming and so enabling UART.
The UART will be disabled by deasserted NBLE_BTWAKE_PIN signal, once
a message has been transmitted.

Change-Id: If538909784363f415f4266f62be57d8d9ff48b09
Signed-off-by: Jonathan Gelie <jonathanx.gelie@intel.com>
This commit is contained in:
Jonathan Gelie 2016-08-23 16:15:56 +02:00 committed by Johan Hedberg
commit 4ba989f837

View file

@ -121,12 +121,20 @@ void rpc_transmit_cb(struct net_buf *buf)
hdr->len = buf->len - sizeof(*hdr); hdr->len = buf->len - sizeof(*hdr);
hdr->channel = 0; hdr->channel = 0;
hdr->src_cpu_id = 0; hdr->src_cpu_id = 0;
#if defined(CONFIG_BLUETOOTH_NRF51_PM)
/* Wake-up nble */
nrf51_enable();
#endif
while (buf->len) { while (buf->len) {
uart_poll_out(nble_dev, net_buf_pull_u8(buf)); uart_poll_out(nble_dev, net_buf_pull_u8(buf));
} }
net_buf_unref(buf); net_buf_unref(buf);
#if defined(CONFIG_BLUETOOTH_NRF51_PM)
/* TODO check if FIFO is empty */
/* Allow nble to go to deep sleep */
nrf51_disable();
#endif
} }
static size_t nble_discard(struct device *uart, size_t len) static size_t nble_discard(struct device *uart, size_t len)