Skip to content

Commit 38c0c7c

Browse files
committed
add print message for debug
define DEBUG to output information define PRINT_HCI_DATA to trace the exact content of the TX packet Signed-off-by: Francois Ramu <[email protected]>
1 parent 5f34c1d commit 38c0c7c

File tree

1 file changed

+51
-36
lines changed

1 file changed

+51
-36
lines changed

src/utility/HCISharedMemTransport.cpp

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ volatile bool sys_resp;
2626
volatile bool acl_data; /* true : data acknowledged by the BLE */
2727
volatile bool data_available;
2828

29-
/* this one is for printing
30-
#define DEBUG */
31-
/* this must be defined */
29+
/* this one is for printing */
30+
#define DEBUG
31+
//#define PRINT_HCI_DATA
32+
33+
/* this CONFIG_DEBUG must be defined */
3234
#define CONFIG_DEBUG
3335

3436
#define HW_IPCC_Tx_Handler IPCC_C1_TX_IRQHandler
@@ -83,6 +85,20 @@ static void evt_received(TL_EvtPacket_t *hcievt)
8385
switch (hcievt->evtserial.type) {
8486
case TL_BLEEVT_PKT_TYPE:
8587

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+
86102
/* check the Rx event of complete the previous bd_addr opcode 0xfc0c */
87103
if ((hcievt->evtserial.evt.evtcode == TL_BLEEVT_CC_OPCODE) &&
88104
(hcievt->evtserial.evt.payload[0] == 0x01) &&
@@ -133,19 +149,18 @@ __enable_irq();
133149
default:
134150
// should not happen - let's block to check
135151
#if defined(DEBUG)
136-
printf("BLE TL evt_received, wrong type:%d", hcievt->evtserial.type);
152+
printf("BLE TL evt_received, wrong type:%d\r\n", hcievt->evtserial.type);
137153
#endif /* DEBUG */
138154
break;
139155
}
140156

141157
if (_write_index > BLE_MODULE_SHARED_MEM_BUFFER_SIZE) {
142158
#if defined(DEBUG)
143-
printf("Error: data read overflow");
159+
printf("Error: data read overflow\r\n");
144160
#endif /* DEBUG */
145161
data_available = true;
146162
}
147163

148-
149164
/* In case Event belongs to the Evt Pool we need to inform */
150165
if (((uint8_t *)hcievt >= EvtPool) && ((uint8_t *)hcievt < (EvtPool + POOL_SIZE))) {
151166
/* Free the message from shared memory */
@@ -286,12 +301,10 @@ int HCISharedMemTransportClass::begin()
286301
WirelessFwInfo_t wireless_info_instance;
287302
WirelessFwInfo_t *p_wireless_info = &wireless_info_instance;
288303
SHCI_GetWirelessFwInfo(p_wireless_info);
289-
/*
290-
* tr_info("WIRELESS COPROCESSOR FW VERSION ID = %d.%d.%d", p_wireless_info->VersionMajor, p_wireless_info->VersionMinor, p_wireless_info->VersionSub);
291-
* tr_info("WIRELESS COPROCESSOR FW STACK TYPE = %d", p_wireless_info->StackType);
292-
*/
293-
294-
304+
#if defined(DEBUG)
305+
printf("WIRELESS COPROCESSOR FW VERSION ID = %d.%d.%d\r\n", p_wireless_info->VersionMajor, p_wireless_info->VersionMinor, p_wireless_info->VersionSub);
306+
printf("WIRELESS COPROCESSOR FW STACK TYPE = %d\r\n", p_wireless_info->StackType);
307+
#endif
295308
/* Now start BLE service on firmware side, using Vendor specific
296309
* command on the System Channel
297310
*/
@@ -653,10 +666,11 @@ static int bt_ipm_set_power(void)
653666
/* if event is a command complete event */
654667
if (*pMsg == HCI_CMD_CMPL_EVT) {
655668
/* "Command Complete Event Command" */
656-
#if (PRINT_HCI_DATA)
669+
#if defined(PRINT_HCI_DATA)
657670
for (uint8_t i = 0; i < 20; i++) {
658-
tr_debug(" %02X", *((uint8_t *)pMsg + i));
671+
printf(" %02X", *((uint8_t *)pMsg + i));
659672
}
673+
printf("\r\n");
660674
#endif
661675
/* parse parameters */
662676
pMsg += HCI_EVT_HDR_LEN;
@@ -831,7 +845,7 @@ static int bt_ipm_set_power(void)
831845
832846
default:
833847
#if defined(DEBUG)
834-
printf("Complete Event in reset seq with unknown opcode =0x%4X", opcode);
848+
printf("Complete Event in reset seq with unknown opcode =0x%4X\r\n", opcode);
835849
#endif /* DEBUG */
836850
break;
837851
}
@@ -845,7 +859,7 @@ static int bt_ipm_set_power(void)
845859
pMsg++; /* skip num packets */
846860
BSTREAM_TO_UINT16(opcode, pMsg);
847861
#if defined(DEBUG)
848-
printf("Command Status event, status:%d, opcode=0x%4X", status, opcode);
862+
printf("Command Status event, status:%d, opcode=0x%4X\r\n", status, opcode);
849863
#endif /* DEBUG */
850864
} else {
851865
/**
@@ -856,11 +870,11 @@ static int bt_ipm_set_power(void)
856870
pMsg += HCI_EVT_HDR_LEN;
857871
BSTREAM_TO_UINT16(opcode, pMsg);
858872
#if defined(DEBUG)
859-
printf("Vendor specific event, opcode=0x%4X", opcode);
873+
printf("Vendor specific event, opcode=0x%4X\r\n", opcode);
860874
#endif /* DEBUG */
861875
} else {
862876
#if defined(DEBUG)
863-
printf("Unknown event %d!", pMsg[0]);
877+
printf("Unknown event %d!\r\n", pMsg[0]);
864878
#endif /* DEBUG */
865879
}
866880
}
@@ -878,9 +892,7 @@ static int bt_ipm_set_power(void)
878892
// type 02 ACL DATA
879893
// type 03 SCO Voice (not supported)
880894
// type 04 event - uplink (not suported)
881-
#if defined(DEBUG)
882-
printf("mbox_write type:%d, len:%d", type, len);
883-
#endif /* DEBUG */
895+
884896
/* TO DO : MANAGE ACL DATA CASE in separate buffer */
885897
switch (type) {
886898
case 1://BLE command
@@ -890,23 +902,25 @@ static int bt_ipm_set_power(void)
890902
/* We're tracing here the command, after copy in shared mem but before
891903
* * M0 trigger. */
892904
#if defined(DEBUG)
893-
printf("TX>> BLE CMD");
894-
#endif /* DEBUG */
895-
#if (PRINT_HCI_DATA)
905+
#if defined(PRINT_HCI_DATA)
896906
/* Trace the buffer including Type (+1 on lngth) */
897-
tr_debug(" Type %#x", bleCmdBuf->cmdserial.type);
898-
tr_debug(" Cmd %#x", bleCmdBuf->cmdserial.cmd.cmdcode);
899-
tr_debug(" Len %#x", bleCmdBuf->cmdserial.cmd.plen);
907+
printf("TX>> CMD : ");
908+
printf(" Type %#x", bleCmdBuf->cmdserial.type);
909+
printf(" Cmd %#x", bleCmdBuf->cmdserial.cmd.cmdcode);
910+
printf(" Len %#d", bleCmdBuf->cmdserial.cmd.plen);
911+
printf(" :");
900912
for (uint8_t i = 0; i < bleCmdBuf->cmdserial.cmd.plen; i++) {
901-
tr_debug(" %02X", *(((uint8_t *)&bleCmdBuf->cmdserial.cmd.payload) + i));
913+
printf(" %02X", *(((uint8_t *)&bleCmdBuf->cmdserial.cmd.payload) + i));
902914
}
915+
printf("\r\n");
903916
#endif /* PRINT_HCI_DATA */
917+
#endif /* DEBUG */
904918
TL_BLE_SendCmd(NULL, 0); // unused parameters for now
905919
break;
906920
case 2://ACL DATA
907921
if (!acl_data) {
908922
#if defined(DEBUG)
909-
printf("ERROR: previous ACL message not ACK'd");
923+
printf("ERROR: previous ACL message not ACK'd\r\n");
910924
#endif /* DEBUG */
911925
/* return number of bytes sent, 0 in this error case */
912926
return 0;
@@ -915,13 +929,14 @@ static int bt_ipm_set_power(void)
915929
&((TL_AclDataPacket_t *)HciAclDataBuffer)->AclDataSerial, pData, len);
916930
TL_BLE_SendAclData(NULL, 0); // unused parameters for now
917931
#if defined(DEBUG)
918-
printf("TX>> BLE ACL");
919-
#endif /* DEBUG */
920-
#if PRINT_HCI_DATA
932+
#if defined(PRINT_HCI_DATA)
933+
printf("TX>> ACL : ");
921934
for (uint8_t i = 0; i < len + 1 + 8; i++) {
922-
tr_debug(" %02x", *(((uint8_t *) aclDataBuffer) + i));
935+
printf("%02x ", *(((uint8_t *) HciAclDataBuffer) + i));
923936
}
924-
#endif
937+
printf("\r\n");
938+
#endif /* PRINT_HCI_DATA */
939+
#endif /* DEBUG */
925940
break;
926941
}
927942
return len;
@@ -938,7 +953,7 @@ static void init_debug(void)
938953

939954
#if defined(CONFIG_DEBUG)
940955
#if defined(DEBUG)
941-
printf("init_debug ENABLED");
956+
printf("init_debug ENABLED\r\n");
942957
#endif /* DEBUG */
943958
/**
944959
* Keep debugger enabled while in any low power mode
@@ -953,7 +968,7 @@ static void init_debug(void)
953968

954969
#else
955970
#if defined(DEBUG)
956-
printf("init_debug DISABLED");
971+
printf("init_debug DISABLED\n\r");
957972
#endif /* DEBUG */
958973
GPIO_InitTypeDef gpio_config = {0};
959974

0 commit comments

Comments
 (0)