|
| 1 | +# CHIP CC1352 CC2652 Lock Example Application |
| 2 | + |
| 3 | +An example application showing the use [CHIP][chip] on the Texas Instruments |
| 4 | +CC13X2_26X2 family of Wireless MCUs. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +- [CHIP CC1352 CC2652 Lock Example Application](#chip-cc1352-cc2652-lock-example-application) |
| 9 | + - [Introduction](#introduction) |
| 10 | + - [Device UI](#device-ui) |
| 11 | + - [Building](#building) |
| 12 | + - [Preparation](#preparation) |
| 13 | + - [Compilation](#compilation) |
| 14 | + - [Programming](#programming) |
| 15 | + - [UniFlash](#uniflash) |
| 16 | + - [Code Composer Studio](#code-composer-studio) |
| 17 | + - [Viewing Logging Output](#viewing-logging-output) |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Introduction |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +The CC13X2_26X2 lock example application provides a working demonstration of a |
| 26 | +connected door lock device. This uses the open-source CHIP implementation and |
| 27 | +the Texas Instruments SimpleLink™ CC13x2 and CC26x2 software development kit. |
| 28 | + |
| 29 | +This example is enabled to build on all members of the `CC13X2_26X2` family of |
| 30 | +MCUs [recommended for Thread][ti_thread_dnd]. By default this example targets |
| 31 | +the [CC1352R1_LAUNCHXL][cc1352r1_launchxl] LaunchPad. |
| 32 | + |
| 33 | +The lock example is intended to serve both as a means to explore the workings of |
| 34 | +CHIP, as well as a template for creating real products based on the Texas |
| 35 | +Instruments devices. |
| 36 | + |
| 37 | +## Device UI |
| 38 | + |
| 39 | +This example application has a simple User Interface to depict the state of the |
| 40 | +door lock and to control the state. The user LEDs on the LaunchPad are set on |
| 41 | +when the lock is locked, and are set off when unlocked. The LEDs will flash when |
| 42 | +in the transition state between locked and unlocked. The user buttons are used |
| 43 | +for requesting lock and unlock of the door lock. The left button (`BTN-1`) is |
| 44 | +used to request locking. The right button (`BTN-2`) us used to request |
| 45 | +unlocking. |
| 46 | + |
| 47 | +## Building |
| 48 | + |
| 49 | +### Preparation |
| 50 | + |
| 51 | +Some initial setup is necessary for preparing the build environment. This |
| 52 | +section will need to be done when migrating to new versions of the SDK. |
| 53 | + |
| 54 | +- Download and install the [SimpleLink™ CC13x2 and CC26x2 software development |
| 55 | + kit (SDK)][simplelink_sdk] ([4.30.00.54][simplelink_sdk_4.30.00.54]) |
| 56 | + |
| 57 | + - Follow the default installation instructions when executing the |
| 58 | + installer. |
| 59 | + |
| 60 | + - The version of OpenThread used in this repository is newer than the one |
| 61 | + packaged with the TI SDK. Check the following section for a list of |
| 62 | + changes needed. |
| 63 | + |
| 64 | +- Download and install [SysConfig][sysconfig] |
| 65 | + ([sysconfig-1.5.0_1397][sysconfig-1.5.0_1397]) |
| 66 | + |
| 67 | + - This may have already been installed with your SimpleLink SDK install |
| 68 | + |
| 69 | +- If you have installed different versions, the build defaults will need to be |
| 70 | + changed to reflect this in |
| 71 | + `${chip_root}/examples/build_overrides/ti_simplelink_sdk.gni`. |
| 72 | + |
| 73 | +- Install Python 3.8 for the GN build system: |
| 74 | + |
| 75 | + ``` |
| 76 | + # Linux |
| 77 | + $ sudo apt-get install python3.8 python3.8-distutils python3.8-dev python3.8-venv |
| 78 | + # Distutils listed due to a package manager error on Ubuntu 18.04 |
| 79 | +
|
| 80 | + ``` |
| 81 | +
|
| 82 | + - You will have to ensure that the default version of Python 3 is Python |
| 83 | + 3.8. |
| 84 | +
|
| 85 | +- run the bootstrap script to setup the build environment. |
| 86 | +
|
| 87 | + ``` |
| 88 | + $ cd ~/connectedhomeip |
| 89 | + $ source ./script/bootstrap.sh |
| 90 | +
|
| 91 | + ``` |
| 92 | +
|
| 93 | +#### Changes to the TI SDK |
| 94 | +
|
| 95 | +The OpenThread library will set the short address assigned to the device as soon |
| 96 | +as it receives the Child ID response. This may happen while the radio driver is |
| 97 | +still in transmit mode. This is easilly fixed by removing state check in the |
| 98 | +else condition in |
| 99 | +`${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/cli_mtd/platform/radio.c` |
| 100 | +on linke 1791. |
| 101 | +
|
| 102 | +``` |
| 103 | +- else if (sState != platformRadio_phyState_Transmit) |
| 104 | ++ else |
| 105 | + { |
| 106 | + sReceiveCmd.localShortAddr = aAddress; |
| 107 | + } |
| 108 | +``` |
| 109 | +
|
| 110 | +### Compilation |
| 111 | +
|
| 112 | +It is necessary to activate the environment in every new shell. Then run GN and |
| 113 | +Ninja to build the executable. |
| 114 | +
|
| 115 | +- Activate the build environment with the repository activate script. |
| 116 | +
|
| 117 | + ``` |
| 118 | + $ cd ~/connectedhomeip |
| 119 | + $ source ./script/activate.sh |
| 120 | +
|
| 121 | + ``` |
| 122 | +
|
| 123 | +- Run the build to produce a default executable. By default on Linux both the |
| 124 | + TI SimpleLink SDK and Sysconfig are located in a `ti` folder in the user's |
| 125 | + home directory, and you must provide the absolute path to them. For example |
| 126 | + `/home/username/ti/simplelink_cc13x2_26x2_sdk_4_30_00_54` and |
| 127 | + `/home/username/ti/sysconfig_1.6.0`. On Windows the default directory is |
| 128 | + `C:\ti` |
| 129 | +
|
| 130 | + ``` |
| 131 | + $ cd ~/connectedhomeip/examples/lock-app/cc13x2_26x2 |
| 132 | + $ export TI_SIMPLELINK_SDK_ROOT=<path-to-simplelink-sdk> |
| 133 | + $ export TI_SYSCONFIG_ROOT=<path-to-sysconfig-sdk> |
| 134 | + $ gn gen out/debug --args="ti_simplelink_sdk_root=\"${TI_SIMPLELINK_SDK_ROOT}\" ti_sysconfig_root=\"${TI_SYSCONFIG_ROOT}\"" |
| 135 | + $ ninja -C out/debug |
| 136 | +
|
| 137 | + ``` |
| 138 | +
|
| 139 | +## Programming |
| 140 | +
|
| 141 | +Loading the built image onto a LaunchPad is supported through two methods; |
| 142 | +Uniflash and Code Composer Studio (CCS). UniFlash can be used to load the image. |
| 143 | +Code Composer Studio can be used to load the image and debug the source code. |
| 144 | +
|
| 145 | +### UniFlash |
| 146 | +
|
| 147 | +[Programming UniFlash](doc/programming-uniflash.md) |
| 148 | +
|
| 149 | +### Code Composer Studio |
| 150 | +
|
| 151 | +[Programming and Debugging with CCS](doc/programming-ccs.md) |
| 152 | +
|
| 153 | +## Viewing Logging Output |
| 154 | +
|
| 155 | +By default the log output will be sent to the Application/User UART. Open a |
| 156 | +terminal emulator to that port to see the output with the following options: |
| 157 | +
|
| 158 | +| Parameter | Value | |
| 159 | +| ------------ | -------- | |
| 160 | +| Speed (baud) | `115200` | |
| 161 | +| Data bits | `8` | |
| 162 | +| Stop bits | `1` | |
| 163 | +| Parity | `None` | |
| 164 | +| Flow control | `None` | |
| 165 | +
|
| 166 | +[chip]: https://github.com/project-chip/connectedhomeip |
| 167 | +[cc1352r1_launchxl]: https://www.ti.com/tool/LAUNCHXL-CC1352R1 |
| 168 | +[simplelink_sdk]: https://www.ti.com/tool/SIMPLELINK-CC13X2-26X2-SDK |
| 169 | +[simplelink_sdk_4.30.00.54]: |
| 170 | + https://www.ti.com/tool/download/SIMPLELINK-CC13X2-26X2-SDK/4.30.00.54 |
| 171 | +[sysconfig]: https://www.ti.com/tool/SYSCONFIG |
| 172 | +[sysconfig-1.5.0_1397]: |
| 173 | + http://software-dl.ti.com/ccs/esd/sysconfig/sysconfig-1.5.0_1397-setup.run |
| 174 | +[ti_thread_dnd]: |
| 175 | + https://www.ti.com/wireless-connectivity/thread/design-development.html |
0 commit comments