]> git.karo-electronics.de Git - oswald.git/blobdiff - metawatch/bt_hci.c
Power saving changes, add new fonts, bitmaps and screens
[oswald.git] / metawatch / bt_hci.c
index 838aafc20aeda695b183f038bfb3d36920e1c960..7bf74449eb8f9d8fe1f85d846241abf2f9e71ac1 100644 (file)
@@ -327,10 +327,14 @@ unsigned char bt_feed_packet_data(unsigned char pdata)
                                        state = HCI_PACKET_START;
                                        // disable BT UART?
                                        // mabye UCA1CTL1 = UCSWRST ?
+
                                        pdata = EHCILL_GO_TO_SLEEP_ACK;
                                        mw_bt_uart_tx(&pdata, 0x01);
-                                       BT_IO_POUT |= BT_IO_RTS; // pull RTS -> stop data
 
+                                       // pull RTS -> stop data
+                                       BT_IO_POUT |= BT_IO_RTS;
+
+                                       // enable IRQ on CTS
                                        P1IFG &= ~BT_IO_CTS;
                                        P1IE |= BT_IO_CTS;
 
@@ -421,7 +425,7 @@ void bt_hci_cmd(const uint8_t OGF, const uint8_t OCF, const uint8_t data_len, co
        if (state == EHCILL_SLEEPING) {
                uint8_t ehcill_p = EHCILL_WAKE_UP_IND;
 
-               debug_uart_tx("HCILL wakeup\n");
+               debug_uart_tx("wakeup HCILL\n");
                state = HCI_PACKET_START;
                mw_bt_uart_tx(&ehcill_p, 1);
                __delay_cycles(300000);
@@ -484,11 +488,12 @@ void bt_hci_init(void)
 
 void bt_hci_ehcill_wake(void)
 {
-       uint8_t ehcill_p = EHCILL_WAKE_UP_ACK;
+       const uint8_t ehcill_p = EHCILL_WAKE_UP_ACK;
 
        debug_uart_tx("HCILL wakeup\n");
 
        P1IE &= ~BT_IO_CTS;
+       P1IFG &= ~BT_IO_CTS;
        state = HCI_PACKET_START;
 
        BT_IO_POUT &= ~BT_IO_RTS; // drop RTS -> start data