This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2642R: CC2652R: How to remove two buttons menu (two_btn_menu) and display from simple_peripheral project

Part Number: CC2642R
Other Parts Discussed in Thread: CC1352R, CC2652P, CC2652R, CC1352P, SYSCONFIG

CC26x2


Note: The following instructions have been written for SDK 3_40_00_02 but can be adapted to quite any SDK version (that is why I provided the sources but also the diff files). In addition, the code was written for CC2642R but can be adapted to all the devices of the family (CC2652R, CC2652P, CC1352R, CC1352P)


By removing the two_btn_menu and the display from the simple_peripheral project, you can significantly increase the remaining memory available on the device.
Remaining FLASH memory:
+ 8.7kB (in comparison with OOB example)

How to do this?

1. Import the simple_peripheral project

2. Change the IO Capabilities (used for pairing/bonding) of your device. This requires SysConfig: BLE > Bond Manager > IO Capabilities. Set it to “No Display or Input Device”. You can also directly use the .syscfg I have modified for you:

Here is the .syscfg file already modified: simple_peripheral.syscfg

3. Remove all the occurrences of "display" and "tbm" in main.c, simple_peripheral.c and simple_peripheral.h.

Here is the diff file for main.c (and the content of main.c at the end of the modification):

1300.main_removeDisplay.diff
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Startup\main.c Wed Dec 18 22:55:20 2019
+++ C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Startup\main_SIMPLE.c Mon Feb 10 15:53:38 2020
@@ -73,8 +73,6 @@
icall_userCfg_t user0Cfg = BLE_USER_CFG;
#endif // USE_DEFAULT_USER_CFG
-#include <ti/display/Display.h>
-
/*******************************************************************************
* MACROS
*/
@@ -100,8 +98,6 @@
*/
extern void AssertHandler(uint8 assertCause, uint8 assertSubcause);
-
-extern Display_Handle dispHandle;
/*******************************************************************************
* @fn Main
@@ -199,61 +195,7 @@
*/
void AssertHandler(uint8 assertCause, uint8 assertSubcause)
{
- // Open the display if the app has not already done so
- if ( !dispHandle )
- {
- dispHandle = Display_open(Display_Type_ANY, NULL);
- }
-
- Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
-
- // check the assert cause
- switch (assertCause)
- {
- case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
- Display_print0(dispHandle, 0, 0, "***ERROR***");
- Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
- break;
-
- case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
- // check the subcause
- if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
- {
- Display_print0(dispHandle, 0, 0, "***ERROR***");
- Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
- }
- else
- {
- Display_print0(dispHandle, 0, 0, "***ERROR***");
- Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
- }
- break;
-
- case HAL_ASSERT_CAUSE_ICALL_ABORT:
- Display_print0(dispHandle, 0, 0, "***ERROR***");
- Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
- HAL_ASSERT_SPINLOCK;
- break;
-
- case HAL_ASSERT_CAUSE_ICALL_TIMEOUT:
- Display_print0(dispHandle, 0, 0, "***ERROR***");
- Display_print0(dispHandle, 2, 0, ">> ICALL TIMEOUT!");
- HAL_ASSERT_SPINLOCK;
- break;
-
- case HAL_ASSERT_CAUSE_WRONG_API_CALL:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

7484.main.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/******************************************************************************
@file main.c
@brief main entry of the BLE stack sample application.
Group: WCS, BTS
Target Device: cc13x2_26x2
******************************************************************************
Copyright (c) 2013-2019, Texas Instruments Incorporated
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Texas Instruments Incorporated nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************
*****************************************************************************/
/*******************************************************************************
* INCLUDES
*/
#include <xdc/runtime/Error.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
#include <ti/sysbios/BIOS.h>
#include <icall.h>
#include "hal_assert.h"
#include "bcomdef.h"
#include "simple_peripheral.h"
#ifdef PTM_MODE
#include "npi_task.h"
#endif // PTM_MODE
/* Header files required to enable instruction fetch cache */
#include <inc/hw_memmap.h>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Here is the diff file for simple_peripheral.c (and the content of simple_peripheral.c at the end of the modification):

8741.simple_peripheral_removeDisplay.diff
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral.c Wed Dec 18 22:55:20 2019
+++ C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral_SIMPLE.c Mon Feb 10 15:50:31 2020
@@ -55,8 +55,6 @@
#include <ti/sysbios/knl/Event.h>
#include <ti/sysbios/knl/Queue.h>
-#include <ti/display/Display.h>
-
#if !(defined __TI_COMPILER_VERSION__)
#include <intrinsics.h>
#endif
@@ -77,11 +75,7 @@
#endif //USE_RCOSC
#include <ti_drivers_config.h>
-#include <board_key.h>
-
-#include <menu/two_btn_menu.h>
-
-#include "simple_peripheral_menu.h"
+
#include "simple_peripheral.h"
#include "ti_ble_config.h"
@@ -131,18 +125,6 @@
// Size of string-converted device address ("0xXXXXXXXXXXXX")
#define SP_ADDR_STR_SIZE 15
-
-// Row numbers for two-button menu
-#define SP_ROW_SEPARATOR_1 (TBM_ROW_APP + 0)
-#define SP_ROW_STATUS_1 (TBM_ROW_APP + 1)
-#define SP_ROW_STATUS_2 (TBM_ROW_APP + 2)
-#define SP_ROW_CONNECTION (TBM_ROW_APP + 3)
-#define SP_ROW_ADVSTATE (TBM_ROW_APP + 4)
-#define SP_ROW_RSSI (TBM_ROW_APP + 5)
-#define SP_ROW_IDA (TBM_ROW_APP + 6)
-#define SP_ROW_RPA (TBM_ROW_APP + 7)
-#define SP_ROW_DEBUG (TBM_ROW_APP + 8)
-#define SP_ROW_AC (TBM_ROW_APP + 9)
// For storing the active connections
#define SP_RSSI_TRACK_CHNLS 1 // Max possible channels can be GAP_BONDINGS_MAX
@@ -244,9 +226,6 @@
/*********************************************************************
* GLOBAL VARIABLES
*/
-
-// Display Interface
-Display_Handle dispHandle = NULL;
// Task configuration
Task_Struct spTask;
@@ -337,8 +316,6 @@
static void SimplePeripheral_processPasscode(spPasscodeData_t *pPasscodeData);
static void SimplePeripheral_charValueChangeCB(uint8_t paramId);
static status_t SimplePeripheral_enqueueMsg(uint8_t event, void *pData);
-static void SimplePeripheral_keyChangeHandler(uint8 keys);
-static void SimplePeripheral_handleKeys(uint8_t keys);
static void SimplePeripheral_processCmdCompleteEvt(hciEvt_CmdComplete_t *pMsg);
static void SimplePeripheral_initPHYRSSIArray(void);
static void SimplePeripheral_updatePHYStat(uint16_t eventCode, uint8_t *pMsg);
@@ -352,8 +329,6 @@
uint8_t txPhy, uint8_t rxPhy,
uint16_t phyOpts);
static uint8_t SimplePeripheral_clearConnListEntry(uint16_t connHandle);
-static void SimplePeripheral_menuSwitchCb(tbmMenuObj_t* pMenuObjCurr,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

0728.simple_peripheral.c

Here is the diff file for simple_peripheral.h (and the content of simple_peripheral.h at the end of the modification):

2376.simple_peripheral_h_removeDisplay.diff
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--- C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral.h Wed Dec 18 22:55:20 2019
+++ C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral_SIMPLE.h Mon Feb 10 15:38:58 2020
@@ -56,7 +56,6 @@
/*********************************************************************
* INCLUDES
*/
-#include <menu/two_btn_menu.h>
/*********************************************************************
* EXTERNAL VARIABLES
@@ -79,18 +78,6 @@
*/
extern void SimplePeripheral_createTask(void);
-/*
- * Functions for menu action
- */
-/* Actions for Menu: Choose connection to work with */
-bool SimplePeripheral_doSelectConn(uint8 index);
-
-/* Action for Menu: AutoConnect */
-bool SimplePeripheral_doAutoConnect(uint8_t index);
-
-/* Actions for Menu: Set PHY - Select */
-bool SimplePeripheral_doSetConnPhy(uint8 index);
-
/*********************************************************************
*********************************************************************/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

3000.simple_peripheral.h

4. The following files can be removed(facultative) from the Application folder: board_key.c, board_key.h, simple_peripheral_menu.c, simple_peripheral_menu.h, two_btn_menu.c, two_btn_menu.h

5. Test the example: it should still compile and work smoothly