From b605a0886717edf422b23c5169ef0e21af9ab7dd Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Mon, 20 Mar 2023 16:16:29 -0500 Subject: [PATCH 01/10] Add more info in PER plot --- .github/workflows/scripts/plot_per_results.py | 113 ++++++++++++------ 1 file changed, 74 insertions(+), 39 deletions(-) diff --git a/.github/workflows/scripts/plot_per_results.py b/.github/workflows/scripts/plot_per_results.py index c3ace735e4..1b668c49fb 100755 --- a/.github/workflows/scripts/plot_per_results.py +++ b/.github/workflows/scripts/plot_per_results.py @@ -167,19 +167,30 @@ ] } -#pprint(per_mask) - # print("--------------------------------------------------------------------------------------------") row = len(lens) * len(txPowers) col = len(phys) # print(f'row: {row}, col: {col}') +# local-full-per-test-2023-03-19_20-51-33_max32655_EvKit_V1.pdf +name = pdf_file_name.split('/')[-1] +board = name.split('_')[2].upper() +board_type = name.split("_")[3].upper() # EVKIT, WLP +if board == "MAX32655": + board_rev = "PCB-00177-B-0" +elif board == "MAX32665": + board_rev = "PCB-00129-C-0" +elif board == "MAX32690" and board_type == "EVKIT": + board_rev = "PCB-00224-A-0" +elif board == "MAX32690" and board_type == "WLP": + board_rev = "PCB-00247-A-0" +else: + board_rev = "" + if row > 1 or col > 1: fig, axs = plt.subplots(row, col) - name = pdf_file_name.split('/')[-1] - board = name.split('_')[2].replace('.pdf', '').upper() - fig.suptitle(f'Packet Error Rate vs Rx Power\n{board}', fontsize=10) + fig.suptitle(f'Packet Error Rate vs Rx Power\n{board} {board_rev}', fontsize=10) if axs.ndim == 1: plt.subplots_adjust(top=0.83, hspace=0.5) @@ -223,45 +234,66 @@ axs[col].tick_params(axis='both', which='major', labelsize=4) axs[col].plot(tempDf["atten"], tempDf["perSlave"], "-x", linewidth=0.25, ms=0.5) - if use_per_mask == "0": - axs[col].axhline(y=SPEC, color='r', linestyle=':', linewidth=0.5) - else: + axs[col].axhline(y=SPEC, color='r', linestyle=':', linewidth=0.1) + + if use_per_mask == "1": axs[col].plot(xx, yy, "r-", linewidth=0.1, ms=0.1) + axs[col].text(0.40, 0.99, f'PER mask margin: {per_mask_margin} dBm', ha='left', va='top', + fontsize=3, transform=axs[col].transAxes) else: axs[row, col].set_title(title, fontdict={'fontsize': 6, 'fontweight': 'medium'}) axs[row, col].set_xlabel('Rx Power (dBm)', fontdict={"fontsize": 4}) axs[row, col].set_ylabel('PER (%)', fontdict={"fontsize": 4}) axs[row, col].tick_params(axis='both', which='major', labelsize=4) axs[row, col].plot(tempDf["atten"], tempDf["perSlave"], "-x", linewidth=0.25, ms=0.5) - if use_per_mask == "0": - axs[row, col].axhline(y=SPEC, color='r', linestyle=':', linewidth=0.5) - else: + + axs[row, col].axhline(y=SPEC, color='r', linestyle=':', linewidth=0.1) + + if use_per_mask == "1": axs[row, col].plot(xx, yy, "r-", linewidth=0.1, ms=0.1) + axs[row, col].text(0.40, 0.99, f'PER mask margin: {per_mask_margin} dBm', ha='left', va='top', fontsize=3, + transform=axs[row, col].transAxes) - if use_per_mask == "0": - a = list(tempDf['atten']) - p = list(tempDf['perSlave']) - for i in range(len(a)): - if p[i] > SPEC: - # print(f'{a[i]}, {p[i]}') - if axs.ndim == 1: - axs[col].axvline(x=a[i], color='r', linestyle=':', linewidth=0.5) - axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', - verticalalignment='center', fontsize=3) - else: - axs[row, col].axvline(x=a[i], color='r', linestyle=':', linewidth=0.5) - axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', - verticalalignment='center', fontsize=3) - break - - # mark the last point - i = -1 + a = list(tempDf['atten']) + p = list(tempDf['perSlave']) + failed = False + failed_index = 0 + for i in range(len(a)): + if p[i] > SPEC: + # print(f'{a[i]}, {p[i]}') + failed = True + failed_index = i + if axs.ndim == 1: + #axs[col].plot((a[i], a[i]), [0, p[i]], color='r', linestyle=':', linewidth=0.1) + axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + va='center', fontsize=3, color='red') + axs[col].text(0.6, 0.75, 'FAIL', fontsize=6, color='red', transform=axs[col].transAxes) + else: + #axs[row, col].plot((a[i], a[i]), [0, p[i]], color='r', linestyle=':', linewidth=0.5) + axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + va='center', fontsize=3, color='red') + axs[row, col].text(0.6, 0.75, 'FAIL', fontsize=6, color='red', transform=axs[row, col].transAxes) + break + + # mark the last point + i = -1 + if not failed: if axs.ndim == 1: - axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', - verticalalignment='center', fontsize=3) + axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + va='center', fontsize=3, color='black') + axs[col].text(0.6, 0.75, 'PASS', fontsize=6, color='green', transform=axs[col].transAxes) else: - axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', - verticalalignment='center', fontsize=3) + axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + va='center', fontsize=3, color='black') + axs[row, col].text(0.6, 0.75, 'PASS', fontsize=6, color='green', transform=axs[row, col].transAxes) + + if failed and a[failed_index] != a[i]: + if axs.ndim == 1: + axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + va='center', fontsize=3, color='red') + else: + axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + va='center', fontsize=3, color='red') # note fig.text(.5, .01, f'Run on all data channels (no advertising channels).\n{args.desc}', ha='center', @@ -276,7 +308,7 @@ # http://10.20.14.104:8000/per/pdf/?pdf=msdk-2023-02-13_15-34-35_max32655_EvKit_V1.pdf url = f'http://{ip}:8000/per/pdf/?pdf={ntpath.basename(saved_file)}' - print(url) + #print(url) url_links.append(url) plt.savefig(saved_file) @@ -328,18 +360,21 @@ a = list(tempDf['atten']) p = list(tempDf['perSlave']) plt.axhline(y=SPEC, color='r', linestyle=':', linewidth=0.75) + failed = False for i in range(len(a)): if p[i] > SPEC: + failed = True print(f'{a[i]}, {p[i]}') - plt.axvline(x=a[i], color='r', linestyle=':', linewidth=0.75) - plt.text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', - verticalalignment='center', fontsize=8) + plt.plot((a[i], a[i]), ([0, p[i]]), color='r', linestyle=':', linewidth=0.75) + plt.text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + va='center', fontsize=8) break # mark the last point i = -1 - plt.text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', - verticalalignment='center', fontsize=8) + if failed and a[failed_index] != a[i]: + plt.text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + va='center', fontsize=8) # resize the figure to match the aspect ratio of the Axes fig.set_size_inches(7, 8, forward=True) From fe89ab9133128e2301de03f921da572159f42844 Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Tue, 30 May 2023 11:43:08 -0500 Subject: [PATCH 02/10] added RSSI reading in PER test --- .github/workflows/scripts/board_per_test.sh | 2 +- .github/workflows/scripts/plot_per_results.py | 133 ++++++++++++------ Tools/Bluetooth/BLE_hci.py | 39 ++++- Tools/Bluetooth/conn_sweep.py | 25 +++- 4 files changed, 144 insertions(+), 55 deletions(-) diff --git a/.github/workflows/scripts/board_per_test.sh b/.github/workflows/scripts/board_per_test.sh index a627ac6a86..44bc9fa31a 100755 --- a/.github/workflows/scripts/board_per_test.sh +++ b/.github/workflows/scripts/board_per_test.sh @@ -160,7 +160,7 @@ echo "#------------------------------------------------------------------------- echo "Test in different packet length, PHY, attenuation, and txPower" i=0 -echo "packetLen,phy,atten,txPower,perMaster,perSlave" > "${all_in_one}" +echo "packetLen,phy,atten,txPower,perMaster,perSlave,mst_rssi,slv_rssi" > "${all_in_one}" step=${STEP} echo "" diff --git a/.github/workflows/scripts/plot_per_results.py b/.github/workflows/scripts/plot_per_results.py index 1b668c49fb..b06a847e1a 100755 --- a/.github/workflows/scripts/plot_per_results.py +++ b/.github/workflows/scripts/plot_per_results.py @@ -196,21 +196,14 @@ plt.subplots_adjust(top=0.83, hspace=0.5) else: fig.tight_layout() - plt.subplots_adjust(top=0.80, bottom=0.1, hspace=0.5) + plt.subplots_adjust(top=0.80, bottom=0.1, hspace=0.6) case = 0 for packetLen, phy, txPower in itertools.product(lens, phys, txPowers): - # print(f'CASE: {case + 1}') col = case % len(phys) row = int(case / len(phys)) - # print(f'row: {row}, col: {col}') - # Create line plot with atten to perSlave - # print("len :", packetLen) - # print("phy :", phy) - # print("txPower :", txPower) - tempDf = df.loc[(df['packetLen'] == packetLen) & ( - df['phy'] == phy) & (df['txPower'] == txPower)] + tempDf = df.loc[(df['packetLen'] == packetLen) & (df['phy'] == phy) & (df['txPower'] == txPower)] # generate per mask profile if use_per_mask == "1": @@ -226,74 +219,122 @@ # Interpolate the y values for the new x values yy = f(xx) - title = f'packet len: {packetLen}, txPower: 0.7 dBm\nphy: {phy_str[phy]}' + x = list(xx) + y = list(yy) + a = list(tempDf['atten']) + p = list(tempDf['perSlave']) + + title = f'PHY: {phy_str[phy]}\nPacket Length: {packetLen}\nTX Power: 0.7 dBm\n' + + colors = [] + shapes = [] + for i in range(len(a)): + if a[i] > 0: + a[i] = -a[i] + if a[i] in x: + index = x.index(a[i]) + if p[i] > y[index]: + colors.append('r') + shapes.append("x") + else: + colors.append('g') + shapes.append(".") + if axs.ndim == 1: - axs[col].set_title(title, fontdict={'fontsize': 6, 'fontweight': 'medium'}) + axs[col].set_title(title, fontdict={'fontsize': 4, 'fontweight': 'medium', 'horizontalalignment': 'left'}) axs[col].set_xlabel('Rx Power (dBm)', fontdict={"fontsize": 5}) axs[col].set_ylabel('PER (%)', fontdict={"fontsize": 5}) - axs[col].tick_params(axis='both', which='major', labelsize=4) - axs[col].plot(tempDf["atten"], tempDf["perSlave"], "-x", linewidth=0.25, ms=0.5) + axs[col].tick_params(axis='both', which='major', labelsize=4) + for i in range(len(a)): + axs[col].scatter(a[i], p[i], marker=shapes[i], s=1, c=colors[i]) + + axs[col].plot(a, p, marker="", linewidth=0.1, c='black') + axs[col].axhline(y=SPEC, color='r', linestyle=':', linewidth=0.1) if use_per_mask == "1": axs[col].plot(xx, yy, "r-", linewidth=0.1, ms=0.1) - axs[col].text(0.40, 0.99, f'PER mask margin: {per_mask_margin} dBm', ha='left', va='top', + axs[col].text(0.40, 0.99, f'PER mask margin={per_mask_margin}%\nRX power correction={per_corr_dtm_to_cm} dB', ha='left', va='top', fontsize=3, transform=axs[col].transAxes) else: axs[row, col].set_title(title, fontdict={'fontsize': 6, 'fontweight': 'medium'}) axs[row, col].set_xlabel('Rx Power (dBm)', fontdict={"fontsize": 4}) axs[row, col].set_ylabel('PER (%)', fontdict={"fontsize": 4}) axs[row, col].tick_params(axis='both', which='major', labelsize=4) - axs[row, col].plot(tempDf["atten"], tempDf["perSlave"], "-x", linewidth=0.25, ms=0.5) + + for i in range(len(a)): + axs[row, col].scatter(a[i], p[i], marker=shapes[i], s=1, c=colors[i]) + + axs[row, col].plot(a, p, marker="", linewidth=0.1, c='black') axs[row, col].axhline(y=SPEC, color='r', linestyle=':', linewidth=0.1) if use_per_mask == "1": axs[row, col].plot(xx, yy, "r-", linewidth=0.1, ms=0.1) - axs[row, col].text(0.40, 0.99, f'PER mask margin: {per_mask_margin} dBm', ha='left', va='top', fontsize=3, + axs[row, col].text(0.40, 0.99, f'PER mask margin={per_mask_margin}%\nRX power correction={per_corr_dtm_to_cm} dB', ha='left', va='top', fontsize=3, transform=axs[row, col].transAxes) - a = list(tempDf['atten']) - p = list(tempDf['perSlave']) + # highlight the failed points + """ + for i in range(len(a)): + if a[i] in x: + index = x.index(a[i]) + + if p[i] > yy[index]: + if axs.ndim == 1: + axs[col].scatter(a[i], p[i], marker="x", c='red', s=1) + else: + axs[row, col].scatter(a[i], p[i], marker="x", c='red', s=1) + """ + failed = False failed_index = 0 + # annontate the first failed point for i in range(len(a)): - if p[i] > SPEC: - # print(f'{a[i]}, {p[i]}') - failed = True - failed_index = i - if axs.ndim == 1: - #axs[col].plot((a[i], a[i]), [0, p[i]], color='r', linestyle=':', linewidth=0.1) - axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', - va='center', fontsize=3, color='red') - axs[col].text(0.6, 0.75, 'FAIL', fontsize=6, color='red', transform=axs[col].transAxes) - else: - #axs[row, col].plot((a[i], a[i]), [0, p[i]], color='r', linestyle=':', linewidth=0.5) - axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + if a[i] in x: + index = x.index(a[i]) + + if p[i] > yy[index]: + failed = True + failed_index = i + if axs.ndim == 1: + axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', va='center', fontsize=3, color='red') - axs[row, col].text(0.6, 0.75, 'FAIL', fontsize=6, color='red', transform=axs[row, col].transAxes) - break - - # mark the last point + axs[col].text(0.6, 0.75, 'FAIL', fontsize=6, color='red', transform=axs[col].transAxes) + else: + axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', + va='center', fontsize=3, color='red') + axs[row, col].text(0.6, 0.75, 'FAIL', fontsize=6, color='red', transform=axs[row, col].transAxes) + break + + # annotate the last point i = -1 - if not failed: - if axs.ndim == 1: - axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', - va='center', fontsize=3, color='black') - axs[col].text(0.6, 0.75, 'PASS', fontsize=6, color='green', transform=axs[col].transAxes) + if a[i] in x and a[failed_index] != a[i]: + index = x.index(a[i]) + if p[i] > yy[index]: + color = 'red' else: - axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', - va='center', fontsize=3, color='black') - axs[row, col].text(0.6, 0.75, 'PASS', fontsize=6, color='green', transform=axs[row, col].transAxes) - - if failed and a[failed_index] != a[i]: + color = 'black' + if axs.ndim == 1: axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', - va='center', fontsize=3, color='red') + va='center', fontsize=3, color=color) else: axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', ha='left', - va='center', fontsize=3, color='red') + va='center', fontsize=3, color=color) + + # annotate pass or fail + color = 'green' + note = 'PASS' + if failed: + color = 'red' + note = 'FAIL' + + if axs.ndim == 1: + axs[col].text(0.6, 0.75, note, fontsize=6, color=color, transform=axs[col].transAxes) + else: + axs[row, col].text(0.6, 0.75, note, fontsize=6, color=color, transform=axs[row, col].transAxes) # note fig.text(.5, .01, f'Run on all data channels (no advertising channels).\n{args.desc}', ha='center', diff --git a/Tools/Bluetooth/BLE_hci.py b/Tools/Bluetooth/BLE_hci.py index 8d3a9fa7c9..0250ad4416 100644 --- a/Tools/Bluetooth/BLE_hci.py +++ b/Tools/Bluetooth/BLE_hci.py @@ -46,9 +46,12 @@ from argparse import RawTextHelpFormatter from time import sleep import datetime +import struct import threading from termcolor import colored import readline + + # Setup the default serial port settings defaultBaud=115200 defaultSP="/dev/ttyUSB0" @@ -296,7 +299,7 @@ def wait_events(self, seconds = 2, print_evt = True): # and print an HCI event by default. ################################################################################ - def send_command(self, packet, resp = True, delay = 0.01, print_cmd = True, timeout=6): + def send_command(self, packet, resp=True, delay=0.01, print_cmd=True, timeout=6): # Send the command and data if(print_cmd): if self.id == "-": @@ -304,8 +307,6 @@ def send_command(self, packet, resp = True, delay = 0.01, print_cmd = True, time else: print(str(datetime.datetime.now()) + f" {self.id}>", packet) - - arr = bytearray.fromhex(packet) self.port.write(arr) @@ -314,7 +315,7 @@ def send_command(self, packet, resp = True, delay = 0.01, print_cmd = True, time sleep(delay) - if(resp): + if resp: return self.wait_event(timeout=timeout) @@ -1134,7 +1135,29 @@ def writeRegFunc(self, args): self.send_command("0100FF"+totalLen+writeLen+addrBytes+data) - + ## Read RSSI function. + # + # Sends HCI command to read RSSI. + ################################################################################ + def rssiFunc(self, args, timeout=None): + if timeout is None: + self.send_command("010514020000", resp=False) + timeout = 0.1 + else: + self.send_command("010514020000", resp=False, timeout=timeout) + + rssi = 0 + evt = self.wait_event(timeout=timeout) + if evt is not None: + rssi_hex_str = evt[-2:] + byte_data = bytes.fromhex(rssi_hex_str) + rssi = struct.unpack('>b', byte_data)[0] + + if rssi is None: + rssi = 0 + + return rssi + ## Help function. # # Prints the help text. @@ -1380,6 +1403,12 @@ def signal_handler(signal, frame): readWrite_parser.add_argument('value', help="Data to write, 8,16, or 32 bit hex value,\nex: \"0x12\"") readWrite_parser.set_defaults(func=ble_hci.writeRegFunc) + rssi_parser = subparsers.add_parser('rssi', formatter_class=RawTextHelpFormatter, + help="read rssi") + rssi_parser.add_argument('-t', '--timeout', default="0.1", + help="read RSSI timeout in seconds, default 0.1 secs.") + rssi_parser.set_defaults(func=ble_hci.rssiFunc) + # Exit function defined above exit_parser = subparsers.add_parser('exit', aliases=['quit'], help="Exit the program") exit_parser.set_defaults(func=ble_hci.exitFunc) diff --git a/Tools/Bluetooth/conn_sweep.py b/Tools/Bluetooth/conn_sweep.py index 806861bdce..da54e5a6a5 100755 --- a/Tools/Bluetooth/conn_sweep.py +++ b/Tools/Bluetooth/conn_sweep.py @@ -202,6 +202,8 @@ def run_script_reset_board(sh_file): # Open the results file, write the parameters results = open(args.results, "a") +rssi_file_name = args.results.replace(".csv", "_rssi.csv") +rssi_results = open(rssi_file_name, "a") print("\nReset the attenuation to 30.") if rf_switch: @@ -346,6 +348,18 @@ def run_script_reset_board(sh_file): print("\nmaster read any pending events") hciMaster.listenFunc(Namespace(time=1, stats="False")) + print("\nMaster: read RSSI") + #hciMaster.cmdFunc(Namespace(cmd="010514020000")) + mst_rssi = hciMaster.rssiFunc(None) + print(f'master rssi: {mst_rssi}') + sleep(0.2) + + print("\nSlave: read RSSI") + #hciSlave.cmdFunc(Namespace(cmd="010514020000")) + slv_rssi = hciSlave.rssiFunc(None) + print(f'slave rssi: {slv_rssi}') + sleep(0.2) + print("\nMaster collects results.") perMaster = hciMaster.connStatsFunc(None) @@ -406,11 +420,15 @@ def run_script_reset_board(sh_file): perSlave = 100 perMax = 100 - ABORTED = True + if not use_per_mask: + ABORTED = True + break - # Save the results to file - results.write(str(packetLen)+","+str(phy)+",-"+str(atten)+","+str(txPower)+","+str(perMaster)+","+str(perSlave)+"\n") + # Save the results to file + results.write(f'{packetLen},{phy},{atten},{txPower},{perMaster},{perSlave},{mst_rssi},{slv_rssi}\n') + rssi_results.write(f'{packetLen},{phy},{atten},{txPower},{perMaster},{perSlave},{mst_rssi},{slv_rssi}\n') + end_secs = time.time() print(f'\nTotally used time for this point (secs): {(end_secs - start_secs):.0f}') @@ -432,6 +450,7 @@ def run_script_reset_board(sh_file): results.write("\n") results.close() +rssi_results.close() print("perMax: ", perMax) From ed23b8cbf220085ce31540b8cdbd33b37b062081 Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Wed, 20 Sep 2023 16:39:00 -0500 Subject: [PATCH 03/10] add long range adv demo --- Examples/MAX32665/BLE_LR_Peripheral/.cproject | 93 ++ Examples/MAX32665/BLE_LR_Peripheral/.project | 26 + .../.settings/language.settings.xml | 15 + .../org.eclipse.cdt.codan.core.prefs | 93 ++ .../.settings/org.eclipse.cdt.core.prefs | 15 + .../BLE_LR_Peripheral/.vscode/README.md | 47 + .../.vscode/c_cpp_properties.json | 53 ++ .../BLE_LR_Peripheral/.vscode/flash.gdb | 15 + .../BLE_LR_Peripheral/.vscode/launch.json | 133 +++ .../BLE_LR_Peripheral/.vscode/settings.json | 99 +++ .../BLE_LR_Peripheral/.vscode/tasks.json | 115 +++ .../BLE_LR_Peripheral.launch | 62 ++ Examples/MAX32665/BLE_LR_Peripheral/Makefile | 395 +++++++++ Examples/MAX32665/BLE_LR_Peripheral/README.md | 59 ++ Examples/MAX32665/BLE_LR_Peripheral/fit_api.h | 82 ++ .../MAX32665/BLE_LR_Peripheral/fit_main.c | 807 ++++++++++++++++++ Examples/MAX32665/BLE_LR_Peripheral/main.c | 285 +++++++ .../MAX32665/BLE_LR_Peripheral/project.mk | 26 + .../MAX32665/BLE_LR_Peripheral/stack_fit.c | 132 +++ .../sources/hci/exactle/hci_cmd_master_ae.c | 6 + .../sources/hci/exactle/hci_core_ps.c | 27 + .../ble-host/sources/hci/exactle/hci_evt.c | 2 +- .../ble-host/sources/stack/dm/dm_adv_ae.c | 21 +- .../Cordio/ble-host/sources/stack/dm/dm_dev.c | 2 +- .../ble-host/sources/stack/dm/dm_scan_ae.c | 6 + .../Cordio/ble-profiles/sources/af/app_main.c | 5 +- .../ble-profiles/sources/af/app_master_leg.c | 11 + .../ble-profiles/sources/af/app_slave_leg.c | 21 +- .../sources/ble/bb/bb_ble_adv_master.c | 5 +- .../sources/ble/bb/bb_ble_adv_slave_ae.c | 14 +- .../sources/ble/lctr/lctr_isr_adv_master_ae.c | 4 +- .../sources/ble/lctr/lctr_main_adv_master.c | 8 + .../ble/lctr/lctr_main_adv_master_ae.c | 23 +- .../ble/lctr/lctr_main_init_master_ae.c | 12 +- .../sources/ble/ll/ll_main_adv_master_ae.c | 13 +- .../controller/sources/common/sch/sch_int.h | 9 +- .../controller/sources/common/sch/sch_list.c | 15 + .../controller/sources/common/sch/sch_main.c | 19 +- .../targets/maxim/max32655/sources/pal_cfg.c | 2 - Libraries/Cordio/wsf/include/wsf_os.h | 34 + Libraries/Cordio/wsf/include/wsf_trace.h | 16 + .../wsf/sources/targets/baremetal/wsf_msg.c | 14 + .../wsf/sources/targets/baremetal/wsf_nvm.c | 2 +- .../wsf/sources/targets/baremetal/wsf_os.c | 24 +- .../wsf/sources/targets/win32/wsf_trace.h | 1 + 45 files changed, 2815 insertions(+), 53 deletions(-) create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/.cproject create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/.project create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/.settings/language.settings.xml create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/.settings/org.eclipse.cdt.codan.core.prefs create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/.settings/org.eclipse.cdt.core.prefs create mode 100755 Examples/MAX32665/BLE_LR_Peripheral/.vscode/README.md create mode 100755 Examples/MAX32665/BLE_LR_Peripheral/.vscode/c_cpp_properties.json create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/.vscode/flash.gdb create mode 100755 Examples/MAX32665/BLE_LR_Peripheral/.vscode/launch.json create mode 100755 Examples/MAX32665/BLE_LR_Peripheral/.vscode/settings.json create mode 100755 Examples/MAX32665/BLE_LR_Peripheral/.vscode/tasks.json create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/BLE_LR_Peripheral.launch create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/Makefile create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/README.md create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/fit_api.h create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/fit_main.c create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/main.c create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/project.mk create mode 100644 Examples/MAX32665/BLE_LR_Peripheral/stack_fit.c diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.cproject b/Examples/MAX32665/BLE_LR_Peripheral/.cproject new file mode 100644 index 0000000000..bfe61c1a4a --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.cproject @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.project b/Examples/MAX32665/BLE_LR_Peripheral/.project new file mode 100644 index 0000000000..1690ce9d8e --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.project @@ -0,0 +1,26 @@ + + + BLE_LR_Peripheral + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.settings/language.settings.xml b/Examples/MAX32665/BLE_LR_Peripheral/.settings/language.settings.xml new file mode 100644 index 0000000000..d32717b6f3 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.settings/language.settings.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.settings/org.eclipse.cdt.codan.core.prefs b/Examples/MAX32665/BLE_LR_Peripheral/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000000..59c0b37ba7 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,93 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"} +org.eclipse.cdt.codan.checkers.nocommentinside=-Error +org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"} +org.eclipse.cdt.codan.checkers.nolinecomment=-Error +org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"} +org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"C-Style cast instead of C++ cast\\")"} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"} +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true} +org.eclipse.cdt.codan.internal.checkers.CopyrightProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.CopyrightProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Lack of copyright information\\")",regex\=>".*Copyright.*"} +org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error +org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Goto statement used\\")"} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.MissCaseProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissCaseProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing cases in switch\\")"} +org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing default in switch\\")",defaultWithAllEnums\=>false} +org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing reference return value in assignment operator\\")"} +org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing self check in assignment operator\\")"} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Using directive in header\\")"} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem=-Error +org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Virtual method call in constructor/destructor\\")"} +org.eclipse.cdt.qt.core.qtproblem=Warning +org.eclipse.cdt.qt.core.qtproblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_ON_FILE_OPEN\=>true,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>null} diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.settings/org.eclipse.cdt.core.prefs b/Examples/MAX32665/BLE_LR_Peripheral/.settings/org.eclipse.cdt.core.prefs new file mode 100644 index 0000000000..27106204ed --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.settings/org.eclipse.cdt.core.prefs @@ -0,0 +1,15 @@ +eclipse.preferences.version=1 +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/BOARD/delimiter=; +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/BOARD/operation=append +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/BOARD/value=EvKit_V1 +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/GCC_PREFIX/delimiter=; +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/GCC_PREFIX/operation=replace +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/GCC_PREFIX/value=arm-none-eabi- +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/PROJECT/delimiter=; +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/PROJECT/operation=append +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/PROJECT/value=BLE_LR_Peripheral +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/TARGET/delimiter=; +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/TARGET/operation=append +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/TARGET/value=MAX32665 +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/append=true +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/appendContributed=true diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.vscode/README.md b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/README.md new file mode 100755 index 0000000000..58733e941c --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/README.md @@ -0,0 +1,47 @@ +# VSCode-Maxim + +_(If you're viewing this document from within Visual Studio Code you can press `CTRL+SHIFT+V` to open a Markdown preview window.)_ + +## Quick Links + +* [MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/) +* [VSCode-Maxim Github](https://github.com/Analog-Devices-MSDK/VSCode-Maxim) + +## Introduction + +VSCode-Maxim is a set of [Visual Studio Code](https://code.visualstudio.com/) project configurations and utilities for enabling embedded development for [Analog Device's MSDK](https://github.com/Analog-Devices-MSDK/msdk) and the [MAX32xxx/MAX78xxx microcontrollers](https://www.analog.com/en/product-category/microcontrollers.html). + +The following features are supported: + +* Code editing with intellisense down to the register level +* Code compilation with the ability to easily re-target a project for different microcontrollers and boards +* Flashing programs +* GUI and command-line debugging + +## Dependencies + +* [Visual Studio Code](https://code.visualstudio.com/) + * [C/C++ VSCode Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) + * [Cortex-Debug Extension](https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug) +* [Analog Devices MSDK](https://analog-devices-msdk.github.io/msdk/) + +## Installation + +Install the MSDK, then set `"MAXIM_PATH"` in your _user_ VS Code settings. + +See [Getting Started with Visual Studio Code](https://analog-devices-msdk.github.io/msdk/USERGUIDE/#getting-started-with-visual-studio-code) in the MSDK User Guide for detailed instructions. + +## Usage + +See the [MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/#visual-studio-code) for detailed usage info. + +## Issue Tracker + +Bug reports, feature requests, and contributions are welcome via the [issues](https://github.com/Analog-Devices-MSDK/VSCode-Maxim/issues) tracker on Github. + +New issues should contain _at minimum_ the following information: + +* Visual Studio Code version #s (see `Help -> About`) +* C/C++ Extension version # +* Target microcontroller and evaluation platform +* The projects `.vscode` folder and `Makefile` (where applicable). Standard compression formats such as `.zip`, `.rar`, `.tar.gz`, etc. are all acceptable. diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.vscode/c_cpp_properties.json b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/c_cpp_properties.json new file mode 100755 index 0000000000..dfbed47b58 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/c_cpp_properties.json @@ -0,0 +1,53 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${default}" + ], + "defines": [ + "${default}" + ], + "intelliSenseMode": "gcc-arm", + "compilerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gcc.exe", + "browse": { + "path": [ + "${default}" + ] + } + }, + { + "name": "Linux", + "includePath": [ + "${default}" + ], + "defines": [ + "${default}" + ], + "intelliSenseMode": "gcc-arm", + "compilerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gcc", + "browse": { + "path": [ + "${default}" + ] + } + }, + { + "name": "Mac", + "includePath": [ + "${default}" + ], + "defines": [ + "${default}" + ], + "intelliSenseMode": "gcc-arm", + "compilerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gcc", + "browse": { + "path": [ + "${default}" + ] + } + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.vscode/flash.gdb b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/flash.gdb new file mode 100644 index 0000000000..fc627ae86a --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/flash.gdb @@ -0,0 +1,15 @@ +define flash_m4 + set architecture armv7e-m + target remote | openocd -c "gdb_port pipe;log_output flash.log" -s $arg0/scripts -f interface/$arg1 -f target/$arg2 -c "init; reset halt" + load + compare-sections + monitor reset halt +end + +define flash_m4_run + set architecture armv7e-m + target remote | openocd -c "gdb_port pipe;log_output flash.log" -s $arg0/scripts -f interface/$arg1 -f target/$arg2 -c "init; reset halt" + load + compare-sections + monitor resume +end \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.vscode/launch.json b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/launch.json new file mode 100755 index 0000000000..a3900ecf2a --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/launch.json @@ -0,0 +1,133 @@ +{ + "configurations": [ + { + "name": "Debug Arm (Cortex-debug)", + "cwd":"${workspaceRoot}", + "executable": "${workspaceFolder}/build/${config:program_file}", + "loadFiles": ["${workspaceFolder}/build/${config:program_file}"], + "symbolFiles": [{ + "file": "${workspaceFolder}/build/${config:symbol_file}" + }], + "request": "launch", + "type": "cortex-debug", + "servertype": "openocd", + "linux": { + "gdbPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb", + "serverpath": "${config:OCD_path}/openocd", + }, + "windows": { + "gdbPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb.exe", + "serverpath": "${config:OCD_path}/openocd.exe", + }, + "osx": { + "gdbPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb", + "serverpath": "${config:OCD_path}/openocd", + }, + "searchDir": ["${config:OCD_path}/scripts"], + "configFiles": ["interface/${config:M4_OCD_interface_file}", "target/${config:M4_OCD_target_file}"], + "interface": "swd", + "runToEntryPoint": "main", + "svdFile": "${config:MAXIM_PATH}/Libraries/CMSIS/Device/Maxim/${config:target}/Include/${config:target}.svd" + }, + { + "name": "GDB (Arm M4)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/${config:program_file}", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "linux": { + "miDebuggerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb", + "debugServerPath": "${config:OCD_path}/openocd", + }, + "windows": { + "miDebuggerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb.exe", + "debugServerPath": "${config:OCD_path}/openocd.exe", + }, + "osx": { + "miDebuggerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb", + "debugServerPath": "${config:OCD_path}/bin/openocd", + }, + "logging": { + "exceptions": true, + "trace": false, + "traceResponse": false, + "engineLogging": false + }, + "miDebuggerServerAddress": "localhost:3333", + "debugServerArgs": "-s ${config:OCD_path}/scripts -f interface/${config:M4_OCD_interface_file} -f target/${config:M4_OCD_target_file} -c \"init; reset halt\"", + "serverStarted": "Info : Listening on port 3333 for gdb connections", + "filterStderr": true, + "targetArchitecture": "arm", + "customLaunchSetupCommands": [ + {"text":"-list-features"} + ], + "setupCommands": [ + { "text":"set logging overwrite on"}, + { "text":"set logging file debug-arm.log"}, + { "text":"set logging on"}, + { "text":"cd ${workspaceFolder}" }, + { "text":"exec-file build/${config:program_file}" }, + { "text":"symbol-file build/${config:symbol_file}" }, + { "text":"target remote localhost:3333" }, + { "text":"monitor reset halt" }, + { "text":"set $pc=Reset_Handler"}, + { "text":"b main" } + ] + }, + { + "name": "GDB (RISC-V)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/buildrv/${config:program_file}", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "linux": { + "miDebuggerPath": "${config:xPack_GCC_path}/bin/riscv-none-elf-gdb", + "debugServerPath": "${config:OCD_path}/openocd", + }, + "windows": { + "miDebuggerPath": "${config:xPack_GCC_path}/bin/riscv-none-elf-gdb.exe", + "debugServerPath": "${config:OCD_path}/openocd.exe", + }, + "osx": { + "miDebuggerPath": "${config:xPack_GCC_path}/bin/riscv-none-elf-gdb", + "debugServerPath": "${config:OCD_path}/bin/openocd", + }, + "logging": { + "exceptions": true, + "trace": false, + "traceResponse": false, + "engineLogging": false + }, + "miDebuggerServerAddress": "localhost:3334", + "debugServerArgs": "-c \"gdb_port 3334\" -s ${config:OCD_path}/scripts -f interface/${config:RV_OCD_interface_file} -f target/${config:RV_OCD_target_file}", + "serverStarted": "Info : Listening on port 3334 for gdb connections", + "filterStderr": true, + "customLaunchSetupCommands": [ + {"text":"-list-features"} + ], + "targetArchitecture": "arm", + "setupCommands": [ + { "text":"set logging overwrite on"}, + { "text":"set logging file debug-riscv.log"}, + { "text":"set logging on"}, + { "text":"cd ${workspaceFolder}" }, + { "text": "set architecture riscv:rv32", "ignoreFailures": false }, + { "text":"exec-file build/${config:program_file}", "ignoreFailures": false }, + { "text":"symbol-file buildrv/${config:symbol_file}", "ignoreFailures": false }, + { "text":"target remote localhost:3334" }, + { "text":"b main" }, + { "text": "set $pc=Reset_Handler","ignoreFailures": false } + ] + } + ] +} \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.vscode/settings.json b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/settings.json new file mode 100755 index 0000000000..981dd2759d --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/settings.json @@ -0,0 +1,99 @@ +{ + "terminal.integrated.env.windows": { + "Path":"${config:OCD_path};${config:ARM_GCC_path}/bin;${config:xPack_GCC_path}/bin;${config:Make_path};${config:MSYS_path}/usr/bin;${env:PATH}", + "MAXIM_PATH":"${config:MAXIM_PATH}" + }, + "terminal.integrated.defaultProfile.windows": "Command Prompt", + + "terminal.integrated.env.linux": { + "PATH":"${config:OCD_path}:${config:ARM_GCC_path}/bin:${config:xPack_GCC_path}/bin:${env:PATH}", + "MAXIM_PATH":"${config:MAXIM_PATH}" + }, + "terminal.integrated.env.osx": { + "PATH":"${config:OCD_path}/bin:${config:ARM_GCC_path}/bin:${config:xPack_GCC_path}/bin:${env:PATH}", + "MAXIM_PATH":"${config:MAXIM_PATH}" + }, + + "target":"MAX32665", + "board":"EvKit_V1", + + "project_name":"${workspaceFolderBasename}", + + "program_file":"${config:project_name}.elf", + "symbol_file":"${config:program_file}", + + "M4_OCD_interface_file":"cmsis-dap.cfg", + "M4_OCD_target_file":"max32665.cfg", + "RV_OCD_interface_file":"ftdi/olimex-arm-usb-ocd-h.cfg", + "RV_OCD_target_file":"${config:target}_riscv.cfg", + + "v_Arm_GCC":"10.3", + "v_xPack_GCC":"12.2.0-3.1", + + "OCD_path":"${config:MAXIM_PATH}/Tools/OpenOCD", + "ARM_GCC_path":"${config:MAXIM_PATH}/Tools/GNUTools/${config:v_Arm_GCC}", + "xPack_GCC_path":"${config:MAXIM_PATH}/Tools/xPack/riscv-none-elf-gcc/${config:v_xPack_GCC}", + "Make_path":"${config:MAXIM_PATH}/Tools/GNUTools/Make", + "MSYS_path":"${config:MAXIM_PATH}/Tools/MSYS2", + + "C_Cpp.default.includePath": [ + "${workspaceFolder}", + "${workspaceFolder}/**", + "${config:MAXIM_PATH}/Libraries/Boards/${config:target}/Include", + "${config:MAXIM_PATH}/Libraries/Boards/${config:target}/${config:board}/Include", + "${config:MAXIM_PATH}/Libraries/CMSIS/Device/Maxim/${config:target}/Include", + "${config:MAXIM_PATH}/Libraries/CMSIS/Include", + "${config:ARM_GCC_path}/arm-none-eabi/include", + "${config:ARM_GCC_path}/lib/gcc/arm-none-eabi/${config:v_Arm_GCC}/include", + "${config:MAXIM_PATH}/Libraries/PeriphDrivers/Include/${config:target}", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Camera", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Display", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/ExtMemory", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/LED", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/PMIC", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/PushButton", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Touchscreen", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/sources/stack/cfg", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-apps/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-model/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-profile/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-profiles/include", + "${config:MAXIM_PATH}/Libraries/Cordio/controller/include/ble", + "${config:MAXIM_PATH}/Libraries/Cordio/controller/include/common", + "${config:MAXIM_PATH}/Libraries/Cordio/platform/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/sources/hci/dual_chip", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/sources/hci/exactle", + "${config:MAXIM_PATH}/Libraries/Cordio/wsf/include", + "${config:MAXIM_PATH}/Libraries/Cordio/wsf/include/util" + ], + "C_Cpp.default.browse.path": [ + "${workspaceFolder}", + "${config:MAXIM_PATH}/Libraries/Boards/${config:target}/Source", + "${config:MAXIM_PATH}/Libraries/Boards/${config:target}/${config:board}/Source", + "${config:MAXIM_PATH}/Libraries/PeriphDrivers/Source", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Camera", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Display", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/LED", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/PMIC", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/PushButton", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Touchscreen", + "${config:MAXIM_PATH}/Libraries/MiscDrivers", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-apps/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-apps/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-model/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-profile/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-profiles/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/controller/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/wsf/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/platform/targets/maxim/max32665/sources" + ], + "C_Cpp.default.defines": [ + + ], + "C_Cpp.default.forcedInclude": [ + "${workspaceFolder}/build/project_defines.h" + ] +} + diff --git a/Examples/MAX32665/BLE_LR_Peripheral/.vscode/tasks.json b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/tasks.json new file mode 100755 index 0000000000..e95445e2b3 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/.vscode/tasks.json @@ -0,0 +1,115 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "make -r -j 8 --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}", + "osx":{ + "command": "source ~/.zshrc && make -r -j 8 --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}" + }, + "group": "build", + "problemMatcher": [] + }, + { + "label": "clean", + "type": "shell", + "command": "make -j 8 clean --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}", + "osx":{ + "command": "source ~/.zshrc && make -j 8 clean --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}" + }, + "group": "build", + "problemMatcher": [] + }, + { + "label": "clean-periph", + "type": "shell", + "command": "make -j 8 distclean --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}", + "osx":{ + "command": "source ~/.zshrc && make -j 8 distclean --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}" + }, + "group": "build", + "problemMatcher": [] + }, + { + "label": "flash", + "type": "shell", + "command": "arm-none-eabi-gdb", + "args": [ + "--cd=\"${workspaceFolder}\"", + "--se=\"build/${config:program_file}\"", + "--symbols=build/${config:symbol_file}", + "-x=\"${workspaceFolder}/.vscode/flash.gdb\"", + "--ex=\"flash_m4 ${config:OCD_path} ${config:M4_OCD_interface_file} ${config:M4_OCD_target_file}\"", + "--batch" + ], + "group": "build", + "problemMatcher": [], + "dependsOn":["build"] + }, + { + "label": "flash & run", + "type": "shell", + "command": "arm-none-eabi-gdb", + "args": [ + "--cd=\"${workspaceFolder}\"", + "--se=\"build/${config:program_file}\"", + "--symbols=build/${config:symbol_file}", + "-x=\"${workspaceFolder}/.vscode/flash.gdb\"", + "--ex=\"flash_m4_run ${config:OCD_path} ${config:M4_OCD_interface_file} ${config:M4_OCD_target_file}\"", + "--batch" + ], + "group": "build", + "problemMatcher": [], + "dependsOn":["build"] + }, + { + "label": "erase flash", + "type": "shell", + "command": "openocd", + "args": [ + "-s", "${config:OCD_path}/scripts", + "-f", "interface/${config:M4_OCD_interface_file}", + "-f", "target/${config:M4_OCD_target_file}", + "-c", "\"init; reset halt; max32xxx mass_erase 0;\"", + "-c", "exit" + ], + "group":"build", + "problemMatcher": [], + "dependsOn":[] + }, + { + "label": "openocd (m4)", + "type": "shell", + "command": "openocd", + "args": [ + "-s", + "${config:OCD_path}/scripts", + "-f", + "interface/${config:M4_OCD_interface_file}", + "-f", + "target/${config:M4_OCD_target_file}", + "-c", + "\"init; reset halt\"" + ], + "problemMatcher": [], + "dependsOn":[] + }, + { + "label": "gdb (m4)", + "type": "shell", + "command": "arm-none-eabi-gdb", + "args": [ + "--ex=\"cd ${workspaceFolder}\"", + "--se=\"build/${config:program_file}\"", + "--symbols=build/${config:symbol_file}", + "--ex=\"target remote localhost:3333\"", + "--ex=\"monitor reset halt\"", + "--ex=\"b main\"", + "--ex=\"c\"" + ], + "problemMatcher": [], + "dependsOn":[] + }, + ] +} \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Peripheral/BLE_LR_Peripheral.launch b/Examples/MAX32665/BLE_LR_Peripheral/BLE_LR_Peripheral.launch new file mode 100644 index 0000000000..37be7b632f --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/BLE_LR_Peripheral.launch @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/MAX32665/BLE_LR_Peripheral/Makefile b/Examples/MAX32665/BLE_LR_Peripheral/Makefile new file mode 100644 index 0000000000..ba87cf6982 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/Makefile @@ -0,0 +1,395 @@ +################################################################################ + # Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + # + # Permission is hereby granted, free of charge, to any person obtaining a + # copy of this software and associated documentation files (the "Software"), + # to deal in the Software without restriction, including without limitation + # the rights to use, copy, modify, merge, publish, distribute, sublicense, + # and/or sell copies of the Software, and to permit persons to whom the + # Software is furnished to do so, subject to the following conditions: + # + # The above copyright notice and this permission notice shall be included + # in all copies or substantial portions of the Software. + # + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + # IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + # OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + # OTHER DEALINGS IN THE SOFTWARE. + # + # Except as contained in this notice, the name of Maxim Integrated + # Products, Inc. shall not be used except as stated in the Maxim Integrated + # Products, Inc. Branding Policy. + # + # The mere transfer of this software does not imply any licenses + # of trade secrets, proprietary technology, copyrights, patents, + # trademarks, maskwork rights, or any other form of intellectual + # property whatsoever. Maxim Integrated Products, Inc. retains all + # ownership rights. + # +############################################################################### + +# ** Readme! ** +# Don't edit this file! This is the core Makefile for a MaximSDK +# project. The available configuration options can be overridden +# in "project.mk", on the command-line, or with system environment +# variables. + +# See https://analog-devices-msdk.github.io/msdk/USERGUIDE/#build-system +# for more detailed instructions on how to use this system. + +# The detailed instructions mentioned above are easier to read than +# this file, but the comments found in this file also outline the +# available configuration variables. This file is organized into +# sub-sections, some of which expose config variables. + + +# ******************************************************************************* +# Set the target microcontroller and board to compile for. + +# Every TARGET microcontroller has some Board Support Packages (BSPs) that are +# available for it under the MaximSDK/Libraries/Boards/TARGET folder. The BSP +# that gets selected is MaximSDK/Libraries/Boards/TARGET/BOARD. + +# Configuration Variables: +# - TARGET : Override the default target microcontroller. Ex: TARGET=MAX78000 +# - BOARD : Override the default BSP (case sensitive). Ex: BOARD=EvKit_V1, BOARD=FTHR_RevA + + +ifeq "$(TARGET)" "" +# Default target microcontroller +TARGET := MAX32665 +TARGET_UC := MAX32665 +TARGET_LC := max32665 +else +# "TARGET" has been overridden in the environment or on the command-line. +# We need to calculate an upper and lowercase version of the part number, +# because paths on Linux and MacOS are case-sensitive. +TARGET_UC := $(subst m,M,$(subst a,A,$(subst x,X,$(TARGET)))) +TARGET_LC := $(subst M,m,$(subst A,a,$(subst X,x,$(TARGET)))) +endif + +# Default board. +BOARD ?= EvKit_V1 + +# ******************************************************************************* +# Locate the MaximSDK + +# This Makefile needs to know where to find the MaximSDK, and the MAXIM_PATH variable +# should point to the root directory of the MaximSDK installation. Setting this manually +# is usually only required if you're working on the command-line. + +# If MAXIM_PATH is not specified, we assume the project still lives inside of the MaximSDK +# and move up from this project's original location. + +# Configuration Variables: +# - MAXIM_PATH : Tell this Makefile where to find the MaximSDK. Ex: MAXIM_PATH=C:/MaximSDK + + +ifneq "$(MAXIM_PATH)" "" +# Sanitize MAXIM_PATH for backslashes +MAXIM_PATH := $(subst \,/,$(MAXIM_PATH)) +# Locate some other useful paths... +LIBS_DIR := $(abspath $(MAXIM_PATH)/Libraries) +CMSIS_ROOT := $(LIBS_DIR)/CMSIS +endif + +# ******************************************************************************* +# Include project Makefile. We do this after formulating TARGET, BOARD, and MAXIM_PATH +# in case project.mk needs to reference those values. However, we also include +# this as early as possible in the Makefile so that it can append to or override +# the variables below. + + +PROJECTMK ?= $(abspath ./project.mk) +include $(PROJECTMK) +$(info Loaded project.mk) +# PROJECTMK is also used by implicit rules and other libraries to add project.mk as a watch file + +# ******************************************************************************* +# Final path sanitization and re-calculation. No options here. + +ifeq "$(MAXIM_PATH)" "" +# MAXIM_PATH is still not defined... +DEPTH := ../../../ +MAXIM_PATH := $(abspath $(DEPTH)) +$(warning Warning: MAXIM_PATH is not set! Set MAXIM_PATH in your environment or in project.mk to clear this warning.) +$(warning Warning: Attempting to use $(MAXIM_PATH) calculated from relative path) +else +# Sanitize MAXIM_PATH for backslashes +MAXIM_PATH := $(subst \,/,$(MAXIM_PATH)) +endif + +# Final recalculation of LIBS_DIR/CMSIS_ROOT +LIBS_DIR := $(abspath $(MAXIM_PATH)/Libraries) +CMSIS_ROOT := $(LIBS_DIR)/CMSIS + +# One final UC/LC check in case user set TARGET in project.mk +TARGET_UC := $(subst m,M,$(subst a,A,$(subst x,X,$(TARGET)))) +TARGET_LC := $(subst M,m,$(subst A,a,$(subst X,x,$(TARGET)))) + +export TARGET +export TARGET_UC +export TARGET_LC +export CMSIS_ROOT +# TODO: Remove dependency on exports for these variables. + +# ******************************************************************************* +# Set up search paths, and auto-detect all source code on those paths. + +# The following paths are searched by default, where "./" is the project directory. +# ./ +# |- *.h +# |- *.c +# |-include (optional) +# |- *.h +# |-src (optional) +# |- *.c + +# Configuration Variables: +# - VPATH : Tell this Makefile to search additional locations for source (.c) files. +# You should use the "+=" operator with this option. +# Ex: VPATH += your/new/path +# - IPATH : Tell this Makefile to search additional locations for header (.h) files. +# You should use the "+=" operator with this option. +# Ex: VPATH += your/new/path +# - SRCS : Tell this Makefile to explicitly add a source (.c) file to the build. +# This is really only useful if you want to add a source file that isn't +# on any VPATH, in which case you can add the full path to the file here. +# You should use the "+=" operator with this option. +# Ex: SRCS += your/specific/source/file.c +# - AUTOSEARCH : Set whether this Makefile should automatically detect .c files on +# VPATH and add them to the build. This is enabled by default. Set +# to 0 to disable. If autosearch is disabled, source files must be +# manually added to SRCS. +# Ex: AUTOSEARCH = 0 + + +# Where to find source files for this project. +VPATH += . +VPATH += src +VPATH := $(VPATH) + +# Where to find header files for this project +IPATH += . +IPATH += include +IPATH := $(IPATH) + +AUTOSEARCH ?= 1 +ifeq ($(AUTOSEARCH), 1) +# Auto-detect all C/C++ source files on VPATH +SRCS += $(wildcard $(addsuffix /*.c, $(VPATH))) +SRCS += $(wildcard $(addsuffix /*.cpp, $(VPATH))) +endif + +# Collapse SRCS before passing them on to the next stage +SRCS := $(SRCS) + +# ******************************************************************************* +# Set the output filename + +# Configuration Variables: +# - PROJECT : Override the default output filename. Ex: PROJECT=MyProject + + +# The default value creates a file named after the target micro. Ex: MAX78000.elf +PROJECT ?= $(TARGET_LC) + +# ******************************************************************************* +# Compiler options + +# Configuration Variables: +# - DEBUG : Set DEBUG=1 to build explicitly for debugging. This adds some additional +# symbols and sets -Og as the default optimization level. +# - MXC_OPTIMIZE_CFLAGS : Override the default compiler optimization level. +# Ex: MXC_OPTIMIZE_CFLAGS = -O2 +# - PROJ_CFLAGS : Add additional compiler flags to the build. +# You should use the "+=" operator with this option. +# Ex: PROJ_CFLAGS += -Wextra +# - MFLOAT_ABI : Set the floating point acceleration level. +# The only options are "hard", "soft", or "softfp". +# Ex: MFLOAT_ABI = hard +# - LINKERFILE : Override the default linkerfile. +# Ex: LINKERFILE = customlinkerfile.ld +# - LINKERPATH : Override the default search location for $(LINKERFILE) +# The default search location is $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/GCC +# If $(LINKERFILE) cannot be found at this path, then the root project +# directory will be used as a fallback. + +# Select 'GCC' or 'IAR' compiler +ifeq "$(COMPILER)" "" +COMPILER := GCC +endif + +# Set default compiler optimization levels +ifeq "$(MAKECMDGOALS)" "release" +# Default optimization level for "release" builds (make release) +MXC_OPTIMIZE_CFLAGS ?= -O2 +DEBUG = 0 +endif + +ifeq ($(DEBUG),1) +# Optimizes for debugging as recommended +# by GNU for code-edit-debug cycles +# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options +MXC_OPTIMIZE_CFLAGS := -Og +endif + +# Default level if not building for release or explicitly for debug +MXC_OPTIMIZE_CFLAGS ?= -Og + +# Set compiler flags +PROJ_CFLAGS += -Wall # Enable warnings +PROJ_CFLAGS += -DMXC_ASSERT_ENABLE + +# Set hardware floating point acceleration. +# Options are: +# - hard +# - soft +# - softfp (default if MFLOAT_ABI is not set) +MFLOAT_ABI ?= softfp +# MFLOAT_ABI must be exported to other Makefiles +export MFLOAT_ABI + +# This path contains system-level intialization files for the target micro. Add to the build. +VPATH += $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source + +# ******************************************************************************* +# Secure Boot Tools (SBT) + +# This section integrates the Secure Boot Tools. It's intended for use with +# microcontrollers that have a secure bootloader. + +# Enabling SBT integration will add some special rules, such as "make sla", "make scpa", etc. + +# Configuration variables: +# SBT : Toggle SBT integration. Set to 1 to enable, or 0 +# to disable +# MAXIM_SBT_DIR : Specify the location of the SBT tool binaries. This defaults to +# Tools/SBT in the MaximSDK. The standalone SBT installer will override +# this via an environment variable. +# TARGET_SEC : Specify the part number to be passed into the SBT. This should match +# the secure variant part #. The default value will depend on TARGET. +# For example, TARGET=MAX32650 will result in TARGET_SEC=MAX32651, and +# the default selection happens in Tools/SBT/SBT-config. +# However, if there are multiple secure part #s for the target +# microcontroller this variable may need to be changed. + +SBT ?= 0 +ifeq ($(SBT), 1) +MAXIM_SBT_DIR ?= $(MAXIM_PATH)/Tools/SBT +MAXIM_SBT_DIR := $(subst \,/,$(MAXIM_SBT_DIR)) +# ^ Must sanitize path for \ on Windows, since this may come from an environment +# variable. + +export MAXIM_SBT_DIR # SBTs must have this environment variable defined to work + +# SBT-config.mk and SBT-rules.mk are included further down this Makefile. + +endif # SBT + +# ******************************************************************************* +# Default goal selection. This section allows you to override the default goal +# that will run if no targets are specified on the command-line. +# (ie. just running 'make' instead of 'make all') + +# Configuration variables: +# .DEFAULT_GOAL : Set the default goal if no targets were specified on the +# command-line +# ** "override" must be used with this variable. ** +# Ex: "override .DEFAULT_GOAL = mygoal" + +ifeq "$(.DEFAULT_GOAL)" "" +ifeq ($(SBT),1) +override .DEFAULT_GOAL := sla +else +override .DEFAULT_GOAL := all +endif +endif + +# Developer note: 'override' is used above for legacy Makefile compatibility. +# gcc.mk/gcc_riscv.mk need to hard-set 'all' internally, so this new system +# uses 'override' to come in over the top without breaking old projects. + +# It's also necessary to explicitly set MAKECMDGOALS... +ifeq "$(MAKECMDGOALS)" "" +MAKECMDGOALS:=$(.DEFAULT_GOAL) +endif + +# Enable colors when --sync-output is used. +# See https://www.gnu.org/software/make/manual/make.html#Terminal-Output (section 13.2) +ifneq ($(MAKE_TERMOUT),) +PROJ_CFLAGS += -fdiagnostics-color=always +endif + +ifneq ($(FORCE_COLOR),) +PROJ_CFLAGS += -fdiagnostics-color=always +endif + +# ******************************************************************************* +# Include SBT config. We need to do this here because it needs to know +# the current MAKECMDGOAL. +ifeq ($(SBT),1) +include $(MAXIM_PATH)/Tools/SBT/SBT-config.mk +endif + +# ******************************************************************************* +# Libraries + +# This section offers "toggle switches" to include or exclude the libraries that +# are available in the MaximSDK. Set a configuration variable to 1 to include the +# library in the build, or 0 to exclude. + +# Each library may also have its own library specific configuration variables. See +# Libraries/libs.mk for more details. + +# Configuration variables: +# - LIB_BOARD : Include the Board-Support Package (BSP) library. (Enabled by default) +# - LIB_PERIPHDRIVERS : Include the peripheral driver library. (Enabled by default) +# - LIB_CMSIS_DSP : Include the CMSIS-DSP library. +# - LIB_CORDIO : Include the Cordio BLE library +# - LIB_FCL : Include the Free Cryptographic Library (FCL) +# - LIB_FREERTOS : Include the FreeRTOS and FreeRTOS-Plus-CLI libraries +# - LIB_LC3 : Include the Low Complexity Communication Codec (LC3) library +# - LIB_LITTLEFS : Include the "little file system" (littleFS) library +# - LIB_LWIP : Include the lwIP library +# - LIB_MAXUSB : Include the MAXUSB library +# - LIB_SDHC : Include the SDHC library + +include $(LIBS_DIR)/libs.mk + + +# ******************************************************************************* +# Rules + +# Include the rules for building for this target. All other makefiles should be +# included before this one. +include $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/$(COMPILER)/$(TARGET_LC).mk + +# Include the rules that integrate the SBTs. SBTs are a special case that must be +# include after the core gcc rules to extend them. +ifeq ($(SBT), 1) +include $(MAXIM_PATH)/Tools/SBT/SBT-rules.mk +endif + + +# Get .DEFAULT_GOAL working. +ifeq "$(MAKECMDGOALS)" "" +MAKECMDGOALS:=$(.DEFAULT_GOAL) +endif + + +all: +# Extend the functionality of the "all" recipe here + arm-none-eabi-size --format=berkeley $(BUILD_DIR)/$(PROJECT).elf + +libclean: + $(MAKE) -f ${PERIPH_DRIVER_DIR}/periphdriver.mk clean.periph + +clean: +# Extend the functionality of the "clean" recipe here + +# The rule to clean out all the build products. +distclean: clean libclean diff --git a/Examples/MAX32665/BLE_LR_Peripheral/README.md b/Examples/MAX32665/BLE_LR_Peripheral/README.md new file mode 100644 index 0000000000..3195687523 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/README.md @@ -0,0 +1,59 @@ +# BLE_LR_Peripheral + +This project is a demo for long range advertising. The coded PHY (s=8) is used. The advertising interval is 40 ms. And in each advertising data, it includes 50-byte user data. + +The project is modified from the BLE_fit project. + +### Project Usage + +Universal instructions on building, flashing, and debugging this project can be found in the **[MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/)**. + +### Required Connections + +If using the Standard EV Kit board (EvKit\_V1): +- Connect a USB cable between the PC and the CN2 (USB/PWR - UART) connector. +- Close jumpers JP7 (RX_EN) and JP8 (TX_EN). +- Close jumpers JP5 (LED1 EN) and JP6 (LED2 EN). + +### Project-Specific Build Notes +* Setting `TRACE=1` in [**project.mk**](project.mk) initializes the on-board USB-to-UART adapter for +viewing the trace messages and interacting with the application. Port uses settings: + - Baud : 115200 + - Char size : 8 + - Parity : None + - Stop bits : 1 + - HW Flow Control : No + - SW Flow Control : No + +### Log +terminal: init␍␊ +===============================␍␊ +Long range demo (coded-PHY s=8)␍␊ +===============================␍␊ +BT_VER: 9␍␊ +DmExtAdvInit␍␊ +FitHandlerInit␍␊ +MAC Addr: 00:18:80:00:A2:22␍␊ +Adv local name: LongRang␍␊ +Fit got evt 32␍␊ +>>> Reset complete <<<␍␊ +dmDevPassEvtToDevPriv: event: 14, param: 2, advHandle: 0␍␊ +dmExtAdvHciHandler: event: 55␍␊ +dmDevPassEvtToDevPriv: event: 12, param: 71, advHandle: 0␍␊ +Fit got evt 71␍␊ +>>> Advertising sets started <<<␍␊ +Fit got evt 21␍␊ +Database hash updated␍␊ +02␍␊ +03␍␊ +Fit got evt 52␍␊ +04␍␊ +05␍␊ +06␍␊ +07␍␊ +08␍␊ +09␍␊ +0A␍␊ +0B␍␊ +... + diff --git a/Examples/MAX32665/BLE_LR_Peripheral/fit_api.h b/Examples/MAX32665/BLE_LR_Peripheral/fit_api.h new file mode 100644 index 0000000000..11f4dc509e --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/fit_api.h @@ -0,0 +1,82 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Fitness sample application interface. + * + * Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved. + * + * Copyright (c) 2019 Packetcraft, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*************************************************************************************************/ +#ifndef EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_API_H_ +#define EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_API_H_ + +#include "wsf_os.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************************************** + Macros +**************************************************************************************************/ + +#ifndef FIT_CONN_MAX +#define FIT_CONN_MAX 1 +#endif + +#define DEFAULT_TX_POWER 4 /* dBm */ + +/************************************************************************************************** + Function Declarations +**************************************************************************************************/ +/*************************************************************************************************/ +/*! + * \brief Start the application. + * + * \return None. + */ +/*************************************************************************************************/ +void FitStart(void); + +/*************************************************************************************************/ +/*! + * \brief Application handler init function called during system initialization. + * + * \param handlerID WSF handler ID for App. + * + * \return None. + */ +/*************************************************************************************************/ +void FitHandlerInit(wsfHandlerId_t handlerId); + +/*************************************************************************************************/ +/*! + * \brief WSF event handler for the application. + * + * \param event WSF event mask. + * \param pMsg WSF message. + * + * \return None. + */ +/*************************************************************************************************/ +void FitHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); + +#ifdef __cplusplus +}; +#endif + +#endif // EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_API_H_ diff --git a/Examples/MAX32665/BLE_LR_Peripheral/fit_main.c b/Examples/MAX32665/BLE_LR_Peripheral/fit_main.c new file mode 100644 index 0000000000..20a721686b --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/fit_main.c @@ -0,0 +1,807 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Fitness sample application for the following profiles: + * Heart Rate profile + * + * Copyright (c) 2011-2019 Arm Ltd. All Rights Reserved. + * + * Copyright (c) 2019 Packetcraft, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*************************************************************************************************/ + +#include +#include "wsf_types.h" +#include "util/bstream.h" +#include "wsf_msg.h" +#include "wsf_trace.h" +#include "hci_api.h" +#include "dm_api.h" +#include "att_api.h" +#include "smp_api.h" +#include "app_api.h" +#include "app_db.h" +#include "app_ui.h" +#include "app_hw.h" +#include "app_main.h" +#include "svc_ch.h" +#include "svc_core.h" +#include "svc_hrs.h" +#include "svc_dis.h" +#include "svc_batt.h" +#include "svc_rscs.h" +#include "gatt/gatt_api.h" +#include "bas/bas_api.h" +#include "hrps/hrps_api.h" +#include "rscp/rscp_api.h" +#include "fit_api.h" +#include "pal_btn.h" +#include "tmr.h" + +/************************************************************************************************** + Macros +**************************************************************************************************/ +#define USER_SPEC_ADV_DATA_LEN (50) +#define ADV_DATA_DISC_LEN (9 + USER_SPEC_ADV_DATA_LEN) + +/*! WSF message event starting value */ +#define FIT_MSG_START 0xA0 + +/* Default Running Speed and Cadence Measurement period (seconds) */ +#define FIT_DEFAULT_RSCM_PERIOD 1 + +/*! WSF message event enumeration */ +enum { + FIT_HR_TIMER_IND = FIT_MSG_START, /*! Heart rate measurement timer expired */ + FIT_BATT_TIMER_IND, /*! Battery measurement timer expired */ + FIT_RUNNING_TIMER_IND /*! Running speed and cadence measurement timer expired */ +}; + +/*! Button press handling constants */ +#define BTN_SHORT_MS 200 +#define BTN_MED_MS 500 +#define BTN_LONG_MS 1000 + +#define BTN_1_TMR MXC_TMR2 +#define BTN_2_TMR MXC_TMR3 + +/************************************************************************************************** + Data Types +**************************************************************************************************/ + +/*! Application message type */ +typedef union { + wsfMsgHdr_t hdr; + dmEvt_t dm; + attsCccEvt_t ccc; + attEvt_t att; +} fitMsg_t; + +/************************************************************************************************** + Configurable Parameters +**************************************************************************************************/ + +/*! configurable parameters for advertising */ +static const appAdvCfg_t fitAdvCfg = { + { 0, 0, 0 }, /*! Advertising durations in ms */ + { 64, 0, 0 } /*! Advertising intervals in 0.625 ms units */ +}; + +/*! configurable parameters for slave */ +static const appSlaveCfg_t fitSlaveCfg = { + FIT_CONN_MAX, /*! Maximum connections */ +}; + +/*! configurable parameters for security */ +static const appSecCfg_t fitSecCfg = { + DM_AUTH_BOND_FLAG | DM_AUTH_SC_FLAG, /*! Authentication and bonding flags */ + 0, /*! Initiator key distribution flags */ + DM_KEY_DIST_LTK, /*! Responder key distribution flags */ + FALSE, /*! TRUE if Out-of-band pairing data is present */ + TRUE /*! TRUE to initiate security upon connection */ +}; + +/*! configurable parameters for connection parameter update */ +static const appUpdateCfg_t fitUpdateCfg = { + 6000, + /*! ^ Connection idle period in ms before attempting + connection parameter update; set to zero to disable */ + 640, /*! Minimum connection interval in 1.25ms units */ + 800, /*! Maximum connection interval in 1.25ms units */ + 0, /*! Connection latency */ + 900, /*! Supervision timeout in 10ms units */ + 5 /*! Number of update attempts before giving up */ +}; + +/*! heart rate measurement configuration */ +static const hrpsCfg_t fitHrpsCfg = { + 2000 /*! Measurement timer expiration period in ms */ +}; + +/*! battery measurement configuration */ +static const basCfg_t fitBasCfg = { + 30, /*! Battery measurement timer expiration period in seconds */ + 1, /*! Perform battery measurement after this many timer periods */ + 100 /*! Send battery level notification to peer when below this level. */ +}; + +/*! SMP security parameter configuration */ +static const smpCfg_t fitSmpCfg = { + 500, /*! 'Repeated attempts' timeout in msec */ + SMP_IO_NO_IN_NO_OUT, /*! I/O Capability */ + 7, /*! Minimum encryption key length */ + 16, /*! Maximum encryption key length */ + 1, /*! Attempts to trigger 'repeated attempts' timeout */ + 0, /*! Device authentication requirements */ + 64000, /*! Maximum repeated attempts timeout in msec */ + 64000, /*! Time msec before attemptExp decreases */ + 2 /*! Repeated attempts multiplier exponent */ +}; + +/************************************************************************************************** + Advertising Data +**************************************************************************************************/ + +/*! advertising data, discoverable mode */ +uint8_t fitAdvDataDisc[ADV_DATA_DISC_LEN] = { + /*! flags */ + 2, /*! length */ + DM_ADV_TYPE_FLAGS, /*! AD type */ + DM_FLAG_LE_GENERAL_DISC | /*! flags */ + DM_FLAG_LE_BREDR_NOT_SUP, + + /*! tx power */ + 2, /*! length */ + DM_ADV_TYPE_TX_POWER, /*! AD type */ + DEFAULT_TX_POWER, /*! tx power */ + + 1 + USER_SPEC_ADV_DATA_LEN, /*! length */ + 0 + /* 50-byte data */ +}; + +/*! scan data, discoverable mode */ +static const uint8_t fitScanDataDisc[] = { + /*! device name */ + 9, /*! length */ + DM_ADV_TYPE_LOCAL_NAME, /*! AD type */ + 'L', 'o', 'n', 'g', 'R', 'a', 'n', 'g' +}; + +/************************************************************************************************** + Client Characteristic Configuration Descriptors +**************************************************************************************************/ + +/*! enumeration of client characteristic configuration descriptors */ +enum { + FIT_GATT_SC_CCC_IDX, /*! GATT service, service changed characteristic */ + FIT_HRS_HRM_CCC_IDX, /*! Heart rate service, heart rate monitor characteristic */ + FIT_BATT_LVL_CCC_IDX, /*! Battery service, battery level characteristic */ + FIT_RSCS_SM_CCC_IDX, /*! Runninc speed and cadence measurement characteristic */ + FIT_NUM_CCC_IDX +}; + +/*! client characteristic configuration descriptors settings, indexed by above enumeration */ +static const attsCccSet_t fitCccSet[FIT_NUM_CCC_IDX] = { + /* cccd handle value range security level */ + { GATT_SC_CH_CCC_HDL, ATT_CLIENT_CFG_INDICATE, DM_SEC_LEVEL_NONE }, /* FIT_GATT_SC_CCC_IDX */ + { HRS_HRM_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE }, /* FIT_HRS_HRM_CCC_IDX */ + { BATT_LVL_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE }, /* FIT_BATT_LVL_CCC_IDX */ + { RSCS_RSM_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE } /* FIT_RSCS_SM_CCC_IDX */ +}; + +/************************************************************************************************** + Global Variables +**************************************************************************************************/ + +/*! WSF handler ID */ +wsfHandlerId_t fitHandlerId; + +/* WSF Timer to send running speed and cadence measurement data */ +wsfTimer_t fitRscmTimer; + +/* Running Speed and Cadence Measurement period - Can be changed at runtime to vary period */ +static uint16_t fitRscmPeriod = FIT_DEFAULT_RSCM_PERIOD; + +/* Heart Rate Monitor feature flags */ +static uint8_t fitHrmFlags = CH_HRM_FLAGS_VALUE_8BIT | CH_HRM_FLAGS_ENERGY_EXP; + +/*************************************************************************************************/ +/*! + * \brief Application DM callback. + * + * \param pDmEvt DM callback event + * + * \return None. + */ +/*************************************************************************************************/ +static void fitDmCback(dmEvt_t *pDmEvt) +{ + dmEvt_t *pMsg; + uint16_t len; + + len = DmSizeOfEvt(pDmEvt); + + if ((pMsg = WsfMsgAlloc(len)) != NULL) { + memcpy(pMsg, pDmEvt, len); + WsfMsgSend(fitHandlerId, pMsg); + } +} + +/*************************************************************************************************/ +/*! + * \brief Application ATT callback. + * + * \param pEvt ATT callback event + * + * \return None. + */ +/*************************************************************************************************/ +static void fitAttCback(attEvt_t *pEvt) +{ + attEvt_t *pMsg; + + if ((pMsg = WsfMsgAlloc(sizeof(attEvt_t) + pEvt->valueLen)) != NULL) { + memcpy(pMsg, pEvt, sizeof(attEvt_t)); + pMsg->pValue = (uint8_t *)(pMsg + 1); + memcpy(pMsg->pValue, pEvt->pValue, pEvt->valueLen); + WsfMsgSend(fitHandlerId, pMsg); + } +} + +/*************************************************************************************************/ +/*! + * \brief Application ATTS client characteristic configuration callback. + * + * \param pDmEvt DM callback event + * + * \return None. + */ +/*************************************************************************************************/ +static void fitCccCback(attsCccEvt_t *pEvt) +{ + attsCccEvt_t *pMsg; + appDbHdl_t dbHdl; + + /* If CCC not set from initialization and there's a device record and currently bonded */ + if ((pEvt->handle != ATT_HANDLE_NONE) && + ((dbHdl = AppDbGetHdl((dmConnId_t)pEvt->hdr.param)) != APP_DB_HDL_NONE) && + AppCheckBonded((dmConnId_t)pEvt->hdr.param)) { + /* Store value in device database. */ + AppDbSetCccTblValue(dbHdl, pEvt->idx, pEvt->value); + } + + if ((pMsg = WsfMsgAlloc(sizeof(attsCccEvt_t))) != NULL) { + memcpy(pMsg, pEvt, sizeof(attsCccEvt_t)); + WsfMsgSend(fitHandlerId, pMsg); + } +} + +/*************************************************************************************************/ +/*! +* \brief Send a Running Speed and Cadence Measurement Notification. +* +* \param connId connection ID +* +* \return None. +*/ +/*************************************************************************************************/ +static void fitSendRunningSpeedMeasurement(dmConnId_t connId) +{ + if (AttsCccEnabled(connId, FIT_RSCS_SM_CCC_IDX)) { + static uint8_t walk_run = 1; + + /* TODO: Set Running Speed and Cadence Measurement Parameters */ + + RscpsSetParameter(RSCP_SM_PARAM_SPEED, 1); + RscpsSetParameter(RSCP_SM_PARAM_CADENCE, 2); + RscpsSetParameter(RSCP_SM_PARAM_STRIDE_LENGTH, 3); + RscpsSetParameter(RSCP_SM_PARAM_TOTAL_DISTANCE, 4); + + /* Toggle running/walking */ + walk_run = walk_run ? 0 : 1; + RscpsSetParameter(RSCP_SM_PARAM_STATUS, walk_run); + + RscpsSendSpeedMeasurement(connId); + } + + /* Configure and start timer to send the next measurement */ + fitRscmTimer.msg.event = FIT_RUNNING_TIMER_IND; + fitRscmTimer.msg.status = FIT_RSCS_SM_CCC_IDX; + fitRscmTimer.handlerId = fitHandlerId; + fitRscmTimer.msg.param = connId; + + WsfTimerStartSec(&fitRscmTimer, fitRscmPeriod); +} + +/*************************************************************************************************/ +/*! + * \brief Process CCC state change. + * + * \param pMsg Pointer to message. + * + * \return None. + */ +/*************************************************************************************************/ +static void fitProcCccState(fitMsg_t *pMsg) +{ + APP_TRACE_INFO3("ccc state ind value:%d handle:%d idx:%d", pMsg->ccc.value, pMsg->ccc.handle, + pMsg->ccc.idx); + + /* handle heart rate measurement CCC */ + if (pMsg->ccc.idx == FIT_HRS_HRM_CCC_IDX) { + if (pMsg->ccc.value == ATT_CLIENT_CFG_NOTIFY) { + HrpsMeasStart((dmConnId_t)pMsg->ccc.hdr.param, FIT_HR_TIMER_IND, FIT_HRS_HRM_CCC_IDX); + } else { + HrpsMeasStop((dmConnId_t)pMsg->ccc.hdr.param); + } + return; + } + + /* handle running speed and cadence measurement CCC */ + if (pMsg->ccc.idx == FIT_RSCS_SM_CCC_IDX) { + if (pMsg->ccc.value == ATT_CLIENT_CFG_NOTIFY) { + fitSendRunningSpeedMeasurement((dmConnId_t)pMsg->ccc.hdr.param); + } else { + WsfTimerStop(&fitRscmTimer); + } + return; + } + + /* handle battery level CCC */ + if (pMsg->ccc.idx == FIT_BATT_LVL_CCC_IDX) { + if (pMsg->ccc.value == ATT_CLIENT_CFG_NOTIFY) { + BasMeasBattStart((dmConnId_t)pMsg->ccc.hdr.param, FIT_BATT_TIMER_IND, + FIT_BATT_LVL_CCC_IDX); + } else { + BasMeasBattStop((dmConnId_t)pMsg->ccc.hdr.param); + } + return; + } +} + +/*************************************************************************************************/ +/*! + * \brief Perform UI actions on connection close. + * + * \param pMsg Pointer to message. + * + * \return None. + */ +/*************************************************************************************************/ +static void fitClose(fitMsg_t *pMsg) +{ + /* stop heart rate measurement */ + HrpsMeasStop((dmConnId_t)pMsg->hdr.param); + + /* stop battery measurement */ + BasMeasBattStop((dmConnId_t)pMsg->hdr.param); + + /* Stop running speed and cadence timer */ + WsfTimerStop(&fitRscmTimer); +} + +/*************************************************************************************************/ +/*! + * \brief Set up advertising and other procedures that need to be performed after + * device reset. + * + * \param pMsg Pointer to message. + * + * \return None. + */ +/*************************************************************************************************/ +static void fitSetup(fitMsg_t *pMsg) +{ + /* set advertising and scan response data for discoverable mode */ + for (uint8_t i = 0; i < USER_SPEC_ADV_DATA_LEN; ++i) + { + fitAdvDataDisc[8 + i] = i + 1; + } + AppAdvSetData(APP_ADV_DATA_DISCOVERABLE, sizeof(fitAdvDataDisc), (uint8_t *)fitAdvDataDisc); + AppAdvSetData(APP_SCAN_DATA_DISCOVERABLE, sizeof(fitScanDataDisc), (uint8_t *)fitScanDataDisc); + + /* set advertising and scan response data for connectable mode */ + AppAdvSetData(APP_ADV_DATA_CONNECTABLE, 0, NULL); + AppAdvSetData(APP_SCAN_DATA_CONNECTABLE, 0, NULL); + + /* start advertising; automatically set connectable/discoverable mode and bondable mode */ + AppAdvStart(APP_MODE_AUTO_INIT); +} + +/*************************************************************************************************/ +/*! + * \brief Button press callback. + * + * \param btn Button press. + * + * \return None. + */ +/*************************************************************************************************/ +static void fitBtnCback(uint8_t btn) +{ + dmConnId_t connId; + static uint8_t heartRate = 78; /* for testing/demonstration */ + + /* button actions when connected */ + if ((connId = AppConnIsOpen()) != DM_CONN_ID_NONE) { + switch (btn) { + case APP_UI_BTN_1_SHORT: + /* increment the heart rate */ + AppHwHrmTest(++heartRate); + break; + + case APP_UI_BTN_1_MED: + break; + + case APP_UI_BTN_1_LONG: + AppConnClose(connId); + break; + + case APP_UI_BTN_2_SHORT: + /* decrement the heart rate */ + AppHwHrmTest(--heartRate); + break; + + case APP_UI_BTN_2_MED: + /* Toggle HRM Sensor DET flags */ + if (!(fitHrmFlags & (CH_HRM_FLAGS_SENSOR_DET | CH_HRM_FLAGS_SENSOR_NOT_DET))) { + fitHrmFlags |= CH_HRM_FLAGS_SENSOR_DET; + } else if (fitHrmFlags & CH_HRM_FLAGS_SENSOR_DET) { + fitHrmFlags &= ~CH_HRM_FLAGS_SENSOR_DET; + fitHrmFlags |= CH_HRM_FLAGS_SENSOR_NOT_DET; + } else { + fitHrmFlags &= ~CH_HRM_FLAGS_SENSOR_NOT_DET; + } + + HrpsSetFlags(fitHrmFlags); + break; + + case APP_UI_BTN_2_LONG: + /* Toggle HRM RR Interval feature flag */ + if (fitHrmFlags & CH_HRM_FLAGS_RR_INTERVAL) { + fitHrmFlags &= ~CH_HRM_FLAGS_RR_INTERVAL; + } else { + fitHrmFlags |= CH_HRM_FLAGS_RR_INTERVAL; + } + + HrpsSetFlags(fitHrmFlags); + break; + + default: + break; + } + } else { /* button actions when not connected */ + switch (btn) { + case APP_UI_BTN_1_SHORT: + /* start or restart advertising */ + AppAdvStart(APP_MODE_AUTO_INIT); + break; + + case APP_UI_BTN_1_MED: + /* enter discoverable and bondable mode */ + AppSetBondable(TRUE); + AppAdvStart(APP_MODE_DISCOVERABLE); + break; + + case APP_UI_BTN_1_LONG: + /* clear all bonding info */ + AppSlaveClearAllBondingInfo(); + + /* restart advertising */ + AppAdvStart(APP_MODE_AUTO_INIT); + break; + + case APP_UI_BTN_2_SHORT: + /* Toggle HRM Flag for 8 and 16 bit values */ + if (fitHrmFlags & CH_HRM_FLAGS_VALUE_16BIT) { + fitHrmFlags &= ~CH_HRM_FLAGS_VALUE_16BIT; + } else { + fitHrmFlags |= CH_HRM_FLAGS_VALUE_16BIT; + } + + HrpsSetFlags(fitHrmFlags); + break; + + default: + break; + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Process messages from the event handler. + * + * \param pMsg Pointer to message. + * + * \return None. + */ +/*************************************************************************************************/ +static void fitProcMsg(fitMsg_t *pMsg) +{ + uint8_t uiEvent = APP_UI_NONE; + + switch (pMsg->hdr.event) { + case FIT_RUNNING_TIMER_IND: + fitSendRunningSpeedMeasurement((dmConnId_t)pMsg->ccc.hdr.param); + break; + + case FIT_HR_TIMER_IND: + HrpsProcMsg(&pMsg->hdr); + break; + + case FIT_BATT_TIMER_IND: + BasProcMsg(&pMsg->hdr); + break; + + case ATTS_HANDLE_VALUE_CNF: + HrpsProcMsg(&pMsg->hdr); + BasProcMsg(&pMsg->hdr); + break; + + case ATTS_CCC_STATE_IND: + fitProcCccState(pMsg); + break; + + case DM_RESET_CMPL_IND: + AttsCalculateDbHash(); + DmSecGenerateEccKeyReq(); + fitSetup(pMsg); + uiEvent = APP_UI_RESET_CMPL; + break; + + case DM_ADV_SET_START_IND: + uiEvent = APP_UI_ADV_SET_START_IND; + break; + + case DM_ADV_SET_STOP_IND: + uiEvent = APP_UI_ADV_SET_STOP_IND; + break; + + case DM_ADV_START_IND: + uiEvent = APP_UI_ADV_START; + break; + + case DM_ADV_STOP_IND: + uiEvent = APP_UI_ADV_STOP; + break; + + case DM_CONN_OPEN_IND: + HrpsProcMsg(&pMsg->hdr); + BasProcMsg(&pMsg->hdr); + uiEvent = APP_UI_CONN_OPEN; + break; + + case DM_CONN_CLOSE_IND: + fitClose(pMsg); + uiEvent = APP_UI_CONN_CLOSE; + break; + + case DM_SEC_PAIR_CMPL_IND: + DmSecGenerateEccKeyReq(); + uiEvent = APP_UI_SEC_PAIR_CMPL; + break; + + case DM_SEC_PAIR_FAIL_IND: + DmSecGenerateEccKeyReq(); + uiEvent = APP_UI_SEC_PAIR_FAIL; + break; + + case DM_SEC_ENCRYPT_IND: + uiEvent = APP_UI_SEC_ENCRYPT; + break; + + case DM_SEC_ENCRYPT_FAIL_IND: + uiEvent = APP_UI_SEC_ENCRYPT_FAIL; + break; + + case DM_SEC_AUTH_REQ_IND: + AppHandlePasskey(&pMsg->dm.authReq); + break; + + case DM_SEC_ECC_KEY_IND: + DmSecSetEccKey(&pMsg->dm.eccMsg.data.key); + break; + + case DM_SEC_COMPARE_IND: + AppHandleNumericComparison(&pMsg->dm.cnfInd); + break; + + case DM_PRIV_CLEAR_RES_LIST_IND: + APP_TRACE_INFO1("Clear resolving list status 0x%02x", pMsg->hdr.status); + break; + + case DM_HW_ERROR_IND: + uiEvent = APP_UI_HW_ERROR; + break; + + default: + break; + } + + if (uiEvent != APP_UI_NONE) { + AppUiAction(uiEvent); + } +} + +/*************************************************************************************************/ +/*! + * \brief Platform button press handler. + * + * \param[in] btnId button ID. + * \param[in] state button state. See ::PalBtnPos_t. + * + * \return None. + */ +/*************************************************************************************************/ +static void btnPressHandler(uint8_t btnId, PalBtnPos_t state) +{ + if (btnId == 1) { + /* Start/stop button timer */ + if (state == PAL_BTN_POS_UP) { + /* Button Up, stop the timer, call the action function */ + unsigned btnUs = MXC_TMR_SW_Stop(BTN_1_TMR); + if ((btnUs > 0) && (btnUs < BTN_SHORT_MS * 1000)) { + AppUiBtnTest(APP_UI_BTN_1_SHORT); + } else if (btnUs < BTN_MED_MS * 1000) { + AppUiBtnTest(APP_UI_BTN_1_MED); + } else if (btnUs < BTN_LONG_MS * 1000) { + AppUiBtnTest(APP_UI_BTN_1_LONG); + } else { + AppUiBtnTest(APP_UI_BTN_1_EX_LONG); + } + } else { + /* Button down, start the timer */ + MXC_TMR_SW_Start(BTN_1_TMR); + } + } else if (btnId == 2) { + /* Start/stop button timer */ + if (state == PAL_BTN_POS_UP) { + /* Button Up, stop the timer, call the action function */ + unsigned btnUs = MXC_TMR_SW_Stop(BTN_2_TMR); + if ((btnUs > 0) && (btnUs < BTN_SHORT_MS * 1000)) { + AppUiBtnTest(APP_UI_BTN_2_SHORT); + } else if (btnUs < BTN_MED_MS * 1000) { + AppUiBtnTest(APP_UI_BTN_2_MED); + } else if (btnUs < BTN_LONG_MS * 1000) { + AppUiBtnTest(APP_UI_BTN_2_LONG); + } else { + AppUiBtnTest(APP_UI_BTN_2_EX_LONG); + } + } else { + /* Button down, start the timer */ + MXC_TMR_SW_Start(BTN_2_TMR); + } + } else { + APP_TRACE_ERR0("Undefined button"); + } +} + +/*************************************************************************************************/ +/*! + * \brief Application handler init function called during system initialization. + * + * \param handlerID WSF handler ID. + * + * \return None. + */ +/*************************************************************************************************/ +void FitHandlerInit(wsfHandlerId_t handlerId) +{ + uint8_t addr[6] = { 0 }; + APP_TRACE_INFO0("FitHandlerInit"); + AppGetBdAddr(addr); + APP_TRACE_INFO6("MAC Addr: %02x:%02x:%02x:%02x:%02x:%02x", addr[5], addr[4], addr[3], addr[2], + addr[1], addr[0]); + APP_TRACE_INFO1("Adv local name: %s", &fitScanDataDisc[2]); + + /* store handler ID */ + fitHandlerId = handlerId; + + /* Set configuration pointers */ + pAppAdvCfg = (appAdvCfg_t *)&fitAdvCfg; + pAppSlaveCfg = (appSlaveCfg_t *)&fitSlaveCfg; + pAppSecCfg = (appSecCfg_t *)&fitSecCfg; + pAppUpdateCfg = (appUpdateCfg_t *)&fitUpdateCfg; + + /* Initialize application framework */ + AppSlaveInit(); + AppServerInit(); + + /* Set stack configuration pointers */ + pSmpCfg = (smpCfg_t *)&fitSmpCfg; + + /* initialize heart rate profile sensor */ + HrpsInit(handlerId, (hrpsCfg_t *)&fitHrpsCfg); + HrpsSetFlags(fitHrmFlags); + + /* initialize battery service server */ + BasInit(handlerId, (basCfg_t *)&fitBasCfg); +} + +/*************************************************************************************************/ +/*! + * \brief WSF event handler for application. + * + * \param event WSF event mask. + * \param pMsg WSF message. + * + * \return None. + */ +/*************************************************************************************************/ +void FitHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) +{ + if (pMsg != NULL) { + APP_TRACE_INFO1("Fit got evt %d", pMsg->event); + + /* process ATT messages */ + if (pMsg->event >= ATT_CBACK_START && pMsg->event <= ATT_CBACK_END) { + /* process server-related ATT messages */ + AppServerProcAttMsg(pMsg); + } else if (pMsg->event >= DM_CBACK_START && pMsg->event <= DM_CBACK_END) { + /* process DM messages */ + /* process advertising and connection-related messages */ + AppSlaveProcDmMsg((dmEvt_t *)pMsg); + + /* process security-related messages */ + AppSlaveSecProcDmMsg((dmEvt_t *)pMsg); + } + + /* perform profile and user interface-related operations */ + fitProcMsg((fitMsg_t *)pMsg); + } +} + +/*************************************************************************************************/ +/*! + * \brief Start the application. + * + * \return None. + */ +/*************************************************************************************************/ +void FitStart(void) +{ + /* Register for stack callbacks */ + DmRegister(fitDmCback); + DmConnRegister(DM_CLIENT_ID_APP, fitDmCback); + AttRegister(fitAttCback); + AttConnRegister(AppServerConnCback); + AttsCccRegister(FIT_NUM_CCC_IDX, (attsCccSet_t *)fitCccSet, fitCccCback); + + /* Register for app framework callbacks */ + AppUiBtnRegister(fitBtnCback); + /* Initialize with button press handler */ + PalBtnInit(btnPressHandler); + /* Initialize attribute server database */ + SvcCoreGattCbackRegister(GattReadCback, GattWriteCback); + SvcCoreAddGroup(); + SvcHrsCbackRegister(NULL, HrpsWriteCback); + SvcHrsAddGroup(); + SvcDisAddGroup(); + SvcBattCbackRegister(BasReadCback, NULL); + SvcBattAddGroup(); + SvcRscsAddGroup(); + + /* Set Service Changed CCCD index. */ + GattSetSvcChangedIdx(FIT_GATT_SC_CCC_IDX); + + /* Set running speed and cadence features */ + RscpsSetFeatures(RSCS_ALL_FEATURES); + + /* Reset the device */ + DmDevReset(); +} diff --git a/Examples/MAX32665/BLE_LR_Peripheral/main.c b/Examples/MAX32665/BLE_LR_Peripheral/main.c new file mode 100644 index 0000000000..6b44beeb73 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/main.c @@ -0,0 +1,285 @@ +/*************************************************************************************************/ +/*! + * @file main.c + * @brief Bluetooth fitness device. Showcases heart rate, battery level, running speed and cadence. +* +* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved. +* +* Copyright (c) 2019 Packetcraft, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/*************************************************************************************************/ + +#include +#include +#include "wsf_types.h" +#include "wsf_trace.h" +#include "wsf_bufio.h" +#include "wsf_msg.h" +#include "wsf_assert.h" +#include "wsf_buf.h" +#include "wsf_heap.h" +#include "wsf_cs.h" +#include "wsf_timer.h" +#include "wsf_os.h" + +#include "sec_api.h" +#include "hci_handler.h" +#include "dm_handler.h" +#include "l2c_handler.h" +#include "att_handler.h" +#include "smp_handler.h" +#include "l2c_api.h" +#include "att_api.h" +#include "smp_api.h" +#include "app_api.h" +#include "hci_core.h" +#include "app_terminal.h" +#include "wut.h" +#include "rtc.h" +#include "trimsir_regs.h" + +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) +#include "ll_init_api.h" +#endif + +#include "pal_bb.h" +#include "pal_cfg.h" +#include "pal_timer.h" +#include "pal_sys.h" +#include "pal_uart.h" + +#include "fit_api.h" +#include "app_ui.h" + +/************************************************************************************************** + Macros +**************************************************************************************************/ + +/*! \brief UART TX buffer size */ +#define PLATFORM_UART_TERMINAL_BUFFER_SIZE 2048U + +/************************************************************************************************** + Global Variables +**************************************************************************************************/ +extern uint8_t appCodedPhy; + +/*! \brief Pool runtime configuration. */ +static wsfBufPoolDesc_t mainPoolDesc[] = { { 16, 8 }, { 32, 4 }, { 192, 8 }, { 256, 8 } }; + +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) +static LlRtCfg_t mainLlRtCfg; +#endif + +volatile int wutTrimComplete; + +/************************************************************************************************** + Functions +**************************************************************************************************/ + +/*! \brief Stack initialization for app. */ +extern void StackInitFit(void); + +/*************************************************************************************************/ +/*! + * \brief Initialize WSF. + * + * \return None. + */ +/*************************************************************************************************/ +static void mainWsfInit(void) +{ +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) + /* +12 for message headroom, + 2 event header, +255 maximum parameter length. */ + const uint16_t maxRptBufSize = 12 + 2 + 255; + + /* +12 for message headroom, +4 for header. */ + const uint16_t aclBufSize = 12 + mainLlRtCfg.maxAclLen + 4 + BB_DATA_PDU_TAILROOM; + + /* Adjust buffer allocation based on platform configuration. */ + mainPoolDesc[2].len = maxRptBufSize; + mainPoolDesc[2].num = mainLlRtCfg.maxAdvReports; + mainPoolDesc[3].len = aclBufSize; + mainPoolDesc[3].num = mainLlRtCfg.numTxBufs + mainLlRtCfg.numRxBufs; +#endif + + const uint8_t numPools = sizeof(mainPoolDesc) / sizeof(mainPoolDesc[0]); + + uint16_t memUsed; + WsfCsEnter(); + memUsed = WsfBufInit(numPools, mainPoolDesc); + WsfHeapAlloc(memUsed); + WsfCsExit(); + + WsfOsInit(); + WsfTimerInit(); +#if (WSF_TOKEN_ENABLED == TRUE) || (WSF_TRACE_ENABLED == TRUE) + WsfTraceRegisterHandler(WsfBufIoWrite); + WsfTraceEnable(TRUE); +#endif +} + +/*************************************************************************************************/ +/*! +* \fn WUT_IRQHandler +* +* \brief WUT interrupt handler. +* +* \return None. +*/ +/*************************************************************************************************/ +void WUT_IRQHandler(void) +{ + MXC_WUT_Handler(); + PalTimerIRQCallBack(); +} + +/*************************************************************************************************/ +/*! +* \fn wutTrimCb +* +* \brief Callback function for the WUT 32 kHz crystal trim. +* +* \param err Error code from the WUT driver. +* +* \return None. +*/ +/*************************************************************************************************/ +void wutTrimCb(int err) +{ + if (err != E_NO_ERROR) { + APP_TRACE_INFO1("32 kHz trim error %d\n", err); + } else { + APP_TRACE_INFO1("32kHz trimmed to 0x%x", (MXC_TRIMSIR->rtc & MXC_F_TRIMSIR_RTC_RTCX1) >> + MXC_F_TRIMSIR_RTC_RTCX1_POS); + } + wutTrimComplete = 1; +} + +/*************************************************************************************************/ +/*! +* \fn setAdvTxPower +* +* \brief Set the default advertising TX power. +* +* \return None. +*/ +/*************************************************************************************************/ +void setAdvTxPower(void) +{ + LlSetAdvTxPower(DEFAULT_TX_POWER); +} + +/*************************************************************************************************/ +/*! +* \fn main +* +* \brief Entry point for demo software. +* +* \param None. +* +* \return None. +*/ +/*************************************************************************************************/ +int main(void) +{ +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) + /* Configurations must be persistent. */ + static BbRtCfg_t mainBbRtCfg; + + PalBbLoadCfg((PalBbCfg_t *)&mainBbRtCfg); + LlGetDefaultRunTimeCfg(&mainLlRtCfg); +#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_0) + /* Set 5.0 requirements. */ + mainLlRtCfg.btVer = LL_VER_BT_CORE_SPEC_5_0; +#endif + PalCfgLoadData(PAL_CFG_ID_LL_PARAM, &mainLlRtCfg.maxAdvSets, sizeof(LlRtCfg_t) - 9); +#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_0) + PalCfgLoadData(PAL_CFG_ID_BLE_PHY, &mainLlRtCfg.phy2mSup, 4); +#endif + + /* Set the 32k sleep clock accuracy into one of the following bins, default is 20 + HCI_CLOCK_500PPM + HCI_CLOCK_250PPM + HCI_CLOCK_150PPM + HCI_CLOCK_100PPM + HCI_CLOCK_75PPM + HCI_CLOCK_50PPM + HCI_CLOCK_30PPM + HCI_CLOCK_20PPM + */ + mainBbRtCfg.clkPpm = 20; + + /* Set the default connection power level */ + mainLlRtCfg.defTxPwrLvl = DEFAULT_TX_POWER; +#endif + + uint32_t memUsed; + WsfCsEnter(); + memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE); + WsfHeapAlloc(memUsed); + WsfCsExit(); + + mainWsfInit(); + AppTerminalInit(); + + APP_TRACE_INFO0("==============================="); + APP_TRACE_INFO0("Long range demo (coded-PHY s=8)"); + APP_TRACE_INFO0("==============================="); + APP_TRACE_INFO1("BT_VER: %d", BT_VER); + appCodedPhy = 1; + +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) + WsfCsEnter(); + LlInitRtCfg_t llCfg = { .pBbRtCfg = &mainBbRtCfg, + .wlSizeCfg = 4, + .rlSizeCfg = 4, + .plSizeCfg = 4, + .pLlRtCfg = &mainLlRtCfg, + .pFreeMem = WsfHeapGetFreeStartAddress(), + .freeMemAvail = WsfHeapCountAvailable() }; + + memUsed = LlInit(&llCfg); + WsfHeapAlloc(memUsed); + WsfCsExit(); + + bdAddr_t bdAddr; + PalCfgLoadData(PAL_CFG_ID_BD_ADDR, bdAddr, sizeof(bdAddr_t)); + LlSetBdAddr((uint8_t *)&bdAddr); + + /* Start the 32 MHz crystal and the BLE DBB counter to trim the 32 kHz crystal */ + PalBbEnable(); + + /* Output buffered square wave of 32 kHz clock to GPIO */ + // MXC_RTC_SquareWaveStart(MXC_RTC_F_32KHZ); + + /* Execute the trim procedure */ + wutTrimComplete = 0; + if (PalSharedTimerIsInit()) { + MXC_WUT_TrimCrystalAsync(wutTrimCb); + while (!wutTrimComplete) {} + } + + /* Shutdown the 32 MHz crystal and the BLE DBB */ + PalBbDisable(); +#endif + + StackInitFit(); + FitStart(); + + WsfOsEnterMainLoop(); + + /* Does not return. */ + return 0; +} diff --git a/Examples/MAX32665/BLE_LR_Peripheral/project.mk b/Examples/MAX32665/BLE_LR_Peripheral/project.mk new file mode 100644 index 0000000000..1c456bfc4c --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/project.mk @@ -0,0 +1,26 @@ +# This file can be used to set build configuration +# variables. These variables are defined in a file called +# "Makefile" that is located next to this one. + +# For instructions on how to use this system, see +# https://analog-devices-msdk.github.io/msdk/USERGUIDE/#build-system + +# ********************************************************** + +# If you have secure version of MCU (MAX32666), set SBT=1 to generate signed binary +# For more information on how sing process works, see +# https://www.analog.com/en/education/education-library/videos/6313214207112.html +SBT=0 + +# Enable Cordio library +LIB_CORDIO = 1 + +# Cordio library options +INIT_PERIPHERAL = 1 +INIT_CENTRAL = 0 + +# TRACE option +# Set to 0 to disable +# Set to 1 to enable serial port trace messages +# Set to 2 to enable verbose messages +TRACE = 1 diff --git a/Examples/MAX32665/BLE_LR_Peripheral/stack_fit.c b/Examples/MAX32665/BLE_LR_Peripheral/stack_fit.c new file mode 100644 index 0000000000..84759d50d0 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Peripheral/stack_fit.c @@ -0,0 +1,132 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Stack initialization for dats. + * + * Copyright (c) 2016-2019 Arm Ltd. All Rights Reserved. + * + * Copyright (c) 2019 Packetcraft, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*************************************************************************************************/ + +#include "wsf_types.h" +#include "wsf_os.h" +#include "wsf_trace.h" +#include "util/bstream.h" + +#include "fit_api.h" + +#include "hci_handler.h" +#include "dm_handler.h" +#include "l2c_handler.h" +#include "att_handler.h" +#include "smp_handler.h" +#include "l2c_api.h" +#include "att_api.h" +#include "smp_api.h" +#include "app_api.h" +#include "hci_core.h" +#include "svc_dis.h" +#include "svc_core.h" +#include "sec_api.h" +#include "hci_defs.h" + +typedef struct +{ + uint8_t advType; /*!< Advertising type. */ + bool_t useLegacyPdu; /*!< Use legacy advertising PDUs. */ + bool_t omitAdvAddr; /*!< Omit advertiser's address from all PDUs. */ + bool_t incTxPwr; /*!< Include TxPower in extended header of advertising PDU. */ + int8_t advTxPwr; /*!< Advertising Tx Power. */ + uint8_t priAdvPhy; /*!< Primary Advertising PHY. */ + uint8_t secAdvMaxSkip; /*!< Secondary Advertising Maximum Skip. */ + uint8_t secAdvPhy; /*!< Secondary Advertising PHY. */ + bool_t scanReqNotifEna; /*!< Scan request notification enable. */ + uint8_t fragPref; /*!< Fragment preference for advertising data. */ + uint8_t advSid; /*!< Advertising Sid. */ + bool_t advDataSet; /*!< TRUE if extended adv data has been set. */ + bool_t scanDataSet; /*!< TRUE if extended scan data has been set. */ + uint8_t connId; /*!< Connection identifier (used by directed advertising). */ +} dmExtAdvCb_t; + +extern dmExtAdvCb_t dmExtAdvCb[]; + +/*************************************************************************************************/ +/*! + * \brief Initialize stack. + * + * \return None. + */ +/*************************************************************************************************/ +void StackInitFit(void) +{ + wsfHandlerId_t handlerId; + + SecInit(); + SecAesInit(); + SecCmacInit(); + SecEccInit(); + + handlerId = WsfOsSetNextHandler(HciHandler); + HciHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(DmHandler); + DmDevVsInit(0); + DmConnInit(); +#if BT_VER >= HCI_VER_BT_CORE_SPEC_5_0 + APP_TRACE_INFO0("DmExtAdvInit"); + DmExtAdvInit(); + + for (uint8_t i = 0; i < DM_NUM_ADV_SETS; i++) + { + // dmExtAdvCbInit(i); + dmExtAdvCb[i].useLegacyPdu = FALSE; + dmExtAdvCb[i].priAdvPhy = HCI_ADV_PHY_LE_CODED; + dmExtAdvCb[i].secAdvPhy = HCI_ADV_PHY_LE_CODED; + } + + DmExtConnSlaveInit(); +#else + DmAdvInit(); + DmConnSlaveInit(); +#endif + DmSecInit(); + DmSecLescInit(); + DmPrivInit(); + DmHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(L2cSlaveHandler); + L2cSlaveHandlerInit(handlerId); + L2cInit(); + L2cSlaveInit(); + + handlerId = WsfOsSetNextHandler(AttHandler); + AttHandlerInit(handlerId); + AttsInit(); + AttsIndInit(); + + handlerId = WsfOsSetNextHandler(SmpHandler); + SmpHandlerInit(handlerId); + SmprInit(); + SmprScInit(); + HciSetMaxRxAclLen(100); + + handlerId = WsfOsSetNextHandler(AppHandler); + AppHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(FitHandler); + FitHandlerInit(handlerId); +} diff --git a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c index a453786cf7..90aa969e72 100644 --- a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c +++ b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c @@ -37,6 +37,8 @@ #include "ll_api.h" +extern uint8_t appCodedPhy; + /*************************************************************************************************/ /*! * \brief HCI LE set extended scanning parameters command. @@ -57,7 +59,11 @@ void HciLeSetExtScanParamCmd(uint8_t ownAddrType, uint8_t scanFiltPolicy, uint8_ status = LlSetExtScanParam(ownAddrType, scanFiltPolicy, scanPhys, (LlExtScanParam_t *)pScanParam); (void)status; + // TODO + if (appCodedPhy == 0) + { WSF_ASSERT(status == LL_SUCCESS); + } } /*************************************************************************************************/ diff --git a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c index 878ad58532..4f802e6600 100644 --- a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c +++ b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c @@ -26,6 +26,7 @@ */ /*************************************************************************************************/ +#include #include #include "wsf_types.h" #include "wsf_msg.h" @@ -39,6 +40,11 @@ #include "hci_api.h" #include "hci_main.h" #include "hci_core_ps.h" +#include "pal_led.h" +#include "../../../controller/sources/common/sch/sch_int.h" + +extern void LED_On(unsigned int idx); +extern uint8_t appCodedPhy; /************************************************************************************************** Local Variables @@ -187,6 +193,27 @@ bool_t hciCoreEvtProcessLlEvt(LlEvt_t *pEvt) case LL_EXT_ADV_REPORT_IND: pMsg->extAdvReportInd.pData = (uint8_t *) pMsg + msgLen; memcpy((uint8_t *) pMsg->extAdvReportInd.pData, pEvt->extAdvReportInd.pData, reportLen); + + // for long range demo, display aux scan data here + // 00:18:80 ADI + if (appCodedPhy) + { + if (pMsg->extAdvReportInd.addr[5] == 0 && pMsg->extAdvReportInd.addr[4] == 0x18 && pMsg->extAdvReportInd.addr[3] == 0x80) + { + LED_On(0); // 0: red led ID + } + + printf("\n%02x:%02x:%02x:%02x:%02x:%02x %02X %02X %02X ... %02X %02X %02X", + pMsg->extAdvReportInd.addr[5], pMsg->extAdvReportInd.addr[4], pMsg->extAdvReportInd.addr[3], + pMsg->extAdvReportInd.addr[2], pMsg->extAdvReportInd.addr[1], pMsg->extAdvReportInd.addr[0], + pMsg->extAdvReportInd.pData[8 + 0], + pMsg->extAdvReportInd.pData[8 + 1], + pMsg->extAdvReportInd.pData[8 + 2], + pMsg->extAdvReportInd.pData[8 + 47], + pMsg->extAdvReportInd.pData[8 + 48], + pMsg->extAdvReportInd.pData[8 + 49]); + } + break; case LL_PER_ADV_REPORT_IND: diff --git a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_evt.c b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_evt.c index f4cdaafd54..c42e231d51 100644 --- a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_evt.c +++ b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_evt.c @@ -348,7 +348,7 @@ void hciEvtProcessMsg(uint8_t *pEvt) event = pMsg->hdr.event; /* Note: HCI and LL event structures identical, no translation needed */ - hciCb.evtCback((hciEvt_t *)pMsg); + hciCb.evtCback((hciEvt_t *)pMsg); // dmHciEvtCback /* execute core procedure for connection close after callback */ if (event == HCI_DISCONNECT_CMPL_CBACK_EVT) diff --git a/Libraries/Cordio/ble-host/sources/stack/dm/dm_adv_ae.c b/Libraries/Cordio/ble-host/sources/stack/dm/dm_adv_ae.c index 635daf02f7..781e6477b0 100644 --- a/Libraries/Cordio/ble-host/sources/stack/dm/dm_adv_ae.c +++ b/Libraries/Cordio/ble-host/sources/stack/dm/dm_adv_ae.c @@ -91,6 +91,11 @@ typedef struct uint8_t advState; /*!< Periodic advertising state. */ } dmPerAdvCb_t; +/************************************************************************************************** + Global Variables +**************************************************************************************************/ +extern uint8_t appCodedPhy; + /************************************************************************************************** Local Variables **************************************************************************************************/ @@ -134,7 +139,7 @@ static const dmFcnIf_t dmPerAdvFcnIf = }; /* extended advertising control block */ -static dmExtAdvCb_t dmExtAdvCb[DM_NUM_ADV_SETS]; +dmExtAdvCb_t dmExtAdvCb[DM_NUM_ADV_SETS]; /* periodic advertising control block */ static dmPerAdvCb_t dmPerAdvCb[DM_NUM_ADV_SETS]; @@ -164,13 +169,21 @@ static void dmExtAdvCbInit(uint8_t advHandle) { /* initialize advertising set */ dmExtAdvCb[advHandle].advType = DM_ADV_NONE; - dmExtAdvCb[advHandle].useLegacyPdu = TRUE; + + if (appCodedPhy) { + dmExtAdvCb[advHandle].useLegacyPdu = FALSE; + dmExtAdvCb[advHandle].priAdvPhy = HCI_ADV_PHY_LE_CODED; + dmExtAdvCb[advHandle].secAdvPhy = HCI_ADV_PHY_LE_CODED; + } else { + dmExtAdvCb[advHandle].useLegacyPdu = TRUE; + dmExtAdvCb[advHandle].priAdvPhy = HCI_ADV_PHY_LE_1M; + dmExtAdvCb[advHandle].secAdvPhy = HCI_ADV_PHY_LE_1M; + } + dmExtAdvCb[advHandle].omitAdvAddr = FALSE; dmExtAdvCb[advHandle].incTxPwr = FALSE; dmExtAdvCb[advHandle].advTxPwr = HCI_TX_PWR_NO_PREFERENCE; - dmExtAdvCb[advHandle].priAdvPhy = HCI_ADV_PHY_LE_1M; dmExtAdvCb[advHandle].secAdvMaxSkip = 0; - dmExtAdvCb[advHandle].secAdvPhy = HCI_ADV_PHY_LE_1M; dmExtAdvCb[advHandle].scanReqNotifEna = FALSE; dmExtAdvCb[advHandle].fragPref = HCI_ADV_DATA_FRAG_PREF_FRAG; dmExtAdvCb[advHandle].advSid = 0; diff --git a/Libraries/Cordio/ble-host/sources/stack/dm/dm_dev.c b/Libraries/Cordio/ble-host/sources/stack/dm/dm_dev.c index 57d8627584..df404c5904 100644 --- a/Libraries/Cordio/ble-host/sources/stack/dm/dm_dev.c +++ b/Libraries/Cordio/ble-host/sources/stack/dm/dm_dev.c @@ -201,7 +201,7 @@ void dmDevPassEvtToDevPriv(uint8_t event, uint8_t param, uint8_t advHandle, bool evt.privCtrl.connectable = connectable; /* pass event to device privacy */ - (*(dmFcnIfTbl[DM_ID_DEV_PRIV]->msgHandler))((wsfMsgHdr_t *) &evt); + (*(dmFcnIfTbl[DM_ID_DEV_PRIV]->msgHandler))((wsfMsgHdr_t *) &evt); // dmDevPrivMsgHandler } /*************************************************************************************************/ diff --git a/Libraries/Cordio/ble-host/sources/stack/dm/dm_scan_ae.c b/Libraries/Cordio/ble-host/sources/stack/dm/dm_scan_ae.c index 23f898c03c..75219b2cd6 100644 --- a/Libraries/Cordio/ble-host/sources/stack/dm/dm_scan_ae.c +++ b/Libraries/Cordio/ble-host/sources/stack/dm/dm_scan_ae.c @@ -31,6 +31,12 @@ #include "dm_conn.h" #include "dm_dev.h" #include "dm_main.h" +#include "lmgr_api.h" + +/************************************************************************************************** + Global Variables +**************************************************************************************************/ +extern lmgrCtrlBlk_t lmgrCb; /************************************************************************************************** Local Variables diff --git a/Libraries/Cordio/ble-profiles/sources/af/app_main.c b/Libraries/Cordio/ble-profiles/sources/af/app_main.c index 11b384d063..ac6f915042 100644 --- a/Libraries/Cordio/ble-profiles/sources/af/app_main.c +++ b/Libraries/Cordio/ble-profiles/sources/af/app_main.c @@ -88,6 +88,9 @@ appReqActCfg_t *pAppMasterReqActCfg = (appReqActCfg_t *) &appReqActCfg; /*! Configurable pointer for incoming request actions on slave */ appReqActCfg_t *pAppSlaveReqActCfg = (appReqActCfg_t *) &appReqActCfg; +/*! For long distance test, use CODED PHY */ +uint8_t appCodedPhy = 0; + /*************************************************************************************************/ /*! * \brief Process messages from the event handler. @@ -534,4 +537,4 @@ void AppUpdatePrivacyMode(appDbHdl_t hdl) void AppGetBdAddr(uint8_t *pBdAddr) { LlGetBdAddr(pBdAddr); -} \ No newline at end of file +} diff --git a/Libraries/Cordio/ble-profiles/sources/af/app_master_leg.c b/Libraries/Cordio/ble-profiles/sources/af/app_master_leg.c index 40748d3289..06b335aecf 100644 --- a/Libraries/Cordio/ble-profiles/sources/af/app_master_leg.c +++ b/Libraries/Cordio/ble-profiles/sources/af/app_master_leg.c @@ -29,6 +29,8 @@ #include "app_api.h" #include "app_main.h" +extern uint8_t appCodedPhy; + /*************************************************************************************************/ /*! * \brief Check if current scanning mode is legacy scanning. @@ -76,9 +78,18 @@ void AppScanStart(uint8_t mode, uint8_t scanType, uint16_t duration) { if (appMasterScanMode()) { + if (appCodedPhy) + { + DmScanSetInterval(HCI_SCAN_PHY_LE_CODED_BIT, &pAppMasterCfg->scanInterval, &pAppMasterCfg->scanWindow); + + DmScanStart(HCI_SCAN_PHY_LE_CODED_BIT, mode, &scanType, FALSE, duration, 0); + } + else + { DmScanSetInterval(HCI_SCAN_PHY_LE_1M_BIT, &pAppMasterCfg->scanInterval, &pAppMasterCfg->scanWindow); DmScanStart(HCI_SCAN_PHY_LE_1M_BIT, mode, &scanType, TRUE, duration, 0); + } } } diff --git a/Libraries/Cordio/ble-profiles/sources/af/app_slave_leg.c b/Libraries/Cordio/ble-profiles/sources/af/app_slave_leg.c index 92592e30be..b1581ac1a5 100644 --- a/Libraries/Cordio/ble-profiles/sources/af/app_slave_leg.c +++ b/Libraries/Cordio/ble-profiles/sources/af/app_slave_leg.c @@ -31,6 +31,8 @@ #include "app_api.h" #include "app_main.h" +extern uint8_t appCodedPhy; + /*************************************************************************************************/ /*! * \brief Utility function to start legacy advertising. @@ -230,14 +232,19 @@ void AppAdvSetData(uint8_t location, uint8_t len, uint8_t *pData) { if (appSlaveAdvMode()) { - /* legacy advertising data length cannot exceed 31 bytes */ - if (len > HCI_ADV_DATA_LEN) - { - len = HCI_ADV_DATA_LEN; + if (appCodedPhy) { + // TODO: check and set length + appAdvSetData(DM_ADV_HANDLE_DEFAULT, location, len, pData, 58, 58); + } else { + /* legacy advertising data length cannot exceed 31 bytes */ + if (len > HCI_ADV_DATA_LEN) + { + len = HCI_ADV_DATA_LEN; + } + + /* maximum advertising data length supported by Controller is 31 bytes */ + appAdvSetData(DM_ADV_HANDLE_DEFAULT, location, len, pData, HCI_ADV_DATA_LEN, HCI_ADV_DATA_LEN); } - - /* maximum advertising data length supported by Controller is 31 bytes */ - appAdvSetData(DM_ADV_HANDLE_DEFAULT, location, len, pData, HCI_ADV_DATA_LEN, HCI_ADV_DATA_LEN); } } diff --git a/Libraries/Cordio/controller/sources/ble/bb/bb_ble_adv_master.c b/Libraries/Cordio/controller/sources/ble/bb/bb_ble_adv_master.c index 0c584d80e0..39609fa941 100644 --- a/Libraries/Cordio/controller/sources/ble/bb/bb_ble_adv_master.c +++ b/Libraries/Cordio/controller/sources/ble/bb/bb_ble_adv_master.c @@ -23,6 +23,7 @@ /*************************************************************************************************/ #include "bb_api.h" +#include "../../common/bb/bb_int.h" #include "pal_bb.h" #include "bb_ble_int.h" #include "sch_api.h" @@ -41,6 +42,7 @@ BbBleScanPktStats_t bbScanStats; /*!< Scan packet statistics. */ extern const BbRtCfg_t *pBbRtCfg; +extern BbCtrlBlk_t bbCb; /*************************************************************************************************/ /*! @@ -165,6 +167,7 @@ static bool_t bbContScanOp(BbOpDesc_t *pBod, BbBleMstAdvEvent_t *pScan) { bbBleClrIfs(); /* passive scan */ } + PalBbBleRxData(pScan->pRxAdvBuf, BB_ADVB_MAX_LEN); return FALSE; @@ -374,7 +377,7 @@ static void bbMstScanRxCompCback(uint8_t status, int8_t rssi, uint32_t crc, uint if (pduAllow && pScan->rxAdvPostCback) { - pScan->rxAdvPostCback(pCur, pScan->pRxAdvBuf); + pScan->rxAdvPostCback(pCur, pScan->pRxAdvBuf); // lctrMstDiscoverRxExtAdvPktPostProcessHandler } break; diff --git a/Libraries/Cordio/controller/sources/ble/bb/bb_ble_adv_slave_ae.c b/Libraries/Cordio/controller/sources/ble/bb/bb_ble_adv_slave_ae.c index 0d672ed3fe..3b1c98021f 100644 --- a/Libraries/Cordio/controller/sources/ble/bb/bb_ble_adv_slave_ae.c +++ b/Libraries/Cordio/controller/sources/ble/bb/bb_ble_adv_slave_ae.c @@ -22,11 +22,13 @@ */ /*************************************************************************************************/ +#include #include "bb_ble_int.h" #include "bb_ble_sniffer_api.h" #include "sch_api.h" #include "sch_api_ble.h" -#include +#include "wsf_trace.h" +#include "lmgr_api.h" /************************************************************************************************** Macros @@ -35,9 +37,12 @@ /************************************************************************************************** Global Variables **************************************************************************************************/ +extern lmgrCtrlBlk_t lmgrCb; BbBleAuxAdvPktStats_t bbAuxAdvStats; /*!< Auxiliary advertising packet statistics. */ +extern int8_t PalRadioGetActualTxPower(int8_t txPwr, bool_t compFlag); + /*************************************************************************************************/ /*! * \brief Setup Tx CHAIN_IND. @@ -396,6 +401,13 @@ static void bbSlvExecuteAuxAdvOp(BbOpDesc_t *pBod, BbBleData_t *pBle) /* CHAIN_IND (i.e. >=MAFS) expected or no request expected. */ bbBleClrIfs(); } + + // for long range adv demo, update the ADV data here + uint8_t *pData = (uint8_t *)pAuxAdv->txAuxAdvPdu[1].pBuf; + uint8_t const pos = 8; + pData[pos]++; // the first byte of the 50-byte data + pData[pos + 49] = pData[pos]; // the last byte + APP_TRACE_INFO1("%02X", pData[pos]); PalBbBleTxData(pAuxAdv->txAuxAdvPdu, 2); } diff --git a/Libraries/Cordio/controller/sources/ble/lctr/lctr_isr_adv_master_ae.c b/Libraries/Cordio/controller/sources/ble/lctr/lctr_isr_adv_master_ae.c index 1be7be1d3c..71d4bd8509 100644 --- a/Libraries/Cordio/controller/sources/ble/lctr/lctr_isr_adv_master_ae.c +++ b/Libraries/Cordio/controller/sources/ble/lctr/lctr_isr_adv_master_ae.c @@ -48,6 +48,7 @@ /************************************************************************************************** Global Variables **************************************************************************************************/ +extern uint8_t appCodedPhy; /*! \brief Transitive context (valid only for a single Advertising Event). */ struct @@ -365,7 +366,7 @@ static bool_t lctrExtAdvRptPend(lctrExtScanCtx_t *pExtScanCtx, LlExtAdvReportInd uint64_t hash; lctrAdvRptGenerateExtHash(&hash, pRpt->addrType, BstreamToBda64(pRpt->addr), pRpt->eventType, pRpt->advSID, pExtScanCtx->extAdvHdr.did); - if (lctrAdvRptCheckDuplicate(&lctrMstExtScan.advFilt, hash)) + if (lctrAdvRptCheckDuplicate(&lctrMstExtScan.advFilt, hash) && (appCodedPhy == 0)) { /* Duplicate found, just exit. */ return FALSE; @@ -1162,7 +1163,6 @@ bool_t lctrMstDiscoverRxAuxAdvPktHandler(BbOpDesc_t *pOp, const uint8_t *pAdvBuf if (lctrMstExtScanIsr.advAReceived == TRUE) { pExtScanCtx->extAdvHdr.extHdrFlags |= LL_EXT_HDR_ADV_ADDR_BIT; - } pExtScanCtx->extAdvHdr.advAddr = lctrMstExtScanIsr.advA; lctrMstExtScanIsr.advHdr.txAddrRnd = lctrMstExtScanIsr.advARand; diff --git a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master.c b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master.c index 8cd90fe3ce..7c465ec5f6 100644 --- a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master.c +++ b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master.c @@ -43,6 +43,8 @@ /*! \brief Scan operational context. */ lctrMstScanCtx_t lctrMstScan; +extern uint8_t appCodedPhy; + /*************************************************************************************************/ /*! * \brief Master scan reset handler. @@ -611,6 +613,12 @@ void lctrAdvRptGenerateExtHash(uint64_t *pHash, uint8_t addrType, uint64_t addr, /*************************************************************************************************/ bool_t lctrAdvRptCheckDuplicate(lctrAdvRptFilt_t *pAdvFilt, uint64_t hash) { + if (appCodedPhy) + { + pAdvFilt->addToFiltTbl = TRUE; + return TRUE; + } + if (!pAdvFilt->enable) { return FALSE; diff --git a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master_ae.c b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master_ae.c index 6d39bca344..f1f662b078 100644 --- a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master_ae.c +++ b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master_ae.c @@ -83,6 +83,8 @@ lctrSyncInfo_t trsfSyncInfo; /*! \brief Active extended scan contexts. */ lctrActiveExtScan_t lctrActiveExtScan; +extern uint8_t appCodedPhy; + /*************************************************************************************************/ /*! * \brief Master create sync message dispatcher. @@ -298,6 +300,7 @@ static void lctrMstExtScanDisp(LctrExtScanMsg_t *pMsg) default: break; } + if (pMsg->hdr.handle == LCTR_SCAN_PHY_ALL) { isBcstMsg = TRUE; @@ -347,7 +350,6 @@ static void lctrMstSendPendingAdvRptHandler(void) lctrExtScanCtx_t *pExtScanCtx = LCTR_GET_EXT_SCAN_CTX(i); - if (pExtScanCtx->data.scan.auxAdvRptState == LCTR_RPT_STATE_COMP) { LmgrSendExtAdvRptInd(&pExtScanCtx->data.scan.auxAdvRpt); @@ -848,7 +850,15 @@ void LctrMstExtScanDefaults(void) lmgrCb.numExtScanPhys = 1; lctrMstExtScanTbl[LCTR_SCAN_PHY_1M]->scanParam = defScanParam; - lctrMstExtScan.enaPhys = 1 << LCTR_SCAN_PHY_1M; + + if (appCodedPhy) + { + lctrMstExtScan.enaPhys = 1 << LCTR_SCAN_PHY_CODED; + } + else + { + lctrMstExtScan.enaPhys = 1 << LCTR_SCAN_PHY_1M; + } /* Setup timers. */ lctrMsgHdr_t *pMsg; @@ -1563,7 +1573,14 @@ lctrPerScanCtx_t *lctrAllocPerScanCtx(void) pMsg->event = LCTR_PER_SCAN_SUP_TIMEOUT; /* Update once PHY is known. */ - pCtx->bleData.chan.txPhy = pCtx->bleData.chan.rxPhy = BB_PHY_BLE_1M; + if (appCodedPhy) + { + pCtx->bleData.chan.txPhy = pCtx->bleData.chan.rxPhy = BB_PHY_BLE_CODED; + } + else + { + pCtx->bleData.chan.txPhy = pCtx->bleData.chan.rxPhy = BB_PHY_BLE_1M; + } /* Default PHY. */ pCtx->rxPhys = lmgrConnCb.rxPhys; diff --git a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_init_master_ae.c b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_init_master_ae.c index 6921013794..f7da9fa930 100644 --- a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_init_master_ae.c +++ b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_init_master_ae.c @@ -60,6 +60,8 @@ lctrExtScanCtx_t lctrMstExtInitTbl[LCTR_SCAN_PHY_TOTAL]; /*! \brief Extended initiator control block. */ lctrExtInitCtrlBlk_t lctrMstExtInit; +extern uint8_t appCodedPhy; + /*************************************************************************************************/ /*! * \brief Master initiate reset handler. @@ -561,7 +563,15 @@ void LctrMstExtInitDefaults(void) memset(&lctrMstExtInit, 0, sizeof(lctrMstExtInit)); lmgrCb.numExtScanPhys = 1; - lctrMstExtInit.enaPhys = 1 << LCTR_SCAN_PHY_1M; + + if (appCodedPhy == 0) + { + lctrMstExtInit.enaPhys = 1 << LCTR_SCAN_PHY_1M; + } + else + { + lctrMstExtInit.enaPhys = 1 << LCTR_SCAN_PHY_CODED; + } } /*************************************************************************************************/ diff --git a/Libraries/Cordio/controller/sources/ble/ll/ll_main_adv_master_ae.c b/Libraries/Cordio/controller/sources/ble/ll/ll_main_adv_master_ae.c index 8d0aa0eed5..12c98c7530 100644 --- a/Libraries/Cordio/controller/sources/ble/ll/ll_main_adv_master_ae.c +++ b/Libraries/Cordio/controller/sources/ble/ll/ll_main_adv_master_ae.c @@ -33,6 +33,8 @@ #include "wsf_msg.h" #include "wsf_trace.h" +extern uint8_t appCodedPhy; + /*************************************************************************************************/ /*! * \brief Validate scan parameter. @@ -167,7 +169,16 @@ void LlExtScanEnable(uint8_t enable, uint8_t filterDup, uint16_t duration, uint1 { const unsigned int durMsPerUnit = 10; const unsigned int perMsPerUnit = 1280; - const unsigned int filterDupMax = LL_SCAN_FILTER_DUP_ENABLE_PERIODIC; + unsigned int filterDupMax; + + if (appCodedPhy) + { + filterDupMax = LL_SCAN_FILTER_DUP_DISABLE; + } + else + { + filterDupMax = LL_SCAN_FILTER_DUP_ENABLE_PERIODIC; + } lctrExtScanEnableMsg_t *pMsg; uint32_t durMs = duration * durMsPerUnit; diff --git a/Libraries/Cordio/controller/sources/common/sch/sch_int.h b/Libraries/Cordio/controller/sources/common/sch/sch_int.h index 15d0912096..2ff7c64338 100644 --- a/Libraries/Cordio/controller/sources/common/sch/sch_int.h +++ b/Libraries/Cordio/controller/sources/common/sch/sch_int.h @@ -65,6 +65,8 @@ typedef struct uint16_t delayLoadWatermarkCount; /*!< Statistics: Delay loading watermark count. */ uint16_t delayLoadCount; /*!< Statistics: Delay loading count. */ uint32_t delayLoadTotalCount; /*!< Statistics: Delay loading total count. */ + + uint8_t cnt; } SchCtrlBlk_t; /************************************************************************************************** @@ -93,12 +95,7 @@ void schRemoveHead(void); * \return TRUE if BOD time is in the future, FALSE otherwise. */ /*************************************************************************************************/ -static inline bool_t schDueTimeInFuture(BbOpDesc_t *pBod) -{ - const uint32_t curTime = PalBbGetCurrentTime(); - - return (BbGetTargetTimeDelta(pBod->dueUsec, curTime) > 0); -} +bool_t schDueTimeInFuture(BbOpDesc_t *pBod); /*************************************************************************************************/ diff --git a/Libraries/Cordio/controller/sources/common/sch/sch_list.c b/Libraries/Cordio/controller/sources/common/sch/sch_list.c index 0b53e3741a..51f7a8eb7e 100644 --- a/Libraries/Cordio/controller/sources/common/sch/sch_list.c +++ b/Libraries/Cordio/controller/sources/common/sch/sch_list.c @@ -197,6 +197,7 @@ static inline void schInsertToEmptyList(BbOpDesc_t *pItem) schCb.pHead = pItem; schCb.pTail = pItem; + schCb.cnt++; pItem->pPrev = NULL; pItem->pNext = NULL; @@ -233,6 +234,8 @@ static inline void schInsertBefore(BbOpDesc_t *pItem, BbOpDesc_t *pTgt) schCb.pHead = pItem; } + schCb.cnt++; + SCH_TRACE_INFO1("++| schInsertBefore |++ pBod=0x%08x", (uint32_t)pItem); SCH_TRACE_INFO1("++| |++ .dueUsec=%u", pItem->dueUsec); SCH_TRACE_INFO1("++| |++ .minDurUsec=%u", pItem->minDurUsec); @@ -265,6 +268,8 @@ static inline void schInsertAfter(BbOpDesc_t *pItem, BbOpDesc_t *pTgt) schCb.pTail = pItem; } + schCb.cnt++; + SCH_TRACE_INFO1("++| schInsertAfter |++ pBod=0x%08x", (uint32_t)pItem); SCH_TRACE_INFO1("++| |++ .dueUsec=%u", pItem->dueUsec); SCH_TRACE_INFO1("++| |++ .minDurUsec=%u", pItem->minDurUsec); @@ -291,6 +296,11 @@ void schRemoveHead(void) /* Now empty list */ schCb.pTail = NULL; } + + if (schCb.cnt) + { + schCb.cnt--; + } } /*************************************************************************************************/ @@ -327,6 +337,11 @@ static void schRemoveMiddle(BbOpDesc_t *pBod) pBod->pPrev->pNext = pBod->pNext; pBod->pNext->pPrev = pBod->pPrev; } + + if (schCb.cnt) + { + schCb.cnt--; + } } /*************************************************************************************************/ diff --git a/Libraries/Cordio/controller/sources/common/sch/sch_main.c b/Libraries/Cordio/controller/sources/common/sch/sch_main.c index 1b265c605f..3c7887c857 100644 --- a/Libraries/Cordio/controller/sources/common/sch/sch_main.c +++ b/Libraries/Cordio/controller/sources/common/sch/sch_main.c @@ -225,6 +225,7 @@ void SchReset(void) schCb.schHandlerWatermarkUsec = 0; schCb.delayLoadWatermarkCount = 0; schCb.delayLoadTotalCount = 0; + schCb.cnt = 0; } /*************************************************************************************************/ @@ -324,6 +325,22 @@ void SchHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) } } +/*************************************************************************************************/ +/*! + * \brief Is BOD due time in the future. + * + * \param pBod Target BOD. + * + * \return TRUE if BOD time is in the future, FALSE otherwise. + */ +/*************************************************************************************************/ +bool_t schDueTimeInFuture(BbOpDesc_t *pBod) +{ + const uint32_t curTime = PalBbGetCurrentTime(); + int32_t delta = BbGetTargetTimeDelta(pBod->dueUsec, curTime); + return (delta > 0); +} + /*************************************************************************************************/ /*! * \brief Load BOD if not already started. @@ -484,4 +501,4 @@ uint32_t SchStatsGetDelayLoadTotalCount(void) schState_t SchGetState(void) { return schCb.state; -} \ No newline at end of file +} diff --git a/Libraries/Cordio/platform/targets/maxim/max32655/sources/pal_cfg.c b/Libraries/Cordio/platform/targets/maxim/max32655/sources/pal_cfg.c index c9bd59f67d..456821dd5e 100644 --- a/Libraries/Cordio/platform/targets/maxim/max32655/sources/pal_cfg.c +++ b/Libraries/Cordio/platform/targets/maxim/max32655/sources/pal_cfg.c @@ -178,8 +178,6 @@ void palCfgLoadBdAddress(uint8_t *pDevAddr) PalSysAssertTrap(); } - - /* MA-L assigend by IEEE to Maxim Integrated Products */ pDevAddr[5] = 0x00; pDevAddr[4] = 0x18; diff --git a/Libraries/Cordio/wsf/include/wsf_os.h b/Libraries/Cordio/wsf/include/wsf_os.h index 6fea74a32d..df2e1f5ac9 100644 --- a/Libraries/Cordio/wsf/include/wsf_os.h +++ b/Libraries/Cordio/wsf/include/wsf_os.h @@ -47,6 +47,14 @@ extern "C" { Macros **************************************************************************************************/ +/* maximum number of event handlers per task */ +#ifndef WSF_MAX_HANDLERS +#define WSF_MAX_HANDLERS 16 +#endif + +/*! \brief OS serivice function number */ +#define WSF_OS_MAX_SERVICE_FUNCTIONS 3 + /*! \brief Derive task from handler ID */ #define WSF_TASK_FROM_ID(handlerID) (((handlerID) >> 4) & 0x0F) @@ -108,6 +116,7 @@ typedef struct uint16_t param; /*!< \brief General purpose parameter passed to event handler */ uint8_t event; /*!< \brief General purpose event value passed to event handler */ uint8_t status; /*!< \brief General purpose status value passed to event handler */ + uint8_t msg_ndx; /*!< \brief message index */ } wsfMsgHdr_t; /************************************************************************************************** @@ -124,6 +133,31 @@ typedef struct /*************************************************************************************************/ typedef void (*wsfEventHandler_t)(wsfEventMask_t event, wsfMsgHdr_t *pMsg); +/*! \brief Task structure */ +typedef struct +{ + wsfEventHandler_t handler[WSF_MAX_HANDLERS]; + wsfEventMask_t handlerEventMask[WSF_MAX_HANDLERS]; + wsfQueue_t msgQueue; + wsfTaskEvent_t taskEventMask; + uint8_t numHandler; +} wsfOsTask_t; + +/*! \brief OS structure */ +typedef struct +{ + wsfOsTask_t task; + WsfOsIdleCheckFunc_t sleepCheckFuncs[WSF_OS_MAX_SERVICE_FUNCTIONS]; + uint8_t numFunc; +} wsfOs_t; + +/************************************************************************************************** + External Variables +**************************************************************************************************/ + +/*! \brief Diagnostic Task Identifier */ +extern wsfHandlerId_t WsfActiveHandler; + /************************************************************************************************** Function Declarations **************************************************************************************************/ diff --git a/Libraries/Cordio/wsf/include/wsf_trace.h b/Libraries/Cordio/wsf/include/wsf_trace.h index 61a2d1bb85..d84ec479de 100644 --- a/Libraries/Cordio/wsf/include/wsf_trace.h +++ b/Libraries/Cordio/wsf/include/wsf_trace.h @@ -303,6 +303,19 @@ bool_t WsfTokenService(void); #define WSF_TRACE_MSG2(msg, var1, var2) /*! \brief 3 argument WSF message trace. */ #define WSF_TRACE_MSG3(msg, var1, var2, var3) +/*! \brief 4 argument WSF message trace. */ +#define WSF_TRACE_MSG4(msg, var1, var2, var3, var4) WSF_TRACE4("WSF", "INFO", msg, var1, var2, var3, var4) +/*! \brief 5 argument WSF message trace. */ +#define WSF_TRACE_MSG5(msg, var1, var2, var3, var4, var5) WSF_TRACE5("WSF", "INFO", msg, var1, var2, var3, var4, var5) + +#define MSG_TRACE_INFO0(msg) WSF_TRACE0(INFO, APP, msg) +#define MSG_TRACE_INFO1(msg, var1) WSF_TRACE1(INFO, APP, msg, var1) +#define MSG_TRACE_INFO2(msg, var1, var2) WSF_TRACE2(INFO, APP, msg, var1, var2) +#define MSG_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE3(INFO, APP, msg, var1, var2, var3) +#define MSG_TRACE_INFO4(msg, var1, var2, var3, var4) \ + WSF_TRACE4(INFO, APP, msg, var1, var2, var3, var4) +#define MSG_TRACE_INFO5(msg, var1, var2, var3, var4, var5) \ + WSF_TRACE5(INFO, APP, msg, var1, var2, var3, var4, var5) /*! \brief 0 argument HCI info trace. */ #define HCI_TRACE_INFO0(msg) WSF_TRACE0V("HCI", "INFO", msg) @@ -537,6 +550,9 @@ bool_t WsfTokenService(void); #define LL_TRACE_INFO2(msg, var1, var2) WSF_TRACE2V("LL", "INFO", msg, var1, var2) /*! \brief 3 argument LL info trace. */ #define LL_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE3V("LL", "INFO", msg, var1, var2, var3) +/*! \brief 4 argument LL info trace. */ +#define LL_TRACE_INFO4(msg, var1, var2, var3, var4) WSF_TRACE4V("LL", "INFO", msg, var1, var2, var3, var4) + /*! \brief 0 argument LL warning trace. */ #define LL_TRACE_WARN0(msg) WSF_TRACE0V("LL", "WARN", msg) /*! \brief 1 argument LL warning trace. */ diff --git a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c index 16725f3805..806049aa00 100644 --- a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c +++ b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c @@ -42,6 +42,8 @@ typedef struct wsfMsg_tag wsfHandlerId_t handlerId; } wsfMsg_t; +uint8_t msg_ndx = 0; + /*************************************************************************************************/ /*! * \brief Allocate a data message buffer to be sent with WsfMsgSend(). @@ -123,6 +125,12 @@ void WsfMsgSend(wsfHandlerId_t handlerId, void *pMsg) /*************************************************************************************************/ void WsfMsgEnq(wsfQueue_t *pQueue, wsfHandlerId_t handlerId, void *pMsg) { + /* + wsfMsgHdr_t *h = (wsfMsgHdr_t *)pMsg; + h->msg_ndx = ++msg_ndx; + WsfTrace("msg_enq %03d hndrId=%u p=0x%04X evt=%03d st=%d", h->msg_ndx, handlerId, h->param, h->event, h->status); + */ + wsfMsg_t *p; WSF_ASSERT(pMsg != NULL); @@ -156,6 +164,12 @@ void *WsfMsgDeq(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId) /* hide header */ pMsg++; + + /* + uint8_t *pData = (uint8_t *)pMsg; + + WsfTrace("msg_deq %03d hndrId=%d p=0x%02X%02X evt=%03d st=%d", pData[4], *pHandlerId, pData[1], pData[0], pData[2], pData[3]); + */ } return pMsg; diff --git a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_nvm.c b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_nvm.c index 92d9318b21..0fa1fc6b5f 100644 --- a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_nvm.c +++ b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_nvm.c @@ -404,7 +404,7 @@ void WsfNvmEraseDataAll(WsfNvmCompEvent_t compCback) { for (uint32_t eraseAddr = WSF_NVM_START_ADDR; eraseAddr < wsfNvmCb.availAddr; eraseAddr += wsfNvmCb.sectorSize) { - PalFlashEraseSector(1, eraseAddr); + PalFlashEraseSector(wsfNvmCb.availAddr, eraseAddr); } wsfNvmCb.availAddr = WSF_NVM_START_ADDR; diff --git a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c index 5040e52bbe..d557736d3a 100644 --- a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c +++ b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c @@ -68,30 +68,14 @@ WSF_CT_ASSERT(sizeof(uint32_t) == 4); #define WSF_OS_THREAD_SLEEP_WAKEUP_FLAG 0x0001 #endif -/*! \brief OS serivice function number */ -#define WSF_OS_MAX_SERVICE_FUNCTIONS 3 - /************************************************************************************************** Data Types **************************************************************************************************/ -/*! \brief Task structure */ -typedef struct -{ - wsfEventHandler_t handler[WSF_MAX_HANDLERS]; - wsfEventMask_t handlerEventMask[WSF_MAX_HANDLERS]; - wsfQueue_t msgQueue; - wsfTaskEvent_t taskEventMask; - uint8_t numHandler; -} wsfOsTask_t; - -/*! \brief OS structure */ -typedef struct -{ - wsfOsTask_t task; - WsfOsIdleCheckFunc_t sleepCheckFuncs[WSF_OS_MAX_SERVICE_FUNCTIONS]; - uint8_t numFunc; -} wsfOs_t; +/************************************************************************************************** + Global Variables +**************************************************************************************************/ +extern uint8_t msg_ndx; /************************************************************************************************** Local Variables diff --git a/Libraries/Cordio/wsf/sources/targets/win32/wsf_trace.h b/Libraries/Cordio/wsf/sources/targets/win32/wsf_trace.h index e1ad33eabd..26a14b9d8a 100644 --- a/Libraries/Cordio/wsf/sources/targets/win32/wsf_trace.h +++ b/Libraries/Cordio/wsf/sources/targets/win32/wsf_trace.h @@ -185,6 +185,7 @@ extern "C" { #define LL_TRACE_INFO1(msg, var1) WSF_TRACE(INFO, LL, msg, var1) #define LL_TRACE_INFO2(msg, var1, var2) WSF_TRACE(INFO, LL, msg, var1, var2) #define LL_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE(INFO, LL, msg, var1, var2, var3) +#define LL_TRACE_INFO4(msg, var1, var2, var3, var4) WSF_TRACE(INFO, LL, msg, var1, var2, var3, var4) /*! \brief 0 argument MESH info trace. */ #define MESH_TRACE_INFO0(msg) WSF_TRACE(INFO, MESH, msg) From ec3a613a24c66f4586c476c8a5833146cb3f825b Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Thu, 21 Sep 2023 10:00:01 -0500 Subject: [PATCH 04/10] Add BLE_LR_Central --- Examples/MAX32665/BLE_LR_Central/.cproject | 93 ++ Examples/MAX32665/BLE_LR_Central/.project | 26 + .../.settings/language.settings.xml | 15 + .../org.eclipse.cdt.codan.core.prefs | 93 ++ .../.settings/org.eclipse.cdt.core.prefs | 15 + .../MAX32665/BLE_LR_Central/.vscode/README.md | 47 + .../.vscode/c_cpp_properties.json | 53 + .../MAX32665/BLE_LR_Central/.vscode/flash.gdb | 15 + .../BLE_LR_Central/.vscode/launch.json | 133 ++ .../BLE_LR_Central/.vscode/settings.json | 99 ++ .../BLE_LR_Central/.vscode/tasks.json | 115 ++ .../BLE_LR_Central/BLE_LR_Central.launch | 62 + Examples/MAX32665/BLE_LR_Central/Makefile | 395 +++++ Examples/MAX32665/BLE_LR_Central/README.md | 70 + Examples/MAX32665/BLE_LR_Central/datc_api.h | 72 + Examples/MAX32665/BLE_LR_Central/datc_main.c | 1425 +++++++++++++++++ Examples/MAX32665/BLE_LR_Central/main.c | 291 ++++ Examples/MAX32665/BLE_LR_Central/project.mk | 26 + Examples/MAX32665/BLE_LR_Central/sdsc_api.h | 81 + Examples/MAX32665/BLE_LR_Central/sdsc_main.c | 92 ++ Examples/MAX32665/BLE_LR_Central/stack_datc.c | 107 ++ Examples/MAX32665/BLE_LR_Peripheral/README.md | 2 +- Examples/MAX32665/BLE_LR_Peripheral/main.c | 4 +- .../sources/hci/exactle/hci_cmd_master_ae.c | 4 +- .../sources/hci/exactle/hci_core_ps.c | 4 +- .../ble-host/sources/stack/dm/dm_adv_ae.c | 4 +- .../ble-host/sources/stack/dm/dm_scan_ae.c | 6 +- .../Cordio/ble-profiles/sources/af/app_main.c | 2 +- .../ble-profiles/sources/af/app_master_leg.c | 4 +- .../ble-profiles/sources/af/app_slave_leg.c | 4 +- .../sources/ble/lctr/lctr_isr_adv_master_ae.c | 4 +- .../sources/ble/lctr/lctr_main_adv_master.c | 4 +- .../ble/lctr/lctr_main_adv_master_ae.c | 6 +- .../ble/lctr/lctr_main_init_master_ae.c | 4 +- .../sources/ble/ll/ll_main_adv_master_ae.c | 4 +- 35 files changed, 3355 insertions(+), 26 deletions(-) create mode 100644 Examples/MAX32665/BLE_LR_Central/.cproject create mode 100644 Examples/MAX32665/BLE_LR_Central/.project create mode 100644 Examples/MAX32665/BLE_LR_Central/.settings/language.settings.xml create mode 100644 Examples/MAX32665/BLE_LR_Central/.settings/org.eclipse.cdt.codan.core.prefs create mode 100644 Examples/MAX32665/BLE_LR_Central/.settings/org.eclipse.cdt.core.prefs create mode 100755 Examples/MAX32665/BLE_LR_Central/.vscode/README.md create mode 100755 Examples/MAX32665/BLE_LR_Central/.vscode/c_cpp_properties.json create mode 100644 Examples/MAX32665/BLE_LR_Central/.vscode/flash.gdb create mode 100755 Examples/MAX32665/BLE_LR_Central/.vscode/launch.json create mode 100755 Examples/MAX32665/BLE_LR_Central/.vscode/settings.json create mode 100755 Examples/MAX32665/BLE_LR_Central/.vscode/tasks.json create mode 100644 Examples/MAX32665/BLE_LR_Central/BLE_LR_Central.launch create mode 100644 Examples/MAX32665/BLE_LR_Central/Makefile create mode 100644 Examples/MAX32665/BLE_LR_Central/README.md create mode 100644 Examples/MAX32665/BLE_LR_Central/datc_api.h create mode 100644 Examples/MAX32665/BLE_LR_Central/datc_main.c create mode 100644 Examples/MAX32665/BLE_LR_Central/main.c create mode 100644 Examples/MAX32665/BLE_LR_Central/project.mk create mode 100644 Examples/MAX32665/BLE_LR_Central/sdsc_api.h create mode 100644 Examples/MAX32665/BLE_LR_Central/sdsc_main.c create mode 100644 Examples/MAX32665/BLE_LR_Central/stack_datc.c diff --git a/Examples/MAX32665/BLE_LR_Central/.cproject b/Examples/MAX32665/BLE_LR_Central/.cproject new file mode 100644 index 0000000000..2799f41c47 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.cproject @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/MAX32665/BLE_LR_Central/.project b/Examples/MAX32665/BLE_LR_Central/.project new file mode 100644 index 0000000000..ef219ece69 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.project @@ -0,0 +1,26 @@ + + + BLE_LR_Central + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/Examples/MAX32665/BLE_LR_Central/.settings/language.settings.xml b/Examples/MAX32665/BLE_LR_Central/.settings/language.settings.xml new file mode 100644 index 0000000000..d32717b6f3 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.settings/language.settings.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/Examples/MAX32665/BLE_LR_Central/.settings/org.eclipse.cdt.codan.core.prefs b/Examples/MAX32665/BLE_LR_Central/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000000..59c0b37ba7 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,93 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"} +org.eclipse.cdt.codan.checkers.nocommentinside=-Error +org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"} +org.eclipse.cdt.codan.checkers.nolinecomment=-Error +org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"} +org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"C-Style cast instead of C++ cast\\")"} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"} +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true} +org.eclipse.cdt.codan.internal.checkers.CopyrightProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.CopyrightProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Lack of copyright information\\")",regex\=>".*Copyright.*"} +org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error +org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Goto statement used\\")"} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.MissCaseProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissCaseProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing cases in switch\\")"} +org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing default in switch\\")",defaultWithAllEnums\=>false} +org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing reference return value in assignment operator\\")"} +org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing self check in assignment operator\\")"} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Using directive in header\\")"} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem=-Error +org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Virtual method call in constructor/destructor\\")"} +org.eclipse.cdt.qt.core.qtproblem=Warning +org.eclipse.cdt.qt.core.qtproblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_ON_FILE_OPEN\=>true,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>null} diff --git a/Examples/MAX32665/BLE_LR_Central/.settings/org.eclipse.cdt.core.prefs b/Examples/MAX32665/BLE_LR_Central/.settings/org.eclipse.cdt.core.prefs new file mode 100644 index 0000000000..1bf0d3002e --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.settings/org.eclipse.cdt.core.prefs @@ -0,0 +1,15 @@ +eclipse.preferences.version=1 +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/BOARD/delimiter=; +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/BOARD/operation=append +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/BOARD/value=EvKit_V1 +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/GCC_PREFIX/delimiter=; +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/GCC_PREFIX/operation=replace +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/GCC_PREFIX/value=arm-none-eabi- +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/PROJECT/delimiter=; +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/PROJECT/operation=append +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/PROJECT/value=BLE_LR_Central +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/TARGET/delimiter=; +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/TARGET/operation=append +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/TARGET/value=MAX32665 +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/append=true +environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1028364529/appendContributed=true diff --git a/Examples/MAX32665/BLE_LR_Central/.vscode/README.md b/Examples/MAX32665/BLE_LR_Central/.vscode/README.md new file mode 100755 index 0000000000..58733e941c --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.vscode/README.md @@ -0,0 +1,47 @@ +# VSCode-Maxim + +_(If you're viewing this document from within Visual Studio Code you can press `CTRL+SHIFT+V` to open a Markdown preview window.)_ + +## Quick Links + +* [MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/) +* [VSCode-Maxim Github](https://github.com/Analog-Devices-MSDK/VSCode-Maxim) + +## Introduction + +VSCode-Maxim is a set of [Visual Studio Code](https://code.visualstudio.com/) project configurations and utilities for enabling embedded development for [Analog Device's MSDK](https://github.com/Analog-Devices-MSDK/msdk) and the [MAX32xxx/MAX78xxx microcontrollers](https://www.analog.com/en/product-category/microcontrollers.html). + +The following features are supported: + +* Code editing with intellisense down to the register level +* Code compilation with the ability to easily re-target a project for different microcontrollers and boards +* Flashing programs +* GUI and command-line debugging + +## Dependencies + +* [Visual Studio Code](https://code.visualstudio.com/) + * [C/C++ VSCode Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) + * [Cortex-Debug Extension](https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug) +* [Analog Devices MSDK](https://analog-devices-msdk.github.io/msdk/) + +## Installation + +Install the MSDK, then set `"MAXIM_PATH"` in your _user_ VS Code settings. + +See [Getting Started with Visual Studio Code](https://analog-devices-msdk.github.io/msdk/USERGUIDE/#getting-started-with-visual-studio-code) in the MSDK User Guide for detailed instructions. + +## Usage + +See the [MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/#visual-studio-code) for detailed usage info. + +## Issue Tracker + +Bug reports, feature requests, and contributions are welcome via the [issues](https://github.com/Analog-Devices-MSDK/VSCode-Maxim/issues) tracker on Github. + +New issues should contain _at minimum_ the following information: + +* Visual Studio Code version #s (see `Help -> About`) +* C/C++ Extension version # +* Target microcontroller and evaluation platform +* The projects `.vscode` folder and `Makefile` (where applicable). Standard compression formats such as `.zip`, `.rar`, `.tar.gz`, etc. are all acceptable. diff --git a/Examples/MAX32665/BLE_LR_Central/.vscode/c_cpp_properties.json b/Examples/MAX32665/BLE_LR_Central/.vscode/c_cpp_properties.json new file mode 100755 index 0000000000..dfbed47b58 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.vscode/c_cpp_properties.json @@ -0,0 +1,53 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${default}" + ], + "defines": [ + "${default}" + ], + "intelliSenseMode": "gcc-arm", + "compilerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gcc.exe", + "browse": { + "path": [ + "${default}" + ] + } + }, + { + "name": "Linux", + "includePath": [ + "${default}" + ], + "defines": [ + "${default}" + ], + "intelliSenseMode": "gcc-arm", + "compilerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gcc", + "browse": { + "path": [ + "${default}" + ] + } + }, + { + "name": "Mac", + "includePath": [ + "${default}" + ], + "defines": [ + "${default}" + ], + "intelliSenseMode": "gcc-arm", + "compilerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gcc", + "browse": { + "path": [ + "${default}" + ] + } + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Central/.vscode/flash.gdb b/Examples/MAX32665/BLE_LR_Central/.vscode/flash.gdb new file mode 100644 index 0000000000..fc627ae86a --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.vscode/flash.gdb @@ -0,0 +1,15 @@ +define flash_m4 + set architecture armv7e-m + target remote | openocd -c "gdb_port pipe;log_output flash.log" -s $arg0/scripts -f interface/$arg1 -f target/$arg2 -c "init; reset halt" + load + compare-sections + monitor reset halt +end + +define flash_m4_run + set architecture armv7e-m + target remote | openocd -c "gdb_port pipe;log_output flash.log" -s $arg0/scripts -f interface/$arg1 -f target/$arg2 -c "init; reset halt" + load + compare-sections + monitor resume +end \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Central/.vscode/launch.json b/Examples/MAX32665/BLE_LR_Central/.vscode/launch.json new file mode 100755 index 0000000000..01fe519904 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.vscode/launch.json @@ -0,0 +1,133 @@ +{ + "configurations": [ + { + "name": "Debug Arm (Cortex-debug)", + "cwd":"${workspaceRoot}", + "executable": "${workspaceFolder}/build/${config:program_file}", + "loadFiles": ["${workspaceFolder}/build/${config:program_file}"], + "symbolFiles": [{ + "file": "${workspaceFolder}/build/${config:symbol_file}" + }], + "request": "launch", + "type": "cortex-debug", + "servertype": "openocd", + "linux": { + "gdbPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb", + "serverpath": "${config:OCD_path}/openocd", + }, + "windows": { + "gdbPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb.exe", + "serverpath": "${config:OCD_path}/openocd.exe", + }, + "osx": { + "gdbPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb", + "serverpath": "${config:OCD_path}/openocd", + }, + "searchDir": ["${config:OCD_path}/scripts"], + "configFiles": ["interface/${config:M4_OCD_interface_file}", "target/${config:M4_OCD_target_file}"], + "interface": "swd", + "runToEntryPoint": "main", + "svdFile": "${config:MAXIM_PATH}/Libraries/CMSIS/Device/Maxim/${config:target}/Include/${config:target}.svd" + }, + { + "name": "GDB (Arm M4)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/${config:program_file}", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "linux": { + "miDebuggerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb", + "debugServerPath": "${config:OCD_path}/openocd", + }, + "windows": { + "miDebuggerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb.exe", + "debugServerPath": "${config:OCD_path}/openocd.exe", + }, + "osx": { + "miDebuggerPath": "${config:ARM_GCC_path}/bin/arm-none-eabi-gdb", + "debugServerPath": "${config:OCD_path}/bin/openocd", + }, + "logging": { + "exceptions": true, + "trace": false, + "traceResponse": false, + "engineLogging": false + }, + "miDebuggerServerAddress": "localhost:3333", + "debugServerArgs": "-s ${config:OCD_path}/scripts -f interface/${config:M4_OCD_interface_file} -f target/${config:M4_OCD_target_file} -c \"init; reset halt\"", + "serverStarted": "Info : Listening on port 3333 for gdb connections", + "filterStderr": true, + "targetArchitecture": "arm", + "customLaunchSetupCommands": [ + {"text":"-list-features"} + ], + "setupCommands": [ + { "text":"set logging overwrite on"}, + { "text":"set logging file debug-arm.log"}, + { "text":"set logging on"}, + { "text":"cd ${workspaceFolder}" }, + { "text":"exec-file build/${config:program_file}" }, + { "text":"symbol-file build/${config:symbol_file}" }, + { "text":"target remote localhost:3333" }, + { "text":"monitor reset halt" }, + { "text":"set $pc=Reset_Handler"}, + { "text":"b main" } + ] + }, + { + "name": "GDB (RISC-V)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/buildrv/${config:program_file}", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "linux": { + "miDebuggerPath": "${config:xPack_GCC_path}/bin/riscv-none-elf-gdb", + "debugServerPath": "${config:OCD_path}/openocd", + }, + "windows": { + "miDebuggerPath": "${config:xPack_GCC_path}/bin/riscv-none-elf-gdb.exe", + "debugServerPath": "${config:OCD_path}/openocd.exe", + }, + "osx": { + "miDebuggerPath": "${config:xPack_GCC_path}/bin/riscv-none-elf-gdb", + "debugServerPath": "${config:OCD_path}/bin/openocd", + }, + "logging": { + "exceptions": true, + "trace": false, + "traceResponse": false, + "engineLogging": false + }, + "miDebuggerServerAddress": "localhost:3334", + "debugServerArgs": "-c \"gdb_port 3334\" -s ${config:OCD_path}/scripts -f interface/${config:RV_OCD_interface_file} -f target/${config:RV_OCD_target_file}", + "serverStarted": "Info : Listening on port 3334 for gdb connections", + "filterStderr": true, + "customLaunchSetupCommands": [ + {"text":"-list-features"} + ], + "targetArchitecture": "arm", + "setupCommands": [ + { "text":"set logging overwrite on"}, + { "text":"set logging file debug-riscv.log"}, + { "text":"set logging on"}, + { "text":"cd ${workspaceFolder}" }, + { "text": "set architecture riscv:rv32", "ignoreFailures": false }, + { "text":"exec-file build/${config:program_file}", "ignoreFailures": false }, + { "text":"symbol-file buildrv/${config:symbol_file}", "ignoreFailures": false }, + { "text":"target remote localhost:3334" }, + { "text":"b main" }, + { "text": "set $pc=Reset_Handler","ignoreFailures": false } + ] + } + ] +} diff --git a/Examples/MAX32665/BLE_LR_Central/.vscode/settings.json b/Examples/MAX32665/BLE_LR_Central/.vscode/settings.json new file mode 100755 index 0000000000..981dd2759d --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.vscode/settings.json @@ -0,0 +1,99 @@ +{ + "terminal.integrated.env.windows": { + "Path":"${config:OCD_path};${config:ARM_GCC_path}/bin;${config:xPack_GCC_path}/bin;${config:Make_path};${config:MSYS_path}/usr/bin;${env:PATH}", + "MAXIM_PATH":"${config:MAXIM_PATH}" + }, + "terminal.integrated.defaultProfile.windows": "Command Prompt", + + "terminal.integrated.env.linux": { + "PATH":"${config:OCD_path}:${config:ARM_GCC_path}/bin:${config:xPack_GCC_path}/bin:${env:PATH}", + "MAXIM_PATH":"${config:MAXIM_PATH}" + }, + "terminal.integrated.env.osx": { + "PATH":"${config:OCD_path}/bin:${config:ARM_GCC_path}/bin:${config:xPack_GCC_path}/bin:${env:PATH}", + "MAXIM_PATH":"${config:MAXIM_PATH}" + }, + + "target":"MAX32665", + "board":"EvKit_V1", + + "project_name":"${workspaceFolderBasename}", + + "program_file":"${config:project_name}.elf", + "symbol_file":"${config:program_file}", + + "M4_OCD_interface_file":"cmsis-dap.cfg", + "M4_OCD_target_file":"max32665.cfg", + "RV_OCD_interface_file":"ftdi/olimex-arm-usb-ocd-h.cfg", + "RV_OCD_target_file":"${config:target}_riscv.cfg", + + "v_Arm_GCC":"10.3", + "v_xPack_GCC":"12.2.0-3.1", + + "OCD_path":"${config:MAXIM_PATH}/Tools/OpenOCD", + "ARM_GCC_path":"${config:MAXIM_PATH}/Tools/GNUTools/${config:v_Arm_GCC}", + "xPack_GCC_path":"${config:MAXIM_PATH}/Tools/xPack/riscv-none-elf-gcc/${config:v_xPack_GCC}", + "Make_path":"${config:MAXIM_PATH}/Tools/GNUTools/Make", + "MSYS_path":"${config:MAXIM_PATH}/Tools/MSYS2", + + "C_Cpp.default.includePath": [ + "${workspaceFolder}", + "${workspaceFolder}/**", + "${config:MAXIM_PATH}/Libraries/Boards/${config:target}/Include", + "${config:MAXIM_PATH}/Libraries/Boards/${config:target}/${config:board}/Include", + "${config:MAXIM_PATH}/Libraries/CMSIS/Device/Maxim/${config:target}/Include", + "${config:MAXIM_PATH}/Libraries/CMSIS/Include", + "${config:ARM_GCC_path}/arm-none-eabi/include", + "${config:ARM_GCC_path}/lib/gcc/arm-none-eabi/${config:v_Arm_GCC}/include", + "${config:MAXIM_PATH}/Libraries/PeriphDrivers/Include/${config:target}", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Camera", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Display", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/ExtMemory", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/LED", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/PMIC", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/PushButton", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Touchscreen", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/sources/stack/cfg", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-apps/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-model/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-profile/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-profiles/include", + "${config:MAXIM_PATH}/Libraries/Cordio/controller/include/ble", + "${config:MAXIM_PATH}/Libraries/Cordio/controller/include/common", + "${config:MAXIM_PATH}/Libraries/Cordio/platform/include", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/sources/hci/dual_chip", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/sources/hci/exactle", + "${config:MAXIM_PATH}/Libraries/Cordio/wsf/include", + "${config:MAXIM_PATH}/Libraries/Cordio/wsf/include/util" + ], + "C_Cpp.default.browse.path": [ + "${workspaceFolder}", + "${config:MAXIM_PATH}/Libraries/Boards/${config:target}/Source", + "${config:MAXIM_PATH}/Libraries/Boards/${config:target}/${config:board}/Source", + "${config:MAXIM_PATH}/Libraries/PeriphDrivers/Source", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Camera", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Display", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/LED", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/PMIC", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/PushButton", + "${config:MAXIM_PATH}/Libraries/MiscDrivers/Touchscreen", + "${config:MAXIM_PATH}/Libraries/MiscDrivers", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-apps/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-host/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-apps/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-model/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-mesh-profile/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/ble-profiles/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/controller/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/wsf/sources", + "${config:MAXIM_PATH}/Libraries/Cordio/platform/targets/maxim/max32665/sources" + ], + "C_Cpp.default.defines": [ + + ], + "C_Cpp.default.forcedInclude": [ + "${workspaceFolder}/build/project_defines.h" + ] +} + diff --git a/Examples/MAX32665/BLE_LR_Central/.vscode/tasks.json b/Examples/MAX32665/BLE_LR_Central/.vscode/tasks.json new file mode 100755 index 0000000000..e95445e2b3 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/.vscode/tasks.json @@ -0,0 +1,115 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "make -r -j 8 --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}", + "osx":{ + "command": "source ~/.zshrc && make -r -j 8 --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}" + }, + "group": "build", + "problemMatcher": [] + }, + { + "label": "clean", + "type": "shell", + "command": "make -j 8 clean --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}", + "osx":{ + "command": "source ~/.zshrc && make -j 8 clean --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}" + }, + "group": "build", + "problemMatcher": [] + }, + { + "label": "clean-periph", + "type": "shell", + "command": "make -j 8 distclean --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}", + "osx":{ + "command": "source ~/.zshrc && make -j 8 distclean --output-sync=target --no-print-directory TARGET=${config:target} BOARD=${config:board} MAXIM_PATH=${config:MAXIM_PATH} MAKE=make PROJECT=${config:project_name}" + }, + "group": "build", + "problemMatcher": [] + }, + { + "label": "flash", + "type": "shell", + "command": "arm-none-eabi-gdb", + "args": [ + "--cd=\"${workspaceFolder}\"", + "--se=\"build/${config:program_file}\"", + "--symbols=build/${config:symbol_file}", + "-x=\"${workspaceFolder}/.vscode/flash.gdb\"", + "--ex=\"flash_m4 ${config:OCD_path} ${config:M4_OCD_interface_file} ${config:M4_OCD_target_file}\"", + "--batch" + ], + "group": "build", + "problemMatcher": [], + "dependsOn":["build"] + }, + { + "label": "flash & run", + "type": "shell", + "command": "arm-none-eabi-gdb", + "args": [ + "--cd=\"${workspaceFolder}\"", + "--se=\"build/${config:program_file}\"", + "--symbols=build/${config:symbol_file}", + "-x=\"${workspaceFolder}/.vscode/flash.gdb\"", + "--ex=\"flash_m4_run ${config:OCD_path} ${config:M4_OCD_interface_file} ${config:M4_OCD_target_file}\"", + "--batch" + ], + "group": "build", + "problemMatcher": [], + "dependsOn":["build"] + }, + { + "label": "erase flash", + "type": "shell", + "command": "openocd", + "args": [ + "-s", "${config:OCD_path}/scripts", + "-f", "interface/${config:M4_OCD_interface_file}", + "-f", "target/${config:M4_OCD_target_file}", + "-c", "\"init; reset halt; max32xxx mass_erase 0;\"", + "-c", "exit" + ], + "group":"build", + "problemMatcher": [], + "dependsOn":[] + }, + { + "label": "openocd (m4)", + "type": "shell", + "command": "openocd", + "args": [ + "-s", + "${config:OCD_path}/scripts", + "-f", + "interface/${config:M4_OCD_interface_file}", + "-f", + "target/${config:M4_OCD_target_file}", + "-c", + "\"init; reset halt\"" + ], + "problemMatcher": [], + "dependsOn":[] + }, + { + "label": "gdb (m4)", + "type": "shell", + "command": "arm-none-eabi-gdb", + "args": [ + "--ex=\"cd ${workspaceFolder}\"", + "--se=\"build/${config:program_file}\"", + "--symbols=build/${config:symbol_file}", + "--ex=\"target remote localhost:3333\"", + "--ex=\"monitor reset halt\"", + "--ex=\"b main\"", + "--ex=\"c\"" + ], + "problemMatcher": [], + "dependsOn":[] + }, + ] +} \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Central/BLE_LR_Central.launch b/Examples/MAX32665/BLE_LR_Central/BLE_LR_Central.launch new file mode 100644 index 0000000000..57af3ee122 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/BLE_LR_Central.launch @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/MAX32665/BLE_LR_Central/Makefile b/Examples/MAX32665/BLE_LR_Central/Makefile new file mode 100644 index 0000000000..ba87cf6982 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/Makefile @@ -0,0 +1,395 @@ +################################################################################ + # Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + # + # Permission is hereby granted, free of charge, to any person obtaining a + # copy of this software and associated documentation files (the "Software"), + # to deal in the Software without restriction, including without limitation + # the rights to use, copy, modify, merge, publish, distribute, sublicense, + # and/or sell copies of the Software, and to permit persons to whom the + # Software is furnished to do so, subject to the following conditions: + # + # The above copyright notice and this permission notice shall be included + # in all copies or substantial portions of the Software. + # + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + # IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + # OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + # OTHER DEALINGS IN THE SOFTWARE. + # + # Except as contained in this notice, the name of Maxim Integrated + # Products, Inc. shall not be used except as stated in the Maxim Integrated + # Products, Inc. Branding Policy. + # + # The mere transfer of this software does not imply any licenses + # of trade secrets, proprietary technology, copyrights, patents, + # trademarks, maskwork rights, or any other form of intellectual + # property whatsoever. Maxim Integrated Products, Inc. retains all + # ownership rights. + # +############################################################################### + +# ** Readme! ** +# Don't edit this file! This is the core Makefile for a MaximSDK +# project. The available configuration options can be overridden +# in "project.mk", on the command-line, or with system environment +# variables. + +# See https://analog-devices-msdk.github.io/msdk/USERGUIDE/#build-system +# for more detailed instructions on how to use this system. + +# The detailed instructions mentioned above are easier to read than +# this file, but the comments found in this file also outline the +# available configuration variables. This file is organized into +# sub-sections, some of which expose config variables. + + +# ******************************************************************************* +# Set the target microcontroller and board to compile for. + +# Every TARGET microcontroller has some Board Support Packages (BSPs) that are +# available for it under the MaximSDK/Libraries/Boards/TARGET folder. The BSP +# that gets selected is MaximSDK/Libraries/Boards/TARGET/BOARD. + +# Configuration Variables: +# - TARGET : Override the default target microcontroller. Ex: TARGET=MAX78000 +# - BOARD : Override the default BSP (case sensitive). Ex: BOARD=EvKit_V1, BOARD=FTHR_RevA + + +ifeq "$(TARGET)" "" +# Default target microcontroller +TARGET := MAX32665 +TARGET_UC := MAX32665 +TARGET_LC := max32665 +else +# "TARGET" has been overridden in the environment or on the command-line. +# We need to calculate an upper and lowercase version of the part number, +# because paths on Linux and MacOS are case-sensitive. +TARGET_UC := $(subst m,M,$(subst a,A,$(subst x,X,$(TARGET)))) +TARGET_LC := $(subst M,m,$(subst A,a,$(subst X,x,$(TARGET)))) +endif + +# Default board. +BOARD ?= EvKit_V1 + +# ******************************************************************************* +# Locate the MaximSDK + +# This Makefile needs to know where to find the MaximSDK, and the MAXIM_PATH variable +# should point to the root directory of the MaximSDK installation. Setting this manually +# is usually only required if you're working on the command-line. + +# If MAXIM_PATH is not specified, we assume the project still lives inside of the MaximSDK +# and move up from this project's original location. + +# Configuration Variables: +# - MAXIM_PATH : Tell this Makefile where to find the MaximSDK. Ex: MAXIM_PATH=C:/MaximSDK + + +ifneq "$(MAXIM_PATH)" "" +# Sanitize MAXIM_PATH for backslashes +MAXIM_PATH := $(subst \,/,$(MAXIM_PATH)) +# Locate some other useful paths... +LIBS_DIR := $(abspath $(MAXIM_PATH)/Libraries) +CMSIS_ROOT := $(LIBS_DIR)/CMSIS +endif + +# ******************************************************************************* +# Include project Makefile. We do this after formulating TARGET, BOARD, and MAXIM_PATH +# in case project.mk needs to reference those values. However, we also include +# this as early as possible in the Makefile so that it can append to or override +# the variables below. + + +PROJECTMK ?= $(abspath ./project.mk) +include $(PROJECTMK) +$(info Loaded project.mk) +# PROJECTMK is also used by implicit rules and other libraries to add project.mk as a watch file + +# ******************************************************************************* +# Final path sanitization and re-calculation. No options here. + +ifeq "$(MAXIM_PATH)" "" +# MAXIM_PATH is still not defined... +DEPTH := ../../../ +MAXIM_PATH := $(abspath $(DEPTH)) +$(warning Warning: MAXIM_PATH is not set! Set MAXIM_PATH in your environment or in project.mk to clear this warning.) +$(warning Warning: Attempting to use $(MAXIM_PATH) calculated from relative path) +else +# Sanitize MAXIM_PATH for backslashes +MAXIM_PATH := $(subst \,/,$(MAXIM_PATH)) +endif + +# Final recalculation of LIBS_DIR/CMSIS_ROOT +LIBS_DIR := $(abspath $(MAXIM_PATH)/Libraries) +CMSIS_ROOT := $(LIBS_DIR)/CMSIS + +# One final UC/LC check in case user set TARGET in project.mk +TARGET_UC := $(subst m,M,$(subst a,A,$(subst x,X,$(TARGET)))) +TARGET_LC := $(subst M,m,$(subst A,a,$(subst X,x,$(TARGET)))) + +export TARGET +export TARGET_UC +export TARGET_LC +export CMSIS_ROOT +# TODO: Remove dependency on exports for these variables. + +# ******************************************************************************* +# Set up search paths, and auto-detect all source code on those paths. + +# The following paths are searched by default, where "./" is the project directory. +# ./ +# |- *.h +# |- *.c +# |-include (optional) +# |- *.h +# |-src (optional) +# |- *.c + +# Configuration Variables: +# - VPATH : Tell this Makefile to search additional locations for source (.c) files. +# You should use the "+=" operator with this option. +# Ex: VPATH += your/new/path +# - IPATH : Tell this Makefile to search additional locations for header (.h) files. +# You should use the "+=" operator with this option. +# Ex: VPATH += your/new/path +# - SRCS : Tell this Makefile to explicitly add a source (.c) file to the build. +# This is really only useful if you want to add a source file that isn't +# on any VPATH, in which case you can add the full path to the file here. +# You should use the "+=" operator with this option. +# Ex: SRCS += your/specific/source/file.c +# - AUTOSEARCH : Set whether this Makefile should automatically detect .c files on +# VPATH and add them to the build. This is enabled by default. Set +# to 0 to disable. If autosearch is disabled, source files must be +# manually added to SRCS. +# Ex: AUTOSEARCH = 0 + + +# Where to find source files for this project. +VPATH += . +VPATH += src +VPATH := $(VPATH) + +# Where to find header files for this project +IPATH += . +IPATH += include +IPATH := $(IPATH) + +AUTOSEARCH ?= 1 +ifeq ($(AUTOSEARCH), 1) +# Auto-detect all C/C++ source files on VPATH +SRCS += $(wildcard $(addsuffix /*.c, $(VPATH))) +SRCS += $(wildcard $(addsuffix /*.cpp, $(VPATH))) +endif + +# Collapse SRCS before passing them on to the next stage +SRCS := $(SRCS) + +# ******************************************************************************* +# Set the output filename + +# Configuration Variables: +# - PROJECT : Override the default output filename. Ex: PROJECT=MyProject + + +# The default value creates a file named after the target micro. Ex: MAX78000.elf +PROJECT ?= $(TARGET_LC) + +# ******************************************************************************* +# Compiler options + +# Configuration Variables: +# - DEBUG : Set DEBUG=1 to build explicitly for debugging. This adds some additional +# symbols and sets -Og as the default optimization level. +# - MXC_OPTIMIZE_CFLAGS : Override the default compiler optimization level. +# Ex: MXC_OPTIMIZE_CFLAGS = -O2 +# - PROJ_CFLAGS : Add additional compiler flags to the build. +# You should use the "+=" operator with this option. +# Ex: PROJ_CFLAGS += -Wextra +# - MFLOAT_ABI : Set the floating point acceleration level. +# The only options are "hard", "soft", or "softfp". +# Ex: MFLOAT_ABI = hard +# - LINKERFILE : Override the default linkerfile. +# Ex: LINKERFILE = customlinkerfile.ld +# - LINKERPATH : Override the default search location for $(LINKERFILE) +# The default search location is $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/GCC +# If $(LINKERFILE) cannot be found at this path, then the root project +# directory will be used as a fallback. + +# Select 'GCC' or 'IAR' compiler +ifeq "$(COMPILER)" "" +COMPILER := GCC +endif + +# Set default compiler optimization levels +ifeq "$(MAKECMDGOALS)" "release" +# Default optimization level for "release" builds (make release) +MXC_OPTIMIZE_CFLAGS ?= -O2 +DEBUG = 0 +endif + +ifeq ($(DEBUG),1) +# Optimizes for debugging as recommended +# by GNU for code-edit-debug cycles +# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options +MXC_OPTIMIZE_CFLAGS := -Og +endif + +# Default level if not building for release or explicitly for debug +MXC_OPTIMIZE_CFLAGS ?= -Og + +# Set compiler flags +PROJ_CFLAGS += -Wall # Enable warnings +PROJ_CFLAGS += -DMXC_ASSERT_ENABLE + +# Set hardware floating point acceleration. +# Options are: +# - hard +# - soft +# - softfp (default if MFLOAT_ABI is not set) +MFLOAT_ABI ?= softfp +# MFLOAT_ABI must be exported to other Makefiles +export MFLOAT_ABI + +# This path contains system-level intialization files for the target micro. Add to the build. +VPATH += $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source + +# ******************************************************************************* +# Secure Boot Tools (SBT) + +# This section integrates the Secure Boot Tools. It's intended for use with +# microcontrollers that have a secure bootloader. + +# Enabling SBT integration will add some special rules, such as "make sla", "make scpa", etc. + +# Configuration variables: +# SBT : Toggle SBT integration. Set to 1 to enable, or 0 +# to disable +# MAXIM_SBT_DIR : Specify the location of the SBT tool binaries. This defaults to +# Tools/SBT in the MaximSDK. The standalone SBT installer will override +# this via an environment variable. +# TARGET_SEC : Specify the part number to be passed into the SBT. This should match +# the secure variant part #. The default value will depend on TARGET. +# For example, TARGET=MAX32650 will result in TARGET_SEC=MAX32651, and +# the default selection happens in Tools/SBT/SBT-config. +# However, if there are multiple secure part #s for the target +# microcontroller this variable may need to be changed. + +SBT ?= 0 +ifeq ($(SBT), 1) +MAXIM_SBT_DIR ?= $(MAXIM_PATH)/Tools/SBT +MAXIM_SBT_DIR := $(subst \,/,$(MAXIM_SBT_DIR)) +# ^ Must sanitize path for \ on Windows, since this may come from an environment +# variable. + +export MAXIM_SBT_DIR # SBTs must have this environment variable defined to work + +# SBT-config.mk and SBT-rules.mk are included further down this Makefile. + +endif # SBT + +# ******************************************************************************* +# Default goal selection. This section allows you to override the default goal +# that will run if no targets are specified on the command-line. +# (ie. just running 'make' instead of 'make all') + +# Configuration variables: +# .DEFAULT_GOAL : Set the default goal if no targets were specified on the +# command-line +# ** "override" must be used with this variable. ** +# Ex: "override .DEFAULT_GOAL = mygoal" + +ifeq "$(.DEFAULT_GOAL)" "" +ifeq ($(SBT),1) +override .DEFAULT_GOAL := sla +else +override .DEFAULT_GOAL := all +endif +endif + +# Developer note: 'override' is used above for legacy Makefile compatibility. +# gcc.mk/gcc_riscv.mk need to hard-set 'all' internally, so this new system +# uses 'override' to come in over the top without breaking old projects. + +# It's also necessary to explicitly set MAKECMDGOALS... +ifeq "$(MAKECMDGOALS)" "" +MAKECMDGOALS:=$(.DEFAULT_GOAL) +endif + +# Enable colors when --sync-output is used. +# See https://www.gnu.org/software/make/manual/make.html#Terminal-Output (section 13.2) +ifneq ($(MAKE_TERMOUT),) +PROJ_CFLAGS += -fdiagnostics-color=always +endif + +ifneq ($(FORCE_COLOR),) +PROJ_CFLAGS += -fdiagnostics-color=always +endif + +# ******************************************************************************* +# Include SBT config. We need to do this here because it needs to know +# the current MAKECMDGOAL. +ifeq ($(SBT),1) +include $(MAXIM_PATH)/Tools/SBT/SBT-config.mk +endif + +# ******************************************************************************* +# Libraries + +# This section offers "toggle switches" to include or exclude the libraries that +# are available in the MaximSDK. Set a configuration variable to 1 to include the +# library in the build, or 0 to exclude. + +# Each library may also have its own library specific configuration variables. See +# Libraries/libs.mk for more details. + +# Configuration variables: +# - LIB_BOARD : Include the Board-Support Package (BSP) library. (Enabled by default) +# - LIB_PERIPHDRIVERS : Include the peripheral driver library. (Enabled by default) +# - LIB_CMSIS_DSP : Include the CMSIS-DSP library. +# - LIB_CORDIO : Include the Cordio BLE library +# - LIB_FCL : Include the Free Cryptographic Library (FCL) +# - LIB_FREERTOS : Include the FreeRTOS and FreeRTOS-Plus-CLI libraries +# - LIB_LC3 : Include the Low Complexity Communication Codec (LC3) library +# - LIB_LITTLEFS : Include the "little file system" (littleFS) library +# - LIB_LWIP : Include the lwIP library +# - LIB_MAXUSB : Include the MAXUSB library +# - LIB_SDHC : Include the SDHC library + +include $(LIBS_DIR)/libs.mk + + +# ******************************************************************************* +# Rules + +# Include the rules for building for this target. All other makefiles should be +# included before this one. +include $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/$(COMPILER)/$(TARGET_LC).mk + +# Include the rules that integrate the SBTs. SBTs are a special case that must be +# include after the core gcc rules to extend them. +ifeq ($(SBT), 1) +include $(MAXIM_PATH)/Tools/SBT/SBT-rules.mk +endif + + +# Get .DEFAULT_GOAL working. +ifeq "$(MAKECMDGOALS)" "" +MAKECMDGOALS:=$(.DEFAULT_GOAL) +endif + + +all: +# Extend the functionality of the "all" recipe here + arm-none-eabi-size --format=berkeley $(BUILD_DIR)/$(PROJECT).elf + +libclean: + $(MAKE) -f ${PERIPH_DRIVER_DIR}/periphdriver.mk clean.periph + +clean: +# Extend the functionality of the "clean" recipe here + +# The rule to clean out all the build products. +distclean: clean libclean diff --git a/Examples/MAX32665/BLE_LR_Central/README.md b/Examples/MAX32665/BLE_LR_Central/README.md new file mode 100644 index 0000000000..ccc31cc92d --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/README.md @@ -0,0 +1,70 @@ +# BLE_LR_Central + +This project is a demo for long range scanning. The coded PHY (s=8) is used. It works with the BLE_LR_Peripheral project. + +The project is modified from the BLE_datc. + +## Software + +### Project Usage + +Universal instructions on building, flashing, and debugging this project can be found in the **[MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/)**. + +### Required Connections +* Connect a USB cable between the PC and the (USB/PWR - UART) connector. + +### Project-Specific Build Notes +* Setting `TRACE=1` in [**project.mk**](project.mk) initializes the on-board USB-to-UART adapter for +viewing the trace messages and interacting with the application. Port uses settings: + - Baud : 115200 + - Char size : 8 + - Parity : None + - Stop bits : 1 + - HW Flow Control : No + - SW Flow Control : No +* Upon server discovery the user will be prompted to enter a passkey. +An arbitrary pin can be entered in the format `pin (connId) passkey` + * Example: `pin 1 123456` + * The server is expected to enter the same connId and passkey to establish a secure connection + and share bonding information + * ***Note***: *Either the client or server can enter the passkey first. The peer device must then match.* + +### Logs +terminal: init␍␊ +==========================================␍␊ +Long distance scanner demo (CODED PHY S=8)␍␊ +BT_VER=9␍␊ +==========================================␍␊ +DatcHandlerInit␍␊ +MAC Addr: 00:18:80:00:44:B1␍␊ +>>> Reset complete <<<␍␊ +Database hash updated␍␊ +dmDevPassEvtToDevPriv: event: 12, param: 74, advHandle: 0␍␊ +␍␊ +00:18:80:00:a2:22 BF 02 03 ... 30 31 BF␍␊ +00:18:80:00:a2:22 C0 02 03 ... 30 31 C0␍␊ +00:18:80:00:a2:22 C1 02 03 ... 30 31 C1␍␊ +00:18:80:00:a2:22 C2 02 03 ... 30 31 C2␍␊ +00:18:80:00:a2:22 C3 02 03 ... 30 31 C3␍␊ +00:18:80:00:a2:22 C4 02 03 ... 30 31 C4␍␊ +00:18:80:00:a2:22 C5 02 03 ... 30 31 C5␍␊ +00:18:80:00:a2:22 C6 02 03 ... 30 31 C6␍␊ +00:18:80:00:a2:22 C7 02 03 ... 30 31 C7␍␊ +00:18:80:00:a2:22 C8 02 03 ... 30 31 C8␍␊ +00:18:80:00:a2:22 C9 02 03 ... 30 31 C9␍␊ +00:18:80:00:a2:22 CA 02 03 ... 30 31 CA␍␊ +00:18:80:00:a2:22 CB 02 03 ... 30 31 CB␍␊ +00:18:80:00:a2:22 CC 02 03 ... 30 31 CC␍␊ +00:18:80:00:a2:22 CD 02 03 ... 30 31 CD␍␊ +00:18:80:00:a2:22 CE 02 03 ... 30 31 CE␍␊ +00:18:80:00:a2:22 CF 02 03 ... 30 31 CF␍␊ +00:18:80:00:a2:22 D0 02 03 ... 30 31 D0␍␊ +00:18:80:00:a2:22 D1 02 03 ... 30 31 D1␍␊ +00:18:80:00:a2:22 D2 02 03 ... 30 31 D2␍␊ +00:18:80:00:a2:22 D3 02 03 ... 30 31 D3␍␊ +00:18:80:00:a2:22 D4 02 03 ... 30 31 D4␍␊ +00:18:80:00:a2:22 D5 02 03 ... 30 31 D5␍␊ +00:18:80:00:a2:22 D6 02 03 ... 30 31 D6␍␊ +00:18:80:00:a2:22 D7 02 03 ... 30 31 D7␍␊ +00:18:80:00:a2:22 D8 02 03 ... 30 31 D8␍␊ +00:18:80:00:a2:22 D9 02 03 ... 30 31 D9␍␊ \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Central/datc_api.h b/Examples/MAX32665/BLE_LR_Central/datc_api.h new file mode 100644 index 0000000000..cb4ee48c32 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/datc_api.h @@ -0,0 +1,72 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Proprietary data transfer client sample application. + * + * Copyright (c) 2012-2018 Arm Ltd. All Rights Reserved. + * + * Copyright (c) 2019 Packetcraft, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*************************************************************************************************/ +#ifndef EXAMPLES_MAX32665_BLE_LR_CENTRAL_API_H_ +#define EXAMPLES_MAX32665_BLE_LR_CENTRAL_API_H_ + +#include "wsf_os.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************************************** + Function Declarations +**************************************************************************************************/ +/*************************************************************************************************/ +/*! + * \brief Start the application. + * + * \return None. + */ +/*************************************************************************************************/ +void DatcStart(void); + +/*************************************************************************************************/ +/*! + * \brief Application handler init function called during system initialization. + * + * \param handlerID WSF handler ID for App. + * + * \return None. + */ +/*************************************************************************************************/ +void DatcHandlerInit(wsfHandlerId_t handlerId); + +/*************************************************************************************************/ +/*! + * \brief WSF event handler for the application. + * + * \param event WSF event mask. + * \param pMsg WSF message. + * + * \return None. + */ +/*************************************************************************************************/ +void DatcHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); + +#ifdef __cplusplus +}; +#endif + +#endif // EXAMPLES_MAX32665_BLE_LR_CENTRAL_API_H_ diff --git a/Examples/MAX32665/BLE_LR_Central/datc_main.c b/Examples/MAX32665/BLE_LR_Central/datc_main.c new file mode 100644 index 0000000000..c011c4c9da --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/datc_main.c @@ -0,0 +1,1425 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Proprietary data transfer client sample application for Nordic-ble. + * + * Copyright (c) 2012-2019 Arm Ltd. All Rights Reserved. + * + * Copyright (c) 2019-2020 Packetcraft, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*************************************************************************************************/ + +#include +#include +#include "wsf_types.h" +#include "util/bstream.h" +#include "wsf_msg.h" +#include "wsf_trace.h" +#include "wsf_assert.h" +#include "wsf_buf.h" +#include "wsf_nvm.h" +#include "hci_api.h" +#include "led.h" +#include "dm_api.h" +#include "dm_priv.h" +#include "gap/gap_api.h" +#include "att_api.h" +#include "smp_api.h" +#include "app_cfg.h" +#include "app_api.h" +#include "app_db.h" +#include "app_ui.h" +#include "svc_core.h" +#include "svc_ch.h" +#include "gatt/gatt_api.h" +#include "wpc/wpc_api.h" +#include "datc_api.h" +#include "util/calc128.h" +#include "pal_btn.h" +#include "pal_led.h" +#include "pal_uart.h" +#include "tmr.h" +#include "sdsc_api.h" +#include "dm_scan.h" + +/************************************************************************************************** +Macros +**************************************************************************************************/ +#if (BT_VER > 8) +/* PHY Test Modes */ +#define DATC_PHY_1M 1 +#define DATC_PHY_2M 2 +#define DATC_PHY_CODED 3 +#endif /* BT_VER */ + +#define SPEED_TEST_COUNT 5000 + +/* Max value is 238 */ +#define SPEED_TEST_PACKET_LEN 238 +#define SPEED_TEST_TMR MXC_TMR3 + +#define SCAN_START_EVT 0x99 +#define USER_APP_TMR_EVT 0x9A + +#define SCAN_START_MS 500 +#define USER_APP_TMR_MS 5000 + +/* Down sample the number of scan reports we print */ +#define SCAN_REPORT_DOWN_SAMPLE 20 + +/*! Button press handling constants */ +#define BTN_SHORT_MS 200 +#define BTN_MED_MS 500 +#define BTN_LONG_MS 1000 + +#define BTN_1_TMR MXC_TMR2 +#define BTN_2_TMR MXC_TMR2 + +/************************************************************************************************** + Local Variables +**************************************************************************************************/ +wsfTimer_t userAppTmr; + +/*! application control block */ +struct { + uint16_t hdlList[DM_CONN_MAX][APP_DB_HDL_LIST_LEN]; /*! Cached handle list */ + wsfHandlerId_t handlerId; /*! WSF hander ID */ + bool_t scanning; /*! TRUE if scanning */ + bool_t autoConnect; /*! TRUE if auto-connecting */ + uint8_t discState[DM_CONN_MAX]; /*! Service discovery state */ + uint8_t hdlListLen; /*! Cached handle list length */ + uint8_t btnConnId; /*! The index of the connection ID for button presses */ +#if (BT_VER > 8) + uint8_t phyMode[DM_CONN_MAX]; /*! PHY Test Mode */ +#endif /* BT_VER */ + appDbHdl_t resListRestoreHdl; /*! Resolving List restoration handle */ + bool_t restoringResList; /*! Restoring resolving list from NVM */ + unsigned speedTestCounter; + wsfTimer_t scanTimer; /* Timer for starting the scanner */ +} datcCb; + +/*! connection control block */ +typedef struct { + appDbHdl_t dbHdl; /*! Device database record handle type */ + uint8_t addrType; /*! Type of address of device to connect to */ + bdAddr_t addr; /*! Address of device to connect to */ + bool_t doConnect; /*! TRUE to issue connect on scan complete */ +} datcConnInfo_t; + +datcConnInfo_t datcConnInfo; + +/************************************************************************************************** + Configurable Parameters +**************************************************************************************************/ + +/*! configurable parameters for master */ +static const appMasterCfg_t datcMasterCfg = { + 64, /*! The scan interval, in 0.625 ms units */ + 64, /*! The scan window, in 0.625 ms units */ + 0, /*! The scan duration in ms */ + DM_DISC_MODE_NONE, /*! The GAP discovery mode */ + DM_SCAN_TYPE_ACTIVE /*! The scan type (active or passive) */ +}; + +/*! Configurable security parameters to set +* pairing and authentication requirements. +* +* Authentication and bonding flags +* -DM_AUTH_BOND_FLAG : Bonding requested +* -DM_AUTH_KP_FLAG : Keypress notifications requested +* -DM_AUTH_MITM_FLAG : MITM (authenticated pairing) requested, + pairing method is determined by IO capabilities below +* -DM_AUTH_SC_FLAG : LE Secure Connections requested +* +* Initiator key distribution flags +* -DM_KEY_DIST_LTK : Distribute LTK used for encryption +* -DM_KEY_DIST_IRK : Distribute IRK used for privacy +* -DM_KEY_DIST_CSRK : Distribute CSRK used for signed data +*/ +static const appSecCfg_t datcSecCfg = { + DM_AUTH_BOND_FLAG | DM_AUTH_SC_FLAG, /*! Authentication and bonding flags */ + DM_KEY_DIST_IRK, /*! Initiator key distribution flags */ + DM_KEY_DIST_LTK | DM_KEY_DIST_IRK, /*! Responder key distribution flags */ + FALSE, /*! TRUE if Out-of-band pairing data is present */ + TRUE /*! TRUE to initiate security upon connection */ +}; + +/* OOB UART parameters */ +#define OOB_BAUD 115200 +#define OOB_FLOW FALSE + +/*! TRUE if Out-of-band pairing data is to be sent */ +static const bool_t datcSendOobData = FALSE; + +/* OOB Connection identifier */ +dmConnId_t oobConnId; + +/*! SMP security parameter configuration +* +* I/O Capability Codes to be set for +* Pairing Request (SMP_CMD_PAIR_REQ) packets and Pairing Response (SMP_CMD_PAIR_RSP) packets +* when the MITM flag is set in Configurable security parameters above. +* -SMP_IO_DISP_ONLY : Display only. +* -SMP_IO_DISP_YES_NO : Display yes/no. +* -SMP_IO_KEY_ONLY : Keyboard only. +* -SMP_IO_NO_IN_NO_OUT : No input, no output. +* -SMP_IO_KEY_DISP : Keyboard display. +*/ +static const smpCfg_t datcSmpCfg = { + 500, /*! 'Repeated attempts' timeout in msec */ + SMP_IO_KEY_ONLY, /*! I/O Capability */ + 7, /*! Minimum encryption key length */ + 16, /*! Maximum encryption key length */ + 1, /*! Attempts to trigger 'repeated attempts' timeout */ + 0, /*! Device authentication requirements */ + 64000, /*! Maximum repeated attempts timeout in msec */ + 64000, /*! Time msec before attemptExp decreases */ + 2 /*! Repeated attempts multiplier exponent */ +}; + +/*! Connection parameters */ +static const hciConnSpec_t datcConnCfg = { + 6, /*! Minimum connection interval in 1.25ms units */ + 6, /*! Maximum connection interval in 1.25ms units */ + 0, /*! Connection latency */ + 600, /*! Supervision timeout in 10ms units */ + 0, /*! Unused */ + 0 /*! Unused */ +}; + +/*! Configurable parameters for service and characteristic discovery */ +static const appDiscCfg_t datcDiscCfg = { + FALSE, /*! TRUE to wait for a secure connection before initiating discovery */ + TRUE /*! TRUE to fall back on database hash to verify handles when no bond exists. */ +}; + +static const appCfg_t datcAppCfg = { + FALSE, /*! TRUE to abort service discovery if service not found */ + TRUE /*! TRUE to disconnect if ATT transaction times out */ +}; + +/*! ATT configurable parameters (increase MTU) */ +static const attCfg_t datcAttCfg = { + 15, /* ATT server service discovery connection idle timeout in seconds */ + 241, /* desired ATT MTU */ + ATT_MAX_TRANS_TIMEOUT, /* transcation timeout in seconds */ + 4 /* number of queued prepare writes supported by server */ +}; + +/*! local IRK */ +static uint8_t localIrk[] = { 0xA6, 0xD9, 0xFF, 0x70, 0xD6, 0x1E, 0xF0, 0xA4, + 0x46, 0x5F, 0x8D, 0x68, 0x19, 0xF3, 0xB4, 0x96 }; + +/************************************************************************************************** + ATT Client Discovery Data +**************************************************************************************************/ + +/*! Discovery states: enumeration of services to be discovered */ +enum { + DATC_DISC_GATT_SVC, /*! GATT service */ + DATC_DISC_GAP_SVC, /*! GAP service */ + DATC_DISC_WP_SVC, /*! Arm Ltd. proprietary service */ + DATC_DISC_SDS_SVC, /*! Secured Data Service */ + DATC_DISC_SVC_MAX /*! Discovery complete */ +}; + +/*! the Client handle list, datcCb.hdlList[], is set as follows: + * + * ------------------------------- <- DATC_DISC_GATT_START + * | GATT svc changed handle | + * ------------------------------- + * | GATT svc changed ccc handle | + * ------------------------------- <- DATC_DISC_GAP_START + * | GAP central addr res handle | + * ------------------------------- + * | GAP RPA Only handle | + * ------------------------------- <- DATC_DISC_WP_START + * | WP handles | + * | ... | + * ------------------------------- + */ + +/*! Start of each service's handles in the the handle list */ +#define DATC_DISC_GATT_START 0 +#define DATC_DISC_GAP_START (DATC_DISC_GATT_START + GATT_HDL_LIST_LEN) +#define DATC_DISC_WP_START (DATC_DISC_GAP_START + GAP_HDL_LIST_LEN) +#define DATC_DISC_SDS_START (DATC_DISC_WP_START + WPC_P1_HDL_LIST_LEN) +#define DATC_DISC_HDL_LIST_LEN (DATC_DISC_SDS_START + SEC_HDL_LIST_LEN) + +/*! Pointers into handle list for each service's handles */ +static uint16_t *pDatcGattHdlList[DM_CONN_MAX]; +static uint16_t *pDatcGapHdlList[DM_CONN_MAX]; +static uint16_t *pDatcWpHdlList[DM_CONN_MAX]; +static uint16_t *pSecDatHdlList[DM_CONN_MAX]; + +/* LESC OOB configuration */ +static dmSecLescOobCfg_t *datcOobCfg; + +/************************************************************************************************** + ATT Client Configuration Data +**************************************************************************************************/ + +/* + * Data for configuration after service discovery + */ + +/* Default value for CCC indications */ +const uint8_t datcCccIndVal[2] = { UINT16_TO_BYTES(ATT_CLIENT_CFG_INDICATE) }; + +/* Default value for CCC notifications */ +const uint8_t datcCccNtfVal[2] = { UINT16_TO_BYTES(ATT_CLIENT_CFG_NOTIFY) }; + +/* Default value for Client Supported Features (enable Robust Caching) */ +const uint8_t datcCsfVal[1] = { ATTS_CSF_ROBUST_CACHING }; + +/* List of characteristics to configure after service discovery */ +static const attcDiscCfg_t datcDiscCfgList[] = { + /* Write: GATT service changed ccc descriptor */ + { datcCccIndVal, sizeof(datcCccIndVal), (GATT_SC_CCC_HDL_IDX + DATC_DISC_GATT_START) }, + + /* Write: GATT client supported features */ + { datcCsfVal, sizeof(datcCsfVal), (GATT_CSF_HDL_IDX + DATC_DISC_GATT_START) }, + + /* Write: Proprietary data service changed ccc descriptor */ + { datcCccNtfVal, sizeof(datcCccNtfVal), (WPC_P1_NA_CCC_HDL_IDX + DATC_DISC_WP_START) }, + + /* Write: Secured data service changed ccc descriptor */ + { datcCccNtfVal, sizeof(datcCccNtfVal), (SEC_DAT_CCC_HDL_IDX + DATC_DISC_SDS_START) }, +}; + +/* Characteristic configuration list length */ +#define DATC_DISC_CFG_LIST_LEN (sizeof(datcDiscCfgList) / sizeof(attcDiscCfg_t)) + +/* sanity check: make sure configuration list length is <= handle list length */ +WSF_CT_ASSERT(DATC_DISC_CFG_LIST_LEN <= DATC_DISC_HDL_LIST_LEN); + +/*************************************************************************************************/ +/*! + * \brief OOB RX callback. + * + * \return None. + */ +/*************************************************************************************************/ +void oobRxCback(void) +{ + if (datcOobCfg != NULL) { + DmSecSetOob(oobConnId, datcOobCfg); + } + + DmSecAuthRsp(oobConnId, 0, NULL); +} + +/*************************************************************************************************/ +/*! + * \brief Application DM callback. + * + * \param pDmEvt DM callback event + * + * \return None. + */ +/*************************************************************************************************/ +static void datcDmCback(dmEvt_t *pDmEvt) +{ + dmEvt_t *pMsg; + uint16_t len; + uint16_t reportLen; + + if (pDmEvt->hdr.event == DM_SEC_ECC_KEY_IND) { + DmSecSetEccKey(&pDmEvt->eccMsg.data.key); + + /* If the local device sends OOB data. */ + if (datcSendOobData) { + uint8_t oobLocalRandom[SMP_RAND_LEN]; + SecRand(oobLocalRandom, SMP_RAND_LEN); + DmSecCalcOobReq(oobLocalRandom, pDmEvt->eccMsg.data.key.pubKey_x); + + /* Setup HCI UART for OOB */ + PalUartConfig_t hciUartCfg; + hciUartCfg.rdCback = oobRxCback; + hciUartCfg.wrCback = NULL; + hciUartCfg.baud = OOB_BAUD; + hciUartCfg.hwFlow = OOB_FLOW; + + PalUartInit(PAL_UART_ID_CHCI, &hciUartCfg); + } + } else if (pDmEvt->hdr.event == DM_SEC_CALC_OOB_IND) { + if (datcOobCfg == NULL) { + datcOobCfg = WsfBufAlloc(sizeof(dmSecLescOobCfg_t)); + memset(datcOobCfg, 0, sizeof(dmSecLescOobCfg_t)); + } + + if (datcOobCfg) { + Calc128Cpy(datcOobCfg->localConfirm, pDmEvt->oobCalcInd.confirm); + Calc128Cpy(datcOobCfg->localRandom, pDmEvt->oobCalcInd.random); + + /* Start the RX for the peer OOB data */ + PalUartReadData(PAL_UART_ID_CHCI, datcOobCfg->peerRandom, + (SMP_RAND_LEN + SMP_CONFIRM_LEN)); + } else { + APP_TRACE_ERR0("Error allocating OOB data"); + } + } else { + len = DmSizeOfEvt(pDmEvt); + + if (pDmEvt->hdr.event == DM_SCAN_REPORT_IND) { + reportLen = pDmEvt->scanReport.len; + } else { + reportLen = 0; + } + + if ((pMsg = WsfMsgAlloc(len + reportLen)) != NULL) { + memcpy(pMsg, pDmEvt, len); + if (pDmEvt->hdr.event == DM_SCAN_REPORT_IND) { + pMsg->scanReport.pData = (uint8_t *)((uint8_t *)pMsg + len); + memcpy(pMsg->scanReport.pData, pDmEvt->scanReport.pData, reportLen); + } + + WsfMsgSend(datcCb.handlerId, pMsg); + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Application ATT callback. + * + * \param pEvt ATT callback event + * + * \return None. + */ +/*************************************************************************************************/ +static void datcAttCback(attEvt_t *pEvt) +{ + attEvt_t *pMsg; + + if ((pMsg = WsfMsgAlloc(sizeof(attEvt_t) + pEvt->valueLen)) != NULL) { + memcpy(pMsg, pEvt, sizeof(attEvt_t)); + pMsg->pValue = (uint8_t *)(pMsg + 1); + memcpy(pMsg->pValue, pEvt->pValue, pEvt->valueLen); + WsfMsgSend(datcCb.handlerId, pMsg); + } +} + +/*************************************************************************************************/ +/*! + * \brief Restart scanning handler. + * + * \param None. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcRestartScanningHandler(void) +{ + datcCb.autoConnect = TRUE; + datcConnInfo.doConnect = FALSE; + AppScanStart(datcMasterCfg.discMode, datcMasterCfg.scanType, datcMasterCfg.scanDuration); +} + +/*************************************************************************************************/ +/*! + * \brief Restart scanning. + * + * \param None. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcRestartScanning(void) +{ + /* Start the scanning start timer */ + WsfTimerStartMs(&datcCb.scanTimer, SCAN_START_MS); +} + +/*************************************************************************************************/ +/*! + * \brief Perform actions on scan start. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcScanStart(dmEvt_t *pMsg) +{ + if (pMsg->hdr.status == HCI_SUCCESS) { + datcCb.scanning = TRUE; + } +} + +/*************************************************************************************************/ +/*! + * \brief Perform actions on scan stop. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcScanStop(dmEvt_t *pMsg) +{ + if (pMsg->hdr.status == HCI_SUCCESS) { + datcCb.scanning = FALSE; + datcCb.autoConnect = FALSE; + + /* Open connection */ + if (datcConnInfo.doConnect) { + AppConnOpen(datcConnInfo.addrType, datcConnInfo.addr, datcConnInfo.dbHdl); + datcConnInfo.doConnect = FALSE; + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Print the name value from a scan report. + * + * \param name Pointer to name parameter from a scan report. + * + * \return None. + */ +/*************************************************************************************************/ +#if WSF_TRACE_ENABLED == TRUE +static void datcPrintName(uint8_t *name) +{ + /* Allocate a buffer for the device name */ + uint8_t *printBuf; + printBuf = WsfBufAlloc(name[DM_AD_LEN_IDX]); + + if (printBuf != NULL) { + /* Copy in the data and null terminate the string */ + memcpy(printBuf, &name[DM_AD_DATA_IDX], name[DM_AD_LEN_IDX] - 1); + printBuf[name[DM_AD_LEN_IDX] - 1] = 0; + + APP_TRACE_INFO1(" Name: %s", printBuf); + WsfBufFree(printBuf); + } +} +#endif + +/*************************************************************************************************/ +/*! + * \brief Print the contents of a scan report. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcPrintScanReport(dmEvt_t *pMsg) +{ +#if WSF_TRACE_ENABLED == TRUE + uint8_t *pData; + + APP_TRACE_INFO0("Scan Report:"); + WsfTrace(" %02x:%02x:%02x:%02x:%02x:%02x", pMsg->scanReport.addr[5], pMsg->scanReport.addr[4], + pMsg->scanReport.addr[3], pMsg->scanReport.addr[2], pMsg->scanReport.addr[1], + pMsg->scanReport.addr[0]); + + if ((pData = DmFindAdType(DM_ADV_TYPE_LOCAL_NAME, pMsg->scanReport.len, + pMsg->scanReport.pData)) != NULL) { + datcPrintName(pData); + } else if ((pData = DmFindAdType(DM_ADV_TYPE_SHORT_NAME, pMsg->scanReport.len, + pMsg->scanReport.pData)) != NULL) { + datcPrintName(pData); + } +#endif +} + +/*************************************************************************************************/ +/*! + * \brief Handle a scan report. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcScanReport(dmEvt_t *pMsg) +{ + uint8_t *pData; + appDbHdl_t dbHdl; + bool_t connect = FALSE; + + /* disregard if not scanning or autoconnecting */ + if (!datcCb.scanning || !datcCb.autoConnect) { + return; + } + + /* if we already have a bond with this device then connect to it */ + if ((dbHdl = AppDbFindByAddr(pMsg->scanReport.addrType, pMsg->scanReport.addr)) != + APP_DB_HDL_NONE) { + /* if this is a directed advertisement where the initiator address is an RPA */ + if (DM_RAND_ADDR_RPA(pMsg->scanReport.directAddr, pMsg->scanReport.directAddrType)) { + /* resolve direct address to see if it's addressed to us */ + AppMasterResolveAddr(pMsg, dbHdl, APP_RESOLVE_DIRECT_RPA); + } else { + connect = TRUE; + } + } else if (DM_RAND_ADDR_RPA(pMsg->scanReport.addr, pMsg->scanReport.addrType)) { + /* if the peer device uses an RPA */ + /* resolve advertiser's RPA to see if we already have a bond with this device */ + AppMasterResolveAddr(pMsg, APP_DB_HDL_NONE, APP_RESOLVE_ADV_RPA); + } + + /* find device name */ + if (!connect && ((pData = DmFindAdType(DM_ADV_TYPE_LOCAL_NAME, pMsg->scanReport.len, + pMsg->scanReport.pData)) != NULL)) { + /* check length and device name */ + if (pData[DM_AD_LEN_IDX] >= 4 && (pData[DM_AD_DATA_IDX] == 'D') && + (pData[DM_AD_DATA_IDX + 1] == 'A') && (pData[DM_AD_DATA_IDX + 2] == 'T') && + (pData[DM_AD_DATA_IDX + 3] == 'S')) { + connect = TRUE; + } + } + + if (connect) { + datcPrintScanReport(pMsg); + + /* stop scanning and connect */ + datcCb.autoConnect = FALSE; + AppScanStop(); + + /* Store peer information for connect on scan stop */ + datcConnInfo.addrType = DmHostAddrType(pMsg->scanReport.addrType); + memcpy(datcConnInfo.addr, pMsg->scanReport.addr, sizeof(bdAddr_t)); + datcConnInfo.dbHdl = dbHdl; + datcConnInfo.doConnect = TRUE; + } else { + static int scanReportDownSample = 0; + + /* Down sample the number of scan reports we print */ + if (scanReportDownSample++ == SCAN_REPORT_DOWN_SAMPLE) { + scanReportDownSample = 0; + datcPrintScanReport(pMsg); + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Perform UI actions on connection open. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcOpen(dmEvt_t *pMsg) +{ +#if (BT_VER > 8) + datcCb.phyMode[pMsg->hdr.param - 1] = DATC_PHY_1M; +#endif /* BT_VER */ +} + +/*************************************************************************************************/ +/*! + * \brief Process a received ATT notification. + * + * \param pMsg Pointer to ATT callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcValueNtf(attEvt_t *pMsg) +{ + if (pMsg->handle == pSecDatHdlList[pMsg->hdr.param - 1][SEC_DAT_HDL_IDX]) + APP_TRACE_INFO0(">> Notification from secure data service <<<"); + /* print the received data */ + if (datcCb.speedTestCounter == 0) { + APP_TRACE_INFO0((const char *)pMsg->pValue); + } +} + +/*************************************************************************************************/ +/*! + * \brief Set up procedures that need to be performed after device reset. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcSetup(dmEvt_t *pMsg) +{ + datcCb.scanning = FALSE; + datcCb.autoConnect = FALSE; + datcConnInfo.doConnect = FALSE; + datcCb.restoringResList = FALSE; + + DmConnSetConnSpec((hciConnSpec_t *)&datcConnCfg); +} + +/*************************************************************************************************/ +/*! + * \brief Begin restoring the resolving list. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcRestoreResolvingList(dmEvt_t *pMsg) +{ + /* Restore first device to resolving list in Controller. */ + datcCb.resListRestoreHdl = AppAddNextDevToResList(APP_DB_HDL_NONE); + + if (datcCb.resListRestoreHdl == APP_DB_HDL_NONE) { + /* No device to restore. Setup application. */ + datcSetup(pMsg); + } else { + datcCb.restoringResList = TRUE; + } +} + +/*************************************************************************************************/ +/*! +* \brief Handle add device to resolving list indication. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcPrivAddDevToResListInd(dmEvt_t *pMsg) +{ + /* Check if in the process of restoring the Device List from NV */ + if (datcCb.restoringResList) { + /* Retore next device to resolving list in Controller. */ + datcCb.resListRestoreHdl = AppAddNextDevToResList(datcCb.resListRestoreHdl); + + if (datcCb.resListRestoreHdl == APP_DB_HDL_NONE) { + /* No additional device to restore. Setup application. */ + datcSetup(pMsg); + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Send example data. + * + * \param connId Connection identifier. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcSendData(dmConnId_t connId) +{ + uint8_t str[] = "hello world"; + + if (pDatcWpHdlList[connId - 1][WPC_P1_DAT_HDL_IDX] != ATT_HANDLE_NONE) { + AttcWriteCmd(connId, pDatcWpHdlList[connId - 1][WPC_P1_DAT_HDL_IDX], sizeof(str), str); + } +} + +/*************************************************************************************************/ +/*! + * \brief Send example data to secured charactersitic. + * + * \param connId Connection identifier. + * + * \return None. + */ +/*************************************************************************************************/ +static void secDatSendData(dmConnId_t connId) +{ + uint8_t str[] = "Secret number is 0x42"; + + if (pSecDatHdlList[connId - 1][SEC_DAT_HDL_IDX] != ATT_HANDLE_NONE) { + AttcWriteCmd(connId, pSecDatHdlList[connId - 1][SEC_DAT_HDL_IDX], sizeof(str), str); + } +} + +/*************************************************************************************************/ +/*! + * \brief GAP service discovery has completed. + * + * \param connId Connection identifier. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcDiscGapCmpl(dmConnId_t connId) +{ + appDbHdl_t dbHdl; + + /* if RPA Only attribute found on peer device */ + if ((pDatcGapHdlList[connId - 1][GAP_RPAO_HDL_IDX] != ATT_HANDLE_NONE) && + ((dbHdl = AppDbGetHdl(connId)) != APP_DB_HDL_NONE)) { + /* update DB */ + AppDbSetPeerRpao(dbHdl, TRUE); + AppDbNvmStorePeerRpao(dbHdl); + } +} + +/*************************************************************************************************/ +/*! + * \brief Handler for the speed test. + * + * \param connId Connection identifier. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcSpeedTestHandler(dmConnId_t connId) +{ + static uint8_t speedTestData[SPEED_TEST_PACKET_LEN]; + uint16_t handle; + + if (datcCb.speedTestCounter == SPEED_TEST_COUNT) { + unsigned us = MXC_TMR_SW_Stop(SPEED_TEST_TMR); + + /* Calculate the throughput */ + unsigned bits = SPEED_TEST_COUNT * SPEED_TEST_PACKET_LEN * 8; + APP_TRACE_INFO2("%d bits transferred in %d us", bits, us); + + float bps = (float)bits / ((float)us / (float)1000000); + (void)bps; + APP_TRACE_INFO1("%d bps", (unsigned)bps); + + /* Reset the counter for the next test */ + datcCb.speedTestCounter = 0; + return; + } + + /* Write the next packet */ + handle = pDatcWpHdlList[connId - 1][WPC_P1_DAT_HDL_IDX]; + AttcWriteCmd(connId, handle, (uint16_t)SPEED_TEST_PACKET_LEN, speedTestData); + + if (datcCb.speedTestCounter == 0) { + /* Start the throughput timer */ + MXC_TMR_SW_Start(SPEED_TEST_TMR); + } + + datcCb.speedTestCounter++; +} + +/*************************************************************************************************/ +/*! + * \brief Starts the speed test. + * + * \param connId Connection identifier. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcStartSpeedTest(dmConnId_t connId) +{ + if (datcCb.speedTestCounter != 0) { + APP_TRACE_ERR0("Speed test already running"); + return; + } + + APP_TRACE_INFO0("Starting speed test"); + datcSpeedTestHandler(connId); +} + +/*************************************************************************************************/ +/*! + * \brief Button press callback. + * + * \param btn Button press. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcBtnCback(uint8_t btn) +{ + dmConnId_t connId = datcCb.btnConnId; + dmConnId_t connIdList[DM_CONN_MAX]; + uint8_t numConnections = AppConnOpenList(connIdList); + + /* button actions when connected */ + if (numConnections > 0) { + switch (btn) { + case APP_UI_BTN_1_SHORT: + if (numConnections < DM_CONN_MAX - 1) { + /* if scanning cancel scanning */ + if (datcCb.scanning) { + AppScanStop(); + } else if (!datcCb.autoConnect) { + /* else auto connect */ + datcRestartScanning(); + } + } else { + APP_TRACE_INFO0("datcBtnCback: Max connections reached."); + } + break; + + case APP_UI_BTN_1_MED: + /* Increment connection ID used in button presses */ + if (++datcCb.btnConnId > DM_CONN_MAX) { + datcCb.btnConnId = 1; + } + APP_TRACE_INFO1("ConnId for Button Press: %d", datcCb.btnConnId); + break; + + case APP_UI_BTN_1_LONG: + /* disconnect */ + AppConnClose(connId); + break; + +#if (BT_VER > 8) + case APP_UI_BTN_2_SHORT: { + static uint32_t coded_phy_cnt = 0; + /* Toggle PHY Test Mode */ + coded_phy_cnt++; + switch (coded_phy_cnt & 0x3) { + case 0: + /* 1M PHY */ + APP_TRACE_INFO0("1 MBit TX and RX PHY Requested"); + DmSetPhy(connId, HCI_ALL_PHY_ALL_PREFERENCES, HCI_PHY_LE_1M_BIT, HCI_PHY_LE_1M_BIT, + HCI_PHY_OPTIONS_NONE); + datcCb.phyMode[connId - 1] = DATC_PHY_1M; + break; + case 1: + /* 2M PHY */ + APP_TRACE_INFO0("2 MBit TX and RX PHY Requested"); + DmSetPhy(connId, HCI_ALL_PHY_ALL_PREFERENCES, HCI_PHY_LE_2M_BIT, HCI_PHY_LE_2M_BIT, + HCI_PHY_OPTIONS_NONE); + datcCb.phyMode[connId - 1] = DATC_PHY_2M; + break; + case 2: + /* Coded S2 PHY */ + APP_TRACE_INFO0("LE Coded S2 TX and RX PHY Requested"); + DmSetPhy(connId, HCI_ALL_PHY_ALL_PREFERENCES, HCI_PHY_LE_CODED_BIT, + HCI_PHY_LE_CODED_BIT, HCI_PHY_OPTIONS_S2_PREFERRED); + datcCb.phyMode[connId - 1] = DATC_PHY_CODED; + break; + case 3: + /* Coded S8 PHY */ + APP_TRACE_INFO0("LE Coded S8 TX and RX PHY Requested"); + DmSetPhy(connId, HCI_ALL_PHY_ALL_PREFERENCES, HCI_PHY_LE_CODED_BIT, + HCI_PHY_LE_CODED_BIT, HCI_PHY_OPTIONS_S8_PREFERRED); + datcCb.phyMode[connId - 1] = DATC_PHY_CODED; + break; + } + break; + } +#endif /* BT_VER */ + case APP_UI_BTN_2_MED: + secDatSendData(connId); + break; + case APP_UI_BTN_2_LONG: + /* send data */ + datcSendData(connId); + break; + + case APP_UI_BTN_2_EX_LONG: + /* Start the speed test */ + datcStartSpeedTest(connId); + break; + + default: + APP_TRACE_INFO0(" - No action assigned"); + break; + } + } else { /* button actions when not connected */ + switch (btn) { + case APP_UI_BTN_1_SHORT: + /* if scanning cancel scanning */ + if (datcCb.scanning) { + AppScanStop(); + } else if (!datcCb.autoConnect) { + /* else auto connect */ + datcRestartScanning(); + } + break; + + case APP_UI_BTN_1_MED: + /* Increment connection ID buttons apply to */ + if (++datcCb.btnConnId > DM_CONN_MAX) { + datcCb.btnConnId = 1; + } + APP_TRACE_INFO1("ConnID for Button Press: %d", datcCb.btnConnId); + break; + + case APP_UI_BTN_1_LONG: + /* clear all bonding info */ + AppClearAllBondingInfo(); + AppDbNvmDeleteAll(); + break; + + case APP_UI_BTN_1_EX_LONG: + /* add RPAO characteristic to GAP service -- needed only when DM Privacy enabled */ + SvcCoreGapAddRpaoCh(); + break; + + case APP_UI_BTN_2_EX_LONG: + /* enable device privacy -- start generating local RPAs every 15 minutes */ + DmDevPrivStart(15 * 60); + + /* set Scanning filter policy to accept directed advertisements with RPAs */ + DmDevSetFilterPolicy(DM_FILT_POLICY_MODE_SCAN, HCI_FILT_RES_INIT); + break; + + default: + APP_TRACE_INFO0(" - No action assigned"); + break; + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Discovery callback. + * + * \param connId Connection identifier. + * \param status Service or configuration status. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcDiscCback(dmConnId_t connId, uint8_t status) +{ + switch (status) { + case APP_DISC_INIT: + /* set handle list when initialization requested */ + AppDiscSetHdlList(connId, datcCb.hdlListLen, datcCb.hdlList[connId - 1]); + break; + + case APP_DISC_READ_DATABASE_HASH: + /* Read peer's database hash */ + AppDiscReadDatabaseHash(connId); + break; + + case APP_DISC_SEC_REQUIRED: + /* initiate security */ + AppMasterSecurityReq(connId); + break; + + case APP_DISC_START: + /* initialize discovery state */ + datcCb.discState[connId - 1] = DATC_DISC_GATT_SVC; + + /* store possible change in cache by hash */ + AppDbNvmStoreCacheByHash(AppDbGetHdl(connId)); + + /* discover GATT service */ + GattDiscover(connId, pDatcGattHdlList[connId - 1]); + break; + + case APP_DISC_FAILED: + if (pAppCfg->abortDisc) { + /* if discovery failed for proprietary data service then disconnect */ + if (datcCb.discState[connId - 1] < DATC_DISC_SVC_MAX) { + AppConnClose(connId); + break; + } + } + /* Else falls through. */ + + case APP_DISC_CMPL: + /* next discovery state */ + datcCb.discState[connId - 1]++; + + if (datcCb.discState[connId - 1] == DATC_DISC_GAP_SVC) { + /* discover GAP service */ + GapDiscover(connId, pDatcGapHdlList[connId - 1]); + } else if (datcCb.discState[connId - 1] == DATC_DISC_WP_SVC) { + /* discover proprietary data service */ + WpcP1Discover(connId, pDatcWpHdlList[connId - 1]); + } else if (datcCb.discState[connId - 1] == DATC_DISC_SDS_SVC) { + /* discover secured data service */ + SecDatSvcDiscover(connId, pSecDatHdlList[connId - 1]); + } else { + /* discovery complete */ + AppDiscComplete(connId, APP_DISC_CMPL); + + /* GAP service discovery completed */ + datcDiscGapCmpl(connId); + + /* store cached handle list in NVM */ + AppDbNvmStoreHdlList(AppDbGetHdl(connId)); + + /* start configuration */ + AppDiscConfigure(connId, APP_DISC_CFG_START, DATC_DISC_CFG_LIST_LEN, + (attcDiscCfg_t *)datcDiscCfgList, DATC_DISC_HDL_LIST_LEN, + datcCb.hdlList[connId - 1]); + } + break; + + case APP_DISC_CFG_START: + case APP_DISC_CFG_CONN_START: + /* start configuration */ + AppDiscConfigure(connId, APP_DISC_CFG_START, DATC_DISC_CFG_LIST_LEN, + (attcDiscCfg_t *)datcDiscCfgList, DATC_DISC_HDL_LIST_LEN, + datcCb.hdlList[connId - 1]); + break; + + case APP_DISC_CFG_CMPL: + AppDiscComplete(connId, status); + break; + + default: + break; + } +} + +/*************************************************************************************************/ +/*! + * \brief Process messages from the event handler. + * + * \param pMsg Pointer to message. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcProcMsg(dmEvt_t *pMsg) +{ + uint8_t uiEvent = APP_UI_NONE; + + switch (pMsg->hdr.event) { + case ATTC_WRITE_CMD_RSP: { + if (datcCb.speedTestCounter != 0) { + dmConnId_t connId = (dmConnId_t)pMsg->hdr.param; + datcSpeedTestHandler(connId); + } + } break; + + case ATTC_HANDLE_VALUE_NTF: + datcValueNtf((attEvt_t *)pMsg); + break; + + case DM_RESET_CMPL_IND: + AttsCalculateDbHash(); + DmSecGenerateEccKeyReq(); + AppDbNvmReadAll(); + datcRestoreResolvingList(pMsg); + datcRestartScanning(); + uiEvent = APP_UI_RESET_CMPL; + break; + + case DM_SCAN_START_IND: + datcScanStart(pMsg); + uiEvent = APP_UI_SCAN_START; + break; + + case DM_SCAN_STOP_IND: + datcScanStop(pMsg); + uiEvent = APP_UI_SCAN_STOP; + break; + + case DM_SCAN_REPORT_IND: + datcScanReport(pMsg); + break; + + case DM_EXT_SCAN_REPORT_IND: + break; + + case DM_CONN_OPEN_IND: + datcOpen(pMsg); + uiEvent = APP_UI_CONN_OPEN; + break; + + case DM_CONN_CLOSE_IND: + APP_TRACE_INFO2("Connection closed status 0x%x, reason 0x%x", pMsg->connClose.status, + pMsg->connClose.reason); + switch (pMsg->connClose.reason) { + case HCI_ERR_CONN_TIMEOUT: + APP_TRACE_INFO0(" TIMEOUT"); + break; + case HCI_ERR_LOCAL_TERMINATED: + APP_TRACE_INFO0(" LOCAL TERM"); + break; + case HCI_ERR_REMOTE_TERMINATED: + APP_TRACE_INFO0(" REMOTE TERM"); + break; + case HCI_ERR_CONN_FAIL: + APP_TRACE_INFO0(" FAIL ESTABLISH"); + break; + case HCI_ERR_MIC_FAILURE: + APP_TRACE_INFO0(" MIC FAILURE"); + break; + } + uiEvent = APP_UI_CONN_CLOSE; + datcRestartScanning(); + break; + + case DM_SEC_PAIR_CMPL_IND: + DmSecGenerateEccKeyReq(); + AppDbNvmStoreBond(AppDbGetHdl((dmConnId_t)pMsg->hdr.param)); + uiEvent = APP_UI_SEC_PAIR_CMPL; + break; + + case DM_SEC_PAIR_FAIL_IND: + DmSecGenerateEccKeyReq(); + uiEvent = APP_UI_SEC_PAIR_FAIL; + break; + + case DM_SEC_ENCRYPT_IND: + uiEvent = APP_UI_SEC_ENCRYPT; + break; + + case DM_SEC_ENCRYPT_FAIL_IND: + uiEvent = APP_UI_SEC_ENCRYPT_FAIL; + break; + + case DM_SEC_AUTH_REQ_IND: + + if (pMsg->authReq.oob) { + dmConnId_t connId = (dmConnId_t)pMsg->hdr.param; + + APP_TRACE_INFO0("Sending OOB data"); + oobConnId = connId; + + /* Start the TX to send the local OOB data */ + PalUartWriteData(PAL_UART_ID_CHCI, datcOobCfg->localRandom, + (SMP_RAND_LEN + SMP_CONFIRM_LEN)); + + } else { + AppHandlePasskey(&pMsg->authReq); + } + break; + + case DM_SEC_COMPARE_IND: + AppHandleNumericComparison(&pMsg->cnfInd); + break; + + case DM_ADV_NEW_ADDR_IND: + break; + + case DM_PRIV_ADD_DEV_TO_RES_LIST_IND: + datcPrivAddDevToResListInd(pMsg); + break; + + case DM_PRIV_CLEAR_RES_LIST_IND: + APP_TRACE_INFO1("Clear resolving list status 0x%02x", pMsg->hdr.status); + break; + +#if (BT_VER > 8) + case DM_PHY_UPDATE_IND: + APP_TRACE_INFO2("DM_PHY_UPDATE_IND - RX: %d, TX: %d", pMsg->phyUpdate.rxPhy, + pMsg->phyUpdate.txPhy); + break; +#endif /* BT_VER */ + + case SCAN_START_EVT: + datcRestartScanningHandler(); + break; + + case USER_APP_TMR_EVT: + WsfTimerStartMs(&userAppTmr, USER_APP_TMR_MS); + LED_Off(0); // turn off red led + break; + + default: + break; + } + + if (uiEvent != APP_UI_NONE) { + AppUiAction(uiEvent); + } +} + +/*************************************************************************************************/ +/*! + * \brief Application handler init function called during system initialization. + * + * \param handlerID WSF handler ID. + * + * \return None. + */ +/*************************************************************************************************/ +void DatcHandlerInit(wsfHandlerId_t handlerId) +{ + uint8_t addr[6] = { 0 }; + APP_TRACE_INFO0("DatcHandlerInit"); + AppGetBdAddr(addr); + APP_TRACE_INFO6("MAC Addr: %02x:%02x:%02x:%02x:%02x:%02x", addr[5], addr[4], addr[3], addr[2], + addr[1], addr[0]); + + /* store handler ID */ + datcCb.handlerId = handlerId; + + /* set handle list length */ + datcCb.hdlListLen = DATC_DISC_HDL_LIST_LEN; + + datcCb.btnConnId = 1; + /* Set configuration pointers */ + pAppMasterCfg = (appMasterCfg_t *)&datcMasterCfg; + pAppSecCfg = (appSecCfg_t *)&datcSecCfg; + pAppDiscCfg = (appDiscCfg_t *)&datcDiscCfg; + pAppCfg = (appCfg_t *)&datcAppCfg; + pSmpCfg = (smpCfg_t *)&datcSmpCfg; + pAttCfg = (attCfg_t *)&datcAttCfg; + + /* Initialize application framework */ + AppMasterInit(); + AppDiscInit(); + + /* Set IRK for the local device */ + DmSecSetLocalIrk(localIrk); + + /* Setup scan start timer */ + datcCb.scanTimer.handlerId = handlerId; + datcCb.scanTimer.msg.event = SCAN_START_EVT; + + userAppTmr.handlerId = handlerId; + userAppTmr.msg.event = USER_APP_TMR_EVT; + WsfTimerStartMs(&userAppTmr, USER_APP_TMR_MS); +} + +/*************************************************************************************************/ +/*! + * \brief Platform button press handler. + * + * \param[in] btnId button ID. + * \param[in] state button state. See ::PalBtnPos_t. + * + * \return None. + */ +/*************************************************************************************************/ +static void btnPressHandler(uint8_t btnId, PalBtnPos_t state) +{ + if (btnId == 1) { + /* Start/stop button timer */ + if (state == PAL_BTN_POS_UP) { + /* Button Up, stop the timer, call the action function */ + unsigned btnUs = MXC_TMR_SW_Stop(BTN_1_TMR); + if ((btnUs > 0) && (btnUs < BTN_SHORT_MS * 1000)) { + AppUiBtnTest(APP_UI_BTN_1_SHORT); + } else if (btnUs < BTN_MED_MS * 1000) { + AppUiBtnTest(APP_UI_BTN_1_MED); + } else if (btnUs < BTN_LONG_MS * 1000) { + AppUiBtnTest(APP_UI_BTN_1_LONG); + } else { + AppUiBtnTest(APP_UI_BTN_1_EX_LONG); + } + } else { + /* Button down, start the timer */ + MXC_TMR_SW_Start(BTN_1_TMR); + } + } else if (btnId == 2) { + /* Start/stop button timer */ + if (state == PAL_BTN_POS_UP) { + /* Button Up, stop the timer, call the action function */ + unsigned btnUs = MXC_TMR_SW_Stop(BTN_2_TMR); + if ((btnUs > 0) && (btnUs < BTN_SHORT_MS * 1000)) { + AppUiBtnTest(APP_UI_BTN_2_SHORT); + } else if (btnUs < BTN_MED_MS * 1000) { + AppUiBtnTest(APP_UI_BTN_2_MED); + } else if (btnUs < BTN_LONG_MS * 1000) { + AppUiBtnTest(APP_UI_BTN_2_LONG); + } else { + AppUiBtnTest(APP_UI_BTN_2_EX_LONG); + } + } else { + /* Button down, start the timer */ + MXC_TMR_SW_Start(BTN_2_TMR); + } + } else { + APP_TRACE_ERR0("Undefined button"); + } +} + +/*************************************************************************************************/ +/*! + * \brief WSF event handler for application. + * + * \param event WSF event mask. + * \param pMsg WSF message. + * + * \return None. + */ +/*************************************************************************************************/ +void DatcHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) +{ + if (pMsg != NULL) { + if (datcCb.speedTestCounter == 0 && pMsg->event != DM_SCAN_REPORT_IND) { + //APP_TRACE_INFO1("\nDatc got evt %d", pMsg->event); + } + + if (pMsg->event <= ATT_CBACK_END) { /* process ATT messages */ + /* process discovery-related ATT messages */ + AppDiscProcAttMsg((attEvt_t *)pMsg); + + /* process server-related ATT messages */ + AppServerProcAttMsg(pMsg); + } else if (pMsg->event <= DM_CBACK_END) { /* process DM messages */ + /* process advertising and connection-related messages */ + AppMasterProcDmMsg((dmEvt_t *)pMsg); + + /* process security-related messages */ + AppMasterSecProcDmMsg((dmEvt_t *)pMsg); + + /* process discovery-related messages */ + AppDiscProcDmMsg((dmEvt_t *)pMsg); + } + + /* perform profile and user interface-related operations */ + datcProcMsg((dmEvt_t *)pMsg); + } +} + +/*************************************************************************************************/ +/*! + * \brief Initialize the pointers into the handle list. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcInitSvcHdlList() +{ + uint8_t i; + + for (i = 0; i < DM_CONN_MAX; i++) { + /*! Pointers into handle list for each service's handles */ + pDatcGattHdlList[i] = &datcCb.hdlList[i][DATC_DISC_GATT_START]; + pDatcGapHdlList[i] = &datcCb.hdlList[i][DATC_DISC_GAP_START]; + pDatcWpHdlList[i] = &datcCb.hdlList[i][DATC_DISC_WP_START]; + pSecDatHdlList[i] = &datcCb.hdlList[i][DATC_DISC_SDS_START]; + } +} +/*************************************************************************************************/ +/*! + * \brief Start the application. + * + * \return None. + */ +/*************************************************************************************************/ +void DatcStart(void) +{ + /* Initialize handle pointers */ + datcInitSvcHdlList(); + + /* Register for stack callbacks */ + DmRegister(datcDmCback); + DmConnRegister(DM_CLIENT_ID_APP, datcDmCback); + AttRegister(datcAttCback); + + /* Register for app framework button callbacks */ + AppUiBtnRegister(datcBtnCback); + + /* Register for app framework discovery callbacks */ + AppDiscRegister(datcDiscCback); + + /* Initialize attribute server database */ + SvcCoreAddGroup(); + +#if (BT_VER > 8) + DmPhyInit(); +#endif /* BT_VER */ + + WsfNvmInit(); + + /* Initialize with button press handler */ + PalBtnInit(btnPressHandler); + + /* Reset the device */ + DmDevReset(); +} diff --git a/Examples/MAX32665/BLE_LR_Central/main.c b/Examples/MAX32665/BLE_LR_Central/main.c new file mode 100644 index 0000000000..cf50a9eeda --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/main.c @@ -0,0 +1,291 @@ +/*************************************************************************************************/ +/*! + * @file main.c + * @brief Simple BLE Data Client for unformatted data exchange. +* +* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved. +* +* Copyright (c) 2019 Packetcraft, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +/*************************************************************************************************/ + +#include +#include "wsf_types.h" +#include "wsf_trace.h" +#include "wsf_bufio.h" +#include "wsf_msg.h" +#include "wsf_assert.h" +#include "wsf_buf.h" +#include "wsf_heap.h" +#include "wsf_cs.h" +#include "wsf_timer.h" +#include "wsf_trace.h" +#include "wsf_os.h" + +#include "sec_api.h" +#include "hci_handler.h" +#include "dm_handler.h" +#include "l2c_handler.h" +#include "att_handler.h" +#include "smp_handler.h" +#include "l2c_api.h" +#include "att_api.h" +#include "smp_api.h" +#include "app_api.h" +#include "hci_core.h" +#include "app_terminal.h" +#include "wut.h" +#include "rtc.h" +#include "trimsir_regs.h" + +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) +#include "ll_init_api.h" +#endif + +#include "pal_bb.h" +#include "pal_cfg.h" +#include "pal_timer.h" +#include "pal_sys.h" + +#include "datc_api.h" +#include "app_ui.h" + +/************************************************************************************************** + Macros +**************************************************************************************************/ + +/*! \brief UART TX buffer size */ +#define PLATFORM_UART_TERMINAL_BUFFER_SIZE 2048U +#define DEFAULT_TX_POWER 0 /* dBm */ + +/************************************************************************************************** + Global Variables +**************************************************************************************************/ + +/*! \brief Pool runtime configuration. */ +static wsfBufPoolDesc_t mainPoolDesc[] = { { 16, 8 }, { 32, 4 }, { 192, 8 }, { 256, 16 } }; + +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) +static LlRtCfg_t mainLlRtCfg; +#endif + +volatile int wutTrimComplete; + +extern uint8_t appCodedPhyDemo; + +/************************************************************************************************** + Functions +**************************************************************************************************/ + +/*! \brief Stack initialization for app. */ +extern void StackInitDatc(void); + +/*************************************************************************************************/ +/*! + * \brief Initialize WSF. + * + * \return None. + */ +/*************************************************************************************************/ +static void mainWsfInit(void) +{ +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) + /* +12 for message headroom, + 2 event header, +255 maximum parameter length. */ + const uint16_t maxRptBufSize = 12 + 2 + 255; + + /* +12 for message headroom, +4 for header. */ + const uint16_t aclBufSize = 12 + mainLlRtCfg.maxAclLen + 4 + BB_DATA_PDU_TAILROOM; + + /* Adjust buffer allocation based on platform configuration. */ + mainPoolDesc[2].len = maxRptBufSize; + mainPoolDesc[2].num = mainLlRtCfg.maxAdvReports; + mainPoolDesc[3].len = aclBufSize; + mainPoolDesc[3].num = mainLlRtCfg.numTxBufs + mainLlRtCfg.numRxBufs; +#endif + + const uint8_t numPools = sizeof(mainPoolDesc) / sizeof(mainPoolDesc[0]); + + uint16_t memUsed; + WsfCsEnter(); + memUsed = WsfBufInit(numPools, mainPoolDesc); + WsfHeapAlloc(memUsed); + WsfCsExit(); + + WsfOsInit(); + WsfTimerInit(); +#if (WSF_TOKEN_ENABLED == TRUE) || (WSF_TRACE_ENABLED == TRUE) + WsfTraceRegisterHandler(WsfBufIoWrite); + WsfTraceEnable(TRUE); +#endif +} + +/*************************************************************************************************/ +/*! +* \fn WUT_IRQHandler +* +* \brief WUT interrupt handler. +* +* \return None. +*/ +/*************************************************************************************************/ +void WUT_IRQHandler(void) +{ + MXC_WUT_Handler(); + PalTimerIRQCallBack(); +} + +/*************************************************************************************************/ +/*! +* \fn wutTrimCb +* +* \brief Callback function for the WUT 32 kHz crystal trim. +* +* \param err Error code from the WUT driver. +* +* \return None. +*/ +/*************************************************************************************************/ +void wutTrimCb(int err) +{ + if (err != E_NO_ERROR) { + APP_TRACE_INFO1("32 kHz trim error %d\n", err); + } else { + APP_TRACE_INFO1("32kHz trimmed to 0x%x", (MXC_TRIMSIR->rtc & MXC_F_TRIMSIR_RTC_RTCX1) >> + MXC_F_TRIMSIR_RTC_RTCX1_POS); + } + wutTrimComplete = 1; +} + +/*************************************************************************************************/ +/*! +* \fn setAdvTxPower +* +* \brief Set the default advertising TX power. +* +* \return None. +*/ +/*************************************************************************************************/ +void setAdvTxPower(void) +{ + LlSetAdvTxPower(DEFAULT_TX_POWER); +} + +/*************************************************************************************************/ +/*! +* \fn main +* +* \brief Entry point for demo software. +* +* \param None. +* +* \return None. +*/ +/*************************************************************************************************/ +int main(void) +{ +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) + /* Configurations must be persistent. */ + static BbRtCfg_t mainBbRtCfg; + + PalBbLoadCfg((PalBbCfg_t *)&mainBbRtCfg); + LlGetDefaultRunTimeCfg(&mainLlRtCfg); +#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_0) + /* Set 5.0 requirements. */ + mainLlRtCfg.btVer = LL_VER_BT_CORE_SPEC_5_0; +#endif + PalCfgLoadData(PAL_CFG_ID_LL_PARAM, &mainLlRtCfg.maxAdvSets, sizeof(LlRtCfg_t) - 9); +#if (BT_VER >= LL_VER_BT_CORE_SPEC_5_0) + PalCfgLoadData(PAL_CFG_ID_BLE_PHY, &mainLlRtCfg.phy2mSup, 4); +#endif + + /* Set the 32k sleep clock accuracy into one of the following bins, default is 20 + HCI_CLOCK_500PPM + HCI_CLOCK_250PPM + HCI_CLOCK_150PPM + HCI_CLOCK_100PPM + HCI_CLOCK_75PPM + HCI_CLOCK_50PPM + HCI_CLOCK_30PPM + HCI_CLOCK_20PPM + */ + mainBbRtCfg.clkPpm = 20; + + /* Increase the default ACL buffer size and count */ + mainLlRtCfg.numTxBufs = 8; + mainLlRtCfg.numRxBufs = 8; + mainLlRtCfg.maxAclLen = 256; + + /* Set the default connection power level */ + mainLlRtCfg.defTxPwrLvl = DEFAULT_TX_POWER; +#endif + + uint32_t memUsed; + WsfCsEnter(); + memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE); + WsfHeapAlloc(memUsed); + WsfCsExit(); + + mainWsfInit(); + AppTerminalInit(); + + APP_TRACE_INFO0("=========================================="); + APP_TRACE_INFO0("Long distance scanner demo (CODED PHY S=8)"); + APP_TRACE_INFO1("BT_VER=%d", BT_VER); + APP_TRACE_INFO0("=========================================="); + appCodedPhyDemo = 1; + +#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) + WsfCsEnter(); + LlInitRtCfg_t llCfg = { .pBbRtCfg = &mainBbRtCfg, + .wlSizeCfg = 4, + .rlSizeCfg = 4, + .plSizeCfg = 4, + .pLlRtCfg = &mainLlRtCfg, + .pFreeMem = WsfHeapGetFreeStartAddress(), + .freeMemAvail = WsfHeapCountAvailable() }; + + memUsed = LlInit(&llCfg); + WsfHeapAlloc(memUsed); + WsfCsExit(); + + bdAddr_t bdAddr; + PalCfgLoadData(PAL_CFG_ID_BD_ADDR, bdAddr, sizeof(bdAddr_t)); + LlSetBdAddr((uint8_t *)&bdAddr); + + /* Start the 32 MHz crystal and the BLE DBB counter to trim the 32 kHz crystal */ + PalBbEnable(); + + /* Output buffered square wave of 32 kHz clock to GPIO */ + // MXC_RTC_SquareWaveStart(MXC_RTC_F_32KHZ); + + /* Execute the trim procedure */ + wutTrimComplete = 0; + if (PalSharedTimerIsInit()) { + MXC_WUT_TrimCrystalAsync(wutTrimCb); + while (!wutTrimComplete) {} + } + + /* Shutdown the 32 MHz crystal and the BLE DBB */ + PalBbDisable(); +#endif + + StackInitDatc(); + DatcStart(); + + WsfOsEnterMainLoop(); + + /* Does not return. */ + return 0; +} diff --git a/Examples/MAX32665/BLE_LR_Central/project.mk b/Examples/MAX32665/BLE_LR_Central/project.mk new file mode 100644 index 0000000000..e66f9057ee --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/project.mk @@ -0,0 +1,26 @@ +# This file can be used to set build configuration +# variables. These variables are defined in a file called +# "Makefile" that is located next to this one. + +# For instructions on how to use this system, see +# https://analog-devices-msdk.github.io/msdk/USERGUIDE/#build-system + +# ********************************************************** + +# If you have secure version of MCU (MAX32666), set SBT=1 to generate signed binary +# For more information on how sing process works, see +# https://www.analog.com/en/education/education-library/videos/6313214207112.html +SBT=0 + +# Enable Cordio library +LIB_CORDIO = 1 + +# Cordio library options +INIT_PERIPHERAL = 0 +INIT_CENTRAL = 1 + +# TRACE option +# Set to 0 to disable +# Set to 1 to enable serial port trace messages +# Set to 2 to enable verbose messages +TRACE = 1 diff --git a/Examples/MAX32665/BLE_LR_Central/sdsc_api.h b/Examples/MAX32665/BLE_LR_Central/sdsc_api.h new file mode 100644 index 0000000000..2fd5c1b220 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/sdsc_api.h @@ -0,0 +1,81 @@ +/****************************************************************************** + * Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + ******************************************************************************/ + +/*************************************************************************************************/ +/*! Secure Data Service Client +* Implements the necessary handles list to perform service +* and characteristic discovery of custom secured service . +* + */ +/*************************************************************************************************/ + +#ifndef EXAMPLES_MAX32665_BLE_LR_CENTRAL_SDSC_API_H_ +#define EXAMPLES_MAX32665_BLE_LR_CENTRAL_SDSC_API_H_ + +#include "att_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \brief Secured service enumeration of handle indexes of characteristics to be discovered */ +enum { + SEC_DAT_HDL_IDX, /*!< \brief Secured data */ + SEC_DAT_CCC_HDL_IDX, /*!< \brief Secured data client characteristic configuration descriptor */ + SEC_HDL_LIST_LEN /*!< \brief Handle list length */ +}; + +/************************************************************************************************** + Function Declarations +**************************************************************************************************/ + +/*************************************************************************************************/ +/*! + * \brief Perform service and characteristic discovery for Secured service . + * Parameter pHdlList must point to an array of length \ref SEC_HDL_LIST_LEN. + * If discovery is successful the handles of discovered characteristics and + * descriptors will be set in pHdlList. + * + * \param connId Connection identifier. + * \param pHdlList Characteristic handle list. + * + * \return None. + */ +/*************************************************************************************************/ +void SecDatSvcDiscover(dmConnId_t connId, uint16_t *pHdlList); + +#ifdef __cplusplus +}; +#endif + +#endif // EXAMPLES_MAX32665_BLE_LR_CENTRAL_SDSC_API_H_ diff --git a/Examples/MAX32665/BLE_LR_Central/sdsc_main.c b/Examples/MAX32665/BLE_LR_Central/sdsc_main.c new file mode 100644 index 0000000000..b20cdced9c --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/sdsc_main.c @@ -0,0 +1,92 @@ +/****************************************************************************** + * Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + ******************************************************************************/ + +#include +#include "wsf_types.h" +#include "wsf_assert.h" +#include "util/bstream.h" +#include "app_api.h" +#include "sdsc_api.h" + +/************************************************************************************************** + Secure Service and Data UUIDs +**************************************************************************************************/ +#define ATT_UUID_SEC_DATA_SERVICE \ + 0xBE, 0x35, 0xD1, 0x24, 0x99, 0x33, 0xC6, 0x87, 0x85, 0x42, 0xD9, 0x32, 0x7E, 0x36, 0xFC, 0x42 +/* MCS service GATT characteristic UUIDs*/ +#define ATT_UUID_SEC_DATA \ + 0xBE, 0x35, 0xD1, 0x24, 0x99, 0x33, 0xC6, 0x87, 0x85, 0x41, 0xD9, 0x31, 0x3E, 0x56, 0xFC, 0x42 +/************************************************************************************************** + Local Variables +**************************************************************************************************/ + +/* UUIDs */ +static const uint8_t SecDatSvcUuid[] = { ATT_UUID_SEC_DATA_SERVICE }; /*! Secured service */ +static const uint8_t SecDatChUuid[] = { ATT_UUID_SEC_DATA }; /*! Secured data */ + +/* Characteristics for discovery */ + +/*! Secured data */ +static const attcDiscChar_t secDat = { SecDatChUuid, ATTC_SET_REQUIRED | ATTC_SET_UUID_128 }; + +/*! Secured data descriptor */ +static const attcDiscChar_t secDatCcc = { attCliChCfgUuid, + ATTC_SET_REQUIRED | ATTC_SET_DESCRIPTOR }; + +/*! List of characteristics to be discovered; order matches handle index enumeration */ +static const attcDiscChar_t *secDatDiscCharList[] = { + &secDat, /*! Secured data */ + &secDatCcc /*! Secured data descriptor */ +}; + +/* sanity check: make sure handle list length matches characteristic list length */ +WSF_CT_ASSERT(SEC_HDL_LIST_LEN == ((sizeof(secDatDiscCharList) / sizeof(attcDiscChar_t *)))); + +/*************************************************************************************************/ +/*! + * \brief Perform service and characteristic discovery for custom secured service . + * Parameter pHdlList must point to an array of length SEC_HDL_LIST_LEN. + * If discovery is successful the handles of discovered characteristics and + * descriptors will be set in pHdlList. + * + * \param connId Connection identifier. + * \param pHdlList Characteristic handle list. + * + * \return None. + */ +/*************************************************************************************************/ +void SecDatSvcDiscover(dmConnId_t connId, uint16_t *pHdlList) +{ + AppDiscFindService(connId, ATT_128_UUID_LEN, (uint8_t *)SecDatSvcUuid, SEC_HDL_LIST_LEN, + (attcDiscChar_t **)secDatDiscCharList, pHdlList); +} diff --git a/Examples/MAX32665/BLE_LR_Central/stack_datc.c b/Examples/MAX32665/BLE_LR_Central/stack_datc.c new file mode 100644 index 0000000000..0a4346f441 --- /dev/null +++ b/Examples/MAX32665/BLE_LR_Central/stack_datc.c @@ -0,0 +1,107 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Stack initialization for datc. + * + * Copyright (c) 2016-2019 Arm Ltd. All Rights Reserved. + * + * Copyright (c) 2019 Packetcraft, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*************************************************************************************************/ + +#include "wsf_types.h" +#include "wsf_os.h" +#include "util/bstream.h" + +#include "datc_api.h" + +#include "hci_handler.h" +#include "dm_handler.h" +#include "l2c_handler.h" +#include "att_handler.h" +#include "smp_handler.h" +#include "l2c_api.h" +#include "att_api.h" +#include "smp_api.h" +#include "app_api.h" +#include "hci_core.h" +#include "svc_dis.h" +#include "svc_core.h" +#include "sec_api.h" +#include "hci_defs.h" + +extern uint8_t appCodedPhyDemo; + +/*************************************************************************************************/ +/*! + * \brief Initialize stack. + * + * \return None. + */ +/*************************************************************************************************/ +void StackInitDatc(void) +{ + wsfHandlerId_t handlerId; + + SecInit(); + SecAesInit(); + SecCmacInit(); + SecEccInit(); + + handlerId = WsfOsSetNextHandler(HciHandler); + HciHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(DmHandler); + DmDevVsInit(0); + DmDevPrivInit(); + DmConnInit(); + + if (appCodedPhyDemo) + { + DmExtScanInit(); + } + else + { + DmScanInit(); + } + + DmConnMasterInit(); + DmSecInit(); + DmSecLescInit(); + DmPrivInit(); + DmHandlerInit(handlerId); + + L2cInit(); + L2cMasterInit(); + + handlerId = WsfOsSetNextHandler(AttHandler); + AttHandlerInit(handlerId); + AttsInit(); + AttsIndInit(); + AttcInit(); + + handlerId = WsfOsSetNextHandler(SmpHandler); + SmpHandlerInit(handlerId); + SmpiInit(); + SmpiScInit(); + HciSetMaxRxAclLen(256); + + handlerId = WsfOsSetNextHandler(AppHandler); + AppHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(DatcHandler); + DatcHandlerInit(handlerId); +} diff --git a/Examples/MAX32665/BLE_LR_Peripheral/README.md b/Examples/MAX32665/BLE_LR_Peripheral/README.md index 3195687523..d40cab73a7 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/README.md +++ b/Examples/MAX32665/BLE_LR_Peripheral/README.md @@ -2,7 +2,7 @@ This project is a demo for long range advertising. The coded PHY (s=8) is used. The advertising interval is 40 ms. And in each advertising data, it includes 50-byte user data. -The project is modified from the BLE_fit project. +The project is modified from the BLE_fit project. It works with the BLE_LR_Central project. ### Project Usage diff --git a/Examples/MAX32665/BLE_LR_Peripheral/main.c b/Examples/MAX32665/BLE_LR_Peripheral/main.c index 6b44beeb73..20d8ca5195 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/main.c +++ b/Examples/MAX32665/BLE_LR_Peripheral/main.c @@ -73,7 +73,7 @@ /************************************************************************************************** Global Variables **************************************************************************************************/ -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /*! \brief Pool runtime configuration. */ static wsfBufPoolDesc_t mainPoolDesc[] = { { 16, 8 }, { 32, 4 }, { 192, 8 }, { 256, 8 } }; @@ -238,7 +238,7 @@ int main(void) APP_TRACE_INFO0("Long range demo (coded-PHY s=8)"); APP_TRACE_INFO0("==============================="); APP_TRACE_INFO1("BT_VER: %d", BT_VER); - appCodedPhy = 1; + appCodedPhyDemo = 1; #if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1) WsfCsEnter(); diff --git a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c index 90aa969e72..e2ab4c49c7 100644 --- a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c +++ b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c @@ -37,7 +37,7 @@ #include "ll_api.h" -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /*************************************************************************************************/ /*! @@ -60,7 +60,7 @@ void HciLeSetExtScanParamCmd(uint8_t ownAddrType, uint8_t scanFiltPolicy, uint8_ (void)status; // TODO - if (appCodedPhy == 0) + if (appCodedPhyDemo == 0) { WSF_ASSERT(status == LL_SUCCESS); } diff --git a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c index 4f802e6600..32a65709fe 100644 --- a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c +++ b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c @@ -44,7 +44,7 @@ #include "../../../controller/sources/common/sch/sch_int.h" extern void LED_On(unsigned int idx); -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /************************************************************************************************** Local Variables @@ -196,7 +196,7 @@ bool_t hciCoreEvtProcessLlEvt(LlEvt_t *pEvt) // for long range demo, display aux scan data here // 00:18:80 ADI - if (appCodedPhy) + if (appCodedPhyDemo) { if (pMsg->extAdvReportInd.addr[5] == 0 && pMsg->extAdvReportInd.addr[4] == 0x18 && pMsg->extAdvReportInd.addr[3] == 0x80) { diff --git a/Libraries/Cordio/ble-host/sources/stack/dm/dm_adv_ae.c b/Libraries/Cordio/ble-host/sources/stack/dm/dm_adv_ae.c index 781e6477b0..7705ddccb7 100644 --- a/Libraries/Cordio/ble-host/sources/stack/dm/dm_adv_ae.c +++ b/Libraries/Cordio/ble-host/sources/stack/dm/dm_adv_ae.c @@ -94,7 +94,7 @@ typedef struct /************************************************************************************************** Global Variables **************************************************************************************************/ -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /************************************************************************************************** Local Variables @@ -170,7 +170,7 @@ static void dmExtAdvCbInit(uint8_t advHandle) /* initialize advertising set */ dmExtAdvCb[advHandle].advType = DM_ADV_NONE; - if (appCodedPhy) { + if (appCodedPhyDemo) { dmExtAdvCb[advHandle].useLegacyPdu = FALSE; dmExtAdvCb[advHandle].priAdvPhy = HCI_ADV_PHY_LE_CODED; dmExtAdvCb[advHandle].secAdvPhy = HCI_ADV_PHY_LE_CODED; diff --git a/Libraries/Cordio/ble-host/sources/stack/dm/dm_scan_ae.c b/Libraries/Cordio/ble-host/sources/stack/dm/dm_scan_ae.c index 75219b2cd6..55f42ae958 100644 --- a/Libraries/Cordio/ble-host/sources/stack/dm/dm_scan_ae.c +++ b/Libraries/Cordio/ble-host/sources/stack/dm/dm_scan_ae.c @@ -37,6 +37,7 @@ Global Variables **************************************************************************************************/ extern lmgrCtrlBlk_t lmgrCb; +extern uint8_t appCodedPhyDemo; /************************************************************************************************** Local Variables @@ -272,7 +273,10 @@ void dmExtScanReset(void) /*************************************************************************************************/ void dmExtScanHciHandler(hciEvt_t *pEvent) { - DM_TRACE_INFO2("dmExtScanHciHandler: event: %d state: %d", pEvent->hdr.event, dmScanCb.scanState); + if (appCodedPhyDemo == 0) + { + DM_TRACE_INFO2("dmExtScanHciHandler: event: %d state: %d", pEvent->hdr.event, dmScanCb.scanState); + } if (pEvent->hdr.event == HCI_LE_EXT_ADV_REPORT_CBACK_EVT) { diff --git a/Libraries/Cordio/ble-profiles/sources/af/app_main.c b/Libraries/Cordio/ble-profiles/sources/af/app_main.c index ac6f915042..c32764411e 100644 --- a/Libraries/Cordio/ble-profiles/sources/af/app_main.c +++ b/Libraries/Cordio/ble-profiles/sources/af/app_main.c @@ -89,7 +89,7 @@ appReqActCfg_t *pAppMasterReqActCfg = (appReqActCfg_t *) &appReqActCfg; appReqActCfg_t *pAppSlaveReqActCfg = (appReqActCfg_t *) &appReqActCfg; /*! For long distance test, use CODED PHY */ -uint8_t appCodedPhy = 0; +uint8_t appCodedPhyDemo = 0; /*************************************************************************************************/ /*! diff --git a/Libraries/Cordio/ble-profiles/sources/af/app_master_leg.c b/Libraries/Cordio/ble-profiles/sources/af/app_master_leg.c index 06b335aecf..6a15309606 100644 --- a/Libraries/Cordio/ble-profiles/sources/af/app_master_leg.c +++ b/Libraries/Cordio/ble-profiles/sources/af/app_master_leg.c @@ -29,7 +29,7 @@ #include "app_api.h" #include "app_main.h" -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /*************************************************************************************************/ /*! @@ -78,7 +78,7 @@ void AppScanStart(uint8_t mode, uint8_t scanType, uint16_t duration) { if (appMasterScanMode()) { - if (appCodedPhy) + if (appCodedPhyDemo) { DmScanSetInterval(HCI_SCAN_PHY_LE_CODED_BIT, &pAppMasterCfg->scanInterval, &pAppMasterCfg->scanWindow); diff --git a/Libraries/Cordio/ble-profiles/sources/af/app_slave_leg.c b/Libraries/Cordio/ble-profiles/sources/af/app_slave_leg.c index b1581ac1a5..a13a6b59b5 100644 --- a/Libraries/Cordio/ble-profiles/sources/af/app_slave_leg.c +++ b/Libraries/Cordio/ble-profiles/sources/af/app_slave_leg.c @@ -31,7 +31,7 @@ #include "app_api.h" #include "app_main.h" -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /*************************************************************************************************/ /*! @@ -232,7 +232,7 @@ void AppAdvSetData(uint8_t location, uint8_t len, uint8_t *pData) { if (appSlaveAdvMode()) { - if (appCodedPhy) { + if (appCodedPhyDemo) { // TODO: check and set length appAdvSetData(DM_ADV_HANDLE_DEFAULT, location, len, pData, 58, 58); } else { diff --git a/Libraries/Cordio/controller/sources/ble/lctr/lctr_isr_adv_master_ae.c b/Libraries/Cordio/controller/sources/ble/lctr/lctr_isr_adv_master_ae.c index 71d4bd8509..d0328a467e 100644 --- a/Libraries/Cordio/controller/sources/ble/lctr/lctr_isr_adv_master_ae.c +++ b/Libraries/Cordio/controller/sources/ble/lctr/lctr_isr_adv_master_ae.c @@ -48,7 +48,7 @@ /************************************************************************************************** Global Variables **************************************************************************************************/ -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /*! \brief Transitive context (valid only for a single Advertising Event). */ struct @@ -366,7 +366,7 @@ static bool_t lctrExtAdvRptPend(lctrExtScanCtx_t *pExtScanCtx, LlExtAdvReportInd uint64_t hash; lctrAdvRptGenerateExtHash(&hash, pRpt->addrType, BstreamToBda64(pRpt->addr), pRpt->eventType, pRpt->advSID, pExtScanCtx->extAdvHdr.did); - if (lctrAdvRptCheckDuplicate(&lctrMstExtScan.advFilt, hash) && (appCodedPhy == 0)) + if (lctrAdvRptCheckDuplicate(&lctrMstExtScan.advFilt, hash) && (appCodedPhyDemo == 0)) { /* Duplicate found, just exit. */ return FALSE; diff --git a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master.c b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master.c index 7c465ec5f6..0ca4077174 100644 --- a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master.c +++ b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master.c @@ -43,7 +43,7 @@ /*! \brief Scan operational context. */ lctrMstScanCtx_t lctrMstScan; -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /*************************************************************************************************/ /*! @@ -613,7 +613,7 @@ void lctrAdvRptGenerateExtHash(uint64_t *pHash, uint8_t addrType, uint64_t addr, /*************************************************************************************************/ bool_t lctrAdvRptCheckDuplicate(lctrAdvRptFilt_t *pAdvFilt, uint64_t hash) { - if (appCodedPhy) + if (appCodedPhyDemo) { pAdvFilt->addToFiltTbl = TRUE; return TRUE; diff --git a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master_ae.c b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master_ae.c index f1f662b078..e2305d9434 100644 --- a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master_ae.c +++ b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master_ae.c @@ -83,7 +83,7 @@ lctrSyncInfo_t trsfSyncInfo; /*! \brief Active extended scan contexts. */ lctrActiveExtScan_t lctrActiveExtScan; -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /*************************************************************************************************/ /*! @@ -851,7 +851,7 @@ void LctrMstExtScanDefaults(void) lmgrCb.numExtScanPhys = 1; lctrMstExtScanTbl[LCTR_SCAN_PHY_1M]->scanParam = defScanParam; - if (appCodedPhy) + if (appCodedPhyDemo) { lctrMstExtScan.enaPhys = 1 << LCTR_SCAN_PHY_CODED; } @@ -1573,7 +1573,7 @@ lctrPerScanCtx_t *lctrAllocPerScanCtx(void) pMsg->event = LCTR_PER_SCAN_SUP_TIMEOUT; /* Update once PHY is known. */ - if (appCodedPhy) + if (appCodedPhyDemo) { pCtx->bleData.chan.txPhy = pCtx->bleData.chan.rxPhy = BB_PHY_BLE_CODED; } diff --git a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_init_master_ae.c b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_init_master_ae.c index f7da9fa930..0ac71e1aa0 100644 --- a/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_init_master_ae.c +++ b/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_init_master_ae.c @@ -60,7 +60,7 @@ lctrExtScanCtx_t lctrMstExtInitTbl[LCTR_SCAN_PHY_TOTAL]; /*! \brief Extended initiator control block. */ lctrExtInitCtrlBlk_t lctrMstExtInit; -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /*************************************************************************************************/ /*! @@ -564,7 +564,7 @@ void LctrMstExtInitDefaults(void) lmgrCb.numExtScanPhys = 1; - if (appCodedPhy == 0) + if (appCodedPhyDemo == 0) { lctrMstExtInit.enaPhys = 1 << LCTR_SCAN_PHY_1M; } diff --git a/Libraries/Cordio/controller/sources/ble/ll/ll_main_adv_master_ae.c b/Libraries/Cordio/controller/sources/ble/ll/ll_main_adv_master_ae.c index 12c98c7530..1d8a425f64 100644 --- a/Libraries/Cordio/controller/sources/ble/ll/ll_main_adv_master_ae.c +++ b/Libraries/Cordio/controller/sources/ble/ll/ll_main_adv_master_ae.c @@ -33,7 +33,7 @@ #include "wsf_msg.h" #include "wsf_trace.h" -extern uint8_t appCodedPhy; +extern uint8_t appCodedPhyDemo; /*************************************************************************************************/ /*! @@ -171,7 +171,7 @@ void LlExtScanEnable(uint8_t enable, uint8_t filterDup, uint16_t duration, uint1 const unsigned int perMsPerUnit = 1280; unsigned int filterDupMax; - if (appCodedPhy) + if (appCodedPhyDemo) { filterDupMax = LL_SCAN_FILTER_DUP_DISABLE; } From 067d0c2ccb86671f78ebda29401f857b4006221c Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Thu, 21 Sep 2023 10:09:52 -0500 Subject: [PATCH 05/10] Format README.md --- Examples/MAX32665/BLE_LR_Central/README.md | 85 ++++++++++--------- Examples/MAX32665/BLE_LR_Peripheral/README.md | 78 ++++++++--------- 2 files changed, 82 insertions(+), 81 deletions(-) diff --git a/Examples/MAX32665/BLE_LR_Central/README.md b/Examples/MAX32665/BLE_LR_Central/README.md index ccc31cc92d..474a75827d 100644 --- a/Examples/MAX32665/BLE_LR_Central/README.md +++ b/Examples/MAX32665/BLE_LR_Central/README.md @@ -1,17 +1,17 @@ # BLE_LR_Central -This project is a demo for long range scanning. The coded PHY (s=8) is used. It works with the BLE_LR_Peripheral project. +This project is a demo for long range scanning. The coded PHY (s=8) is used. It works with the BLE_LR_Peripheral project. -The project is modified from the BLE_datc. +The project is modified from the BLE_datc. ## Software ### Project Usage -Universal instructions on building, flashing, and debugging this project can be found in the **[MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/)**. +Universal instructions on building, flashing, and debugging this project can be found in the **[MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/)**. ### Required Connections -* Connect a USB cable between the PC and the (USB/PWR - UART) connector. +* Connect a USB cable between the PC and the (USB/PWR - UART) connector. ### Project-Specific Build Notes * Setting `TRACE=1` in [**project.mk**](project.mk) initializes the on-board USB-to-UART adapter for @@ -30,41 +30,42 @@ An arbitrary pin can be entered in the format `pin (connId) passkey` * ***Note***: *Either the client or server can enter the passkey first. The peer device must then match.* ### Logs -terminal: init␍␊ -==========================================␍␊ -Long distance scanner demo (CODED PHY S=8)␍␊ -BT_VER=9␍␊ -==========================================␍␊ -DatcHandlerInit␍␊ -MAC Addr: 00:18:80:00:44:B1␍␊ ->>> Reset complete <<<␍␊ -Database hash updated␍␊ -dmDevPassEvtToDevPriv: event: 12, param: 74, advHandle: 0␍␊ -␍␊ -00:18:80:00:a2:22 BF 02 03 ... 30 31 BF␍␊ -00:18:80:00:a2:22 C0 02 03 ... 30 31 C0␍␊ -00:18:80:00:a2:22 C1 02 03 ... 30 31 C1␍␊ -00:18:80:00:a2:22 C2 02 03 ... 30 31 C2␍␊ -00:18:80:00:a2:22 C3 02 03 ... 30 31 C3␍␊ -00:18:80:00:a2:22 C4 02 03 ... 30 31 C4␍␊ -00:18:80:00:a2:22 C5 02 03 ... 30 31 C5␍␊ -00:18:80:00:a2:22 C6 02 03 ... 30 31 C6␍␊ -00:18:80:00:a2:22 C7 02 03 ... 30 31 C7␍␊ -00:18:80:00:a2:22 C8 02 03 ... 30 31 C8␍␊ -00:18:80:00:a2:22 C9 02 03 ... 30 31 C9␍␊ -00:18:80:00:a2:22 CA 02 03 ... 30 31 CA␍␊ -00:18:80:00:a2:22 CB 02 03 ... 30 31 CB␍␊ -00:18:80:00:a2:22 CC 02 03 ... 30 31 CC␍␊ -00:18:80:00:a2:22 CD 02 03 ... 30 31 CD␍␊ -00:18:80:00:a2:22 CE 02 03 ... 30 31 CE␍␊ -00:18:80:00:a2:22 CF 02 03 ... 30 31 CF␍␊ -00:18:80:00:a2:22 D0 02 03 ... 30 31 D0␍␊ -00:18:80:00:a2:22 D1 02 03 ... 30 31 D1␍␊ -00:18:80:00:a2:22 D2 02 03 ... 30 31 D2␍␊ -00:18:80:00:a2:22 D3 02 03 ... 30 31 D3␍␊ -00:18:80:00:a2:22 D4 02 03 ... 30 31 D4␍␊ -00:18:80:00:a2:22 D5 02 03 ... 30 31 D5␍␊ -00:18:80:00:a2:22 D6 02 03 ... 30 31 D6␍␊ -00:18:80:00:a2:22 D7 02 03 ... 30 31 D7␍␊ -00:18:80:00:a2:22 D8 02 03 ... 30 31 D8␍␊ -00:18:80:00:a2:22 D9 02 03 ... 30 31 D9␍␊ \ No newline at end of file +terminal: init␍␊ +==========================================␍␊ +Long distance scanner demo (CODED PHY S=8)␍␊ +BT_VER=9␍␊ +==========================================␍␊ +DatcHandlerInit␍␊ +MAC Addr: 00:18:80:00:44:B1␍␊ +>>> Reset complete <<<␍␊ +Database hash updated␍␊ +dmDevPassEvtToDevPriv: event: 12, param: 74, advHandle: 0␍␊ +␍␊ +00:18:80:00:a2:22 BF 02 03 ... 30 31 BF␍␊ +00:18:80:00:a2:22 C0 02 03 ... 30 31 C0␍␊ +00:18:80:00:a2:22 C1 02 03 ... 30 31 C1␍␊ +00:18:80:00:a2:22 C2 02 03 ... 30 31 C2␍␊ +00:18:80:00:a2:22 C3 02 03 ... 30 31 C3␍␊ +00:18:80:00:a2:22 C4 02 03 ... 30 31 C4␍␊ +00:18:80:00:a2:22 C5 02 03 ... 30 31 C5␍␊ +00:18:80:00:a2:22 C6 02 03 ... 30 31 C6␍␊ +00:18:80:00:a2:22 C7 02 03 ... 30 31 C7␍␊ +00:18:80:00:a2:22 C8 02 03 ... 30 31 C8␍␊ +00:18:80:00:a2:22 C9 02 03 ... 30 31 C9␍␊ +00:18:80:00:a2:22 CA 02 03 ... 30 31 CA␍␊ +00:18:80:00:a2:22 CB 02 03 ... 30 31 CB␍␊ +00:18:80:00:a2:22 CC 02 03 ... 30 31 CC␍␊ +00:18:80:00:a2:22 CD 02 03 ... 30 31 CD␍␊ +00:18:80:00:a2:22 CE 02 03 ... 30 31 CE␍␊ +00:18:80:00:a2:22 CF 02 03 ... 30 31 CF␍␊ +00:18:80:00:a2:22 D0 02 03 ... 30 31 D0␍␊ +00:18:80:00:a2:22 D1 02 03 ... 30 31 D1␍␊ +00:18:80:00:a2:22 D2 02 03 ... 30 31 D2␍␊ +00:18:80:00:a2:22 D3 02 03 ... 30 31 D3␍␊ +00:18:80:00:a2:22 D4 02 03 ... 30 31 D4␍␊ +00:18:80:00:a2:22 D5 02 03 ... 30 31 D5␍␊ +00:18:80:00:a2:22 D6 02 03 ... 30 31 D6␍␊ +00:18:80:00:a2:22 D7 02 03 ... 30 31 D7␍␊ +00:18:80:00:a2:22 D8 02 03 ... 30 31 D8␍␊ +00:18:80:00:a2:22 D9 02 03 ... 30 31 D9␍␊ +... \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Peripheral/README.md b/Examples/MAX32665/BLE_LR_Peripheral/README.md index d40cab73a7..86b8294467 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/README.md +++ b/Examples/MAX32665/BLE_LR_Peripheral/README.md @@ -1,23 +1,23 @@ # BLE_LR_Peripheral -This project is a demo for long range advertising. The coded PHY (s=8) is used. The advertising interval is 40 ms. And in each advertising data, it includes 50-byte user data. +This project is a demo for long range advertising. The coded PHY (s=8) is used. The advertising interval is 40 ms. And in each advertising data, it includes 50-byte user data. -The project is modified from the BLE_fit project. It works with the BLE_LR_Central project. +The project is modified from the BLE_fit project. It works with the BLE_LR_Central project. ### Project Usage -Universal instructions on building, flashing, and debugging this project can be found in the **[MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/)**. +Universal instructions on building, flashing, and debugging this project can be found in the **[MSDK User Guide](https://analog-devices-msdk.github.io/msdk/USERGUIDE/)**. ### Required Connections -If using the Standard EV Kit board (EvKit\_V1): -- Connect a USB cable between the PC and the CN2 (USB/PWR - UART) connector. -- Close jumpers JP7 (RX_EN) and JP8 (TX_EN). -- Close jumpers JP5 (LED1 EN) and JP6 (LED2 EN). +If using the Standard EV Kit board (EvKit\_V1): +- Connect a USB cable between the PC and the CN2 (USB/PWR - UART) connector. +- Close jumpers JP7 (RX_EN) and JP8 (TX_EN). +- Close jumpers JP5 (LED1 EN) and JP6 (LED2 EN). ### Project-Specific Build Notes -* Setting `TRACE=1` in [**project.mk**](project.mk) initializes the on-board USB-to-UART adapter for -viewing the trace messages and interacting with the application. Port uses settings: +* Setting `TRACE=1` in [**project.mk**](project.mk) initializes the on-board USB-to-UART adapter for +viewing the trace messages and interacting with the application. Port uses settings: - Baud : 115200 - Char size : 8 - Parity : None @@ -26,34 +26,34 @@ viewing the trace messages and interacting with the application. Port uses setti - SW Flow Control : No ### Log -terminal: init␍␊ -===============================␍␊ -Long range demo (coded-PHY s=8)␍␊ -===============================␍␊ -BT_VER: 9␍␊ -DmExtAdvInit␍␊ -FitHandlerInit␍␊ -MAC Addr: 00:18:80:00:A2:22␍␊ -Adv local name: LongRang␍␊ -Fit got evt 32␍␊ ->>> Reset complete <<<␍␊ -dmDevPassEvtToDevPriv: event: 14, param: 2, advHandle: 0␍␊ -dmExtAdvHciHandler: event: 55␍␊ -dmDevPassEvtToDevPriv: event: 12, param: 71, advHandle: 0␍␊ -Fit got evt 71␍␊ ->>> Advertising sets started <<<␍␊ -Fit got evt 21␍␊ -Database hash updated␍␊ -02␍␊ -03␍␊ -Fit got evt 52␍␊ -04␍␊ -05␍␊ -06␍␊ -07␍␊ -08␍␊ -09␍␊ -0A␍␊ -0B␍␊ -... +terminal: init␍␊ +===============================␍␊ +Long range demo (coded-PHY s=8)␍␊ +===============================␍␊ +BT_VER: 9␍␊ +DmExtAdvInit␍␊ +FitHandlerInit␍␊ +MAC Addr: 00:18:80:00:A2:22␍␊ +Adv local name: LongRang␍␊ +Fit got evt 32␍␊ +>>> Reset complete <<<␍␊ +dmDevPassEvtToDevPriv: event: 14, param: 2, advHandle: 0␍␊ +dmExtAdvHciHandler: event: 55␍␊ +dmDevPassEvtToDevPriv: event: 12, param: 71, advHandle: 0␍␊ +Fit got evt 71␍␊ +>>> Advertising sets started <<<␍␊ +Fit got evt 21␍␊ +Database hash updated␍␊ +02␍␊ +03␍␊ +Fit got evt 52␍␊ +04␍␊ +05␍␊ +06␍␊ +07␍␊ +08␍␊ +09␍␊ +0A␍␊ +0B␍␊ +... From dd723d37b35feef055767fe66f9e399c2326142c Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Thu, 21 Sep 2023 16:10:50 -0500 Subject: [PATCH 06/10] changed file names and formats --- Examples/MAX32665/BLE_LR_Central/README.md | 4 +- .../{datc_api.h => lr_central_api.h} | 6 ++- .../{datc_main.c => lr_central_main.c} | 16 +++---- Examples/MAX32665/BLE_LR_Central/main.c | 7 ++-- .../{stack_datc.c => stack_lr_central.c} | 15 ++++--- Examples/MAX32665/BLE_LR_Peripheral/README.md | 3 +- .../{fit_api.h => lr_periph_api.h} | 6 ++- .../{fit_main.c => lr_periph_main.c} | 24 +++++++---- Examples/MAX32665/BLE_LR_Peripheral/main.c | 8 ++-- .../{stack_fit.c => stack_lr_periph.c} | 42 +++++++++---------- .../sources/hci/exactle/hci_core_ps.c | 3 +- Libraries/Cordio/wsf/include/wsf_os.h | 1 - .../wsf/sources/targets/baremetal/wsf_msg.c | 8 ---- .../wsf/sources/targets/baremetal/wsf_os.c | 1 - 14 files changed, 75 insertions(+), 69 deletions(-) rename Examples/MAX32665/BLE_LR_Central/{datc_api.h => lr_central_api.h} (93%) rename Examples/MAX32665/BLE_LR_Central/{datc_main.c => lr_central_main.c} (99%) rename Examples/MAX32665/BLE_LR_Central/{stack_datc.c => stack_lr_central.c} (92%) rename Examples/MAX32665/BLE_LR_Peripheral/{fit_api.h => lr_periph_api.h} (95%) rename Examples/MAX32665/BLE_LR_Peripheral/{fit_main.c => lr_periph_main.c} (98%) rename Examples/MAX32665/BLE_LR_Peripheral/{stack_fit.c => stack_lr_periph.c} (69%) diff --git a/Examples/MAX32665/BLE_LR_Central/README.md b/Examples/MAX32665/BLE_LR_Central/README.md index 474a75827d..4fbf21c093 100644 --- a/Examples/MAX32665/BLE_LR_Central/README.md +++ b/Examples/MAX32665/BLE_LR_Central/README.md @@ -30,6 +30,7 @@ An arbitrary pin can be entered in the format `pin (connId) passkey` * ***Note***: *Either the client or server can enter the passkey first. The peer device must then match.* ### Logs +``` terminal: init␍␊ ==========================================␍␊ Long distance scanner demo (CODED PHY S=8)␍␊ @@ -68,4 +69,5 @@ dmDevPassEvtToDevPriv: event: 12, param: 74, advHandle: 0␍␊ 00:18:80:00:a2:22 D7 02 03 ... 30 31 D7␍␊ 00:18:80:00:a2:22 D8 02 03 ... 30 31 D8␍␊ 00:18:80:00:a2:22 D9 02 03 ... 30 31 D9␍␊ -... \ No newline at end of file +... +``` \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Central/datc_api.h b/Examples/MAX32665/BLE_LR_Central/lr_central_api.h similarity index 93% rename from Examples/MAX32665/BLE_LR_Central/datc_api.h rename to Examples/MAX32665/BLE_LR_Central/lr_central_api.h index cb4ee48c32..bf230edadc 100644 --- a/Examples/MAX32665/BLE_LR_Central/datc_api.h +++ b/Examples/MAX32665/BLE_LR_Central/lr_central_api.h @@ -2,11 +2,13 @@ /*! * \file * - * \brief Proprietary data transfer client sample application. + * \brief Long range central device demo interface * * Copyright (c) 2012-2018 Arm Ltd. All Rights Reserved. * * Copyright (c) 2019 Packetcraft, Inc. + * + * Partial Copyright (c) 2023 Analog Devices, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,4 +71,4 @@ void DatcHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); }; #endif -#endif // EXAMPLES_MAX32665_BLE_LR_CENTRAL_API_H_ +#endif // EXAMPLES_MAX32665_BLE_LR_CENTRAL_API_H_ diff --git a/Examples/MAX32665/BLE_LR_Central/datc_main.c b/Examples/MAX32665/BLE_LR_Central/lr_central_main.c similarity index 99% rename from Examples/MAX32665/BLE_LR_Central/datc_main.c rename to Examples/MAX32665/BLE_LR_Central/lr_central_main.c index c011c4c9da..de247b8a38 100644 --- a/Examples/MAX32665/BLE_LR_Central/datc_main.c +++ b/Examples/MAX32665/BLE_LR_Central/lr_central_main.c @@ -2,7 +2,7 @@ /*! * \file * - * \brief Proprietary data transfer client sample application for Nordic-ble. + * \brief Long range application on a central device * * Copyright (c) 2012-2019 Arm Ltd. All Rights Reserved. * @@ -46,7 +46,7 @@ #include "svc_ch.h" #include "gatt/gatt_api.h" #include "wpc/wpc_api.h" -#include "datc_api.h" +#include "lr_central_api.h" #include "util/calc128.h" #include "pal_btn.h" #include "pal_led.h" @@ -71,11 +71,11 @@ Macros #define SPEED_TEST_PACKET_LEN 238 #define SPEED_TEST_TMR MXC_TMR3 -#define SCAN_START_EVT 0x99 -#define USER_APP_TMR_EVT 0x9A +#define SCAN_START_EVT 0x99 +#define USER_APP_TMR_EVT 0x9A -#define SCAN_START_MS 500 -#define USER_APP_TMR_MS 5000 +#define SCAN_START_MS 500 +#define USER_APP_TMR_MS 5000 /* Down sample the number of scan reports we print */ #define SCAN_REPORT_DOWN_SAMPLE 20 @@ -386,7 +386,7 @@ static void datcDmCback(dmEvt_t *pDmEvt) pMsg->scanReport.pData = (uint8_t *)((uint8_t *)pMsg + len); memcpy(pMsg->scanReport.pData, pDmEvt->scanReport.pData, reportLen); } - + WsfMsgSend(datcCb.handlerId, pMsg); } } @@ -1214,7 +1214,7 @@ static void datcProcMsg(dmEvt_t *pMsg) case USER_APP_TMR_EVT: WsfTimerStartMs(&userAppTmr, USER_APP_TMR_MS); - LED_Off(0); // turn off red led + LED_Off(0); // turn off red led break; default: diff --git a/Examples/MAX32665/BLE_LR_Central/main.c b/Examples/MAX32665/BLE_LR_Central/main.c index cf50a9eeda..edbc6e005a 100644 --- a/Examples/MAX32665/BLE_LR_Central/main.c +++ b/Examples/MAX32665/BLE_LR_Central/main.c @@ -1,12 +1,14 @@ /*************************************************************************************************/ /*! * @file main.c - * @brief Simple BLE Data Client for unformatted data exchange. + * @brief Long range demo on a central device * * Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved. * * Copyright (c) 2019 Packetcraft, Inc. * +* Partial Copyright (c) 2023 Analog Devices, Inc. +* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,7 +33,6 @@ #include "wsf_heap.h" #include "wsf_cs.h" #include "wsf_timer.h" -#include "wsf_trace.h" #include "wsf_os.h" #include "sec_api.h" @@ -59,7 +60,7 @@ #include "pal_timer.h" #include "pal_sys.h" -#include "datc_api.h" +#include "lr_central_api.h" #include "app_ui.h" /************************************************************************************************** diff --git a/Examples/MAX32665/BLE_LR_Central/stack_datc.c b/Examples/MAX32665/BLE_LR_Central/stack_lr_central.c similarity index 92% rename from Examples/MAX32665/BLE_LR_Central/stack_datc.c rename to Examples/MAX32665/BLE_LR_Central/stack_lr_central.c index 0a4346f441..e6d416a7dc 100644 --- a/Examples/MAX32665/BLE_LR_Central/stack_datc.c +++ b/Examples/MAX32665/BLE_LR_Central/stack_lr_central.c @@ -2,11 +2,13 @@ /*! * \file * - * \brief Stack initialization for datc. + * \brief Stack initialization for long range central. * * Copyright (c) 2016-2019 Arm Ltd. All Rights Reserved. * * Copyright (c) 2019 Packetcraft, Inc. + * + * Partial Copyright (c) 2023 Analog Devices, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +28,7 @@ #include "wsf_os.h" #include "util/bstream.h" -#include "datc_api.h" +#include "lr_central_api.h" #include "hci_handler.h" #include "dm_handler.h" @@ -69,13 +71,10 @@ void StackInitDatc(void) DmDevPrivInit(); DmConnInit(); - if (appCodedPhyDemo) - { + if (appCodedPhyDemo) { DmExtScanInit(); - } - else - { - DmScanInit(); + } else { + DmScanInit(); } DmConnMasterInit(); diff --git a/Examples/MAX32665/BLE_LR_Peripheral/README.md b/Examples/MAX32665/BLE_LR_Peripheral/README.md index 86b8294467..485671a6e0 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/README.md +++ b/Examples/MAX32665/BLE_LR_Peripheral/README.md @@ -26,6 +26,7 @@ viewing the trace messages and interacting with the application. Port uses setti - SW Flow Control : No ### Log +``` terminal: init␍␊ ===============================␍␊ Long range demo (coded-PHY s=8)␍␊ @@ -56,4 +57,4 @@ Fit got evt 52␍␊ 0A␍␊ 0B␍␊ ... - +``` diff --git a/Examples/MAX32665/BLE_LR_Peripheral/fit_api.h b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h similarity index 95% rename from Examples/MAX32665/BLE_LR_Peripheral/fit_api.h rename to Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h index 11f4dc509e..5f3b6bd200 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/fit_api.h +++ b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h @@ -2,11 +2,13 @@ /*! * \file * - * \brief Fitness sample application interface. + * \brief Long range application interface. * * Copyright (c) 2011-2018 Arm Ltd. All Rights Reserved. * * Copyright (c) 2019 Packetcraft, Inc. + * + * Paritial Copyright (c) 2023 Analog Devices, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +40,7 @@ extern "C" { #define FIT_CONN_MAX 1 #endif -#define DEFAULT_TX_POWER 4 /* dBm */ +#define DEFAULT_TX_POWER 4 /* dBm */ /************************************************************************************************** Function Declarations diff --git a/Examples/MAX32665/BLE_LR_Peripheral/fit_main.c b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c similarity index 98% rename from Examples/MAX32665/BLE_LR_Peripheral/fit_main.c rename to Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c index 20a721686b..3a15401d59 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/fit_main.c +++ b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c @@ -2,13 +2,14 @@ /*! * \file * - * \brief Fitness sample application for the following profiles: - * Heart Rate profile + * \brief Long range application demo * * Copyright (c) 2011-2019 Arm Ltd. All Rights Reserved. * * Copyright (c) 2019 Packetcraft, Inc. * + * Paritial Copyright (c) 2023 Analog Devices, Inc. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -23,6 +24,7 @@ */ /*************************************************************************************************/ + #include #include "wsf_types.h" #include "util/bstream.h" @@ -47,7 +49,7 @@ #include "bas/bas_api.h" #include "hrps/hrps_api.h" #include "rscp/rscp_api.h" -#include "fit_api.h" +#include "lr_periph_api.h" #include "pal_btn.h" #include "tmr.h" @@ -96,8 +98,8 @@ typedef union { /*! configurable parameters for advertising */ static const appAdvCfg_t fitAdvCfg = { - { 0, 0, 0 }, /*! Advertising durations in ms */ - { 64, 0, 0 } /*! Advertising intervals in 0.625 ms units */ + {0, 0, 0}, /*! Advertising durations in ms */ + {64, 0, 0} /*! Advertising intervals in 0.625 ms units */ }; /*! configurable parameters for slave */ @@ -178,7 +180,14 @@ static const uint8_t fitScanDataDisc[] = { /*! device name */ 9, /*! length */ DM_ADV_TYPE_LOCAL_NAME, /*! AD type */ - 'L', 'o', 'n', 'g', 'R', 'a', 'n', 'g' + 'L', + 'o', + 'n', + 'g', + 'R', + 'a', + 'n', + 'g' }; /************************************************************************************************** @@ -407,8 +416,7 @@ static void fitClose(fitMsg_t *pMsg) static void fitSetup(fitMsg_t *pMsg) { /* set advertising and scan response data for discoverable mode */ - for (uint8_t i = 0; i < USER_SPEC_ADV_DATA_LEN; ++i) - { + for (uint8_t i = 0; i < USER_SPEC_ADV_DATA_LEN; ++i) { fitAdvDataDisc[8 + i] = i + 1; } AppAdvSetData(APP_ADV_DATA_DISCOVERABLE, sizeof(fitAdvDataDisc), (uint8_t *)fitAdvDataDisc); diff --git a/Examples/MAX32665/BLE_LR_Peripheral/main.c b/Examples/MAX32665/BLE_LR_Peripheral/main.c index 20d8ca5195..7b2d15bc88 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/main.c +++ b/Examples/MAX32665/BLE_LR_Peripheral/main.c @@ -1,12 +1,14 @@ /*************************************************************************************************/ /*! * @file main.c - * @brief Bluetooth fitness device. Showcases heart rate, battery level, running speed and cadence. + * @brief BLE long range application demo on a peripheral device. * * Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved. * * Copyright (c) 2019 Packetcraft, Inc. * +* Paritial Copyright (c) 2023 Analog Devices, Inc. +* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -60,7 +62,7 @@ #include "pal_sys.h" #include "pal_uart.h" -#include "fit_api.h" +#include "lr_periph_api.h" #include "app_ui.h" /************************************************************************************************** @@ -233,7 +235,7 @@ int main(void) mainWsfInit(); AppTerminalInit(); - + APP_TRACE_INFO0("==============================="); APP_TRACE_INFO0("Long range demo (coded-PHY s=8)"); APP_TRACE_INFO0("==============================="); diff --git a/Examples/MAX32665/BLE_LR_Peripheral/stack_fit.c b/Examples/MAX32665/BLE_LR_Peripheral/stack_lr_periph.c similarity index 69% rename from Examples/MAX32665/BLE_LR_Peripheral/stack_fit.c rename to Examples/MAX32665/BLE_LR_Peripheral/stack_lr_periph.c index 84759d50d0..e124ab46a6 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/stack_fit.c +++ b/Examples/MAX32665/BLE_LR_Peripheral/stack_lr_periph.c @@ -2,12 +2,14 @@ /*! * \file * - * \brief Stack initialization for dats. + * \brief Stack initialization for long range peripheral. * * Copyright (c) 2016-2019 Arm Ltd. All Rights Reserved. * * Copyright (c) 2019 Packetcraft, Inc. * + * Paritial Copyright (c) 2023 Analog Devices, Inc. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -27,7 +29,7 @@ #include "wsf_trace.h" #include "util/bstream.h" -#include "fit_api.h" +#include "lr_periph_api.h" #include "hci_handler.h" #include "dm_handler.h" @@ -44,22 +46,21 @@ #include "sec_api.h" #include "hci_defs.h" -typedef struct -{ - uint8_t advType; /*!< Advertising type. */ - bool_t useLegacyPdu; /*!< Use legacy advertising PDUs. */ - bool_t omitAdvAddr; /*!< Omit advertiser's address from all PDUs. */ - bool_t incTxPwr; /*!< Include TxPower in extended header of advertising PDU. */ - int8_t advTxPwr; /*!< Advertising Tx Power. */ - uint8_t priAdvPhy; /*!< Primary Advertising PHY. */ - uint8_t secAdvMaxSkip; /*!< Secondary Advertising Maximum Skip. */ - uint8_t secAdvPhy; /*!< Secondary Advertising PHY. */ - bool_t scanReqNotifEna; /*!< Scan request notification enable. */ - uint8_t fragPref; /*!< Fragment preference for advertising data. */ - uint8_t advSid; /*!< Advertising Sid. */ - bool_t advDataSet; /*!< TRUE if extended adv data has been set. */ - bool_t scanDataSet; /*!< TRUE if extended scan data has been set. */ - uint8_t connId; /*!< Connection identifier (used by directed advertising). */ +typedef struct { + uint8_t advType; /*!< Advertising type. */ + bool_t useLegacyPdu; /*!< Use legacy advertising PDUs. */ + bool_t omitAdvAddr; /*!< Omit advertiser's address from all PDUs. */ + bool_t incTxPwr; /*!< Include TxPower in extended header of advertising PDU. */ + int8_t advTxPwr; /*!< Advertising Tx Power. */ + uint8_t priAdvPhy; /*!< Primary Advertising PHY. */ + uint8_t secAdvMaxSkip; /*!< Secondary Advertising Maximum Skip. */ + uint8_t secAdvPhy; /*!< Secondary Advertising PHY. */ + bool_t scanReqNotifEna; /*!< Scan request notification enable. */ + uint8_t fragPref; /*!< Fragment preference for advertising data. */ + uint8_t advSid; /*!< Advertising Sid. */ + bool_t advDataSet; /*!< TRUE if extended adv data has been set. */ + bool_t scanDataSet; /*!< TRUE if extended scan data has been set. */ + uint8_t connId; /*!< Connection identifier (used by directed advertising). */ } dmExtAdvCb_t; extern dmExtAdvCb_t dmExtAdvCb[]; @@ -90,14 +91,13 @@ void StackInitFit(void) APP_TRACE_INFO0("DmExtAdvInit"); DmExtAdvInit(); - for (uint8_t i = 0; i < DM_NUM_ADV_SETS; i++) - { + for (uint8_t i = 0; i < DM_NUM_ADV_SETS; i++) { // dmExtAdvCbInit(i); dmExtAdvCb[i].useLegacyPdu = FALSE; dmExtAdvCb[i].priAdvPhy = HCI_ADV_PHY_LE_CODED; dmExtAdvCb[i].secAdvPhy = HCI_ADV_PHY_LE_CODED; } - + DmExtConnSlaveInit(); #else DmAdvInit(); diff --git a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c index 32a65709fe..a901e06738 100644 --- a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c +++ b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_core_ps.c @@ -41,7 +41,6 @@ #include "hci_main.h" #include "hci_core_ps.h" #include "pal_led.h" -#include "../../../controller/sources/common/sch/sch_int.h" extern void LED_On(unsigned int idx); extern uint8_t appCodedPhyDemo; @@ -203,7 +202,7 @@ bool_t hciCoreEvtProcessLlEvt(LlEvt_t *pEvt) LED_On(0); // 0: red led ID } - printf("\n%02x:%02x:%02x:%02x:%02x:%02x %02X %02X %02X ... %02X %02X %02X", + WsfTrace("\n%02x:%02x:%02x:%02x:%02x:%02x %02X %02X %02X ... %02X %02X %02X", pMsg->extAdvReportInd.addr[5], pMsg->extAdvReportInd.addr[4], pMsg->extAdvReportInd.addr[3], pMsg->extAdvReportInd.addr[2], pMsg->extAdvReportInd.addr[1], pMsg->extAdvReportInd.addr[0], pMsg->extAdvReportInd.pData[8 + 0], diff --git a/Libraries/Cordio/wsf/include/wsf_os.h b/Libraries/Cordio/wsf/include/wsf_os.h index df2e1f5ac9..1c74bc0780 100644 --- a/Libraries/Cordio/wsf/include/wsf_os.h +++ b/Libraries/Cordio/wsf/include/wsf_os.h @@ -116,7 +116,6 @@ typedef struct uint16_t param; /*!< \brief General purpose parameter passed to event handler */ uint8_t event; /*!< \brief General purpose event value passed to event handler */ uint8_t status; /*!< \brief General purpose status value passed to event handler */ - uint8_t msg_ndx; /*!< \brief message index */ } wsfMsgHdr_t; /************************************************************************************************** diff --git a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c index 806049aa00..cbe21eac70 100644 --- a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c +++ b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c @@ -42,8 +42,6 @@ typedef struct wsfMsg_tag wsfHandlerId_t handlerId; } wsfMsg_t; -uint8_t msg_ndx = 0; - /*************************************************************************************************/ /*! * \brief Allocate a data message buffer to be sent with WsfMsgSend(). @@ -125,12 +123,6 @@ void WsfMsgSend(wsfHandlerId_t handlerId, void *pMsg) /*************************************************************************************************/ void WsfMsgEnq(wsfQueue_t *pQueue, wsfHandlerId_t handlerId, void *pMsg) { - /* - wsfMsgHdr_t *h = (wsfMsgHdr_t *)pMsg; - h->msg_ndx = ++msg_ndx; - WsfTrace("msg_enq %03d hndrId=%u p=0x%04X evt=%03d st=%d", h->msg_ndx, handlerId, h->param, h->event, h->status); - */ - wsfMsg_t *p; WSF_ASSERT(pMsg != NULL); diff --git a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c index d557736d3a..37b9e1613b 100644 --- a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c +++ b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c @@ -75,7 +75,6 @@ WSF_CT_ASSERT(sizeof(uint32_t) == 4); /************************************************************************************************** Global Variables **************************************************************************************************/ -extern uint8_t msg_ndx; /************************************************************************************************** Local Variables From 4816e3a5224f9f927b5fc8f4de39fe08a912f3fc Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Thu, 21 Sep 2023 16:32:05 -0500 Subject: [PATCH 07/10] Fixed wsf_os build error and formats --- .../MAX32665/BLE_LR_Central/lr_central_api.h | 6 +++--- .../MAX32665/BLE_LR_Peripheral/lr_periph_api.h | 6 +++--- .../MAX32665/BLE_LR_Peripheral/lr_periph_main.c | 4 ++-- Libraries/Cordio/wsf/include/wsf_os.h | 17 ----------------- 4 files changed, 8 insertions(+), 25 deletions(-) diff --git a/Examples/MAX32665/BLE_LR_Central/lr_central_api.h b/Examples/MAX32665/BLE_LR_Central/lr_central_api.h index bf230edadc..87b7444964 100644 --- a/Examples/MAX32665/BLE_LR_Central/lr_central_api.h +++ b/Examples/MAX32665/BLE_LR_Central/lr_central_api.h @@ -23,8 +23,8 @@ * limitations under the License. */ /*************************************************************************************************/ -#ifndef EXAMPLES_MAX32665_BLE_LR_CENTRAL_API_H_ -#define EXAMPLES_MAX32665_BLE_LR_CENTRAL_API_H_ +#ifndef EXAMPLES_MAX32665_BLE_LR_CENTRAL_LR_CENTRAL_API_H_ +#define EXAMPLES_MAX32665_BLE_LR_CENTRAL_LR_CENTRAL_API_H_ #include "wsf_os.h" @@ -71,4 +71,4 @@ void DatcHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); }; #endif -#endif // EXAMPLES_MAX32665_BLE_LR_CENTRAL_API_H_ +#endif // EXAMPLES_MAX32665_BLE_LR_CENTRAL_LR_CENTRAL_API_H_ \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h index 5f3b6bd200..329d6bb52d 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h +++ b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h @@ -23,8 +23,8 @@ * limitations under the License. */ /*************************************************************************************************/ -#ifndef EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_API_H_ -#define EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_API_H_ +#ifndef EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_LR_PERIPH_API_H_ +#define EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_LR_PERIPH_API_H_ #include "wsf_os.h" @@ -81,4 +81,4 @@ void FitHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); }; #endif -#endif // EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_API_H_ +#endif // EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_LR_PERIPH_API_H_ \ No newline at end of file diff --git a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c index 3a15401d59..2d50ffd3f5 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c +++ b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c @@ -98,8 +98,8 @@ typedef union { /*! configurable parameters for advertising */ static const appAdvCfg_t fitAdvCfg = { - {0, 0, 0}, /*! Advertising durations in ms */ - {64, 0, 0} /*! Advertising intervals in 0.625 ms units */ + { 0, 0, 0 }, /*! Advertising durations in ms */ + { 64, 0, 0 } /*! Advertising intervals in 0.625 ms units */ }; /*! configurable parameters for slave */ diff --git a/Libraries/Cordio/wsf/include/wsf_os.h b/Libraries/Cordio/wsf/include/wsf_os.h index 1c74bc0780..1d711d4c4d 100644 --- a/Libraries/Cordio/wsf/include/wsf_os.h +++ b/Libraries/Cordio/wsf/include/wsf_os.h @@ -132,23 +132,6 @@ typedef struct /*************************************************************************************************/ typedef void (*wsfEventHandler_t)(wsfEventMask_t event, wsfMsgHdr_t *pMsg); -/*! \brief Task structure */ -typedef struct -{ - wsfEventHandler_t handler[WSF_MAX_HANDLERS]; - wsfEventMask_t handlerEventMask[WSF_MAX_HANDLERS]; - wsfQueue_t msgQueue; - wsfTaskEvent_t taskEventMask; - uint8_t numHandler; -} wsfOsTask_t; - -/*! \brief OS structure */ -typedef struct -{ - wsfOsTask_t task; - WsfOsIdleCheckFunc_t sleepCheckFuncs[WSF_OS_MAX_SERVICE_FUNCTIONS]; - uint8_t numFunc; -} wsfOs_t; /************************************************************************************************** External Variables From e57f678d9a92549e0a5e22095ec276d2c20d9e28 Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Fri, 22 Sep 2023 10:08:07 -0500 Subject: [PATCH 08/10] Fixed wsf missing types --- Examples/MAX32665/BLE_LR_Peripheral/main.c | 1 + Libraries/Cordio/wsf/include/wsf_os.h | 8 -------- .../wsf/sources/targets/baremetal/wsf_msg.c | 6 ------ .../wsf/sources/targets/baremetal/wsf_os.c | 20 ++++++++++++++++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Examples/MAX32665/BLE_LR_Peripheral/main.c b/Examples/MAX32665/BLE_LR_Peripheral/main.c index 7b2d15bc88..1ba1a53a28 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/main.c +++ b/Examples/MAX32665/BLE_LR_Peripheral/main.c @@ -23,6 +23,7 @@ */ /*************************************************************************************************/ + #include #include #include "wsf_types.h" diff --git a/Libraries/Cordio/wsf/include/wsf_os.h b/Libraries/Cordio/wsf/include/wsf_os.h index 1d711d4c4d..76a81a7b2a 100644 --- a/Libraries/Cordio/wsf/include/wsf_os.h +++ b/Libraries/Cordio/wsf/include/wsf_os.h @@ -132,14 +132,6 @@ typedef struct /*************************************************************************************************/ typedef void (*wsfEventHandler_t)(wsfEventMask_t event, wsfMsgHdr_t *pMsg); - -/************************************************************************************************** - External Variables -**************************************************************************************************/ - -/*! \brief Diagnostic Task Identifier */ -extern wsfHandlerId_t WsfActiveHandler; - /************************************************************************************************** Function Declarations **************************************************************************************************/ diff --git a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c index cbe21eac70..16725f3805 100644 --- a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c +++ b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_msg.c @@ -156,12 +156,6 @@ void *WsfMsgDeq(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId) /* hide header */ pMsg++; - - /* - uint8_t *pData = (uint8_t *)pMsg; - - WsfTrace("msg_deq %03d hndrId=%d p=0x%02X%02X evt=%03d st=%d", pData[4], *pHandlerId, pData[1], pData[0], pData[2], pData[3]); - */ } return pMsg; diff --git a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c index 37b9e1613b..52c579b8ef 100644 --- a/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c +++ b/Libraries/Cordio/wsf/sources/targets/baremetal/wsf_os.c @@ -72,9 +72,23 @@ WSF_CT_ASSERT(sizeof(uint32_t) == 4); Data Types **************************************************************************************************/ -/************************************************************************************************** - Global Variables -**************************************************************************************************/ +/*! \brief Task structure */ +typedef struct +{ + wsfEventHandler_t handler[WSF_MAX_HANDLERS]; + wsfEventMask_t handlerEventMask[WSF_MAX_HANDLERS]; + wsfQueue_t msgQueue; + wsfTaskEvent_t taskEventMask; + uint8_t numHandler; +} wsfOsTask_t; + +/*! \brief OS structure */ +typedef struct +{ + wsfOsTask_t task; + WsfOsIdleCheckFunc_t sleepCheckFuncs[WSF_OS_MAX_SERVICE_FUNCTIONS]; + uint8_t numFunc; +} wsfOs_t; /************************************************************************************************** Local Variables From 1f4d563a4433474b7ff1cc1dae54503e911dc990 Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Fri, 22 Sep 2023 10:54:00 -0500 Subject: [PATCH 09/10] Fixed format errors --- Examples/MAX32665/BLE_LR_Central/lr_central_api.h | 2 +- Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h | 2 +- Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c | 1 - Examples/MAX32665/BLE_LR_Peripheral/main.c | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Examples/MAX32665/BLE_LR_Central/lr_central_api.h b/Examples/MAX32665/BLE_LR_Central/lr_central_api.h index 87b7444964..173c1d1748 100644 --- a/Examples/MAX32665/BLE_LR_Central/lr_central_api.h +++ b/Examples/MAX32665/BLE_LR_Central/lr_central_api.h @@ -71,4 +71,4 @@ void DatcHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); }; #endif -#endif // EXAMPLES_MAX32665_BLE_LR_CENTRAL_LR_CENTRAL_API_H_ \ No newline at end of file +#endif // EXAMPLES_MAX32665_BLE_LR_CENTRAL_LR_CENTRAL_API_H_ diff --git a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h index 329d6bb52d..2d14e2be37 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h +++ b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_api.h @@ -81,4 +81,4 @@ void FitHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); }; #endif -#endif // EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_LR_PERIPH_API_H_ \ No newline at end of file +#endif // EXAMPLES_MAX32665_BLE_LR_PERIPHERAL_LR_PERIPH_API_H_ diff --git a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c index 2d50ffd3f5..e4c2a80e1f 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c +++ b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c @@ -24,7 +24,6 @@ */ /*************************************************************************************************/ - #include #include "wsf_types.h" #include "util/bstream.h" diff --git a/Examples/MAX32665/BLE_LR_Peripheral/main.c b/Examples/MAX32665/BLE_LR_Peripheral/main.c index 1ba1a53a28..7b2d15bc88 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/main.c +++ b/Examples/MAX32665/BLE_LR_Peripheral/main.c @@ -23,7 +23,6 @@ */ /*************************************************************************************************/ - #include #include #include "wsf_types.h" From 26a85be9f9f0cbf874b246f2dcab1045638310f2 Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Mon, 25 Sep 2023 09:25:08 -0500 Subject: [PATCH 10/10] device name LongRange, central tx pwr 4 dBm --- Examples/MAX32665/BLE_LR_Central/main.c | 2 +- Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c | 5 +++-- .../Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Examples/MAX32665/BLE_LR_Central/main.c b/Examples/MAX32665/BLE_LR_Central/main.c index edbc6e005a..66d40ecf49 100644 --- a/Examples/MAX32665/BLE_LR_Central/main.c +++ b/Examples/MAX32665/BLE_LR_Central/main.c @@ -69,7 +69,7 @@ /*! \brief UART TX buffer size */ #define PLATFORM_UART_TERMINAL_BUFFER_SIZE 2048U -#define DEFAULT_TX_POWER 0 /* dBm */ +#define DEFAULT_TX_POWER 4 /* dBm */ /************************************************************************************************** Global Variables diff --git a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c index e4c2a80e1f..37d71be1b7 100644 --- a/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c +++ b/Examples/MAX32665/BLE_LR_Peripheral/lr_periph_main.c @@ -177,7 +177,7 @@ uint8_t fitAdvDataDisc[ADV_DATA_DISC_LEN] = { /*! scan data, discoverable mode */ static const uint8_t fitScanDataDisc[] = { /*! device name */ - 9, /*! length */ + 10, /*! length */ DM_ADV_TYPE_LOCAL_NAME, /*! AD type */ 'L', 'o', @@ -186,7 +186,8 @@ static const uint8_t fitScanDataDisc[] = { 'R', 'a', 'n', - 'g' + 'g', + 'e' }; /************************************************************************************************** diff --git a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c index e2ab4c49c7..2d3be7906a 100644 --- a/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c +++ b/Libraries/Cordio/ble-host/sources/hci/exactle/hci_cmd_master_ae.c @@ -62,7 +62,7 @@ void HciLeSetExtScanParamCmd(uint8_t ownAddrType, uint8_t scanFiltPolicy, uint8_ // TODO if (appCodedPhyDemo == 0) { - WSF_ASSERT(status == LL_SUCCESS); + WSF_ASSERT(status == LL_SUCCESS); } }