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.

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

Part Number: CC2640R2F

CC2640R2 (BLE5)

Note: The following instructions have been written for SDK 3_40_00_10 but can be adapted to quite any SDK version (that is why I provided the sources but also the diff files)

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 +130% - yes more than two times more (in comparison with OOB example)

How to do this?

1. Import the ble5_simple_peripheral project

2. Remove all the occurrences of "display" and "tbm" in main.c, simple_peripheral.c and simple_peripheral.h. Don't forget to change the IO capabilities of the device (look for "GAPBOND_IO_CAP_DISPLAY_ONLY" in simple_peripheral.c and modify it in "GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT").

    • Here is the diff file for main.c (and the content of main.c at the end of the modification):
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_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\main.c Thu Jan 9 23:49:34 2020
+++ C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\main_SIMPLE.c Tue Feb 11 08:09:11 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
@@ -194,61 +190,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
6888.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: cc2640r2
******************************************************************************
Copyright (c) 2013-2020, 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):
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_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\simple_peripheral.c Mon Feb 10 14:52:29 2020
+++ C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\simple_peripheral_SIMPLE.c Tue Feb 11 08:08:37 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 <board.h>
-#include <board_key.h>
-
-#include <menu/two_btn_menu.h>
-
-#include "simple_peripheral_menu.h"
+
#include "simple_peripheral.h"
#ifdef PTM_MODE
@@ -141,7 +135,6 @@
// Application events
#define SP_STATE_CHANGE_EVT 0
#define SP_CHAR_CHANGE_EVT 1
-#define SP_KEY_CHANGE_EVT 2
#define SP_ADV_EVT 3
#define SP_PAIR_STATE_EVT 4
#define SP_PASSCODE_EVT 5
@@ -160,17 +153,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)
// For storing the active connections
#define SP_RSSI_TRACK_CHNLS 1 // Max possible channels can be GAP_BONDINGS_MAX
@@ -247,25 +229,22 @@
// Connected device information
typedef struct
{
- uint16_t connHandle; // Connection Handle
+ uint16_t connHandle; // Connection Handle
spClockEventData_t* pParamUpdateEventData;
- Clock_Struct* pUpdateClock; // pointer to clock struct
- int8_t rssiArr[SP_MAX_RSSI_STORE_DEPTH];
- uint8_t rssiCntr;
- int8_t rssiAvg;
- bool phyCngRq; // Set to true if PHY change request is in progress
- uint8_t currPhy;
- uint8_t rqPhy;
- uint8_t phyRqFailCnt; // PHY change request count
- bool isAutoPHYEnable; // Flag to indicate auto phy change
+ Clock_Struct* pUpdateClock; // pointer to clock struct
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    • Here is the diff file for simple_peripheral.h (and the content of simple_peripheral.h at the end of the modification 
    • 2110.simple_peripheral.h
      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
      --- C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\simple_peripheral.h Thu Jan 9 23:49:34 2020
      +++ C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\simple_peripheral_SIMPLE.h Mon Feb 10 14:50:18 2020
      @@ -56,7 +56,6 @@
      /*********************************************************************
      * INCLUDES
      */
      -#include <menu/two_btn_menu.h>
      /*********************************************************************
      * EXTERNAL VARIABLES
      @@ -79,15 +78,6 @@
      */
      extern void SimplePeripheral_createTask(void);
      -/*
      - * Functions for menu action
      - */
      -/* Actions for Menu: Choose connection to work with */
      -bool SimplePeripheral_doSelectConn(uint8 index);
      -
      -/* Actions for Menu: Set PHY - Select */
      -bool SimplePeripheral_doSetConnPhy(uint8 index);
      -
      #ifdef PTM_MODE
      /* Actions for Menu: Enable PTM Mode */
      bool SimplePeripheral_doEnablePTMMode(uint8 index);
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

3. 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

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