@@ -26,8 +26,10 @@ volatile bool sys_resp;
26
26
volatile bool acl_data; /* true : data acknowledged by the BLE */
27
27
volatile bool data_available;
28
28
29
- /* this one is for printing
30
- #define DEBUG */
29
+ /* this one is for printing */
30
+ #define DEBUG
31
+ #define PRINT_HCI_DATA
32
+
31
33
/* this must be defined */
32
34
#define CONFIG_DEBUG
33
35
@@ -83,6 +85,20 @@ static void evt_received(TL_EvtPacket_t *hcievt)
83
85
switch (hcievt->evtserial .type ) {
84
86
case TL_BLEEVT_PKT_TYPE:
85
87
88
+ #if defined(DEBUG)
89
+ #if defined(PRINT_HCI_DATA)
90
+ printf (" RX<< BLE EVT : " );
91
+ printf (" Type %#x" , hcievt->evtserial .type );
92
+ printf (" evt %#x" , hcievt->evtserial .evt .evtcode );
93
+ printf (" Len %#d" , hcievt->evtserial .evt .plen );
94
+ printf (" :" );
95
+ for (uint8_t i = 0 ; i < hcievt->evtserial .evt .plen ; i++) {
96
+ printf (" %02X" , hcievt->evtserial .evt .payload [i]);
97
+ }
98
+ printf (" \r\n " );
99
+ #endif /* PRINT_HCI_DATA */
100
+ #endif /* DEBUG */
101
+
86
102
/* check the Rx event of complete the previous bd_addr opcode 0xfc0c */
87
103
if ((hcievt->evtserial .evt .evtcode == TL_BLEEVT_CC_OPCODE) &&
88
104
(hcievt->evtserial .evt .payload [0 ] == 0x01 ) &&
@@ -141,19 +157,18 @@ __enable_irq();
141
157
default :
142
158
// should not happen - let's block to check
143
159
#if defined(DEBUG)
144
- printf (" BLE TL evt_received, wrong type:%d" , hcievt->evtserial .type );
160
+ printf (" BLE TL evt_received, wrong type:%d\r\n " , hcievt->evtserial .type );
145
161
#endif /* DEBUG */
146
162
break ;
147
163
}
148
164
149
165
if (_write_index > BLE_MODULE_SHARED_MEM_BUFFER_SIZE) {
150
166
#if defined(DEBUG)
151
- printf (" Error: data read overflow" );
167
+ printf (" Error: data read overflow\r\n " );
152
168
#endif /* DEBUG */
153
169
data_available = true ;
154
170
}
155
171
156
-
157
172
/* In case Event belongs to the Evt Pool we need to inform */
158
173
if (((uint8_t *)hcievt >= EvtPool) && ((uint8_t *)hcievt < (EvtPool + POOL_SIZE))) {
159
174
/* Free the message from shared memory */
@@ -661,10 +676,11 @@ static int bt_ipm_set_power(void)
661
676
/* if event is a command complete event */
662
677
if (*pMsg == HCI_CMD_CMPL_EVT) {
663
678
/* "Command Complete Event Command" */
664
- #if (PRINT_HCI_DATA)
679
+ #if defined (PRINT_HCI_DATA)
665
680
for (uint8_t i = 0; i < 20; i++) {
666
- tr_debug (" %02X", *((uint8_t *)pMsg + i));
681
+ printf (" %02X", *((uint8_t *)pMsg + i));
667
682
}
683
+ printf("\r\n");
668
684
#endif
669
685
/* parse parameters */
670
686
pMsg += HCI_EVT_HDR_LEN;
@@ -839,7 +855,7 @@ static int bt_ipm_set_power(void)
839
855
840
856
default:
841
857
#if defined(DEBUG)
842
- printf("Complete Event in reset seq with unknown opcode =0x%4X", opcode);
858
+ printf("Complete Event in reset seq with unknown opcode =0x%4X\r\n ", opcode);
843
859
#endif /* DEBUG */
844
860
break;
845
861
}
@@ -853,7 +869,7 @@ static int bt_ipm_set_power(void)
853
869
pMsg++; /* skip num packets */
854
870
BSTREAM_TO_UINT16(opcode, pMsg);
855
871
#if defined(DEBUG)
856
- printf("Command Status event, status:%d, opcode=0x%4X", status, opcode);
872
+ printf("Command Status event, status:%d, opcode=0x%4X\r\n ", status, opcode);
857
873
#endif /* DEBUG */
858
874
} else {
859
875
/**
@@ -864,11 +880,11 @@ static int bt_ipm_set_power(void)
864
880
pMsg += HCI_EVT_HDR_LEN;
865
881
BSTREAM_TO_UINT16(opcode, pMsg);
866
882
#if defined(DEBUG)
867
- printf("Vendor specific event, opcode=0x%4X", opcode);
883
+ printf("Vendor specific event, opcode=0x%4X\r\n ", opcode);
868
884
#endif /* DEBUG */
869
885
} else {
870
886
#if defined(DEBUG)
871
- printf("Unknown event %d!", pMsg[0]);
887
+ printf("Unknown event %d!\r\n ", pMsg[0]);
872
888
#endif /* DEBUG */
873
889
}
874
890
}
@@ -886,9 +902,7 @@ static int bt_ipm_set_power(void)
886
902
// type 02 ACL DATA
887
903
// type 03 SCO Voice (not supported)
888
904
// type 04 event - uplink (not suported)
889
- #if defined(DEBUG)
890
- printf (" mbox_write type:%d, len:%d" , type, len);
891
- #endif /* DEBUG */
905
+
892
906
/* TO DO : MANAGE ACL DATA CASE in separate buffer */
893
907
switch (type) {
894
908
case 1 :// BLE command
@@ -898,23 +912,26 @@ static int bt_ipm_set_power(void)
898
912
/* We're tracing here the command, after copy in shared mem but before
899
913
* * M0 trigger. */
900
914
#if defined(DEBUG)
901
- printf (" TX>> BLE CMD" );
902
- #endif /* DEBUG */
903
- #if (PRINT_HCI_DATA)
904
- /* Trace the buffer including Type (+1 on lngth) */
905
- tr_debug (" Type %#x" , bleCmdBuf->cmdserial .type );
906
- tr_debug (" Cmd %#x" , bleCmdBuf->cmdserial .cmd .cmdcode );
907
- tr_debug (" Len %#x" , bleCmdBuf->cmdserial .cmd .plen );
915
+ #if !defined(PRINT_HCI_DATA)
916
+ printf (" mbox_write type:%d, len:%d\r\n " , type, len);
917
+ #else /* Trace the buffer including Type (+1 on lngth) */
918
+ printf (" TX>> BLE CMD : " );
919
+ printf (" Type %#x" , bleCmdBuf->cmdserial .type );
920
+ printf (" Cmd %#x" , bleCmdBuf->cmdserial .cmd .cmdcode );
921
+ printf (" Len %#d" , bleCmdBuf->cmdserial .cmd .plen );
922
+ printf (" :" );
908
923
for (uint8_t i = 0 ; i < bleCmdBuf->cmdserial .cmd .plen ; i++) {
909
- tr_debug ( " %02X" , *(((uint8_t *)&bleCmdBuf->cmdserial .cmd .payload ) + i));
924
+ printf ( " %02X" , *(((uint8_t *)&bleCmdBuf->cmdserial .cmd .payload ) + i));
910
925
}
926
+ printf (" \r\n " );
911
927
#endif /* PRINT_HCI_DATA */
928
+ #endif /* DEBUG */
912
929
TL_BLE_SendCmd (NULL , 0 ); // unused parameters for now
913
930
break ;
914
931
case 2 :// ACL DATA
915
932
if (!acl_data) {
916
933
#if defined(DEBUG)
917
- printf (" ERROR: previous ACL message not ACK'd" );
934
+ printf (" ERROR: previous ACL message not ACK'd\r\n " );
918
935
#endif /* DEBUG */
919
936
/* return number of bytes sent, 0 in this error case */
920
937
return 0 ;
@@ -923,13 +940,16 @@ static int bt_ipm_set_power(void)
923
940
&((TL_AclDataPacket_t *)HciAclDataBuffer)->AclDataSerial , pData, len);
924
941
TL_BLE_SendAclData (NULL , 0 ); // unused parameters for now
925
942
#if defined(DEBUG)
926
- printf (" TX>> BLE ACL" );
927
- #endif /* DEBUG */
928
- #if PRINT_HCI_DATA
943
+ #if !defined(PRINT_HCI_DATA)
944
+ printf (" mbox_write type:%d, len:%d \r\n " , type, len);
945
+ #else
946
+ printf (" TX>> BLE ACL : " );
929
947
for (uint8_t i = 0 ; i < len + 1 + 8 ; i++) {
930
- tr_debug ( " %02x" , *(((uint8_t *) aclDataBuffer ) + i));
948
+ printf ( " %02x " , *(((uint8_t *) HciAclDataBuffer ) + i));
931
949
}
932
- #endif
950
+ printf (" \r\n " );
951
+ #endif /* PRINT_HCI_DATA */
952
+ #endif /* DEBUG */
933
953
break ;
934
954
}
935
955
return len;
@@ -946,7 +966,7 @@ static void init_debug(void)
946
966
947
967
#if defined(CONFIG_DEBUG)
948
968
#if defined(DEBUG)
949
- printf (" init_debug ENABLED" );
969
+ printf (" init_debug ENABLED\r\n " );
950
970
#endif /* DEBUG */
951
971
/* *
952
972
* Keep debugger enabled while in any low power mode
@@ -961,7 +981,7 @@ static void init_debug(void)
961
981
962
982
#else
963
983
#if defined(DEBUG)
964
- printf (" init_debug DISABLED" );
984
+ printf (" init_debug DISABLED\n\r " );
965
985
#endif /* DEBUG */
966
986
GPIO_InitTypeDef gpio_config = {0 };
967
987
0 commit comments