8.9.2 BLE Powersave
To use BLE powersave, UART flow control must be enabled, to hold the host back from sending new commands to the ATWILC3000 BLE controller when it is in Sleep mode.
This can be done using the Update UART Parameters vendor specific HCI command to enable flow control on ATWILC3000, then update the host's UART configuration to enable flow control. Also, the host application must allow the ATWILC3000 BLE controller to enter powersave, by setting the host's UART Tx line low, entering a Break mode. Before starting any HCI communication, the application must get the host's UART out of the Break mode, then proceed with sending the HCI commands to the ATWILC3000.
When ATWILC3000 is in Powersave mode, it will set the UART RTS line high to hold back the host from sending any additional HCI commands. Once the host UART Tx line is back high, ATWILC3000 will go out of Powersave mode, but will not be fully active instantly. After ATWILC3000 is up and ready to receive more HCI commands, it will set the UART RTS line low, and the host will be able to send more HCI commands.
This is illustrated in the following figure:
- Yellow: UART Rx (ATWILC3000 perspective)
- Blue: UART Tx
- Purple: UART RTS
- Green: ATWILC3000 Ready
int main(int argc,char *argv[])
{
int fd, serial;
fd = open("/dev/ttyS1", O_RDWR);
if(atoi(argv[1])==1) {
printf("assert on %d\n",fd);
ioctl(fd, TIOCCBRK, 0);
} else if(atoi(argv[1])==0) {
printf("deassert on %d\n",fd);
ioctl(fd, TIOCSBRK, 0);
}
close(fd);
}
etc/uart_brk_ioctl
. To enable powersave, the following commands can
be
used:# modprobe wilc-sdio.ko
# echo BT_POWER_UP > /dev/wilc_bt
# echo BT_DOWNLOAD_FW > /dev/wilc_bt
# hciattach ttyS1 any 115200 noflow
# hciconfig hci0 up
# hcitool cmd 0x3F 0x0053 00 C2 01 00 01
# stty -F /dev/ttyS1 crtscts
# /etc/etc/uart_brk_ioctl 1
# /etc/etc/uart_brk_ioctl 0