├── AndroidApp
├── settings.gradle
├── .idea
│ ├── .gitignore
│ ├── compiler.xml
│ ├── vcs.xml
│ ├── misc.xml
│ ├── gradle.xml
│ └── jarRepositories.xml
├── app
│ ├── lint.xml
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ └── nrfuart_hdpi_icon.png
│ │ │ ├── layout
│ │ │ │ ├── message_detail.xml
│ │ │ │ ├── title_bar.xml
│ │ │ │ ├── device_element.xml
│ │ │ │ ├── device_list.xml
│ │ │ │ ├── dis_values.xml
│ │ │ │ └── main.xml
│ │ │ └── values
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── com
│ │ │ └── nordicsemi
│ │ │ └── nrfUARTv2
│ │ │ ├── EpdDownloader.java
│ │ │ ├── DeviceListActivity.java
│ │ │ └── UartService.java
│ └── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .gitignore
├── build.gradle
├── import-summary.txt
├── gradlew.bat
└── gradlew
├── doc
├── result.jpg
├── protocol.txt
├── pins.txt
└── usage.txt
├── 5.14_advance_peripheral_uarttrans
├── src
│ ├── app
│ │ ├── hw_uart.c
│ │ ├── task_epd.c
│ │ ├── hw_uart.h
│ │ ├── epd2in13.h
│ │ ├── task_epd.h
│ │ ├── peripheral_uarttrans.h
│ │ ├── epd2in13.c
│ │ └── main.c
│ ├── profile
│ │ ├── uarttrans_service.h
│ │ └── uarttrans_service.c
│ └── stack
│ │ └── osal_icall_ble.c
├── tirtos
│ └── iar
│ │ ├── 5.14_advance_peripheral_uarttrans.eww
│ │ ├── config
│ │ ├── lib_linker.cmd
│ │ └── ccfg_app_ble.c
│ │ ├── 5.14_advance_peripheral_uarttrans.custom_argvars
│ │ └── stack
│ │ └── build_config.opt
└── .gitignore
├── README.md
└── target
├── board.h
├── board.c
├── cc2640r2iot
├── cc2640r2iot_board.h
└── cc2640r2iot_board.c
├── iotboard_key.h
├── iotboard_key.c
├── LAUNCHIOT_CC2640R2MOD_RGZ
├── Board.h
└── LAUNCHIOT_CC2640R2MOD_RGZ.h
├── urfc.h
└── urfc.c
/AndroidApp/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/AndroidApp/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/AndroidApp/app/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/doc/result.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muyuchl/cc2640BleEpd/HEAD/doc/result.jpg
--------------------------------------------------------------------------------
/AndroidApp/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muyuchl/cc2640BleEpd/HEAD/AndroidApp/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/app/hw_uart.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muyuchl/cc2640BleEpd/HEAD/5.14_advance_peripheral_uarttrans/src/app/hw_uart.c
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cc2640BleEpd
2 | firmware and Android tool to update the epaper display on a cc2640 controlled shelf tag device
3 | 
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/app/task_epd.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muyuchl/cc2640BleEpd/HEAD/5.14_advance_peripheral_uarttrans/src/app/task_epd.c
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/res/drawable-hdpi/nrfuart_hdpi_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muyuchl/cc2640BleEpd/HEAD/AndroidApp/app/src/main/res/drawable-hdpi/nrfuart_hdpi_icon.png
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/app/hw_uart.h:
--------------------------------------------------------------------------------
1 | #ifndef HW_UART_H
2 | #define HW_UART_H
3 |
4 |
5 | void HWUART_Init();
6 | void HWUART_Printf(const char* format, ...);
7 |
8 | #endif
9 |
--------------------------------------------------------------------------------
/AndroidApp/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AndroidApp/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/doc/protocol.txt:
--------------------------------------------------------------------------------
1 | a simple protocol is used to send image data to the device via BLE.
2 |
3 | * Android app send each frame contains one command with zero or frameLength bytes data
4 | * CC2640R2 will reply with the same command back, but no data payload (may add later)
5 |
6 |
--------------------------------------------------------------------------------
/AndroidApp/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Feb 07 20:04:50 CST 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
7 |
--------------------------------------------------------------------------------
/AndroidApp/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 | app/build
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/tirtos/iar/5.14_advance_peripheral_uarttrans.eww:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $WS_DIR$\app\cc2640r2lp_app.ewp
5 |
6 |
7 | $WS_DIR$\stack\cc2640r2lp_stack.ewp
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/res/layout/message_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/.gitignore:
--------------------------------------------------------------------------------
1 | tirtos/iar/app/FlashROM_StackLibrary/
2 | tirtos/iar/app/settings/
3 | tirtos/iar/app/cc2640r2lp_app.dep
4 | tirtos/iar/config/ble_r2.symbols
5 | tirtos/iar/settings/
6 | tirtos/iar/stack/FlashROM_Library/
7 | tirtos/iar/stack/cc2640r2lp_stack.dep
8 | tirtos/iar/stack/settings/
9 | tirtos/iar/config/configPkg/
10 | tirtos/iar/config/src/
11 |
--------------------------------------------------------------------------------
/AndroidApp/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AndroidApp/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:4.0.0'
9 | }
10 | }
11 |
12 | allprojects {
13 | repositories {
14 | google()
15 | jcenter()
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/res/layout/title_bar.xml:
--------------------------------------------------------------------------------
1 |
5 |
10 |
11 |
--------------------------------------------------------------------------------
/doc/pins.txt:
--------------------------------------------------------------------------------
1 | note: some models don't have led
2 | RED LED IOID_6 // low active
3 | GREEN LED IOID_7
4 | BLUE LED IOID_0
5 |
6 | epd_sda (MOSI) IOID_19
7 | epd CLK IOID_18
8 |
9 | EPD_POWER_PIN IOID_20 // low active
10 |
11 | EPD_RST_PIN IOID_10
12 | EPD_DC_PIN IOID_11
13 | EPD_BUSY_PIN IOID_9
14 | EPD_CS_PIN IOID_12
15 |
16 | REED_PIN IOID_13 // will read 0 if there is a magnet near
17 | TEST_PIN IOID_15 // on backe of pcb with name 'test'
--------------------------------------------------------------------------------
/AndroidApp/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 30
5 | buildToolsVersion "30.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.nordicsemi.nrfUARTv2"
9 | minSdkVersion 18
10 | targetSdkVersion 18
11 | }
12 |
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile 'com.android.support:support-v4:18.+'
23 | }
24 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/app/epd2in13.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef EPD_2IN13_H
3 | #define EPD_2IN13_H
4 |
5 | #include
6 |
7 | // Display resolution
8 | #define EPD_2IN13_WIDTH 104
9 | #define EPD_2IN13_HEIGHT 212
10 |
11 | // #define EPD_2IN13_FULL 0
12 | // #define EPD_2IN13_PART 1
13 |
14 | void epd_hw_init();
15 |
16 | void EPD_2IN13_Init();
17 | void EPD_2IN13_Clear(void);
18 | void EPD_2IN13_Display(const uint8_t *Image);
19 |
20 | void EPD_2IN13_PrepareBlkRAM(void);
21 | void EPD_2IN13_PrepareRedRAM(void);
22 | void EPD_2IN13_WriteRAM(const uint8_t *buf, const int len);
23 |
24 | void EPD_2IN13_UpdateDisplay(void);
25 |
26 | // void EPD_2IN13_DisplayPart(UBYTE *Image);
27 | // void EPD_2IN13_DisplayPartBaseImage(UBYTE *Image);
28 |
29 | void EPD_2IN13_Sleep(void);
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/app/task_epd.h:
--------------------------------------------------------------------------------
1 | #ifndef TASK_EPD_H
2 | #define TASK_EPD_H
3 |
4 |
5 |
6 |
7 |
8 | // -----------------------------------------------------------------------------
9 | //! \brief API for application task to parse received epd request
10 | //!
11 | //! \param[in] pMsg Pointer to "unframed" message buffer.
12 | //! \param[in] length Length of buffer
13 | //!
14 | //! \return void
15 | // -----------------------------------------------------------------------------
16 | extern void EPDTask_parseCommand(uint8_t *pMsg, uint8_t length);
17 |
18 |
19 | // used to call when epd processed request, and response is ready
20 | typedef void (*EpdResponseCallback)(uint8_t event, uint8_t *buf, uint8_t len);
21 | void EPDTask_RegisterResponseCallback(EpdResponseCallback callback);
22 |
23 | void TaskEPD_createTask(void);
24 |
25 | // called by other task to notify this task with command frame
26 | //void epd_on_rx_cmd(const uint8_t *buf, int len);
27 |
28 | #endif
--------------------------------------------------------------------------------
/AndroidApp/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
22 |
23 |
--------------------------------------------------------------------------------
/AndroidApp/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/tirtos/iar/config/lib_linker.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * DO NOT MODIFY. This file is automatically generated during the pre-build
3 | * step by the lib_search utility
4 | */
5 |
6 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\ctrl\cc2640_hci_pxxx.a"
7 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\ctrl\cc2640_ll_pxxx.a"
8 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\hci_tl\cc26xx_hci_tl_none.a"
9 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\host\cc26xx_att_pxxx.a"
10 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\host\cc26xx_gap_pxxx.a"
11 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\host\cc26xx_gatt_pxxx.a"
12 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\host\cc26xx_l2cap_pxxx.a"
13 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\host\cc26xx_profiles_pxxx.a"
14 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\host\cc26xx_smp_pxxx.a"
15 | "C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\source\ti\ble5stack\blelib\host\cc26xx_sm_pxxx.a"
16 |
--------------------------------------------------------------------------------
/doc/usage.txt:
--------------------------------------------------------------------------------
1 | ## Usage
2 | * build cc2640r2 project and flash to the device
3 | * build Android app, and open it on phone
4 | * connect the the device with name like 'simple peripheral uarttrans'
5 | * use any tool you like to convert image to lcd data, (https://www.waveshare.net/w/upload/3/36/Image2Lcd.7z)
6 | * load black image bin file (2756 bytes, 104x212)
7 | * load red image bin file
8 | * click download, and wait the device to receive and update
9 |
10 | ## Android App Dev
11 | This is the environment I developed:
12 | Android Studio 4.1.2
13 | Android SDK 11.0 (API 30)
14 |
15 | test device:
16 | Redmi Note3
17 |
18 |
19 | ## cc2640r2 project Dev
20 | Iar 8.11 (it is recommended that no blank space in stall path)
21 | TI ble5 sdk: simplelink_cc2640r2_sdk_1_40_00_45
22 |
23 | * sdk is installed into default location: c/ti/simplelink_cc2640r2_sdk_1_40_00_45/
24 | * create a folder named 'CC2640R2_LAUNCHIOT' in sdk's example/rtos/
25 | * move whole folder to /c/ti/simplelink_cc2640r2_sdk_1_40_00_45/examples/rtos/CC2640R2_LAUNCHIOT/ble5stack/5.14_advance_peripheral_uarttrans
26 | * move 'target' folder to /c/ti/simplelink_cc2640r2_sdk_1_40_00_45/examples/rtos/CC2640R2_LAUNCHIOT/ble5stack
27 |
28 | You don't need to follow the above steps. If that happens, you need to adapt your project to your real case.
29 | The target folder contains pin configs for the device.
30 |
31 |
32 |
33 | ## to improve
34 | * currently CC2640R2's low power consumption is not considered, so use with care on battery
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/tirtos/iar/5.14_advance_peripheral_uarttrans.custom_argvars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SIMPLELINK_CORE_SDK_INSTALL_DIR
6 | C:\ti\simplelink_cc2640r2_sdk_1_40_00_45
7 |
8 |
9 | XDCROOT
10 | $SIMPLELINK_CORE_SDK_INSTALL_DIR$\..\xdctools_3_50_02_20_core
11 |
12 |
13 | EXAMPLE_BLE_ROOT
14 | $PROJ_DIR$\..\..\..
15 |
16 |
17 | XDCPATH
18 | $SIMPLELINK_CORE_SDK_INSTALL_DIR$\kernel\tirtos\packages;$SIMPLELINK_CORE_SDK_INSTALL_DIR$\source;$SRC_BLE_DIR$
19 |
20 |
21 | SRC_BLE_DIR
22 | $SIMPLELINK_CORE_SDK_INSTALL_DIR$\source\ti\ble5stack
23 |
24 |
25 | SRC_COMMON_DIR
26 | $SIMPLELINK_CORE_SDK_INSTALL_DIR$/source/ti/ble5stack
27 |
28 |
29 | TOOLS_BLE_DIR
30 | $SIMPLELINK_CORE_SDK_INSTALL_DIR$\tools\ble5stack
31 |
32 |
33 | ROM_DIR
34 | $SIMPLELINK_CORE_SDK_INSTALL_DIR$\source\ti\ble5stack\rom
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/AndroidApp/import-summary.txt:
--------------------------------------------------------------------------------
1 | ECLIPSE ANDROID PROJECT IMPORT SUMMARY
2 | ======================================
3 |
4 | Ignored Files:
5 | --------------
6 | The following files were *not* copied into the new Gradle project; you
7 | should evaluate whether these are still needed in your project and if
8 | so manually move them:
9 |
10 | * Android.mk
11 |
12 | Replaced Jars with Dependencies:
13 | --------------------------------
14 | The importer recognized the following .jar files as third party
15 | libraries and replaced them with Gradle dependencies instead. This has
16 | the advantage that more explicit version information is known, and the
17 | libraries can be updated automatically. However, it is possible that
18 | the .jar file in your project was of an older version than the
19 | dependency we picked, which could render the project not compileable.
20 | You can disable the jar replacement in the import wizard and try again:
21 |
22 | android-support-v4.jar => com.android.support:support-v4:18.+
23 |
24 | Moved Files:
25 | ------------
26 | Android Gradle projects use a different directory structure than ADT
27 | Eclipse projects. Here's how the projects were restructured:
28 |
29 | * AndroidManifest.xml => app\src\main\AndroidManifest.xml
30 | * assets\ => app\src\main\assets
31 | * lint.xml => app\lint.xml
32 | * res\ => app\src\main\res\
33 | * src\ => app\src\main\java\
34 |
35 | Next Steps:
36 | -----------
37 | You can now build the project. The Gradle project needs network
38 | connectivity to download dependencies.
39 |
40 | Bugs:
41 | -----
42 | If for some reason your project does not build, and you determine that
43 | it is due to a bug or limitation of the Eclipse to Gradle importer,
44 | please file a bug at http://b.android.com with category
45 | Component-Tools.
46 |
47 | (This import summary is for your information only, and can be deleted
48 | after import once you are satisfied with the results.)
49 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
23 |
30 |
31 |
32 |
35 | #FF000000
36 | #FFF2F2F2
37 |
38 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
30 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/res/layout/device_element.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
24 |
25 |
33 |
34 |
42 |
43 |
49 |
50 |
56 |
57 |
--------------------------------------------------------------------------------
/AndroidApp/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/res/layout/device_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
22 |
23 |
27 |
28 |
38 |
39 |
46 |
47 |
50 |
56 |
57 |
62 |
63 |
68 |
69 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/tirtos/iar/config/ccfg_app_ble.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file ccfg_app_ble.c
4 |
5 | @brief Customer Configuration CC26xx PG2 device family.
6 |
7 | Group: CMCU, SCS
8 | Target Device: CC2640R2
9 |
10 | ******************************************************************************
11 |
12 | Copyright (c) 2014-2017, Texas Instruments Incorporated
13 | All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions
17 | are met:
18 |
19 | * Redistributions of source code must retain the above copyright
20 | notice, this list of conditions and the following disclaimer.
21 |
22 | * Redistributions in binary form must reproduce the above copyright
23 | notice, this list of conditions and the following disclaimer in the
24 | documentation and/or other materials provided with the distribution.
25 |
26 | * Neither the name of Texas Instruments Incorporated nor the names of
27 | its contributors may be used to endorse or promote products derived
28 | from this software without specific prior written permission.
29 |
30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 |
42 | ******************************************************************************
43 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
44 | Release Date: 2017-07-20 17:16:59
45 | *****************************************************************************/
46 |
47 | //
48 | // ===> READ THIS BEFORE MODIFYING THIS FILE
49 | //
50 | //
51 | // ===> READ THIS BEFORE MODIFYING THIS FILE
52 | //
53 | //
54 | // ===> READ THIS BEFORE MODIFYING THIS FILE
55 | //
56 |
57 | // The customer configuration area (ccfg section) is located at the end of the
58 | // flash and reflect the hw configuration of the device. it is very important
59 | // that it remains align with the version of driverlib you are using.
60 | // all BLE project except sensor tag use the same configuration.
61 | // Keeping the "#include " guarantee that your project using
62 | // driverlib and the ccfg area will be align.
63 |
64 | // you can modify it if you want, the recommend way will be to remove the
65 | // bellow include, copy the content of the file in this
66 | // file and rebuild.
67 |
68 | // ==> KEEP IN MIND that if you do so, be sure that any further update of the
69 | // driverlib must be align with your modified version of ccfg area.
70 | #include
71 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | BleEpd
20 | Device:
21 | <Select a device>
22 | Select a device
23 | Status
24 | LinkLossAlert
25 | ImmediateAlert
26 | Scanning for devices...
27 | No LE devices found.
28 | Connected
29 | Not connected
30 | Ready
31 | Disconnect
32 | connect
33 | unpair
34 | pair
35 | Alert level high
36 | Alert level mid
37 | Stop alerting
38 | SystemId
39 | ModelNumber
40 | SerialNumber
41 | FirmwareRevision
42 | HardwareRevision
43 | SoftwareRevision
44 | ManufactureName
45 | RegCertDataList
46 | ManufactureId
47 | Battery Level
48 | OrganizationId
49 | Txpower Level
50 | No Update
51 | ReadTxPower
52 | HIGH Alert triggered!
53 | LOW Alert triggered!
54 | TxNoti
55 | Read Rssi Value
56 | D Read
57 | Remove Bond
58 | paired
59 | Quit nRF UART?
60 | Do you want to quit this Application?
61 | YES
62 | NO
63 | Bluetooth Low Energy not supported
64 | Scan
65 | Cancel
66 |
67 |
68 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/res/layout/dis_values.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
21 |
22 |
27 |
28 |
29 |
34 |
35 |
36 |
41 |
42 |
43 |
48 |
49 |
50 |
55 |
56 |
57 |
62 |
63 |
64 |
69 |
70 |
71 |
76 |
77 |
78 |
83 |
84 |
85 |
90 |
91 |
92 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/target/board.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | @file board.h
4 |
5 | @brief This file is a simple gateway to include the appropriate board.h file
6 | which is located in a corresponding subdirectory relative to this file.
7 | In this way, all projects look the same and only need to include this
8 | board.h. To change a board, the project only need update the board
9 | define. Presently, the following board targets are possible:
10 |
11 | CC2640R2DK_CXS
12 | CC2640R2_LAUNCHXL
13 |
14 | If a project needs to change the board defined for a particular target,
15 | they can modify the board.h located in the corresponding board
16 | subdirectory.
17 |
18 | NOTE: THIS FILE SHOULD ONLY BE CHANGED TO ADD A NEW BOARD/TARGET!
19 |
20 | Group: CMCU, LPC, SCS
21 | Target Device: CC2640R2
22 |
23 | *******************************************************************************
24 |
25 | Copyright (c) 2015-2017, Texas Instruments Incorporated
26 | All rights reserved.
27 |
28 | Redistribution and use in source and binary forms, with or without
29 | modification, are permitted provided that the following conditions
30 | are met:
31 |
32 | * Redistributions of source code must retain the above copyright
33 | notice, this list of conditions and the following disclaimer.
34 |
35 | * Redistributions in binary form must reproduce the above copyright
36 | notice, this list of conditions and the following disclaimer in the
37 | documentation and/or other materials provided with the distribution.
38 |
39 | * Neither the name of Texas Instruments Incorporated nor the names of
40 | its contributors may be used to endorse or promote products derived
41 | from this software without specific prior written permission.
42 |
43 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
44 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
45 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
47 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
48 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
49 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
50 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
52 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 |
55 | *******************************************************************************
56 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
57 | Release Date: 2017-07-20 17:16:59
58 | ******************************************************************************/
59 |
60 | #if defined(CC2640R2DK_CXS) || defined (CC2640R2DK_4XS) \
61 | || defined (CC2640R2DK_5XD) || defined (CC2640R2DK_7ID)
62 | #include "./cc2640r2em/cc2640r2em_board.h"
63 | #elif defined(CC2640R2_LAUNCHXL)
64 | #include "./cc2640r2lp/cc2640r2lp_board.h"
65 | #elif defined(CC2640R2_RC)
66 | #include "./cc2640r2rc/cc2640r2rc_board.h"
67 | #elif defined(CC2640R2MOD_RGZ)
68 | #include "./cc2640r2iot/cc2640r2iot_board.h"
69 | #elif defined(CC2640R2MOD_RSM)
70 | #include "./cc2640r2iot/cc2640r2iot_board.h"
71 | #else // unknown board
72 | #error "***ERROR*** Invalid Board Specified! Please see board.h for options."
73 | #endif
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/target/board.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 |
3 | @file board.c
4 |
5 | @brief This file is a simple gateway to include the appropriate board.h file
6 | which is located in a corresponding subdirectory relative to this file.
7 | In this way, all projects look the same and only need to include this
8 | board.h. To change a board, the project only need update the board
9 | define in the application preprocessor options. Presently, the following
10 | board target defines are possible:
11 |
12 | CC2640R2DK_CXS
13 | CC2640R2_LAUNCHXL
14 |
15 | If a project needs to change the board defined for a particular target,
16 | they can modify the board.h located in the corresponding board
17 | subdirectory.
18 |
19 | NOTE: THIS FILE SHOULD ONLY BE CHANGED TO ADD A NEW BOARD/TARGET!
20 |
21 | Group: CMCU, LPC, SCS
22 | Target Device: CC2640R2
23 |
24 | *******************************************************************************
25 |
26 | Copyright (c) 2015-2017, Texas Instruments Incorporated
27 | All rights reserved.
28 |
29 | Redistribution and use in source and binary forms, with or without
30 | modification, are permitted provided that the following conditions
31 | are met:
32 |
33 | * Redistributions of source code must retain the above copyright
34 | notice, this list of conditions and the following disclaimer.
35 |
36 | * Redistributions in binary form must reproduce the above copyright
37 | notice, this list of conditions and the following disclaimer in the
38 | documentation and/or other materials provided with the distribution.
39 |
40 | * Neither the name of Texas Instruments Incorporated nor the names of
41 | its contributors may be used to endorse or promote products derived
42 | from this software without specific prior written permission.
43 |
44 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
45 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
46 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
48 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
49 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
50 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
51 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
52 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
53 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
54 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 |
56 | *******************************************************************************
57 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
58 | Release Date: 2017-07-20 17:16:59
59 | ******************************************************************************/
60 |
61 | #if defined(CC2640R2DK_CXS) || defined (CC2640R2DK_4XS) \
62 | || defined (CC2640R2DK_5XD) || defined (CC2640R2DK_7ID)
63 | #include "./cc2640r2em/cc2640r2em_board.c"
64 | #elif defined(CC2640R2_LAUNCHXL)
65 | #include "./cc2640r2lp/cc2640r2lp_board.c"
66 | #elif defined(CC2640R2_RC)
67 | #include "./cc2640r2rc/cc2640r2rc_board.c"
68 | #elif defined(CC2640R2MOD_RGZ)
69 | #include "./cc2640r2iot/cc2640r2iot_board.c"
70 | #elif defined(CC2640R2MOD_RSM)
71 | #include "./cc2640r2iot/cc2640r2iot_board.c"
72 | #else // unknown board
73 | #error "***ERROR*** Invalid Board Specified! Please see board.h for options."
74 | #endif
75 |
--------------------------------------------------------------------------------
/target/cc2640r2iot/cc2640r2iot_board.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file cc2640r2lp_board.h
4 |
5 | @brief This file is a simple gateway to include the appropriate Board.h
6 | file which is located in the following directories relative to this file:
7 | - CC2640R2_LAUNCHXL
8 |
9 | The project should set the include path to Board.h to point to
10 | the Board.h in this directory.
11 | This Board.h file will then define a symbol which is used in this
12 | file to include the appropriate Board.c file which is found in
13 | the same directory as Board.h
14 | This way the project can look the same (and only include this Board.c)
15 | file, when changing EM user only needs to update include path in
16 | the project options.
17 | Alternatively, the device specific board files can just be included
18 | directly in the project.
19 |
20 | Group: CMCU, LPC, SCS
21 | Target Device: CC2640R2
22 |
23 | ******************************************************************************
24 |
25 | Copyright (c) 2015-2017, Texas Instruments Incorporated
26 | All rights reserved.
27 |
28 | Redistribution and use in source and binary forms, with or without
29 | modification, are permitted provided that the following conditions
30 | are met:
31 |
32 | * Redistributions of source code must retain the above copyright
33 | notice, this list of conditions and the following disclaimer.
34 |
35 | * Redistributions in binary form must reproduce the above copyright
36 | notice, this list of conditions and the following disclaimer in the
37 | documentation and/or other materials provided with the distribution.
38 |
39 | * Neither the name of Texas Instruments Incorporated nor the names of
40 | its contributors may be used to endorse or promote products derived
41 | from this software without specific prior written permission.
42 |
43 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
44 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
45 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
47 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
48 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
49 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
50 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
52 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 |
55 | ******************************************************************************
56 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
57 | Release Date: 2017-07-20 17:16:59
58 | *****************************************************************************/
59 |
60 | #ifndef SDK_BOARD_H
61 | #define SDK_BOARD_H
62 |
63 | /*
64 | * The location of this Board.h file depends on your project include path.
65 | * Set it correctly to point to your CC2640R2_LAUNCHXL
66 | */
67 | #if defined(CC2640R2_LAUNCHXL)
68 | #include "../../boards/CC2640R2_LAUNCHXL/Board.h"
69 | #elif defined(CC2640R2MOD_RGZ)
70 | #include "../LAUNCHIOT_CC2640R2MOD_RGZ/Board.h"
71 | #elif defined(CC2640R2MOD_RSM)
72 | #include "../LAUNCHIOT_CC2640R2MOD_RSM/Board.h"
73 | #else
74 | #error "Must define 'CC2640R2_LAUNCHXL'. Please set include path to point \
75 | to appropriate device."
76 | #endif
77 |
78 | #endif /* SDK_BOARD_H */
79 |
--------------------------------------------------------------------------------
/target/cc2640r2iot/cc2640r2iot_board.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file cc2640r2lp_board.c
4 |
5 | @brief This file is a simple gateway to include the appropriate Board.c
6 | file which is located in the following directories relative to this file:
7 | - CC2640R2_LAUNCHXL
8 |
9 | The project should set the include path to Board.h to point to
10 | the Board.h in this directory.
11 | This Board.h file will then define a symbol which is used in this
12 | file to include the appropriate Board.c file which is found in
13 | the same directory as Board.h
14 | This way the project can look the same (and only include this Board.c)
15 | file, when changing EM user only needs to update include path in
16 | the project options.
17 | Alternatively, the device specific board files can just be included
18 | directly in the project.
19 |
20 | Group: CMCU, LPC, SCS
21 | Target Device: CC2640R2
22 |
23 | ******************************************************************************
24 |
25 | Copyright (c) 2015-2017, Texas Instruments Incorporated
26 | All rights reserved.
27 |
28 | Redistribution and use in source and binary forms, with or without
29 | modification, are permitted provided that the following conditions
30 | are met:
31 |
32 | * Redistributions of source code must retain the above copyright
33 | notice, this list of conditions and the following disclaimer.
34 |
35 | * Redistributions in binary form must reproduce the above copyright
36 | notice, this list of conditions and the following disclaimer in the
37 | documentation and/or other materials provided with the distribution.
38 |
39 | * Neither the name of Texas Instruments Incorporated nor the names of
40 | its contributors may be used to endorse or promote products derived
41 | from this software without specific prior written permission.
42 |
43 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
44 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
45 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
47 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
48 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
49 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
50 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
52 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 |
55 | ******************************************************************************
56 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
57 | Release Date: 2017-07-20 17:16:59
58 | *****************************************************************************/
59 |
60 | /*
61 | * The location of this Board.h file depends on your project include path.
62 | * Set it correctly to point to your CC2640R2_LAUNCHXL
63 | */
64 | #if defined(CC2640R2_LAUNCHXL)
65 | #include "../../boards/CC2640R2_LAUNCHXL/Board.h"
66 | #include "../../boards/CC2640R2_LAUNCHXL/CC2640R2_LAUNCHXL.c"
67 | #elif defined(CC2640R2MOD_RGZ)
68 | #include "../LAUNCHIOT_CC2640R2MOD_RGZ/Board.h"
69 | #include "../LAUNCHIOT_CC2640R2MOD_RGZ/LAUNCHIOT_CC2640R2MOD_RGZ.c"
70 | #elif defined(CC2640R2MOD_RSM)
71 | #include "../LAUNCHIOT_CC2640R2MOD_RSM/Board.h"
72 | #include "../LAUNCHIOT_CC2640R2MOD_RSM/LAUNCHIOT_CC2640R2MOD_RSM.c"
73 | #else
74 | #error "Must define 'CC2640R2_LAUNCHXL'. Please set include path to point \
75 | to appropriate device."
76 | #endif
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/target/iotboard_key.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file board_key.h
4 |
5 | @brief This file contains the SRF06EB Key Service definitions and prototypes
6 | prototypes.
7 |
8 | Group: CMCU, SCS
9 | Target Device: CC2640R2
10 |
11 | ******************************************************************************
12 |
13 | Copyright (c) 2014-2017, Texas Instruments Incorporated
14 | All rights reserved.
15 |
16 | Redistribution and use in source and binary forms, with or without
17 | modification, are permitted provided that the following conditions
18 | are met:
19 |
20 | * Redistributions of source code must retain the above copyright
21 | notice, this list of conditions and the following disclaimer.
22 |
23 | * Redistributions in binary form must reproduce the above copyright
24 | notice, this list of conditions and the following disclaimer in the
25 | documentation and/or other materials provided with the distribution.
26 |
27 | * Neither the name of Texas Instruments Incorporated nor the names of
28 | its contributors may be used to endorse or promote products derived
29 | from this software without specific prior written permission.
30 |
31 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
33 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
35 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
37 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
40 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
41 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 |
43 | ******************************************************************************
44 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
45 | Release Date: 2017-07-20 17:16:59
46 | *****************************************************************************/
47 |
48 | #ifndef BOARD_KEY_H
49 | #define BOARD_KEY_H
50 |
51 | #ifdef __cplusplus
52 | extern "C" {
53 | #endif
54 |
55 | /*********************************************************************
56 | * INCLUDES
57 | */
58 |
59 | /*********************************************************************
60 | * EXTERNAL VARIABLES
61 | */
62 |
63 | /*********************************************************************
64 | * CONSTANTS
65 | */
66 |
67 | #define KEY_BTN1 0x0001
68 | #define KEY_BTN2 0x0002
69 |
70 | // Debounce timeout in milliseconds
71 | #define KEY_DEBOUNCE_TIMEOUT 100
72 |
73 | /*********************************************************************
74 | * TYPEDEFS
75 | */
76 | typedef void (*keysPressedCB_t)(uint8_t keysPressed);
77 |
78 | /*********************************************************************
79 | * MACROS
80 | */
81 |
82 | /*********************************************************************
83 | * API FUNCTIONS
84 | */
85 |
86 | /*********************************************************************
87 | * @fn Board_initKeys
88 | *
89 | * @brief Enable interrupts for keys on GPIOs.
90 | *
91 | * @param appKeyCB - application key pressed callback
92 | *
93 | * @return none
94 | */
95 | void Board_initKeys(keysPressedCB_t appKeyCB);
96 |
97 | /*********************************************************************
98 | *********************************************************************/
99 |
100 | #ifdef __cplusplus
101 | }
102 | #endif
103 |
104 | #endif /* BOARD_KEY_H */
105 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/app/peripheral_uarttrans.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file spp_ble_server.h
4 |
5 | @brief This file contains the Serial Port Profile sample application
6 | definitions and prototypes.
7 |
8 | Group: CMCU, SCS
9 | Target Device: CC2640R2
10 |
11 | ******************************************************************************
12 |
13 | Copyright (c) 2013-2017, Texas Instruments Incorporated
14 | All rights reserved.
15 |
16 | Redistribution and use in source and binary forms, with or without
17 | modification, are permitted provided that the following conditions
18 | are met:
19 |
20 | * Redistributions of source code must retain the above copyright
21 | notice, this list of conditions and the following disclaimer.
22 |
23 | * Redistributions in binary form must reproduce the above copyright
24 | notice, this list of conditions and the following disclaimer in the
25 | documentation and/or other materials provided with the distribution.
26 |
27 | * Neither the name of Texas Instruments Incorporated nor the names of
28 | its contributors may be used to endorse or promote products derived
29 | from this software without specific prior written permission.
30 |
31 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
33 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
35 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
37 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
40 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
41 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 | *****************************************************************************/
43 |
44 | #ifndef SPP_BLE_SERVER_H
45 | #define SPP_BLE_SERVER_H
46 |
47 | #ifdef __cplusplus
48 | extern "C"
49 | {
50 | #endif
51 |
52 | /*********************************************************************
53 | * INCLUDES
54 | */
55 | #include
56 |
57 | /*********************************************************************
58 | * EXTERNAL VARIABLES
59 | */
60 |
61 | /*********************************************************************
62 | * CONSTANTS
63 | */
64 | // External Events for RTOS application
65 | #define SBP_UART_DATA_EVT 0x0010
66 | #define SBP_UART_ERROR_EVT 0x0020
67 |
68 | //LED parameters
69 | #define Board_LED_TOGGLE 3
70 | #define BLINK_DURATION 500 // Milliseconds
71 |
72 | /* Delay */
73 | #define delay_ms(i) ( CPUdelay(12000*(i)) )
74 |
75 | /*********************************************************************
76 | * MACROS
77 | */
78 | #define DEBUG_SIMPLE
79 |
80 | #if !defined(DEBUG_SIMPLE)
81 | # define Display_print0(handle, line, col, fmt) DEBUG(fmt); \
82 | DEBUG_NEWLINE()
83 | # define Display_print1(handle, line, col, fmt, a0) DEBUG((uint8 *)fmt); \
84 | DEBUG((uint8_t*)convInt32ToText((int32)a0)); DEBUG_NEWLINE()
85 | #else
86 | # define Display_print0(handle, line, col, fmt)
87 |
88 | # define Display_print1(handle, line, col, fmt, a0)
89 |
90 | #endif
91 | /*********************************************************************
92 | * FUNCTIONS
93 | */
94 |
95 | /*
96 | * Task creation function for the Simple BLE Peripheral.
97 | */
98 | extern void SPPBLEServer_createTask(void);
99 |
100 |
101 | extern char* convInt32ToText(int32 value);
102 |
103 | /*********************************************************************
104 | *********************************************************************/
105 |
106 | #ifdef __cplusplus
107 | }
108 | #endif
109 |
110 | #endif /* SPP_BLE_SERVER_H */
111 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/java/com/nordicsemi/nrfUARTv2/EpdDownloader.java:
--------------------------------------------------------------------------------
1 | package com.nordicsemi.nrfUARTv2;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.File;
6 | import java.io.FileInputStream;
7 | import java.io.FileNotFoundException;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 |
11 | public class EpdDownloader {
12 | private static String TAG = "EpdDownloader";
13 | //private final static int STATE_ = 1;
14 | private final static int WIDTH = 104;
15 | private final static int HEIGHT = 212;
16 |
17 | // buf of data to send
18 | private byte[] black_buf = new byte[WIDTH / 8 * HEIGHT];
19 | private byte[] red_buf = new byte[WIDTH / 8 * HEIGHT];
20 |
21 | private int frame_index_black = 0;
22 | private int frame_index_red = 0;
23 | public final static int FRAME_DATA_SIZE = 13;
24 | // todo: check if the last frame is complete
25 | private final static int TOTAL_FRAME_COUNT = WIDTH / 8 * HEIGHT / FRAME_DATA_SIZE;
26 |
27 |
28 | private String errString;
29 |
30 | public final static byte EPD_CMD_PING = 0x10;
31 | public final static byte EPD_CMD_INIT = 0x11;
32 | public final static byte EPD_CMD_DEINIT = 0x12;
33 |
34 | public final static byte EPD_CMD_PREPARE_BLK_RAM = 0x13;
35 | public final static byte EPD_CMD_WRITE_BLK_RAM = 0x14;
36 | public final static byte EPD_CMD_GET_BLK_RAM_CRC = 0x15;
37 | public final static byte EPD_CMD_PREPARE_RED_RAM = 0x18;
38 | public final static byte EPD_CMD_WRITE_RED_RAM = 0x19;
39 | public final static byte EPD_CMD_GET_RED_RAM_CRC = 0x20;
40 |
41 | public final static byte EPD_CMD_UPDATE_DISPLAY = 0x21; // ask epd to show ram data
42 |
43 | public final static byte EPD_CMD_READ_VERSION = 0x22;
44 |
45 | public EpdDownloader() {
46 | for (int i = 0; i < (WIDTH / 8 * HEIGHT) ; i++) {
47 | // fill with 0xff, (white color)
48 | black_buf[i] = (byte) 0xff;
49 | red_buf[i] = (byte) 0xff;
50 | }
51 | }
52 |
53 | public String getErrString() {
54 | return errString;
55 | }
56 |
57 | public boolean loadFile(String filePath, boolean isBlack) {
58 | Log.i(TAG, "loading file: " + filePath);
59 | File file = new File(filePath);
60 | try {
61 | InputStream inputStream = new FileInputStream(file);
62 |
63 | if (isBlack) {
64 | inputStream.read(black_buf, 0, WIDTH / 8 * HEIGHT);
65 | } else {
66 | inputStream.read(red_buf, 0, WIDTH / 8 * HEIGHT);
67 | }
68 |
69 | // byte[] logBuf = new byte[10];
70 | // for (int i = 0; i < 10; i++) {
71 | // logBuf[i] = buff[i];
72 | // }
73 | // Log.i(TAG, "loaded, first ten bytes: " + bytesToHexString(logBuf));
74 | return true;
75 |
76 | } catch (FileNotFoundException e) {
77 | e.printStackTrace();
78 | errString = "file not found";
79 | return false;
80 | } catch (IOException e) {
81 | e.printStackTrace();
82 | errString = "ioException";
83 | return false;
84 | }
85 | }
86 |
87 | public void start() {
88 | // reset
89 | frame_index_black = 0;
90 | frame_index_red = 0;
91 | }
92 |
93 | public boolean isDataFinish(boolean isBlack) {
94 | if (isBlack) {
95 | return frame_index_black >= TOTAL_FRAME_COUNT;
96 | } else {
97 | return frame_index_red >= TOTAL_FRAME_COUNT;
98 | }
99 |
100 | }
101 |
102 | public int getProgress(boolean isBlack) {
103 | int frm_idx = 0;
104 | if (isBlack) {
105 | frm_idx = frame_index_black ;
106 | } else {
107 | frm_idx = frame_index_red ;
108 | }
109 |
110 | if (frm_idx >= TOTAL_FRAME_COUNT) {
111 | return 100;
112 | } else {
113 | return (frm_idx * 100 / TOTAL_FRAME_COUNT);
114 | }
115 | }
116 |
117 | public byte[] getNextFrame(boolean isBlack) {
118 | byte[] ret = new byte[FRAME_DATA_SIZE];
119 |
120 | if (isBlack) {
121 | for (int i = 0; i < FRAME_DATA_SIZE; i++) {
122 | ret[i] = black_buf[FRAME_DATA_SIZE * frame_index_black + i];
123 | }
124 | frame_index_black++;
125 | } else {
126 | for (int i = 0; i < FRAME_DATA_SIZE; i++) {
127 | byte inverted = (byte) (0xff - red_buf[FRAME_DATA_SIZE * frame_index_red + i]);
128 | ret[i] = inverted;
129 | }
130 | frame_index_red ++;
131 | }
132 |
133 | return ret;
134 | }
135 |
136 | private static String bytesToHexString(byte[] src) {
137 | StringBuilder stringBuilder = new StringBuilder("");
138 | if (src == null || src.length <= 0) {
139 | return null;
140 | }
141 | for (int i = 0; i < src.length; i++) {
142 | int v = src[i] & 0xFF;
143 | String hv = Integer.toHexString(v);
144 | if (hv.length() < 2) {
145 | stringBuilder.append(0);
146 | }
147 | stringBuilder.append(hv);
148 | stringBuilder.append(' ');
149 | }
150 | return stringBuilder.toString();
151 | }
152 |
153 | }
154 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/profile/uarttrans_service.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Filename: serial_port_service.h
3 | *
4 | * Description: This is the simple_peripheral example modified to send
5 | * data over BLE at a high throughput.
6 | *
7 | *
8 | * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
9 | *
10 | *
11 | * Redistribution and use in source and binary forms, with or without
12 | * modification, are permitted provided that the following conditions
13 | * are met:
14 | *
15 | * Redistributions of source code must retain the above copyright
16 | * notice, this list of conditions and the following disclaimer.
17 | *
18 | * Redistributions in binary form must reproduce the above copyright
19 | * notice, this list of conditions and the following disclaimer in the
20 | * documentation and/or other materials provided with the
21 | * distribution.
22 | *
23 | * Neither the name of Texas Instruments Incorporated nor the names of
24 | * its contributors may be used to endorse or promote products derived
25 | * from this software without specific prior written permission.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 | *
39 | */
40 |
41 | #ifndef SERIALPORTSERVICE_H
42 | #define SERIALPORTSERVICE_H
43 |
44 | #ifdef __cplusplus
45 | extern "C"
46 | {
47 | #endif
48 |
49 | /*********************************************************************
50 | * INCLUDES
51 | */
52 |
53 | #include
54 | #include
55 |
56 |
57 | /*********************************************************************
58 | * CONSTANTS
59 | */
60 |
61 | // Profile Parameters
62 |
63 | #define SERIALPORTSERVICE_CHAR_DATA 0 // RW uint8 - Profile Characteristic 2 value
64 |
65 | // Serial Port Service UUID
66 | #define SERIALPORTSERVICE_SERV_UUID 0xFFF0
67 |
68 | // Key Pressed UUID
69 | #define SERIALPORTSERVICE_DATA_UUID 0xFFF1
70 |
71 | // Serial Port Profile Services bit fields
72 | #define SERIALPORTSERVICE_SERVICE 0x00000001
73 |
74 | //Length of Data Characteristic in bytes
75 | #define SERIALPORTSERVICE_DATA_LEN 251 //set to allow max OTA MTU
76 |
77 |
78 | /*********************************************************************
79 | * TYPEDEFS
80 | */
81 |
82 |
83 | /*********************************************************************
84 | * MACROS
85 | */
86 |
87 | /*********************************************************************
88 | * Profile Callbacks
89 | */
90 |
91 | // Callback when a characteristic value has changed
92 | typedef void (*SerialPortServiceChange_t)( uint8 paramID );
93 |
94 | typedef struct
95 | {
96 | SerialPortServiceChange_t pfnSerialPortServiceChange; // Called when characteristic value changes
97 | } SerialPortServiceCBs_t;
98 |
99 |
100 | /*********************************************************************
101 | * API FUNCTIONS
102 | */
103 |
104 | /*
105 | * SerialPortService_AddService- Initializes the Serial Port Profile service by registering
106 | * GATT attributes with the GATT server.
107 | *
108 | * @param services - services to add. This is a bit map and can
109 | * contain more than one service.
110 | */
111 |
112 | extern bStatus_t SerialPortService_AddService( uint32 services );
113 |
114 | /*
115 | * SerialPortService_RegisterAppCBs - Registers the application callback function.
116 | * Only call this function once.
117 | *
118 | * appCallbacks - pointer to application callbacks.
119 | */
120 | extern bStatus_t SerialPortService_RegisterAppCBs( SerialPortServiceCBs_t *appCallbacks );
121 |
122 | /*
123 | * SerialPortService_SetParameter - Set a Serial Port Profile parameter.
124 | *
125 | * param - Profile parameter ID
126 | * len - length of data to right
127 | * value - pointer to data to write. This is dependent on
128 | * the parameter ID and WILL be cast to the appropriate
129 | * data type (example: data type of uint16 will be cast to
130 | * uint16 pointer).
131 | */
132 | extern bStatus_t SerialPortService_SetParameter( uint8 param, uint8 len, void *value );
133 |
134 | /*
135 | * SerialPortService_GetParameter - Get a Serial Port Profile parameter.
136 | *
137 | * param - Profile parameter ID
138 | * value - pointer to data to write. This is dependent on
139 | * the parameter ID and WILL be cast to the appropriate
140 | * data type (example: data type of uint16 will be cast to
141 | * uint16 pointer).
142 | */
143 | extern bStatus_t SerialPortService_GetParameter( uint8 param, void *value );
144 |
145 |
146 | /*********************************************************************
147 | *********************************************************************/
148 |
149 | #ifdef __cplusplus
150 | }
151 | #endif
152 |
153 | #endif /* SERIALPORTSERVICE_H */
154 |
--------------------------------------------------------------------------------
/AndroidApp/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
19 |
20 |
21 |
27 |
28 |
34 |
35 |
50 |
51 |
58 |
59 |
60 |
69 |
70 |
71 |
72 |
73 |
74 |
81 |
82 |
89 |
90 |
99 |
100 |
108 |
109 |
110 |
115 |
116 |
120 |
121 |
126 |
127 |
132 |
133 |
138 |
139 |
144 |
145 |
150 |
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/target/iotboard_key.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file board_key.c
4 |
5 | @brief This file contains the interface to the SRF06EB Key Service.
6 |
7 | Group: CMCU, SCS
8 | Target Device: CC2640R2
9 |
10 | ******************************************************************************
11 |
12 | Copyright (c) 2014-2017, Texas Instruments Incorporated
13 | All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions
17 | are met:
18 |
19 | * Redistributions of source code must retain the above copyright
20 | notice, this list of conditions and the following disclaimer.
21 |
22 | * Redistributions in binary form must reproduce the above copyright
23 | notice, this list of conditions and the following disclaimer in the
24 | documentation and/or other materials provided with the distribution.
25 |
26 | * Neither the name of Texas Instruments Incorporated nor the names of
27 | its contributors may be used to endorse or promote products derived
28 | from this software without specific prior written permission.
29 |
30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 |
42 | ******************************************************************************
43 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
44 | Release Date: 2017-07-20 17:16:59
45 | *****************************************************************************/
46 |
47 | /*********************************************************************
48 | * INCLUDES
49 | */
50 | #include
51 | #include
52 | #include
53 | #include
54 | #include
55 |
56 | #include
57 |
58 | #ifdef USE_ICALL
59 | #include
60 | #endif
61 |
62 | #include
63 |
64 | #include "util.h"
65 | #include "iotboard_key.h"
66 | #include "board.h"
67 |
68 | /*********************************************************************
69 | * TYPEDEFS
70 | */
71 |
72 | /*********************************************************************
73 | * LOCAL FUNCTIONS
74 | */
75 | static void Board_keyChangeHandler(UArg a0);
76 | static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId);
77 |
78 | /*******************************************************************************
79 | * EXTERNAL VARIABLES
80 | */
81 |
82 | /*********************************************************************
83 | * LOCAL VARIABLES
84 | */
85 |
86 | // Value of keys Pressed
87 | static uint8_t keysPressed;
88 |
89 | // Key debounce clock
90 | static Clock_Struct keyChangeClock;
91 |
92 | // Pointer to application callback
93 | keysPressedCB_t appKeyChangeHandler = NULL;
94 |
95 | // Memory for the GPIO module to construct a Hwi
96 | Hwi_Struct callbackHwiKeys;
97 |
98 | // PIN configuration structure to set all KEY pins as inputs with pullups enabled
99 | PIN_Config keyPinsCfg[] =
100 | {
101 | #if defined(CC2640R2MOD_RGZ)
102 | Board_BTN1 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
103 | Board_BTN2 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
104 | #endif
105 | PIN_TERMINATE
106 | };
107 |
108 | PIN_State keyPins;
109 | PIN_Handle hKeyPins;
110 |
111 | /*********************************************************************
112 | * PUBLIC FUNCTIONS
113 | */
114 | /*********************************************************************
115 | * @fn Board_initKeys
116 | *
117 | * @brief Enable interrupts for keys on GPIOs.
118 | *
119 | * @param appKeyCB - application key pressed callback
120 | *
121 | * @return none
122 | */
123 | void Board_initKeys(keysPressedCB_t appKeyCB)
124 | {
125 | // Initialize KEY pins. Enable int after callback registered
126 | hKeyPins = PIN_open(&keyPins, keyPinsCfg);
127 | PIN_registerIntCb(hKeyPins, Board_keyCallback);
128 |
129 | #if defined(CC2640R2MOD_RGZ)
130 | PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN1 | PIN_IRQ_NEGEDGE);
131 | PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN2 | PIN_IRQ_NEGEDGE);
132 | #endif
133 |
134 | #ifdef POWER_SAVING
135 | //Enable wakeup
136 | #if defined(CC2640R2MOD_RGZ)
137 | PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_BTN1 | PINCC26XX_WAKEUP_NEGEDGE);
138 | PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_BTN2 | PINCC26XX_WAKEUP_NEGEDGE);
139 | #endif
140 | #endif //POWER_SAVING
141 |
142 | // Setup keycallback for keys
143 | Util_constructClock(&keyChangeClock, Board_keyChangeHandler,
144 | KEY_DEBOUNCE_TIMEOUT, 0, false, 0);
145 |
146 | // Set the application callback
147 | appKeyChangeHandler = appKeyCB;
148 | }
149 |
150 | /*********************************************************************
151 | * @fn Board_keyCallback
152 | *
153 | * @brief Interrupt handler for Keys
154 | *
155 | * @param none
156 | *
157 | * @return none
158 | */
159 | static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId)
160 | {
161 | Util_startClock(&keyChangeClock);
162 | }
163 |
164 | /*********************************************************************
165 | * @fn Board_keyChangeHandler
166 | *
167 | * @brief Handler for key change
168 | *
169 | * @param UArg a0 - ignored
170 | *
171 | * @return none
172 | */
173 | static void Board_keyChangeHandler(UArg a0)
174 | {
175 | if (appKeyChangeHandler != NULL)
176 | {
177 | keysPressed = 0;
178 |
179 | #if defined(CC2640R2MOD_RGZ)
180 | if ( PIN_getInputValue(Board_BTN1) == 0 )
181 | {
182 | keysPressed |= KEY_BTN1;
183 | }
184 |
185 | if ( PIN_getInputValue(Board_BTN2) == 0 )
186 | {
187 | keysPressed |= KEY_BTN2;
188 | }
189 | #endif
190 |
191 | // Notify the application
192 | (*appKeyChangeHandler)(keysPressed);
193 | }
194 | }
195 | /*********************************************************************
196 | *********************************************************************/
197 |
--------------------------------------------------------------------------------
/target/LAUNCHIOT_CC2640R2MOD_RGZ/Board.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016, Texas Instruments Incorporated
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | *
9 | * * Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | *
12 | * * Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | *
16 | * * Neither the name of Texas Instruments Incorporated nor the names of
17 | * its contributors may be used to endorse or promote products derived
18 | * from this software without specific prior written permission.
19 | *
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | */
32 |
33 | #ifndef __BOARD_H
34 | #define __BOARD_H
35 |
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 |
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 |
47 | #include "LAUNCHIOT_CC2640R2MOD_RGZ.h"
48 |
49 | #define Board_initGeneral() CC2640R2_LAUNCHXL_initGeneral()
50 |
51 | /* These #defines allow us to reuse TI-RTOS across other device families */
52 |
53 | #define Board_ADC0 CC2640R2_LAUNCHXL_ADCVSS
54 | #define Board_ADC1 CC2640R2_LAUNCHXL_ADCVDDS
55 |
56 | #define Board_ADCBUF0 CC2640R2_LAUNCHXL_ADCBUF0
57 | #define Board_ADCBUFCHANNEL0 0
58 | #define Board_ADCBUFCHANNEL1 1
59 |
60 | #define Board_CRYPTO0 CC2640R2_LAUNCHXL_CRYPTO0
61 |
62 | #define Board_DIO0 CC2640R2_LAUNCHXL_DIO0
63 | #define Board_DIO1_RFSW CC2640R2_LAUNCHXL_DIO1_RFSW
64 | #define Board_DIO12 CC2640R2_LAUNCHXL_DIO12
65 | #define Board_DIO15 CC2640R2_LAUNCHXL_DIO15
66 | #define Board_DIO16_TDO CC2640R2_LAUNCHXL_DIO16_TDO
67 | #define Board_DIO17_TDI CC2640R2_LAUNCHXL_DIO17_TDI
68 | #define Board_DIO21 CC2640R2_LAUNCHXL_DIO21
69 | #define Board_DIO22 CC2640R2_LAUNCHXL_DIO22
70 |
71 | #define Board_DIO23_ANALOG CC2640R2_LAUNCHXL_DIO23_ANALOG
72 | #define Board_DIO24_ANALOG CC2640R2_LAUNCHXL_DIO24_ANALOG
73 | #define Board_DIO25_ANALOG CC2640R2_LAUNCHXL_DIO25_ANALOG
74 | #define Board_DIO26_ANALOG CC2640R2_LAUNCHXL_DIO26_ANALOG
75 | #define Board_DIO27_ANALOG CC2640R2_LAUNCHXL_DIO27_ANALOG
76 | #define Board_DIO28_ANALOG CC2640R2_LAUNCHXL_DIO28_ANALOG
77 | #define Board_DIO29_ANALOG CC2640R2_LAUNCHXL_DIO29_ANALOG
78 | #define Board_DIO30_ANALOG CC2640R2_LAUNCHXL_DIO30_ANALOG
79 |
80 | #define Board_GPIO_BUTTON0 CC2640R2_LAUNCHXL_GPIO_S1
81 | #define Board_GPIO_BUTTON1 CC2640R2_LAUNCHXL_GPIO_S2
82 | #define Board_GPIO_BTN1 CC2640R2_LAUNCHXL_GPIO_S1
83 | #define Board_GPIO_BTN2 CC2640R2_LAUNCHXL_GPIO_S2
84 | #define Board_GPIO_LED0 CC2640R2_LAUNCHXL_GPIO_LED_RED
85 | #define Board_GPIO_LED1 CC2640R2_LAUNCHXL_GPIO_LED_GREEN
86 | #define Board_GPIO_LED2 CC2640R2_LAUNCHXL_GPIO_LED_RED
87 | #define Board_GPIO_RLED CC2640R2_LAUNCHXL_GPIO_LED_RED
88 | #define Board_GPIO_GLED CC2640R2_LAUNCHXL_GPIO_LED_GREEN
89 | #define Board_GPIO_LED_ON CC2640R2_LAUNCHXL_GPIO_LED_ON
90 | #define Board_GPIO_LED_OFF CC2640R2_LAUNCHXL_GPIO_LED_OFF
91 |
92 | #define Board_GPTIMER0A CC2640R2_LAUNCHXL_GPTIMER0A
93 | #define Board_GPTIMER0B CC2640R2_LAUNCHXL_GPTIMER0B
94 | #define Board_GPTIMER1A CC2640R2_LAUNCHXL_GPTIMER1A
95 | #define Board_GPTIMER1B CC2640R2_LAUNCHXL_GPTIMER1B
96 | #define Board_GPTIMER2A CC2640R2_LAUNCHXL_GPTIMER2A
97 | #define Board_GPTIMER2B CC2640R2_LAUNCHXL_GPTIMER2B
98 | #define Board_GPTIMER3A CC2640R2_LAUNCHXL_GPTIMER3A
99 | #define Board_GPTIMER3B CC2640R2_LAUNCHXL_GPTIMER3B
100 |
101 | #define Board_I2C0 CC2640R2_LAUNCHXL_I2C0
102 |
103 | #define Board_PIN_BUTTON0 CC2640R2_LAUNCHXL_PIN_BTN1
104 | #define Board_PIN_BUTTON1 CC2640R2_LAUNCHXL_PIN_BTN2
105 | #define Board_PIN_BTN1 CC2640R2_LAUNCHXL_PIN_BTN1
106 | #define Board_PIN_BTN2 CC2640R2_LAUNCHXL_PIN_BTN2
107 | #define Board_PIN_LED0 CC2640R2_LAUNCHXL_PIN_RLED
108 | #define Board_PIN_LED1 CC2640R2_LAUNCHXL_PIN_GLED
109 | #define Board_PIN_LED2 CC2640R2_LAUNCHXL_PIN_RLED
110 | #define Board_PIN_RLED CC2640R2_LAUNCHXL_PIN_RLED
111 | #define Board_PIN_GLED CC2640R2_LAUNCHXL_PIN_GLED
112 |
113 | #define Board_PWM0 CC2640R2_LAUNCHXL_PWM0
114 | #define Board_PWM1 CC2640R2_LAUNCHXL_PWM1
115 | #define Board_PWM2 CC2640R2_LAUNCHXL_PWM2
116 | #define Board_PWM3 CC2640R2_LAUNCHXL_PWM3
117 | #define Board_PWM4 CC2640R2_LAUNCHXL_PWM4
118 | #define Board_PWM5 CC2640R2_LAUNCHXL_PWM5
119 | #define Board_PWM6 CC2640R2_LAUNCHXL_PWM6
120 | #define Board_PWM7 CC2640R2_LAUNCHXL_PWM7
121 |
122 | #define Board_SPI0 CC2640R2_LAUNCHXL_SPI0
123 | #define Board_SPI1 CC2640R2_LAUNCHXL_SPI1
124 | #define Board_SPI_FLASH_CS CC2640R2_LAUNCHXL_SPI_FLASH_CS
125 | #define Board_FLASH_CS_ON 0
126 | #define Board_FLASH_CS_OFF 1
127 |
128 | #define Board_UART0 CC2640R2_LAUNCHXL_UART0
129 |
130 | #define Board_WATCHDOG0 CC2640R2_LAUNCHXL_WATCHDOG0
131 |
132 | /*
133 | * These macros are provided for backwards compatibility.
134 | * Please use the _init functions directly rather
135 | * than Board_init.
136 | */
137 | #define Board_initADC() ADC_init()
138 | #define Board_initADCBuf() ADCBuf_init()
139 | #define Board_initGPIO() GPIO_init()
140 | #define Board_initPWM() PWM_init()
141 | #define Board_initSPI() SPI_init()
142 | #define Board_initUART() UART_init()
143 | #define Board_initWatchdog() Watchdog_init()
144 |
145 | /*
146 | * These macros are provided for backwards compatibility.
147 | * Please use the 'Board_PIN_xxx' macros to differentiate
148 | * them from the 'Board_GPIO_xxx' macros.
149 | */
150 | #define Board_BUTTON0 Board_PIN_BUTTON0
151 | #define Board_BUTTON1 Board_PIN_BUTTON1
152 | #define Board_BTN1 Board_PIN_BTN1
153 | #define Board_BTN2 Board_PIN_BTN2
154 | #define Board_LED_ON Board_GPIO_LED_ON
155 | #define Board_LED_OFF Board_GPIO_LED_OFF
156 | #define Board_LED0 Board_PIN_LED0
157 | #define Board_LED1 Board_PIN_LED1
158 | #define Board_LED2 Board_PIN_LED2
159 | #define Board_RLED Board_PIN_RLED
160 | #define Board_GLED Board_PIN_GLED
161 |
162 | #ifdef __cplusplus
163 | }
164 | #endif
165 |
166 | #endif /* __BOARD_H */
167 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/tirtos/iar/stack/build_config.opt:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file build_config.opt
4 |
5 | @brief This file contains the Bluetooth Low Energy (BLE) build config options.
6 |
7 | Group: CMCU, SCS
8 | Target Device: CC2640R2
9 |
10 | ******************************************************************************
11 |
12 | Copyright (c) 2011-2017, Texas Instruments Incorporated
13 | All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions
17 | are met:
18 |
19 | * Redistributions of source code must retain the above copyright
20 | notice, this list of conditions and the following disclaimer.
21 |
22 | * Redistributions in binary form must reproduce the above copyright
23 | notice, this list of conditions and the following disclaimer in the
24 | documentation and/or other materials provided with the distribution.
25 |
26 | * Neither the name of Texas Instruments Incorporated nor the names of
27 | its contributors may be used to endorse or promote products derived
28 | from this software without specific prior written permission.
29 |
30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 |
42 | ******************************************************************************
43 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
44 | Release Date: 2017-07-20 17:16:59
45 | *****************************************************************************/
46 |
47 | /*
48 | The following is a list of all possible build defines and corresponding options
49 | that can be set for each define:
50 |
51 | GATT_DB_OFF_CHIP - Indicates that the GATT database is maintained off the chip on the
52 | Application Processor (AP).
53 |
54 | GAP_BOND_MGR - Used to include the Bond Manager
55 |
56 | HOST_CONFIG (BLE Host Build Configurations) Possible Options:
57 | PERIPHERAL_CFG - Used to include the GAP Peripheral Role support
58 | CENTRAL_CFG - Used to include the GAP Central Role support
59 | BROADCASTER_CFG - Used to include the GAP Broadcaster Role support
60 | OBSERVER_CFG - Used to include the GAP Observer Role support
61 |
62 | BLE_V41_FEATURES Configure the stack to use features from the BLE 4.1 Specification
63 | L2CAP_COC_CFG - Enable L2CAP Connection Oriented Channels
64 | V41_CTRL_CFG - Enable Ping, Slave Feature Exchange, Connection Parameter Request, and
65 | Master Slave connection roles within the Controller. This feature
66 | is enabled by default and cannot be disabled.
67 |
68 | BLE_V42_FEATURES Configure the stack to use features from the BLE 4.2 Specification
69 | The following BLE 4.2 features are enabled by default and cannot
70 | be disabled.
71 | EXT_DATA_LEN_CFG - Enable the Extended Data Length Feature in the Controller
72 | SECURE_CONNS_CFG - Enable Secure Connections Pairing Procedure
73 | PRIVACY_1_2_CFG - Enable Enhanced Privacy
74 |
75 | BLE_V50_FEATURES Configure the stack to use features from the BLE 5.0 Specification
76 | The following BLE 5.0 features are enabled by default and cannot
77 | be disabled.
78 | PHY_2MBPS_CFG - Enable 2 Mbps data rate in the Controller
79 | HDC_NC_ADV_CFG - Enable High Duty Cycle Non-Connectable Advertising
80 | CHAN_ALGO2_CFG - Enable Channel Selection Algorithm 2
81 |
82 | HCI_TL_FULL - All supported HCI commands are available via the Tranport Layer's NPI.
83 | - Intended for NP solution.
84 | HCI_TL_PTM - Only those HCI commands needed for Production Test Mode are available
85 | via the Transport Layer's NPI
86 | - Intended for SOC solutions where, during production, accesss is temporarily
87 | needed (e.g. for PHY testing using Direct Test Mode, etc.).
88 | HCI_TL_NONE - No supported HCI commands are available via the Transport Layer's NPI.
89 | - Intended for SOC solutions.
90 |
91 | Below is general information for using and/or changing this configuration option file:
92 |
93 | Combo Roles: Combo roles can be set by defining multiple roles for HOST_CONFIG. The possible
94 | combo roles and HOST_CONFIG defines are:
95 | Peripheral + Observer : PERIPHERAL_CFG+OBSERVER_CFG
96 | Central + Broadcaster : CENTRAL_CFG+BROADCASTER_CFG
97 | Peripheral + Central : PERIPHERAL_CFG+CENTRAL_CFG
98 |
99 | lib_search tool: There is a pre build action for every stack project that runs a tool
100 | lib_search.exe. This tool aims to automatically import the correct library
101 | files into your project based on the defines in this file.
102 |
103 | The locations of all library files and their correspond options are
104 | /ble_core/ble_[host,ctrl]_lib/ for stack libs
105 | and at /ble_core/hci_tl_lib/ for
106 | HCI Transport Layer libs
107 |
108 | If an library is found that was built with matching options, it will be
109 | copied into the project local directory at /../../lib/ and
110 | subsequently linked with the stack.
111 |
112 | If you experience a build error with lib_search.exe, expand the build error
113 | message by clicking Tools->Options->Messages->Show build messages:->All.
114 | The error messages printed out by the lib_search tool should now appear in
115 | your Build Message window.
116 |
117 | */
118 |
119 | /* BLE Host Build Configurations */
120 | -DHOST_CONFIG=PERIPHERAL_CFG
121 | /* -DHOST_CONFIG=CENTRAL_CFG */
122 | /* -DHOST_CONFIG=BROADCASTER_CFG */
123 | /* -DHOST_CONFIG=OBSERVER_CFG */
124 | /* -DHOST_CONFIG=PERIPHERAL_CFG+OBSERVER_CFG */
125 | /* -DHOST_CONFIG=CENTRAL_CFG+BROADCASTER_CFG */
126 | /* -DHOST_CONFIG=PERIPHERAL_CFG+CENTRAL_CFG */
127 |
128 | /* GATT Database being off chip */
129 | /* -DGATT_DB_OFF_CHIP */
130 |
131 | /* Include GAP Bond Manager */
132 | -DGAP_BOND_MGR
133 |
134 | /* BLE v4.1 Features */
135 | /* -DV41_FEATURES=L2CAP_COC_CFG */
136 |
137 | /* BLE v4.2 Features
138 | * Note: For advanced users who choose to explicitly build their BLE
139 | * Stack without ROM the following upper limit on RAM usage must be
140 | * observed when using the Secure Connections Feature:
141 | * R1: 0x20004F2C
142 | * R2: 0x20004F80
143 | * When using linker command files provided by this SDK, the linker
144 | * symbol ENCRYPTION_ROM=1 or ENCRYPTION_ROM=2 may be defined to set
145 | * this upper limit for R1 and R2 devices, respectively.
146 | */
147 |
148 | /* BLE v5.0 Features
149 | * Note: The Long Range feature is for evaluation only.
150 | */
151 | /* -DV50_FEATURES=PHY_LR_CFG */
152 |
153 | /* Include Transport Layer (Full or PTM) */
154 | -DHCI_TL_NONE
155 | /* -DHCI_TL_PTM */
156 | /* -DHCI_TL_FULL */
157 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/stack/osal_icall_ble.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file osal_icall_ble.c
4 |
5 | @brief This file contains function that allows user setup tasks
6 |
7 | Group: CMCU, SCS
8 | Target Device: CC2640R2
9 |
10 | ******************************************************************************
11 |
12 | Copyright (c) 2013-2017, Texas Instruments Incorporated
13 | All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions
17 | are met:
18 |
19 | * Redistributions of source code must retain the above copyright
20 | notice, this list of conditions and the following disclaimer.
21 |
22 | * Redistributions in binary form must reproduce the above copyright
23 | notice, this list of conditions and the following disclaimer in the
24 | documentation and/or other materials provided with the distribution.
25 |
26 | * Neither the name of Texas Instruments Incorporated nor the names of
27 | its contributors may be used to endorse or promote products derived
28 | from this software without specific prior written permission.
29 |
30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 |
42 | ******************************************************************************
43 | Release Name: simplelink_cc2640r2_sdk_1_35_00_29
44 | Release Date: 2017-04-21 17:44:47
45 | *****************************************************************************/
46 |
47 | /**************************************************************************************************
48 | * INCLUDES
49 | **************************************************************************************************/
50 | #include
51 | #include "hal_types.h"
52 | #include "hal_mcu.h"
53 | #include "osal.h"
54 | #include "osal_tasks.h"
55 | #include "osal_snv.h"
56 |
57 |
58 | /* LL */
59 | #include "ll.h"
60 |
61 | #if defined ( OSAL_CBTIMER_NUM_TASKS )
62 | #include "osal_cbtimer.h"
63 | #endif
64 |
65 | /* L2CAP */
66 | #include "l2cap.h"
67 |
68 | /* gap */
69 | #include "gap.h"
70 |
71 | #if defined ( GAP_BOND_MGR )
72 | #include "gapbondmgr.h"
73 | #endif
74 |
75 | /* GATT */
76 | #include "gatt.h"
77 |
78 | /* Application */
79 | #include "hci_tl.h"
80 |
81 | #include "gattservapp.h"
82 |
83 | #include "gapbondmgr.h"
84 |
85 | #include "ble_user_config.h"
86 | #include "ble_dispatch.h"
87 |
88 |
89 | #ifdef USE_ICALL
90 |
91 | #ifdef ICALL_JT
92 | #include "icall_jt.h"
93 | #endif /* ICALL_JT */
94 |
95 | #ifdef ICALL_LITE
96 | #include "icall_lite_translation.h"
97 | #include "ble_dispatch_lite.h"
98 | #endif /* ICALL_LITE */
99 |
100 | #endif /* USE_ICALL */
101 |
102 | /*********************************************************************
103 | * GLOBAL VARIABLES
104 | */
105 |
106 | // The order in this table must be identical to the task initialization calls below in osalInitTask.
107 | const pTaskEventHandlerFn tasksArr[] =
108 | {
109 | LL_ProcessEvent, // task 0
110 | HCI_ProcessEvent, // task 1
111 | #if defined ( OSAL_CBTIMER_NUM_TASKS )
112 | OSAL_CBTIMER_PROCESS_EVENT( osal_CbTimerProcessEvent ), // task 2
113 | #endif
114 | L2CAP_ProcessEvent, // task 3
115 | GAP_ProcessEvent, // task 4
116 | SM_ProcessEvent, // task 5
117 | GATT_ProcessEvent, // task 6
118 | GATTServApp_ProcessEvent, // task 7
119 | #if defined ( GAP_BOND_MGR )
120 | GAPBondMgr_ProcessEvent, // task 8
121 | #endif
122 | #ifdef ICALL_LITE
123 | ble_dispatch_liteProcess, // task 9
124 | #else
125 | bleDispatch_ProcessEvent // task 9
126 | #endif /* ICALL_LITE */
127 | };
128 |
129 | const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
130 | uint16 *tasksEvents;
131 |
132 | /*********************************************************************
133 | * FUNCTIONS
134 | *********************************************************************/
135 |
136 | /*********************************************************************
137 | * @fn osalInitTasks
138 | *
139 | * @brief This function invokes the initialization function for each task.
140 | *
141 | * @param void
142 | *
143 | * @return none
144 | */
145 | void osalInitTasks( void )
146 | {
147 | ICall_EntityID entity;
148 | ICall_SyncHandle syncHandle;
149 | uint8 taskID = 0;
150 | uint8 i;
151 |
152 | tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
153 | osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));
154 |
155 | /* LL Task */
156 | LL_Init( taskID++ );
157 |
158 | /* HCI Task */
159 | HCI_Init( taskID++ );
160 |
161 | #if defined ( OSAL_CBTIMER_NUM_TASKS )
162 | /* Callback Timer Tasks */
163 | osal_CbTimerInit( taskID );
164 | taskID += OSAL_CBTIMER_NUM_TASKS;
165 | #endif
166 |
167 | /* L2CAP Task */
168 | L2CAP_Init( taskID++ );
169 |
170 | /* GAP Task */
171 | GAP_Init( taskID++ );
172 |
173 | /* SM Task */
174 | SM_Init( taskID++ );
175 |
176 | /* GATT Task */
177 | GATT_Init( taskID++ );
178 |
179 | /* GATT Server App Task */
180 | GATTServApp_Init( taskID++ );
181 |
182 | #if defined ( GAP_BOND_MGR )
183 | /* Bond Manager Task */
184 | GAPBondMgr_Init( taskID++ );
185 | #endif
186 |
187 | #ifdef ICALL_LITE
188 | ble_dispatch_liteInit(taskID++);
189 | #else
190 | /* ICall BLE Dispatcher Task */
191 | bleDispatch_Init( taskID );
192 | #endif /* ICALL_LITE */
193 |
194 | // ICall enrollment
195 | /* Enroll the service that this stack represents */
196 | ICall_enrollService(ICALL_SERVICE_CLASS_BLE, NULL, &entity, &syncHandle);
197 |
198 | #ifndef ICALL_LITE
199 | /* Enroll the obtained dispatcher entity and OSAL task ID of HCI Ext App
200 | * to OSAL so that OSAL can route the dispatcher message into
201 | * the appropriate OSAL task.
202 | */
203 | osal_enroll_dispatchid(taskID, entity);
204 | #endif /* ICALL_LITE */
205 | /* Register all other OSAL tasks to use the registered dispatcher entity
206 | * ID as the source of dispatcher messages, even though the other OSAL
207 | * tasks didn't register themselves to receive messages from application.
208 | */
209 | for (i = 0; i < taskID; i++)
210 | {
211 | osal_enroll_senderid(i, entity);
212 | }
213 | }
214 |
215 | /**
216 | * Main entry function for the stack image
217 | */
218 | int stack_main( void *arg )
219 | {
220 | /* User reconfiguration of BLE Controller and Host variables */
221 | #ifdef ICALL_JT
222 | setBleUserConfig( (icall_userCfg_t *)arg );
223 | #else /* !(ICALL_JT) */
224 | setBleUserConfig( (bleUserCfg_t *)arg );
225 | #endif /* ICALL_JT */
226 |
227 | /* Establish OSAL for a stack service that requires accompanying
228 | * messaging service */
229 | if (ICall_enrollService(ICALL_SERVICE_CLASS_BLE_MSG,
230 | (ICall_ServiceFunc) osal_service_entry,
231 | &osal_entity,
232 | &osal_syncHandle) != ICALL_ERRNO_SUCCESS)
233 | {
234 | /* abort */
235 | ICall_abort();
236 | }
237 |
238 | // Disable interrupts
239 | halIntState_t state;
240 | HAL_ENTER_CRITICAL_SECTION(state);
241 |
242 | #if defined(ICALL_LITE) && (!defined(STACK_LIBRARY))
243 | {
244 | icall_liteTranslationInit((uint32_t*)bleAPItable);
245 | }
246 | #endif /* ICALL_LITE */
247 |
248 | #ifdef ICALL_LITE
249 | {
250 | osal_set_icall_hook(icall_liteMsgParser);
251 | }
252 | #endif /* ICALL_LITE */
253 |
254 | // Initialize NV System
255 | osal_snv_init( );
256 |
257 | // Initialize the operating system
258 | osal_init_system();
259 |
260 | // Allow interrupts
261 | HAL_EXIT_CRITICAL_SECTION(state);
262 |
263 | osal_start_system(); // No Return from here
264 |
265 | return 0; // Shouldn't get here.
266 | }
267 |
268 | /*********************************************************************
269 | *********************************************************************/
270 |
--------------------------------------------------------------------------------
/target/urfc.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | Group: WCS BTS
4 | Target Device: CC2640R2
5 |
6 | ******************************************************************************
7 |
8 | Copyright (c) 2016-2017, Texas Instruments Incorporated
9 | All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions
13 | are met:
14 |
15 | * Redistributions of source code must retain the above copyright
16 | notice, this list of conditions and the following disclaimer.
17 |
18 | * Redistributions in binary form must reproduce the above copyright
19 | notice, this list of conditions and the following disclaimer in the
20 | documentation and/or other materials provided with the distribution.
21 |
22 | * Neither the name of Texas Instruments Incorporated nor the names of
23 | its contributors may be used to endorse or promote products derived
24 | from this software without specific prior written permission.
25 |
26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
36 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 |
38 | ******************************************************************************
39 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
40 | Release Date: 2017-07-20 17:16:59
41 | *****************************************************************************/
42 |
43 | /**
44 | * @addtogroup Micro_BLE_Stack
45 | * @{
46 | * @defgroup URF Micro RF Settings
47 | * @{
48 | * @file urfc.h
49 | * @brief This file contains configurable variables for the Micro BLE Stack
50 | * radio.
51 | *
52 | * In general, the configuration values vary by device type, device version
53 | * and board characteristics. The definitions and values listed in
54 | * urfcfg.h and urfcfg.c can be changed or more sets of definitions and
55 | * values can be added, depending on which version/type of device and what
56 | * characteristics the board has.
57 | *
58 | * @note User configurable variables except the elements of
59 | * the power table are only used during the initialization
60 | * of the MAC. Changing the values of these variables
61 | * except power table elements after this will have no
62 | * effect.
63 | */
64 |
65 | #ifndef URFC_H
66 | #define URFC_H
67 |
68 | #ifdef __cplusplus
69 | extern "C"
70 | {
71 | #endif
72 |
73 | /*******************************************************************************
74 | * INCLUDES
75 | */
76 | #include
77 | #if !defined(CC26XX_R2)
78 | #include
79 | #include
80 | #endif /* !CC26XX_R2 */
81 | #include
82 |
83 | /*******************************************************************************
84 | * MACROS
85 | */
86 |
87 | /**
88 | * @brief TX power table calculation
89 | *
90 | * 15..8 | 7..6 | 5..0
91 | * tempCoeff | GC | IB
92 | */
93 | #define TX_POUT( IB, GC, TC ) \
94 | (uint16)((((TC) & 0xFF) << 8) | (((GC) & 0x03) << 6) | ((IB) & 0x3F))
95 |
96 | /*******************************************************************************
97 | * CONSTANTS
98 | */
99 |
100 | /** @defgroup URF_Constants Micro RF Constants
101 | * @{
102 | */
103 |
104 | /**
105 | * @defgroup URF_RF_Front_Settings Micro BLE Stack RF Front End Settings
106 | * @{
107 | * @note The use of these values completely depends on how the PCB is laid out.
108 | *
109 | * The device may come in more than one type of packages.
110 | * For each package, the user may change how the RF Front End (FE) is
111 | * configured. The possible FE settings are provided as a set of defines.
112 | * (The user can also set the FE bias, the settings of which are also provided
113 | * as defines.) The user can change the value of @ref RF_FE_MODE_AND_BIAS to
114 | * configure the RF FE as desired. However, while setting the FE configuration
115 | * determines how the device is configured at the package, it is the PCB the
116 | * device is mounted on (the EM) that determines how those signals are routed.
117 | * So while the FE is configurable, how signals are used is fixed by the EM.
118 | * As can be seen, the value of @ref RF_FE_MODE_AND_BIAS is organized by the EM
119 | * board as defined by EMs produced by Texas Instruments Inc. How the device
120 | * is mounted, routed, and configured for a user product would of course be
121 | * user defined, and the value of @ref RF_FE_MODE_AND_BIAS would have to be set
122 | * accordingly; the user could even dispense with the conditional board
123 | * compiles entirely. So too with the usage of the Tx Power tables.
124 | */
125 | #define RF_FRONTEND_MODE_MASK 0x07 //!< Frontend Mode Mask
126 | #define RF_FE_DIFFERENTIAL 0 //!< Differential
127 | #define RF_FE_SINGLE_ENDED_RFP 1 //!< Single Ended RFP
128 | #define RF_FE_SINGLE_ENDED_RFN 2 //!< Single Ended RFN
129 | #define RF_FE_ANT_DIVERSITY_RFP_FIRST 3 //!< Antenna Diversity RFP First
130 | #define RF_FE_ANT_DIVERSITY_RFN_FIRST 4 //!< Antenna Diveristy RFN First
131 | #define RF_FE_SINGLE_ENDED_RFP_EXT_PINS 5 //!< Single Ended RFP External Pins
132 | #define RF_FE_SINGLE_ENDED_RFN_EXT_PINS 6 //!< Single Ended RFN External Pins
133 |
134 | #define RF_BIAS_MODE_MASK 0x08 //!< RF Bias Mode Mask
135 | #define RF_FE_INT_BIAS (0<<3) //!< Internal Bias
136 | #define RF_FE_EXT_BIAS (1<<3) //!< External Bias
137 |
138 | #if defined(CC2650_LAUNCHXL) || defined(CC2640R2MOD_RGZ) || defined(CC2650DK_7ID)
139 |
140 | #define RF_FE_MODE_AND_BIAS (RF_FE_DIFFERENTIAL | RF_FE_EXT_BIAS) //!< RF Front End Mode and Bias Configuration
141 | #define RF_FE_IOD_NUM 3 //!< IOD Number
142 | #define RF_FE_IOD {NULL, NULL, NULL} //!< IOD
143 | #define RF_FE_IOD_VAL {NULL, NULL, NULL} //!< IOD Value
144 | #define RF_FE_SATURATION 0 //!< // RF FE saturation
145 | #define RF_FE_SENSITIVITY 0 //!< // RF FE sensitivity
146 |
147 | /** @} End URF_RF_Front_Settings */
148 |
149 | /**
150 | * @defgroup URF_TX_Power Micro BLE Stack TX Power Options
151 | * @{
152 | */
153 | #define TX_POWER_5_DBM 5 //!< 5 dBm
154 | #define TX_POWER_4_DBM 4 //!< 4 dBm
155 | #define TX_POWER_3_DBM 3 //!< 3 dBm
156 | #define TX_POWER_2_DBM 2 //!< 2 dBm
157 | #define TX_POWER_1_DBM 1 //!< 1 dBm
158 | #define TX_POWER_0_DBM 0 //!< 0 dBm
159 | #define TX_POWER_MINUS_3_DBM -3 //!< -3 dBm
160 | #define TX_POWER_MINUS_6_DBM -6 //!< -6 dBm
161 | #define TX_POWER_MINUS_9_DBM -9 //!< -9 dBm
162 | #define TX_POWER_MINUS_12_DBM -12 //!< -12 dBm
163 | #define TX_POWER_MINUS_15_DBM -15 //!< -15 dBm
164 | #define TX_POWER_MINUS_18_DBM -18 //!< -18 dBm
165 | #define TX_POWER_MINUS_21_DBM -21 //!< -21 dBm
166 | /** @} End URF_TX_Power */
167 |
168 | #endif /* CC2650_LAUNCHXL || CC2640R2_LAUNCHXL || CC2650DK_7ID */
169 |
170 | /** @} End URF_Constants */
171 |
172 | /*******************************************************************************
173 | * TYPEDEFS
174 | */
175 |
176 | /** @defgroup URF_Structures Micro RF Structures
177 | * @{
178 | */
179 |
180 | PACKED_TYPEDEF_CONST_STRUCT
181 | {
182 | int8 dBm; //!< dBm
183 | uint16 txPowerVal; //!< Tx Power Value
184 | } ubTxPowerVal_t; //!< Tx Power Value
185 |
186 | PACKED_TYPEDEF_CONST_STRUCT
187 | {
188 | ubTxPowerVal_t* pTxPowerVals; //!< pointer to Tx Power Values
189 | uint8 numTxPowerVal; //!< Number of Tx Power Values
190 | } ubTxPowerTable_t; //!< Tx Power Table
191 |
192 | /*******************************************************************************
193 | * LOCAL VARIABLES
194 | */
195 |
196 | /*******************************************************************************
197 | * GLOBAL VARIABLES
198 | */
199 |
200 | /** @brief RF Core patch */
201 | extern const RF_Mode ubRfMode;
202 | /** @brief Overrides for CMD_RADIO_SETUP */
203 | extern uint32 ubRfRegOverride[];
204 | /** @brief TX Power table */
205 | extern const ubTxPowerTable_t ubTxPowerTable;
206 | /** @brief RF frontend mode bias */
207 | extern const uint8 ubFeModeBias;
208 |
209 | /** @} End URF_Structures */
210 |
211 | /*********************************************************************
212 | * FUNCTIONS
213 | */
214 |
215 | #ifdef __cplusplus
216 | }
217 | #endif
218 |
219 | #endif /* URFC_H */
220 |
221 | /** @} End URF */
222 |
223 | /** @} */ // end of Micro_BLE_Stack
224 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/app/epd2in13.c:
--------------------------------------------------------------------------------
1 |
2 | #include "epd2in13.h"
3 |
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | #include "board.h"
10 |
11 | // for debug
12 | //#include "inc/sdi_task.h"
13 | #include "util.h"
14 |
15 | #include
16 |
17 |
18 | #define BLUE_LED_PIN IOID_0 // low active
19 |
20 | #define REED_PIN IOID_13 // reed switch, ground when there is magnet
21 | #define TEST_PIN IOID_15 // on back of pcb with 'test'
22 |
23 | #define EPD_POWER_PIN IOID_20 // low active
24 |
25 | #define EPD_RST_PIN IOID_10
26 | #define EPD_DC_PIN IOID_11
27 | #define EPD_BUSY_PIN IOID_9
28 | #define EPD_CS_PIN IOID_12
29 |
30 |
31 |
32 | /*********************************************************************
33 | * LOCAL PARAMETER
34 | */
35 | static PIN_Handle GPIOHandle = NULL;
36 | static PIN_State GPIOState;
37 | static PIN_Config GPIOTable[] =
38 | {
39 | EPD_BUSY_PIN | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
40 |
41 | EPD_POWER_PIN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,
42 |
43 | EPD_DC_PIN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,
44 | EPD_RST_PIN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,
45 | EPD_CS_PIN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,
46 |
47 |
48 | PIN_TERMINATE
49 | };
50 |
51 | static SPI_Handle SPIHandle = NULL;
52 | static SPI_Params SPIparams;
53 |
54 |
55 | const unsigned char EPD_2IN13_lut_full_update[]= {
56 | 0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7
57 | 0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7
58 | 0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7
59 | 0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7
60 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7
61 |
62 | 0x03,0x03,0x00,0x00,0x02, // TP0 A~D RP0
63 | 0x09,0x09,0x00,0x00,0x02, // TP1 A~D RP1
64 | 0x03,0x03,0x00,0x00,0x02, // TP2 A~D RP2
65 | 0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3
66 | 0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4
67 | 0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5
68 | 0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6
69 |
70 | 0x15,0x41,0xA8,0x32,0x30,0x0A,
71 | };
72 |
73 | // quick and dirty way
74 | // Task_sleep defined in
75 | static void Util_delay_ms(uint16_t t)
76 | {
77 | Task_sleep( ((t) * 1000) / Clock_tickPeriod );
78 | }
79 |
80 | static void HwUARTPrintf(const char *str)
81 | {
82 | // HWUART_Printf(str);
83 | }
84 |
85 | static void DEV_Digital_Write(uint32_t pin, uint8_t value)
86 | {
87 | PIN_setOutputValue(GPIOHandle, pin, value);
88 | }
89 |
90 | static int DEV_Digital_Read(uint32_t pin)
91 | {
92 | int ret;
93 | ret = PIN_getInputValue(pin);
94 | return ret;
95 | }
96 |
97 | static void DEV_Delay_ms(uint16_t t)
98 | {
99 | Util_delay_ms(t);
100 | }
101 |
102 | static void DEV_SPI_WriteByte(uint8_t byte)
103 | {
104 | uint8_t txbuf[2];
105 | uint8_t rxbuf[2];
106 |
107 | txbuf[0] = byte;
108 |
109 | SPI_Transaction spiTransaction;
110 | spiTransaction.arg = NULL;
111 | spiTransaction.count = 1;
112 | spiTransaction.txBuf = txbuf;
113 | spiTransaction.rxBuf = rxbuf;
114 |
115 |
116 |
117 | bool ok = SPI_transfer(SPIHandle, &spiTransaction);
118 |
119 | if (!ok) {
120 | HwUARTPrintf("spi transf fail\r\n");
121 | }
122 |
123 |
124 | }
125 |
126 | // should be only called once!
127 | void epd_hw_init()
128 | {
129 |
130 | HwUARTPrintf("setup epd gpio\r\n");
131 | GPIOHandle = PIN_open(&GPIOState, GPIOTable);
132 |
133 | HwUARTPrintf("setup epd spi\r\n");
134 |
135 | SPI_init();
136 | SPI_Params_init(&SPIparams);
137 | SPIparams.bitRate = 1000000; //1MHz
138 | SPIparams.dataSize = 8;
139 | SPIparams.frameFormat = SPI_POL0_PHA0; //
140 | SPIparams.mode = SPI_MASTER; //SPI master
141 | SPIparams.transferCallbackFxn = NULL;
142 | SPIparams.transferMode = SPI_MODE_BLOCKING; // blocking
143 | SPIparams.transferTimeout = SPI_WAIT_FOREVER;
144 |
145 | SPIHandle = SPI_open(CC2640R2_LAUNCHXL_SPI0, &SPIparams);
146 | if (NULL == SPIHandle) {
147 | HwUARTPrintf("spi open fail\r\n");
148 | }
149 |
150 | }
151 |
152 |
153 |
154 | /******************************************************************************
155 | function : Software reset
156 | parameter:
157 | ******************************************************************************/
158 | static void EPD_2IN13_Reset(void)
159 | {
160 | DEV_Digital_Write(EPD_RST_PIN, 1);
161 | DEV_Delay_ms(200);
162 | DEV_Digital_Write(EPD_RST_PIN, 0);
163 | DEV_Delay_ms(2);
164 | DEV_Digital_Write(EPD_RST_PIN, 1);
165 | DEV_Delay_ms(200);
166 | }
167 |
168 | /******************************************************************************
169 | function : send command
170 | parameter:
171 | Reg : Command register
172 | ******************************************************************************/
173 | static void EPD_2IN13_SendCommand(uint8_t Reg)
174 | {
175 | DEV_Digital_Write(EPD_DC_PIN, 0);
176 | DEV_Digital_Write(EPD_CS_PIN, 0);
177 | DEV_SPI_WriteByte(Reg);
178 | DEV_Digital_Write(EPD_CS_PIN, 1);
179 | }
180 |
181 | /******************************************************************************
182 | function : send data
183 | parameter:
184 | Data : Write data
185 | ******************************************************************************/
186 | static void EPD_2IN13_SendData(uint8_t Data)
187 | {
188 | DEV_Digital_Write(EPD_DC_PIN, 1);
189 | DEV_Digital_Write(EPD_CS_PIN, 0);
190 | DEV_SPI_WriteByte(Data);
191 | DEV_Digital_Write(EPD_CS_PIN, 1);
192 | }
193 |
194 | /******************************************************************************
195 | function : Wait until the busy_pin goes LOW
196 | parameter:
197 | ******************************************************************************/
198 | void EPD_2IN13_ReadBusy(void)
199 | {
200 | HwUARTPrintf("e-Paper busy\r\n");
201 | while(DEV_Digital_Read(EPD_BUSY_PIN) == 1) { //LOW: idle, HIGH: busy
202 | DEV_Delay_ms(100);
203 | }
204 | HwUARTPrintf("e-Paper busy release\r\n");
205 | }
206 |
207 |
208 | /******************************************************************************
209 | function : Initialize the e-Paper register
210 | parameter:
211 | ******************************************************************************/
212 | void EPD_2IN13_Init()
213 | {
214 | // power on
215 | DEV_Digital_Write(EPD_POWER_PIN, 0);
216 | DEV_Delay_ms(100);
217 |
218 | EPD_2IN13_Reset();
219 |
220 |
221 | EPD_2IN13_ReadBusy();
222 | EPD_2IN13_SendCommand(0x12); // soft reset
223 | EPD_2IN13_ReadBusy();
224 |
225 | EPD_2IN13_SendCommand(0x74); //set analog block control
226 | EPD_2IN13_SendData(0x54);
227 | EPD_2IN13_SendCommand(0x7E); //set digital block control
228 | EPD_2IN13_SendData(0x3B);
229 |
230 | EPD_2IN13_SendCommand(0x01); //Driver output control
231 | EPD_2IN13_SendData(0xD3);
232 | EPD_2IN13_SendData(0x00);
233 | EPD_2IN13_SendData(0x00);
234 |
235 | EPD_2IN13_SendCommand(0x11); //data entry mode
236 | EPD_2IN13_SendData(0x01);
237 |
238 | EPD_2IN13_SendCommand(0x44); //set Ram-X address start/end position
239 | EPD_2IN13_SendData(0x00);
240 | EPD_2IN13_SendData(0x0C); //0x0C-->(15+1)*8=128
241 |
242 | EPD_2IN13_SendCommand(0x45); //set Ram-Y address start/end position
243 | EPD_2IN13_SendData(0xD3); //0xF9-->(249+1)=250
244 | EPD_2IN13_SendData(0x00);
245 | EPD_2IN13_SendData(0x00);
246 | EPD_2IN13_SendData(0x00);
247 |
248 | EPD_2IN13_SendCommand(0x3C); //BorderWavefrom
249 | EPD_2IN13_SendData(0x01);
250 |
251 | // load lut
252 |
253 | EPD_2IN13_SendCommand(0x18); // set built in temperature sensor
254 | EPD_2IN13_SendData(0x80); //
255 |
256 | EPD_2IN13_SendCommand(0x22); //
257 | EPD_2IN13_SendData(0xB1); //
258 |
259 | EPD_2IN13_SendCommand(0x20); // load LUT from OTP
260 |
261 | EPD_2IN13_ReadBusy();
262 | DEV_Delay_ms(100);
263 |
264 | HwUARTPrintf("epd initialized\r\n");
265 | }
266 |
267 | /******************************************************************************
268 | function : Clear screen
269 | parameter:
270 | ******************************************************************************/
271 | void EPD_2IN13_Clear(void)
272 | {
273 | HwUARTPrintf("epd clear\r\n");
274 | uint16_t Width, Height;
275 | Width = (EPD_2IN13_WIDTH % 8 == 0)? (EPD_2IN13_WIDTH / 8 ): (EPD_2IN13_WIDTH / 8 + 1);
276 | Height = EPD_2IN13_HEIGHT;
277 |
278 | EPD_2IN13_SendCommand(0x24);
279 | for (uint16_t j = 0; j < Height; j++) {
280 | for (uint16_t i = 0; i < Width; i++) {
281 | EPD_2IN13_SendData(0XFF);
282 | }
283 | }
284 |
285 | EPD_2IN13_UpdateDisplay();
286 | }
287 |
288 | /******************************************************************************
289 | function : Sends the image buffer in RAM to e-Paper and displays
290 | parameter:
291 | ******************************************************************************/
292 | void EPD_2IN13_Display(const uint8_t *Image)
293 | {
294 | uint16_t Width, Height;
295 | Width = (EPD_2IN13_WIDTH % 8 == 0)? (EPD_2IN13_WIDTH / 8 ): (EPD_2IN13_WIDTH / 8 + 1);
296 | Height = EPD_2IN13_HEIGHT;
297 |
298 | EPD_2IN13_SendCommand(0x24);
299 | for (uint16_t j = 0; j < Height; j++) {
300 | for (uint16_t i = 0; i < Width; i++) {
301 | EPD_2IN13_SendData(Image[i + j * Width]);
302 | }
303 | }
304 | EPD_2IN13_UpdateDisplay();
305 | }
306 |
307 | void EPD_2IN13_PrepareBlkRAM(void)
308 | {
309 | EPD_2IN13_SendCommand(0x4E); // set RAM x address counter
310 | EPD_2IN13_SendData(0x00);
311 |
312 | EPD_2IN13_SendCommand(0x4F); // set RAM Y address counter
313 | EPD_2IN13_SendData(0xD3);
314 | EPD_2IN13_SendData(0x00);
315 |
316 | // black white image
317 | EPD_2IN13_SendCommand(0x24);
318 |
319 | }
320 |
321 | void EPD_2IN13_PrepareRedRAM(void)
322 | {
323 | EPD_2IN13_SendCommand(0x4E); // set RAM x address counter
324 | EPD_2IN13_SendData(0x00);
325 |
326 | EPD_2IN13_SendCommand(0x4F); // set RAM Y address counter
327 | EPD_2IN13_SendData(0xD3);
328 | EPD_2IN13_SendData(0x00);
329 |
330 | // red white image
331 | EPD_2IN13_SendCommand(0x26);
332 | }
333 |
334 | void EPD_2IN13_WriteRAM(const uint8_t *buf, const int len)
335 | {
336 | for (int i = 0; i < len; i++) {
337 | EPD_2IN13_SendData(buf[i]);
338 | }
339 | }
340 |
341 | void EPD_2IN13_UpdateDisplay(void)
342 | {
343 | HwUARTPrintf("turn on display\r\n");
344 |
345 | EPD_2IN13_SendCommand(0x22);
346 | EPD_2IN13_SendData(0xC7);
347 | EPD_2IN13_SendCommand(0x20);
348 | EPD_2IN13_ReadBusy();
349 | DEV_Delay_ms(200);
350 | }
351 |
352 | /******************************************************************************
353 | function : Enter sleep mode
354 | parameter:
355 | ******************************************************************************/
356 | void EPD_2IN13_Sleep(void)
357 | {
358 | EPD_2IN13_SendCommand(0x22); //POWER OFF
359 | EPD_2IN13_SendData(0xC3);
360 | EPD_2IN13_SendCommand(0x20);
361 |
362 | EPD_2IN13_SendCommand(0x10); //enter deep sleep
363 | EPD_2IN13_SendData(0x01);
364 | DEV_Delay_ms(100);
365 |
366 | // power off
367 | DEV_Digital_Write(EPD_POWER_PIN, 1);
368 | DEV_Delay_ms(100);
369 | }
370 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/java/com/nordicsemi/nrfUARTv2/DeviceListActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.nordicsemi.nrfUARTv2;
18 |
19 | import java.util.ArrayList;
20 | import java.util.HashMap;
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 |
25 |
26 | import android.app.Activity;
27 | import android.bluetooth.BluetoothAdapter;
28 | import android.bluetooth.BluetoothDevice;
29 | import android.bluetooth.BluetoothManager;
30 | import android.content.BroadcastReceiver;
31 | import android.content.ComponentName;
32 | import android.content.Context;
33 | import android.content.Intent;
34 | import android.content.IntentFilter;
35 | import android.content.ServiceConnection;
36 | import android.content.pm.PackageManager;
37 | import android.graphics.Color;
38 | import android.os.Bundle;
39 | import android.os.Handler;
40 | import android.os.IBinder;
41 | import android.os.Message;
42 | import android.util.Log;
43 | import android.view.Gravity;
44 | import android.view.LayoutInflater;
45 | import android.view.View;
46 | import android.view.View.OnClickListener;
47 | import android.view.ViewGroup;
48 | import android.view.Window;
49 | import android.widget.AdapterView;
50 | import android.widget.AdapterView.OnItemClickListener;
51 | import android.widget.BaseAdapter;
52 | import android.widget.Button;
53 | import android.widget.ListView;
54 | import android.widget.TextView;
55 | import android.widget.Toast;
56 |
57 | public class DeviceListActivity extends Activity {
58 | private BluetoothAdapter mBluetoothAdapter;
59 |
60 | // private BluetoothAdapter mBtAdapter;
61 | private TextView mEmptyList;
62 | public static final String TAG = "DeviceListActivity";
63 |
64 | List deviceList;
65 | private DeviceAdapter deviceAdapter;
66 | private ServiceConnection onService = null;
67 | Map devRssiValues;
68 | private static final long SCAN_PERIOD = 10000; //10 seconds
69 | private Handler mHandler;
70 | private boolean mScanning;
71 |
72 |
73 |
74 | @Override
75 | protected void onCreate(Bundle savedInstanceState) {
76 |
77 | super.onCreate(savedInstanceState);
78 | Log.d(TAG, "onCreate");
79 | getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
80 | setContentView(R.layout.device_list);
81 | android.view.WindowManager.LayoutParams layoutParams = this.getWindow().getAttributes();
82 | layoutParams.gravity=Gravity.TOP;
83 | layoutParams.y = 200;
84 | mHandler = new Handler();
85 | // Use this check to determine whether BLE is supported on the device. Then you can
86 | // selectively disable BLE-related features.
87 | if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
88 | Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
89 | finish();
90 | }
91 |
92 | // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to
93 | // BluetoothAdapter through BluetoothManager.
94 | final BluetoothManager bluetoothManager =
95 | (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
96 | mBluetoothAdapter = bluetoothManager.getAdapter();
97 |
98 | // Checks if Bluetooth is supported on the device.
99 | if (mBluetoothAdapter == null) {
100 | Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
101 | finish();
102 | return;
103 | }
104 | populateList();
105 | mEmptyList = (TextView) findViewById(R.id.empty);
106 | Button cancelButton = (Button) findViewById(R.id.btn_cancel);
107 | cancelButton.setOnClickListener(new OnClickListener() {
108 | @Override
109 | public void onClick(View v) {
110 |
111 | if (mScanning==false) scanLeDevice(true);
112 | else finish();
113 | }
114 | });
115 |
116 | }
117 |
118 | private void populateList() {
119 | /* Initialize device list container */
120 | Log.d(TAG, "populateList");
121 | deviceList = new ArrayList();
122 | deviceAdapter = new DeviceAdapter(this, deviceList);
123 | devRssiValues = new HashMap();
124 |
125 | ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
126 | newDevicesListView.setAdapter(deviceAdapter);
127 | newDevicesListView.setOnItemClickListener(mDeviceClickListener);
128 |
129 | scanLeDevice(true);
130 |
131 | }
132 |
133 | private void scanLeDevice(final boolean enable) {
134 | final Button cancelButton = (Button) findViewById(R.id.btn_cancel);
135 | if (enable) {
136 | // Stops scanning after a pre-defined scan period.
137 | mHandler.postDelayed(new Runnable() {
138 | @Override
139 | public void run() {
140 | mScanning = false;
141 | mBluetoothAdapter.stopLeScan(mLeScanCallback);
142 |
143 | cancelButton.setText(R.string.scan);
144 |
145 | }
146 | }, SCAN_PERIOD);
147 |
148 | mScanning = true;
149 | mBluetoothAdapter.startLeScan(mLeScanCallback);
150 | cancelButton.setText(R.string.cancel);
151 | } else {
152 | mScanning = false;
153 | mBluetoothAdapter.stopLeScan(mLeScanCallback);
154 | cancelButton.setText(R.string.scan);
155 | }
156 |
157 | }
158 |
159 | private BluetoothAdapter.LeScanCallback mLeScanCallback =
160 | new BluetoothAdapter.LeScanCallback() {
161 |
162 | @Override
163 | public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) {
164 | runOnUiThread(new Runnable() {
165 | @Override
166 | public void run() {
167 |
168 | runOnUiThread(new Runnable() {
169 | @Override
170 | public void run() {
171 | addDevice(device,rssi);
172 | }
173 | });
174 |
175 | }
176 | });
177 | }
178 | };
179 |
180 | private void addDevice(BluetoothDevice device, int rssi) {
181 | boolean deviceFound = false;
182 |
183 | for (BluetoothDevice listDev : deviceList) {
184 | if (listDev.getAddress().equals(device.getAddress())) {
185 | deviceFound = true;
186 | break;
187 | }
188 | }
189 |
190 |
191 | devRssiValues.put(device.getAddress(), rssi);
192 | if (!deviceFound) {
193 | deviceList.add(device);
194 | mEmptyList.setVisibility(View.GONE);
195 |
196 |
197 |
198 |
199 | deviceAdapter.notifyDataSetChanged();
200 | }
201 | }
202 |
203 | @Override
204 | public void onStart() {
205 | super.onStart();
206 |
207 | IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
208 | filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
209 | filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
210 | }
211 |
212 | @Override
213 | public void onStop() {
214 | super.onStop();
215 | mBluetoothAdapter.stopLeScan(mLeScanCallback);
216 |
217 | }
218 |
219 | @Override
220 | protected void onDestroy() {
221 | super.onDestroy();
222 | mBluetoothAdapter.stopLeScan(mLeScanCallback);
223 |
224 | }
225 |
226 | private OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
227 |
228 | @Override
229 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
230 | BluetoothDevice device = deviceList.get(position);
231 | mBluetoothAdapter.stopLeScan(mLeScanCallback);
232 |
233 | Bundle b = new Bundle();
234 | b.putString(BluetoothDevice.EXTRA_DEVICE, deviceList.get(position).getAddress());
235 |
236 | Intent result = new Intent();
237 | result.putExtras(b);
238 | setResult(Activity.RESULT_OK, result);
239 | finish();
240 |
241 | }
242 | };
243 |
244 |
245 |
246 | protected void onPause() {
247 | super.onPause();
248 | scanLeDevice(false);
249 | }
250 |
251 | class DeviceAdapter extends BaseAdapter {
252 | Context context;
253 | List devices;
254 | LayoutInflater inflater;
255 |
256 | public DeviceAdapter(Context context, List devices) {
257 | this.context = context;
258 | inflater = LayoutInflater.from(context);
259 | this.devices = devices;
260 | }
261 |
262 | @Override
263 | public int getCount() {
264 | return devices.size();
265 | }
266 |
267 | @Override
268 | public Object getItem(int position) {
269 | return devices.get(position);
270 | }
271 |
272 | @Override
273 | public long getItemId(int position) {
274 | return position;
275 | }
276 |
277 | @Override
278 | public View getView(int position, View convertView, ViewGroup parent) {
279 | ViewGroup vg;
280 |
281 | if (convertView != null) {
282 | vg = (ViewGroup) convertView;
283 | } else {
284 | vg = (ViewGroup) inflater.inflate(R.layout.device_element, null);
285 | }
286 |
287 | BluetoothDevice device = devices.get(position);
288 | final TextView tvadd = ((TextView) vg.findViewById(R.id.address));
289 | final TextView tvname = ((TextView) vg.findViewById(R.id.name));
290 | final TextView tvpaired = (TextView) vg.findViewById(R.id.paired);
291 | final TextView tvrssi = (TextView) vg.findViewById(R.id.rssi);
292 |
293 | tvrssi.setVisibility(View.VISIBLE);
294 | byte rssival = (byte) devRssiValues.get(device.getAddress()).intValue();
295 | if (rssival != 0) {
296 | tvrssi.setText("Rssi = " + String.valueOf(rssival));
297 | }
298 |
299 | tvname.setText(device.getName());
300 | tvadd.setText(device.getAddress());
301 | if (device.getBondState() == BluetoothDevice.BOND_BONDED) {
302 | Log.i(TAG, "device::"+device.getName());
303 | tvname.setTextColor(Color.WHITE);
304 | tvadd.setTextColor(Color.WHITE);
305 | tvpaired.setTextColor(Color.GRAY);
306 | tvpaired.setVisibility(View.VISIBLE);
307 | tvpaired.setText(R.string.paired);
308 | tvrssi.setVisibility(View.VISIBLE);
309 | tvrssi.setTextColor(Color.WHITE);
310 |
311 | } else {
312 | tvname.setTextColor(Color.WHITE);
313 | tvadd.setTextColor(Color.WHITE);
314 | tvpaired.setVisibility(View.GONE);
315 | tvrssi.setVisibility(View.VISIBLE);
316 | tvrssi.setTextColor(Color.WHITE);
317 | }
318 | return vg;
319 | }
320 | }
321 | private void showMessage(String msg) {
322 | Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
323 | }
324 | }
325 |
--------------------------------------------------------------------------------
/target/urfc.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file urfc.c
4 |
5 | @brief User configurable variables for the Micro BLE Stack Radio.
6 |
7 | Group: CMCU, SCS
8 | Target Device: CC2640R2
9 |
10 | ******************************************************************************
11 |
12 | Copyright (c) 2009-2017, Texas Instruments Incorporated
13 | All rights reserved.
14 |
15 | IMPORTANT: Your use of this Software is limited to those specific rights
16 | granted under the terms of a software license agreement between the user
17 | who downloaded the software, his/her employer (which must be your employer)
18 | and Texas Instruments Incorporated (the "License"). You may not use this
19 | Software unless you agree to abide by the terms of the License. The License
20 | limits your use, and you acknowledge, that the Software may not be modified,
21 | copied or distributed unless embedded on a Texas Instruments microcontroller
22 | or used solely and exclusively in conjunction with a Texas Instruments radio
23 | frequency transceiver, which is integrated into your product. Other than for
24 | the foregoing purpose, you may not use, reproduce, copy, prepare derivative
25 | works of, modify, distribute, perform, display or sell this Software and/or
26 | its documentation for any purpose.
27 |
28 | YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
29 | PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
30 | INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
31 | NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
32 | TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
33 | NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
34 | LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
35 | INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
36 | OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
37 | OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
38 | (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
39 |
40 | Should you have any questions regarding your right to use this Software,
41 | contact Texas Instruments Incorporated at www.TI.com.
42 |
43 | ******************************************************************************
44 | Release Name: simplelink_cc2640r2_sdk_1_40_00_45
45 | Release Date: 2017-07-20 17:16:59
46 | *****************************************************************************/
47 |
48 | /******************************************************************************
49 | * INCLUDES
50 | */
51 |
52 | #include "urfc.h"
53 | #include
54 |
55 | /******************************************************************************
56 | * MACROS
57 | */
58 |
59 | /******************************************************************************
60 | * CONSTANTS
61 | */
62 |
63 | /* # of TX power entries in the table */
64 | #define UB_NUM_TX_POWER_VALUE (sizeof(ubTxPowerVal) / sizeof(ubTxPowerVal_t))
65 |
66 | /******************************************************************************
67 | * TYPEDEFS
68 | */
69 |
70 | /******************************************************************************
71 | * LOCAL VARIABLES
72 | */
73 |
74 | /******************************************************************************
75 | * GLOBAL VARIABLES
76 | */
77 |
78 | /* RF patch function pointers */
79 | const RF_Mode ubRfMode =
80 | {
81 | .rfMode = RF_MODE_BLE,
82 | #if defined(CC26XX_R2)
83 | .cpePatchFxn = 0,
84 | .mcePatchFxn = 0,
85 | .rfePatchFxn = 0,
86 | #else /* !CC26XX_R2 */
87 | .cpePatchFxn = &rf_patch_cpe_ble,
88 | .mcePatchFxn = 0,
89 | .rfePatchFxn = &rf_patch_rfe_ble,
90 | #endif /* CC26XX_R2 */
91 | };
92 |
93 | uint32 ubRfRegOverride[] = {
94 | #if defined(CC26XX_R2)
95 | // RFC_RFE:SPARE0. Select R1-style gain table
96 | HW_REG_OVERRIDE(0x6084, 0x05F8),
97 | 0x04280243, // add 10us to RF SYNTH calibration
98 | #elif defined(CC26XX)
99 | #if defined(CC2650EM_7ID) || defined(CC2650EM_5XD) || defined(CC2650M5A)
100 | 0x00001007,
101 | 0x00354038,
102 | 0x4001402D,
103 | 0x00608402,
104 | 0x4001405D,
105 | 0x1801F800,
106 | 0x000784A3,
107 | 0xA47E0583,
108 | 0xEAE00603,
109 | 0x00010623,
110 | 0x02010403,
111 | 0x40014035,
112 | 0x177F0408,
113 | 0x38000463,
114 | 0x00456088,
115 | 0x013800C3,
116 | 0x036052AC,
117 | 0x01AD02A3,
118 | 0x01680263,
119 | #elif defined(CC2650EM_4XS) || defined(CC2650EM_4IS)
120 | 0x00001007,
121 | 0x00354038,
122 | 0x4001402D,
123 | 0x00608402,
124 | 0x4001405D,
125 | 0x1801F800,
126 | 0x000784A3,
127 | 0xA47E0583,
128 | 0xEAE00603,
129 | 0x00010623,
130 | 0x02010403,
131 | 0x40014035,
132 | 0x177F0408,
133 | 0x38000463,
134 | 0x000288A3,
135 | 0x00456088,
136 | 0x013800C3,
137 | 0x036052AC,
138 | 0x01AD02A3,
139 | 0x01680263,
140 | #else /* unknown device package */
141 | #error "MICRO RF CONFIG BUILD ERROR: Unknown package type!"
142 | #endif
143 | #elif defined(CC13XX)
144 | #if defined(CC1350LP_7XD) || defined(CC2650EM_7ID)
145 | 0x00001007,
146 | 0x849f0002,
147 | 0xc7440002,
148 | 0x00344038,
149 | 0x00456088,
150 | 0x05fd6084,
151 | 0x7f004020,
152 | 0x00404064,
153 | 0x4001405d,
154 | 0x18000000,
155 | 0x013800c3,
156 | 0x000784a3,
157 | 0xb1070503,
158 | 0x05330523,
159 | 0xa47e0583,
160 | 0xeae00603,
161 | 0x00010623,
162 | 0x00038883,
163 | 0x00f388a3,
164 | 0x04b00243,
165 | #elif defined(CC1350STK_7XS)
166 | // override_use_patch_ble_1mbps.xml
167 | // PHY: Use MCE ROM, RFE RAM patch
168 | MCE_RFE_OVERRIDE(0,0,0,1,0,0),
169 | // override_synth_ble_1mbps.xml
170 | // Synth: Set recommended RTRIM to 4
171 | HW_REG_OVERRIDE(0x4038,0x0034),
172 | // Synth: Set Fref to 3.43 MHz
173 | (uint32_t)0x000784A3,
174 | // Synth: Configure fine calibration setting
175 | HW_REG_OVERRIDE(0x4020,0x7F00),
176 | // Synth: Configure fine calibration setting
177 | HW_REG_OVERRIDE(0x4064,0x0040),
178 | // Synth: Configure fine calibration setting
179 | (uint32_t)0xB1070503,
180 | // Synth: Configure fine calibration setting
181 | (uint32_t)0x05330523,
182 | // Synth: Set loop bandwidth after lock to 80 kHz
183 | (uint32_t)0xA47E0583,
184 | // Synth: Set loop bandwidth after lock to 80 kHz
185 | (uint32_t)0xEAE00603,
186 | // Synth: Set loop bandwidth after lock to 80 kHz
187 | (uint32_t)0x00010623,
188 | // Synth: Configure PLL bias
189 | HW32_ARRAY_OVERRIDE(0x405C,1),
190 | // Synth: Configure PLL bias
191 | (uint32_t)0x18000000,
192 | // Synth: Configure VCO LDO (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference)
193 | ADI_REG_OVERRIDE(1,4,0x9F),
194 | // Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1)
195 | ADI_HALFREG_OVERRIDE(1,7,0x4,0x4),
196 | // override_phy_ble_1mbps.xml
197 | // Tx: Configure symbol shape for BLE frequency deviation requirements
198 | (uint32_t)0x013800C3,
199 | // Rx: Configure AGC reference level
200 | HW_REG_OVERRIDE(0x6088, 0x0045),
201 | // Rx: Configure AGC gain level
202 | HW_REG_OVERRIDE(0x6084, 0x05FD),
203 | // Rx: Configure LNA bias current trim offset
204 | (uint32_t)0x00038883,
205 | // override_frontend_xd.xml
206 | // Rx: Set RSSI offset to adjust reported RSSI by +13 dB
207 | (uint32_t)0x00F388A3,
208 |
209 | ADI_HALFREG_OVERRIDE(0, 16, 0x7, 1),
210 | #else /* unknown device package */
211 | #error "MICRO RF CONFIG BUILD ERROR: Unknown package type!"
212 | #endif
213 | #else /* unknown platform */
214 | #error "MICRO RF CONFIG BUILD ERROR: Unknown platform!"
215 | #endif
216 |
217 | #ifdef CACHE_AS_RAM
218 | 0x00018063,
219 | #endif /* CACHE_AS_RAM */
220 |
221 | 0xFFFFFFFF
222 | };
223 |
224 | const ubTxPowerVal_t ubTxPowerVal[] = {
225 | #if defined(CC26XX)
226 | #if defined(CC2650EM_7ID) || defined(CC2650EM_5XD) || defined(CC2650M5A)
227 | /* Tx Power Values (dBm, TC, GC, IB) */
228 | { TX_POWER_MINUS_21_DBM, TX_POUT( 0x07, 3, 0x0C ) },
229 | { TX_POWER_MINUS_18_DBM, TX_POUT( 0x09, 3, 0x0C ) },
230 | { TX_POWER_MINUS_15_DBM, TX_POUT( 0x0B, 3, 0x0C ) },
231 | { TX_POWER_MINUS_12_DBM, TX_POUT( 0x0B, 1, 0x14 ) },
232 | { TX_POWER_MINUS_9_DBM, TX_POUT( 0x0E, 1, 0x19 ) },
233 | { TX_POWER_MINUS_6_DBM, TX_POUT( 0x12, 1, 0x1D ) },
234 | { TX_POWER_MINUS_3_DBM, TX_POUT( 0x18, 1, 0x25 ) },
235 | { TX_POWER_0_DBM, TX_POUT( 0x21, 1, 0x31 ) },
236 | { TX_POWER_1_DBM, TX_POUT( 0x14, 0, 0x42 ) },
237 | { TX_POWER_2_DBM, TX_POUT( 0x18, 0, 0x4E ) },
238 | { TX_POWER_3_DBM, TX_POUT( 0x1C, 0, 0x5A ) },
239 | { TX_POWER_4_DBM, TX_POUT( 0x24, 0, 0x93 ) },
240 | { TX_POWER_5_DBM, TX_POUT( 0x30, 0, 0x93 ) },
241 | #elif defined(CC2650EM_4XS) || defined(CC2650EM_4IS)
242 | { TX_POWER_MINUS_21_DBM, TX_POUT( 0x07, 3, 0x0C ) },
243 | { TX_POWER_MINUS_18_DBM, TX_POUT( 0x09, 3, 0x10 ) },
244 | { TX_POWER_MINUS_15_DBM, TX_POUT( 0x0B, 3, 0x14 ) },
245 | { TX_POWER_MINUS_12_DBM, TX_POUT( 0x0E, 3, 0x14 ) },
246 | { TX_POWER_MINUS_9_DBM, TX_POUT( 0x0F, 1, 0x21 ) },
247 | { TX_POWER_MINUS_6_DBM, TX_POUT( 0x14, 1, 0x29 ) },
248 | { TX_POWER_MINUS_3_DBM, TX_POUT( 0x1C, 1, 0x35 ) },
249 | { TX_POWER_0_DBM, TX_POUT( 0x2C, 1, 0x56 ) },
250 | { TX_POWER_1_DBM, TX_POUT( 0x1F, 0, 0x6A ) },
251 | { TX_POWER_2_DBM, TX_POUT( 0x29, 0, 0x9C ) },
252 | #elif defined(CC2640R2EM_CXS)
253 | { TX_POWER_MINUS_21_DBM, TX_POUT( 0xC3, 3, 0x0C ) },
254 | { TX_POWER_MINUS_18_DBM, TX_POUT( 0xC5, 3, 0x10 ) },
255 | { TX_POWER_MINUS_15_DBM, TX_POUT( 0xC7, 3, 0x10 ) },
256 | { TX_POWER_MINUS_12_DBM, TX_POUT( 0xC9, 3, 0x10 ) },
257 | { TX_POWER_MINUS_9_DBM, TX_POUT( 0xCC, 3, 0x19 ) },
258 | { TX_POWER_MINUS_6_DBM, TX_POUT( 0x4E, 1, 0x25 ) },
259 | { TX_POWER_MINUS_3_DBM, TX_POUT( 0x54, 1, 0x2D ) },
260 | { TX_POWER_0_DBM, TX_POUT( 0x10, 0, 0x46 ) },
261 | { TX_POWER_1_DBM, TX_POUT( 0x16, 0, 0x62 ) },
262 | { TX_POWER_2_DBM, TX_POUT( 0x25, 0, 0xBC ) },
263 | #else /* unknown device package */
264 | #error "MICRO RF CONFIG BUILD ERROR: Unknown package type!"
265 | #endif
266 | #elif defined(CC13XX)
267 | #if defined(CC1350LP_7XD) || defined(CC2650EM_7ID)
268 | { TX_POWER_MINUS_21_DBM, 0x0DC8 },
269 | { TX_POWER_MINUS_18_DBM, 0x0DCB },
270 | { TX_POWER_MINUS_15_DBM, 0x15CE },
271 | { TX_POWER_MINUS_12_DBM, 0x19D4 },
272 | { TX_POWER_MINUS_9_DBM, 0x1DDA },
273 | { TX_POWER_MINUS_6_DBM, 0x25E3 },
274 | { TX_POWER_MINUS_3_DBM, 0x2DEF },
275 | { TX_POWER_0_DBM, 0x5B29 },
276 | { TX_POWER_1_DBM, 0x6321 },
277 | { TX_POWER_2_DBM, 0x6F26 },
278 | { TX_POWER_3_DBM, 0x7F2C },
279 | { TX_POWER_4_DBM, 0x7734 },
280 | { TX_POWER_5_DBM, 0x5F3C },
281 | #elif defined(CC1350STK_7XS)
282 | { TX_POWER_MINUS_21_DBM, 0x0DC8 },
283 | { TX_POWER_MINUS_18_DBM, 0x0DCB },
284 | { TX_POWER_MINUS_15_DBM, 0x15CE },
285 | { TX_POWER_MINUS_12_DBM, 0x19D4 },
286 | { TX_POWER_MINUS_9_DBM, 0x1DDA },
287 | { TX_POWER_MINUS_6_DBM, 0x25E3 },
288 | { TX_POWER_MINUS_3_DBM, 0x2DEF },
289 | { TX_POWER_0_DBM, 0x5B29 },
290 | { TX_POWER_1_DBM, 0x6321 },
291 | { TX_POWER_2_DBM, 0x6F26 },
292 | { TX_POWER_3_DBM, 0x7F2C },
293 | { TX_POWER_4_DBM, 0x7734 },
294 | { TX_POWER_5_DBM, 0x5F3C },
295 | #else /* unknown device package */
296 | #error "MICRO RF CONFIG BUILD ERROR: Unknown package type!"
297 | #endif
298 | #else /* unknown platform */
299 | #error "MICRO RF CONFIG BUILD ERROR: Unknown platform!"
300 | #endif
301 | };
302 |
303 | /* RF Frontend Mode and Bias */
304 | const uint8 ubFeModeBias =
305 | #if defined(CC26XX)
306 | #if defined(CC2650EM_7ID)
307 | RF_FE_DIFFERENTIAL | RF_FE_INT_BIAS;
308 | #elif defined(CC2650EM_5XD) || defined(CC2650EM_4XD) || defined(CC2650M5A)
309 | RF_FE_DIFFERENTIAL | RF_FE_EXT_BIAS;
310 | #elif defined(CC2650EM_4XS)
311 | RF_FE_SINGLE_ENDED_RFP | RF_FE_EXT_BIAS;
312 | #elif defined(CC2640R2EM_CXS)
313 | RF_FE_SINGLE_ENDED_RFN | RF_FE_EXT_BIAS;
314 | #else /* unknown device package */
315 | #error "MICRO RF CONFIG BUILD ERROR: Unknown package type!"
316 | #endif
317 | #elif defined(CC13XX)
318 | #if defined(CC2650EM_7ID)
319 | /* TEMP : Proper values for CC1350DK_7XD */
320 | RF_FE_DIFFERENTIAL | RF_FE_EXT_BIAS;
321 | #elif defined(CC1350EM_7ID)
322 | RF_FE_DIFFERENTIAL | RF_FE_INT_BIAS;
323 | #elif defined(CC1350LP_7XD)
324 | RF_FE_DIFFERENTIAL | RF_FE_EXT_BIAS;
325 | #elif defined(CC1350STK_7XS)
326 | RF_FE_SINGLE_ENDED_RFP | RF_FE_EXT_BIAS;
327 | #else /* unknown device package */
328 | #error "MICRO RF CONFIG BUILD ERROR: Unknown package type!"
329 | #endif
330 | #else /* unknown platform */
331 | #error "MICRO RF CONFIG BUILD ERROR: Unknown platform!"
332 | #endif
333 |
334 | /* Tx Power Table */
335 | const ubTxPowerTable_t ubTxPowerTable = { ubTxPowerVal, UB_NUM_TX_POWER_VALUE };
336 |
337 | /******************************************************************************
338 | */
339 |
340 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/app/main.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 |
3 | @file main.c
4 |
5 | @brief main entry of the BLE stack sample application.
6 |
7 | Group: CMCU, SCS
8 | Target Device: CC2640R2
9 |
10 | ******************************************************************************
11 |
12 | Copyright (c) 2013-2017, Texas Instruments Incorporated
13 | All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions
17 | are met:
18 |
19 | * Redistributions of source code must retain the above copyright
20 | notice, this list of conditions and the following disclaimer.
21 |
22 | * Redistributions in binary form must reproduce the above copyright
23 | notice, this list of conditions and the following disclaimer in the
24 | documentation and/or other materials provided with the distribution.
25 |
26 | * Neither the name of Texas Instruments Incorporated nor the names of
27 | its contributors may be used to endorse or promote products derived
28 | from this software without specific prior written permission.
29 |
30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 |
42 | ******************************************************************************
43 | Release Name: simplelink_cc2640r2_sdk_1_35_00_33
44 | Release Date: 2017-05-02 17:08:44
45 | *****************************************************************************/
46 |
47 | /*******************************************************************************
48 | * INCLUDES
49 | */
50 |
51 | #include
52 |
53 | #include
54 | #include
55 | #include
56 | #include
57 |
58 | #include
59 | #include "hal_assert.h"
60 | #include "bcomdef.h"
61 | #include "peripheral.h"
62 | #include "peripheral_uarttrans.h"
63 | //#include "inc/sdi_task.h"
64 | #include "task_epd.h"
65 | #include "hw_uart.h"
66 |
67 | /* Header files required to enable instruction fetch cache */
68 | #include
69 | #include
70 |
71 | #ifndef USE_DEFAULT_USER_CFG
72 |
73 | #include "ble_user_config.h"
74 |
75 | // BLE user defined configuration
76 | #ifdef ICALL_JT
77 | icall_userCfg_t user0Cfg = BLE_USER_CFG;
78 | #else /* ! ICALL_JT */
79 | bleUserCfg_t user0Cfg = BLE_USER_CFG;
80 | #endif /* ICALL_JT */
81 |
82 | #endif // USE_DEFAULT_USER_CFG
83 |
84 | /*******************************************************************************
85 | * MACROS
86 | */
87 |
88 | /*******************************************************************************
89 | * CONSTANTS
90 | */
91 |
92 | /*******************************************************************************
93 | * TYPEDEFS
94 | */
95 |
96 | /*******************************************************************************
97 | * LOCAL VARIABLES
98 | */
99 |
100 | /*******************************************************************************
101 | * GLOBAL VARIABLES
102 | */
103 |
104 | #ifdef CC1350_LAUNCHXL
105 | #ifdef POWER_SAVING
106 | // Power Notify Object for wake-up callbacks
107 | Power_NotifyObj rFSwitchPowerNotifyObj;
108 | static uint8_t rFSwitchNotifyCb(uint8_t eventType, uint32_t *eventArg,
109 | uint32_t *clientArg);
110 | #endif //POWER_SAVING
111 |
112 | PIN_State radCtrlState;
113 | PIN_Config radCtrlCfg[] =
114 | {
115 | Board_DIO1_RFSW | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* RF SW Switch defaults to 2.4GHz path*/
116 | Board_DIO30_SWPWR | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Power to the RF Switch */
117 | PIN_TERMINATE
118 | };
119 | PIN_Handle radCtrlHandle;
120 | #endif //CC1350_LAUNCHXL
121 |
122 | /*******************************************************************************
123 | * EXTERNS
124 | */
125 |
126 | extern void AssertHandler(uint8 assertCause, uint8 assertSubcause);
127 | /*******************************************************************************
128 | * @fn Main
129 | *
130 | * @brief Application Main
131 | *
132 | * input parameters
133 | *
134 | * @param None.
135 | *
136 | * output parameters
137 | *
138 | * @param None.
139 | *
140 | * @return None.
141 | */
142 | int main()
143 | {
144 | /* Register Application callback to trap asserts raised in the Stack */
145 | RegisterAssertCback(AssertHandler);
146 | PIN_init(BoardGpioInitTable);
147 |
148 | #ifdef CC1350_LAUNCHXL
149 | // Enable 2.4GHz Radio
150 | radCtrlHandle = PIN_open(&radCtrlState, radCtrlCfg);
151 |
152 | #ifdef POWER_SAVING
153 | Power_registerNotify(&rFSwitchPowerNotifyObj,
154 | PowerCC26XX_ENTERING_STANDBY | PowerCC26XX_AWAKE_STANDBY,
155 | (Power_NotifyFxn) rFSwitchNotifyCb, NULL);
156 | #endif //POWER_SAVING
157 | #endif //CC1350_LAUNCHXL
158 |
159 | #if defined( USE_FPGA )
160 | // set RFC mode to support BLE
161 | // Note: This must be done before the RF Core is released from reset!
162 | SET_RFC_BLE_MODE(RFC_MODE_BLE);
163 | #endif // USE_FPGA
164 |
165 | #ifdef CACHE_AS_RAM
166 | // retain cache during standby
167 | Power_setConstraint(PowerCC26XX_SB_VIMS_CACHE_RETAIN);
168 | Power_setConstraint(PowerCC26XX_NEED_FLASH_IN_IDLE);
169 | #else
170 | // Enable iCache prefetching
171 | VIMSConfigure(VIMS_BASE, TRUE, TRUE);
172 | // Enable cache
173 | VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);
174 | #endif //CACHE_AS_RAM
175 |
176 | #if !defined( POWER_SAVING ) || defined( USE_FPGA )
177 | /* Set constraints for Standby, powerdown and idle mode */
178 | // PowerCC26XX_SB_DISALLOW may be redundant
179 | Power_setConstraint(PowerCC26XX_SB_DISALLOW);
180 | Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW);
181 | #endif // POWER_SAVING | USE_FPGA
182 |
183 | #ifdef ICALL_JT
184 | /* Update User Configuration of the stack */
185 | user0Cfg.appServiceInfo->timerTickPeriod = Clock_tickPeriod;
186 | user0Cfg.appServiceInfo->timerMaxMillisecond = ICall_getMaxMSecs();
187 | #endif /* ICALL_JT */
188 | /* Initialize ICall module */
189 | ICall_init();
190 |
191 | /* Start tasks of external images - Priority 5 */
192 | ICall_createRemoteTasks();
193 |
194 | /* Kick off profile - Priority 3 */
195 | GAPRole_createTask();
196 |
197 | /* SDI UART Example Task - Priority 2 */
198 | // SDITask_createTask();
199 |
200 | HWUART_Init();
201 |
202 | TaskEPD_createTask();
203 | SPPBLEServer_createTask();
204 |
205 | /* enable interrupts and start SYS/BIOS */
206 | BIOS_start();
207 |
208 | return 0;
209 | }
210 |
211 |
212 | /*******************************************************************************
213 | * @fn AssertHandler
214 | *
215 | * @brief This is the Application's callback handler for asserts raised
216 | * in the stack. When EXT_HAL_ASSERT is defined in the Stack
217 | * project this function will be called when an assert is raised,
218 | * and can be used to observe or trap a violation from expected
219 | * behavior.
220 | *
221 | * As an example, for Heap allocation failures the Stack will raise
222 | * HAL_ASSERT_CAUSE_OUT_OF_MEMORY as the assertCause and
223 | * HAL_ASSERT_SUBCAUSE_NONE as the assertSubcause. An application
224 | * developer could trap any malloc failure on the stack by calling
225 | * HAL_ASSERT_SPINLOCK under the matching case.
226 | *
227 | * An application developer is encouraged to extend this function
228 | * for use by their own application. To do this, add hal_assert.c
229 | * to your project workspace, the path to hal_assert.h (this can
230 | * be found on the stack side). Asserts are raised by including
231 | * hal_assert.h and using macro HAL_ASSERT(cause) to raise an
232 | * assert with argument assertCause. the assertSubcause may be
233 | * optionally set by macro HAL_ASSERT_SET_SUBCAUSE(subCause) prior
234 | * to asserting the cause it describes. More information is
235 | * available in hal_assert.h.
236 | *
237 | * input parameters
238 | *
239 | * @param assertCause - Assert cause as defined in hal_assert.h.
240 | * @param assertSubcause - Optional assert subcause (see hal_assert.h).
241 | *
242 | * output parameters
243 | *
244 | * @param None.
245 | *
246 | * @return None.
247 | */
248 | void AssertHandler(uint8 assertCause, uint8 assertSubcause)
249 | {
250 | // Open the display if the app has not already done so
251 | #if !defined(Display_DISABLE_ALL)
252 | if ( !dispHandle )
253 | {
254 | dispHandle = Display_open(Display_Type_LCD, NULL);
255 | }
256 | #endif
257 |
258 | //Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
259 |
260 | // check the assert cause
261 | switch (assertCause)
262 | {
263 | case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
264 | //Display_print0(dispHandle, 0, 0, "***ERROR***");
265 | //Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
266 | break;
267 |
268 | case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
269 | // check the subcause
270 | if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
271 | {
272 | //Display_print0(dispHandle, 0, 0, "***ERROR***");
273 | //Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
274 | }
275 | else
276 | {
277 | //Display_print0(dispHandle, 0, 0, "***ERROR***");
278 | //Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
279 | }
280 | break;
281 |
282 | case HAL_ASSERT_CAUSE_ICALL_ABORT:
283 | //Display_print0(dispHandle, 0, 0, "***ERROR***");
284 | //Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
285 | HAL_ASSERT_SPINLOCK;
286 | break;
287 |
288 | case HAL_ASSERT_CAUSE_ICALL_TIMEOUT:
289 | //Display_print0(dispHandle, 0, 0, "***ERROR***");
290 | //Display_print0(dispHandle, 2, 0, ">> ICALL TIMEOUT!");
291 | HAL_ASSERT_SPINLOCK;
292 | break;
293 |
294 | case HAL_ASSERT_CAUSE_WRONG_API_CALL:
295 | //Display_print0(dispHandle, 0, 0, "***ERROR***");
296 | //Display_print0(dispHandle, 2, 0, ">> WRONG API CALL!");
297 | HAL_ASSERT_SPINLOCK;
298 | break;
299 |
300 | default:
301 | //Display_print0(dispHandle, 0, 0, "***ERROR***");
302 | //Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
303 | HAL_ASSERT_SPINLOCK;
304 | }
305 |
306 | return;
307 | }
308 |
309 |
310 | /*******************************************************************************
311 | * @fn smallErrorHook
312 | *
313 | * @brief Error handler to be hooked into TI-RTOS.
314 | *
315 | * input parameters
316 | *
317 | * @param eb - Pointer to Error Block.
318 | *
319 | * output parameters
320 | *
321 | * @param None.
322 | *
323 | * @return None.
324 | */
325 | void smallErrorHook(Error_Block *eb)
326 | {
327 | for (;;);
328 | }
329 |
330 | #if defined (CC1350_LAUNCHXL) && defined (POWER_SAVING)
331 | /*******************************************************************************
332 | * @fn rFSwitchNotifyCb
333 | *
334 | * @brief Power driver callback to toggle RF switch on Power state
335 | * transitions.
336 | *
337 | * input parameters
338 | *
339 | * @param eventType - The state change.
340 | * @param eventArg - Not used.
341 | * @param clientArg - Not used.
342 | *
343 | * @return Power_NOTIFYDONE to indicate success.
344 | */
345 | static uint8_t rFSwitchNotifyCb(uint8_t eventType, uint32_t *eventArg,
346 | uint32_t *clientArg)
347 | {
348 | if (eventType == PowerCC26XX_ENTERING_STANDBY)
349 | {
350 | // Power down RF Switch
351 | PIN_setOutputValue(radCtrlHandle, Board_DIO30_SWPWR, 0);
352 | }
353 | else if (eventType == PowerCC26XX_AWAKE_STANDBY)
354 | {
355 | // Power up RF Switch
356 | PIN_setOutputValue(radCtrlHandle, Board_DIO30_SWPWR, 1);
357 | }
358 |
359 | // Notification handled successfully
360 | return Power_NOTIFYDONE;
361 | }
362 | #endif //CC1350_LAUNCHXL || POWER_SAVING
363 |
364 |
365 | /*******************************************************************************
366 | */
367 |
--------------------------------------------------------------------------------
/target/LAUNCHIOT_CC2640R2MOD_RGZ/LAUNCHIOT_CC2640R2MOD_RGZ.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016, Texas Instruments Incorporated
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | *
9 | * * Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | *
12 | * * Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | *
16 | * * Neither the name of Texas Instruments Incorporated nor the names of
17 | * its contributors may be used to endorse or promote products derived
18 | * from this software without specific prior written permission.
19 | *
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | */
32 | /** ============================================================================
33 | * @file CC2640R2_LAUNCHXL.h
34 | *
35 | * @brief CC2640R2 LaunchPad Board Specific header file.
36 | *
37 | * The CC2640R2_LAUNCHXL header file should be included in an application as
38 | * follows:
39 | * @code
40 | * #include "CC2640R2_LAUNCHXL.h"
41 | * @endcode
42 | *
43 | * This board file is made for the 7x7 mm QFN package, to convert this board
44 | * file to use for other smaller device packages please refer to the table
45 | * below which lists the max IOID values supported by each package. All other
46 | * unused pins should be set to IOID_UNUSED.
47 | *
48 | * Furthermore the board file is also used
49 | * to define a symbol that configures the RF front end and bias.
50 | * See the comments below for more information.
51 | * For an in depth tutorial on how to create a custom board file, please refer
52 | * to the section "Running the SDK on Custom Boards" with in the Software
53 | * Developer's Guide.
54 | *
55 | * Refer to the datasheet for all the package options and IO descriptions:
56 | * http://www.ti.com/lit/ds/symlink/cc2640r2f.pdf
57 | *
58 | * +-----------------------+------------------+-----------------------+
59 | * | Package Option | Total GPIO Pins | MAX IOID |
60 | * +=======================+==================+=======================+
61 | * | 7x7 mm QFN | 31 | IOID_30 |
62 | * +-----------------------+------------------+-----------------------+
63 | * | 5x5 mm QFN | 15 | IOID_14 |
64 | * +-----------------------+------------------+-----------------------+
65 | * | 4x4 mm QFN | 10 | IOID_9 |
66 | * +-----------------------+------------------+-----------------------+
67 | * | 2.7 x 2.7 mm WCSP | 14 | IOID_13 |
68 | * +-----------------------+------------------+-----------------------+
69 | * ============================================================================
70 | */
71 | #ifndef __CC2640R2_LAUNCHXL_BOARD_H__
72 | #define __CC2640R2_LAUNCHXL_BOARD_H__
73 |
74 | #ifdef __cplusplus
75 | extern "C" {
76 | #endif
77 |
78 | /* Includes */
79 | #include
80 | #include
81 |
82 | /* Externs */
83 | extern const PIN_Config BoardGpioInitTable[];
84 |
85 |
86 | /*
87 | * ============================================================================
88 | * RF Front End and Bias configuration symbols for TI reference designs and
89 | * kits. This symbol sets the RF Front End configuration in ble_user_config.h
90 | * and selects the appropriate PA table in ble_user_config.c.
91 | * Other configurations can be used by editing these files.
92 | *
93 | * Define only one symbol:
94 | * CC2650EM_7ID - Differential RF and internal biasing
95 | (default for CC2640R2 LaunchPad)
96 | * CC2650EM_5XD – Differential RF and external biasing
97 | * CC2650EM_4XS – Single-ended RF on RF-P and external biasing
98 | * CC2640R2DK_CXS - WCSP: Single-ended RF on RF-N and external biasing
99 | * (Note that the WCSP is only tested and characterized for
100 | * single ended configuration, and it has a WCSP-specific
101 | * PA table)
102 | *
103 | * Note: CC2650EM_xxx reference designs apply to all CC26xx devices.
104 | * ==========================================================================
105 | */
106 | #define CC2650EM_7ID
107 |
108 | /* Mapping of pins to board signals using general board aliases
109 | *
110 | */
111 |
112 | /* Analog Capable DIOs */
113 | #define CC2640R2_LAUNCHXL_DIO23_ANALOG IOID_23
114 | #define CC2640R2_LAUNCHXL_DIO24_ANALOG IOID_24
115 | #define CC2640R2_LAUNCHXL_DIO25_ANALOG IOID_25
116 | #define CC2640R2_LAUNCHXL_DIO26_ANALOG IOID_26
117 | #define CC2640R2_LAUNCHXL_DIO27_ANALOG IOID_27
118 | #define CC2640R2_LAUNCHXL_DIO28_ANALOG IOID_28
119 | #define CC2640R2_LAUNCHXL_DIO29_ANALOG IOID_29
120 | #define CC2640R2_LAUNCHXL_DIO30_ANALOG IOID_30
121 |
122 | /* Digital IOs */
123 | #define CC2640R2_LAUNCHXL_DIO0 IOID_0
124 | #define CC2640R2_LAUNCHXL_DIO1_RFSW IOID_1
125 | #define CC2640R2_LAUNCHXL_DIO12 IOID_12
126 | #define CC2640R2_LAUNCHXL_DIO15 IOID_15
127 | #define CC2640R2_LAUNCHXL_DIO16_TDO IOID_16
128 | #define CC2640R2_LAUNCHXL_DIO17_TDI IOID_17
129 | #define CC2640R2_LAUNCHXL_DIO21 IOID_21
130 | #define CC2640R2_LAUNCHXL_DIO22 IOID_22
131 |
132 | /* Discrete Inputs */
133 | #define CC2640R2_LAUNCHXL_PIN_BTN1 IOID_13
134 | #define CC2640R2_LAUNCHXL_PIN_BTN2 IOID_14
135 |
136 | /* GPIO */
137 | #define CC2640R2_LAUNCHXL_GPIO_LED_ON 1
138 | #define CC2640R2_LAUNCHXL_GPIO_LED_OFF 0
139 |
140 | /* I2C */
141 | #define CC2640R2_LAUNCHXL_I2C0_SCL0 IOID_4
142 | #define CC2640R2_LAUNCHXL_I2C0_SDA0 IOID_5
143 |
144 | /* LCD (430BOOST - Sharp96 Rev 1.1) */
145 | #define CC2640R2_LAUNCHXL_LCD_CS IOID_24 /* SPI chip select */
146 | #define CC2640R2_LAUNCHXL_LCD_EXTCOMIN IOID_12 /* External COM inversion */
147 | #define CC2640R2_LAUNCHXL_LCD_ENABLE IOID_22 /* LCD enable */
148 | #define CC2640R2_LAUNCHXL_LCD_POWER IOID_23 /* LCD power control */
149 | #define CC2640R2_LAUNCHXL_LCD_CS_ON 1
150 | #define CC2640R2_LAUNCHXL_LCD_CS_OFF 0
151 |
152 | /* LEDs */
153 | #define CC2640R2_LAUNCHXL_PIN_LED_ON 1
154 | #define CC2640R2_LAUNCHXL_PIN_LED_OFF 0
155 | #define CC2640R2_LAUNCHXL_PIN_RLED IOID_6
156 | #define CC2640R2_LAUNCHXL_PIN_GLED IOID_7
157 |
158 | /* PWM Outputs */
159 | #define CC2640R2_LAUNCHXL_PWMPIN0 CC2640R2_LAUNCHXL_PIN_RLED
160 | #define CC2640R2_LAUNCHXL_PWMPIN1 CC2640R2_LAUNCHXL_PIN_GLED
161 | #define CC2640R2_LAUNCHXL_PWMPIN2 IOID_19
162 | #define CC2640R2_LAUNCHXL_PWMPIN3 IOID_20
163 | #define CC2640R2_LAUNCHXL_PWMPIN4 IOID_21
164 | #define CC2640R2_LAUNCHXL_PWMPIN5 IOID_22
165 | #define CC2640R2_LAUNCHXL_PWMPIN6 PIN_UNASSIGNED
166 | #define CC2640R2_LAUNCHXL_PWMPIN7 PIN_UNASSIGNED
167 |
168 | /* SPI */
169 | #define CC2640R2_LAUNCHXL_SPI_FLASH_CS IOID_12
170 | #define CC2640R2_LAUNCHXL_FLASH_CS_ON 0
171 | #define CC2640R2_LAUNCHXL_FLASH_CS_OFF 1
172 |
173 | /* SPI Board */
174 | #define CC2640R2_LAUNCHXL_SPI0_MISO IOID_6 /* not used */
175 | #define CC2640R2_LAUNCHXL_SPI0_MOSI IOID_19
176 | #define CC2640R2_LAUNCHXL_SPI0_CLK IOID_18
177 | #define CC2640R2_LAUNCHXL_SPI0_CSN PIN_UNASSIGNED
178 | #define CC2640R2_LAUNCHXL_SPI1_MISO PIN_UNASSIGNED
179 | #define CC2640R2_LAUNCHXL_SPI1_MOSI PIN_UNASSIGNED
180 | #define CC2640R2_LAUNCHXL_SPI1_CLK PIN_UNASSIGNED
181 | #define CC2640R2_LAUNCHXL_SPI1_CSN PIN_UNASSIGNED
182 |
183 | /* UART Board */
184 | #define CC2640R2_LAUNCHXL_UART_RX IOID_2 /* RXD */
185 | #define CC2640R2_LAUNCHXL_UART_TX IOID_3 /* TXD */
186 | //#define CC2640R2_LAUNCHXL_UART_CTS IOID_19 /* CTS */
187 | //#define CC2640R2_LAUNCHXL_UART_RTS IOID_18 /* RTS */
188 |
189 |
190 | /* LCD Board */
191 | #define Board_LCD_MODE IOID_1
192 | #define Board_LCD_CSN IOID_11
193 | #define Board_3V3_EN IOID_0
194 |
195 | /* Motor Board */
196 | #define Board_MOTOR IOID_18
197 |
198 | /* Generic SPI instance identifiers */
199 | #define Board_LCD_SPI CC2640R2_LAUNCHXL_SPI0
200 |
201 | /* PWM outputs */
202 | #define Board_PWMBuzzer CC2640R2_LAUNCHXL_PWMPIN2
203 | #define Board_PWMRED CC2640R2_LAUNCHXL_PWMPIN3
204 | #define Board_PWMGREEN CC2640R2_LAUNCHXL_PWMPIN4
205 | #define Board_PWMBLUE CC2640R2_LAUNCHXL_PWMPIN5
206 |
207 |
208 | /*!
209 | * @brief Initialize the general board specific settings
210 | *
211 | * This function initializes the general board specific settings.
212 | */
213 | void CC2640R2_LAUNCHXL_initGeneral(void);
214 |
215 | /*!
216 | * @def CC2640R2_LAUNCHXL_ADCBufName
217 | * @brief Enum of ADCs
218 | */
219 | typedef enum CC2640R2_LAUNCHXL_ADCBufName {
220 | CC2640R2_LAUNCHXL_ADCBUF0 = 0,
221 |
222 | CC2640R2_LAUNCHXL_ADCBUFCOUNT
223 | } CC2640R2_LAUNCHXL_ADCBufName;
224 |
225 | /*!
226 | * @def CC2640R2_LAUNCHXL_ADCBuf0SourceName
227 | * @brief Enum of ADCBuf channels
228 | */
229 | typedef enum CC2640R2_LAUNCHXL_ADCBuf0ChannelName {
230 | CC2640R2_LAUNCHXL_ADCBUF0CHANNEL0 = 0,
231 | CC2640R2_LAUNCHXL_ADCBUF0CHANNEL1,
232 | CC2640R2_LAUNCHXL_ADCBUF0CHANNEL2,
233 | CC2640R2_LAUNCHXL_ADCBUF0CHANNEL3,
234 | CC2640R2_LAUNCHXL_ADCBUF0CHANNEL4,
235 | CC2640R2_LAUNCHXL_ADCBUF0CHANNEL5,
236 | CC2640R2_LAUNCHXL_ADCBUF0CHANNEL6,
237 | CC2640R2_LAUNCHXL_ADCBUF0CHANNEL7,
238 | CC2640R2_LAUNCHXL_ADCBUF0CHANNELVDDS,
239 | CC2640R2_LAUNCHXL_ADCBUF0CHANNELDCOUPL,
240 | CC2640R2_LAUNCHXL_ADCBUF0CHANNELVSS,
241 |
242 | CC2640R2_LAUNCHXL_ADCBUF0CHANNELCOUNT
243 | } CC2640R2_LAUNCHXL_ADCBuf0ChannelName;
244 |
245 | /*!
246 | * @def CC2640R2_LAUNCHXL_ADCName
247 | * @brief Enum of ADCs
248 | */
249 | typedef enum CC2640R2_LAUNCHXL_ADCName {
250 | CC2640R2_LAUNCHXL_ADC0 = 0,
251 | CC2640R2_LAUNCHXL_ADC1,
252 | CC2640R2_LAUNCHXL_ADC2,
253 | CC2640R2_LAUNCHXL_ADC3,
254 | CC2640R2_LAUNCHXL_ADC4,
255 | CC2640R2_LAUNCHXL_ADC5,
256 | CC2640R2_LAUNCHXL_ADC6,
257 | CC2640R2_LAUNCHXL_ADC7,
258 | CC2640R2_LAUNCHXL_ADCDCOUPL,
259 | CC2640R2_LAUNCHXL_ADCVSS,
260 | CC2640R2_LAUNCHXL_ADCVDDS,
261 |
262 | CC2640R2_LAUNCHXL_ADCCOUNT
263 | } CC2640R2_LAUNCHXL_ADCName;
264 |
265 | /*!
266 | * @def CC2640R2_LAUNCHXL_CryptoName
267 | * @brief Enum of Crypto names
268 | */
269 | typedef enum CC2640R2_LAUNCHXL_CryptoName {
270 | CC2640R2_LAUNCHXL_CRYPTO0 = 0,
271 |
272 | CC2640R2_LAUNCHXL_CRYPTOCOUNT
273 | } CC2640R2_LAUNCHXL_CryptoName;
274 |
275 | /*!
276 | * @def CC2640R2_LAUNCHXL_GPIOName
277 | * @brief Enum of GPIO names
278 | */
279 | typedef enum CC2640R2_LAUNCHXL_GPIOName {
280 | CC2640R2_LAUNCHXL_GPIO_S1 = 0,
281 | CC2640R2_LAUNCHXL_GPIO_S2,
282 | CC2640R2_LAUNCHXL_GPIO_LED_GREEN,
283 | CC2640R2_LAUNCHXL_GPIO_LED_RED,
284 |
285 | CC2640R2_LAUNCHXL_GPIOCOUNT
286 | } CC2640R2_LAUNCHXL_GPIOName;
287 |
288 | /*!
289 | * @def CC2640R2_LAUNCHXL_GPTimerName
290 | * @brief Enum of GPTimer parts
291 | */
292 | typedef enum CC2640R2_LAUNCHXL_GPTimerName {
293 | CC2640R2_LAUNCHXL_GPTIMER0A = 0,
294 | CC2640R2_LAUNCHXL_GPTIMER0B,
295 | CC2640R2_LAUNCHXL_GPTIMER1A,
296 | CC2640R2_LAUNCHXL_GPTIMER1B,
297 | CC2640R2_LAUNCHXL_GPTIMER2A,
298 | CC2640R2_LAUNCHXL_GPTIMER2B,
299 | CC2640R2_LAUNCHXL_GPTIMER3A,
300 | CC2640R2_LAUNCHXL_GPTIMER3B,
301 |
302 | CC2640R2_LAUNCHXL_GPTIMERPARTSCOUNT
303 | } CC2640R2_LAUNCHXL_GPTimerName;
304 |
305 | /*!
306 | * @def CC2640R2_LAUNCHXL_GPTimers
307 | * @brief Enum of GPTimers
308 | */
309 | typedef enum CC2640R2_LAUNCHXL_GPTimers {
310 | CC2640R2_LAUNCHXL_GPTIMER0 = 0,
311 | CC2640R2_LAUNCHXL_GPTIMER1,
312 | CC2640R2_LAUNCHXL_GPTIMER2,
313 | CC2640R2_LAUNCHXL_GPTIMER3,
314 |
315 | CC2640R2_LAUNCHXL_GPTIMERCOUNT
316 | } CC2640R2_LAUNCHXL_GPTimers;
317 |
318 | /*!
319 | * @def CC2640R2_LAUNCHXL_I2CName
320 | * @brief Enum of I2C names
321 | */
322 | typedef enum CC2640R2_LAUNCHXL_I2CName {
323 | CC2640R2_LAUNCHXL_I2C0 = 0,
324 |
325 | CC2640R2_LAUNCHXL_I2CCOUNT
326 | } CC2640R2_LAUNCHXL_I2CName;
327 |
328 | /*!
329 | * @def CC2640R2_LAUNCHXL_PWM
330 | * @brief Enum of PWM outputs
331 | */
332 | typedef enum CC2640R2_LAUNCHXL_PWMName {
333 | CC2640R2_LAUNCHXL_PWM0 = 0,
334 | CC2640R2_LAUNCHXL_PWM1,
335 | CC2640R2_LAUNCHXL_PWM2,
336 | CC2640R2_LAUNCHXL_PWM3,
337 | CC2640R2_LAUNCHXL_PWM4,
338 | CC2640R2_LAUNCHXL_PWM5,
339 | CC2640R2_LAUNCHXL_PWM6,
340 | CC2640R2_LAUNCHXL_PWM7,
341 |
342 | CC2640R2_LAUNCHXL_PWMCOUNT
343 | } CC2640R2_LAUNCHXL_PWMName;
344 | /*!
345 | * @def CC2640R2_LAUNCHXL_SPIName
346 | * @brief Enum of SPI names
347 | */
348 | typedef enum CC2640R2_LAUNCHXL_SPIName {
349 | CC2640R2_LAUNCHXL_SPI0 = 0,
350 | CC2640R2_LAUNCHXL_SPI1,
351 |
352 | CC2640R2_LAUNCHXL_SPICOUNT
353 | } CC2640R2_LAUNCHXL_SPIName;
354 |
355 | /*!
356 | * @def CC2640R2_LAUNCHXL_UARTName
357 | * @brief Enum of UARTs
358 | */
359 | typedef enum CC2640R2_LAUNCHXL_UARTName {
360 | CC2640R2_LAUNCHXL_UART0 = 0,
361 |
362 | CC2640R2_LAUNCHXL_UARTCOUNT
363 | } CC2640R2_LAUNCHXL_UARTName;
364 |
365 | /*!
366 | * @def CC2640R2_LAUNCHXL_UDMAName
367 | * @brief Enum of DMA buffers
368 | */
369 | typedef enum CC2640R2_LAUNCHXL_UDMAName {
370 | CC2640R2_LAUNCHXL_UDMA0 = 0,
371 |
372 | CC2640R2_LAUNCHXL_UDMACOUNT
373 | } CC2640R2_LAUNCHXL_UDMAName;
374 |
375 | /*!
376 | * @def CC2640R2_LAUNCHXL_WatchdogName
377 | * @brief Enum of Watchdogs
378 | */
379 | typedef enum CC2640R2_LAUNCHXL_WatchdogName {
380 | CC2640R2_LAUNCHXL_WATCHDOG0 = 0,
381 |
382 | CC2640R2_LAUNCHXL_WATCHDOGCOUNT
383 | } CC2640R2_LAUNCHXL_WatchdogName;
384 |
385 | /*!
386 | * @def CC2650_LAUNCHXL_TRNGName
387 | * @brief Enum of TRNG names on the board
388 | */
389 | typedef enum CC2640R2_LAUNCHXL_TRNGName {
390 | CC2640R2_LAUNCHXL_TRNG0 = 0,
391 | CC2640R2_LAUNCHXL_TRNGCOUNT
392 | } CC2640R2_LAUNCHXL_TRNGName;
393 |
394 | #ifdef __cplusplus
395 | }
396 | #endif
397 |
398 | #endif /* __CC2640R2_LAUNCHXL_BOARD_H__ */
399 |
--------------------------------------------------------------------------------
/AndroidApp/app/src/main/java/com/nordicsemi/nrfUARTv2/UartService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.nordicsemi.nrfUARTv2;
18 |
19 | import android.app.Service;
20 | import android.bluetooth.BluetoothAdapter;
21 | import android.bluetooth.BluetoothDevice;
22 | import android.bluetooth.BluetoothGatt;
23 | import android.bluetooth.BluetoothGattCallback;
24 | import android.bluetooth.BluetoothGattCharacteristic;
25 | import android.bluetooth.BluetoothGattDescriptor;
26 | import android.bluetooth.BluetoothGattService;
27 | import android.bluetooth.BluetoothManager;
28 | import android.bluetooth.BluetoothProfile;
29 | import android.content.Context;
30 | import android.content.Intent;
31 | import android.os.Binder;
32 | import android.os.IBinder;
33 | import android.support.v4.content.LocalBroadcastManager;
34 | import android.util.Log;
35 |
36 | import java.util.List;
37 | import java.util.UUID;
38 |
39 | /**
40 | * Service for managing connection and data communication with a GATT server hosted on a
41 | * given Bluetooth LE device.
42 | */
43 | public class UartService extends Service {
44 | private final static String TAG = UartService.class.getSimpleName();
45 |
46 | private BluetoothManager mBluetoothManager;
47 | private BluetoothAdapter mBluetoothAdapter;
48 | private String mBluetoothDeviceAddress;
49 | private BluetoothGatt mBluetoothGatt;
50 | private int mConnectionState = STATE_DISCONNECTED;
51 |
52 | private static final int STATE_DISCONNECTED = 0;
53 | private static final int STATE_CONNECTING = 1;
54 | private static final int STATE_CONNECTED = 2;
55 |
56 | public final static String ACTION_GATT_CONNECTED =
57 | "com.nordicsemi.nrfUART.ACTION_GATT_CONNECTED";
58 | public final static String ACTION_GATT_DISCONNECTED =
59 | "com.nordicsemi.nrfUART.ACTION_GATT_DISCONNECTED";
60 | public final static String ACTION_GATT_SERVICES_DISCOVERED =
61 | "com.nordicsemi.nrfUART.ACTION_GATT_SERVICES_DISCOVERED";
62 | public final static String ACTION_DATA_AVAILABLE =
63 | "com.nordicsemi.nrfUART.ACTION_DATA_AVAILABLE";
64 | public final static String EXTRA_DATA =
65 | "com.nordicsemi.nrfUART.EXTRA_DATA";
66 | public final static String DEVICE_DOES_NOT_SUPPORT_UART =
67 | "com.nordicsemi.nrfUART.DEVICE_DOES_NOT_SUPPORT_UART";
68 |
69 | public static final UUID TX_POWER_UUID = UUID.fromString("00001804-0000-1000-8000-00805f9b34fb");
70 | public static final UUID TX_POWER_LEVEL_UUID = UUID.fromString("00002a07-0000-1000-8000-00805f9b34fb");
71 | public static final UUID CCCD = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
72 | public static final UUID FIRMWARE_REVISON_UUID = UUID.fromString("00002a26-0000-1000-8000-00805f9b34fb");
73 | public static final UUID DIS_UUID = UUID.fromString("0000180a-0000-1000-8000-00805f9b34fb");
74 | public static final UUID RX_SERVICE_UUID = UUID.fromString("f000fff0-0451-4000-b000-000000000000");
75 |
76 | //注意,这里的RX对于CC254x来说的接收,也就是0xfff1
77 | public static final UUID RX_CHAR_UUID = UUID.fromString("f000fff1-0451-4000-b000-000000000000");
78 | //注意,这里的TX对于CC254x来说的发送,也就是0xfff4,notify方式。
79 | public static final UUID TX_CHAR_UUID = UUID.fromString("f000fff1-0451-4000-b000-000000000000");
80 |
81 |
82 | // Implements callback methods for GATT events that the app cares about. For example,
83 | // connection change and services discovered.
84 | private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
85 | @Override
86 | public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
87 | String intentAction;
88 |
89 | if (newState == BluetoothProfile.STATE_CONNECTED) {
90 | intentAction = ACTION_GATT_CONNECTED;
91 | mConnectionState = STATE_CONNECTED;
92 | broadcastUpdate(intentAction);
93 | Log.i(TAG, "Connected to GATT server.");
94 | // Attempts to discover services after successful connection.
95 | Log.i(TAG, "Attempting to start service discovery:" +
96 | mBluetoothGatt.discoverServices());
97 |
98 | } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
99 | intentAction = ACTION_GATT_DISCONNECTED;
100 | mConnectionState = STATE_DISCONNECTED;
101 | Log.i(TAG, "Disconnected from GATT server.");
102 | broadcastUpdate(intentAction);
103 | }
104 | }
105 |
106 | @Override
107 | public void onServicesDiscovered(BluetoothGatt gatt, int status) {
108 | if (status == BluetoothGatt.GATT_SUCCESS) {
109 | Log.w(TAG, "mBluetoothGatt = " + mBluetoothGatt );
110 |
111 | broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
112 | } else {
113 | Log.w(TAG, "onServicesDiscovered received: " + status);
114 | }
115 | }
116 |
117 | @Override
118 | public void onCharacteristicRead(BluetoothGatt gatt,
119 | BluetoothGattCharacteristic characteristic,
120 | int status) {
121 | if (status == BluetoothGatt.GATT_SUCCESS) {
122 | broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
123 | }
124 | }
125 |
126 | @Override
127 | public void onCharacteristicChanged(BluetoothGatt gatt,
128 | BluetoothGattCharacteristic characteristic) {
129 | broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
130 | }
131 | };
132 |
133 | private void broadcastUpdate(final String action) {
134 | final Intent intent = new Intent(action);
135 | LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
136 | }
137 |
138 | private void broadcastUpdate(final String action,
139 | final BluetoothGattCharacteristic characteristic) {
140 | final Intent intent = new Intent(action);
141 |
142 | // This is special handling for the Heart Rate Measurement profile. Data parsing is
143 | // carried out as per profile specifications:
144 | // http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml
145 | if (TX_CHAR_UUID.equals(characteristic.getUuid())) {
146 |
147 | // Log.d(TAG, String.format("Received TX: %d",characteristic.getValue() ));
148 | intent.putExtra(EXTRA_DATA, characteristic.getValue());
149 | } else {
150 |
151 | }
152 | LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
153 | }
154 |
155 | public class LocalBinder extends Binder {
156 | UartService getService() {
157 | return UartService.this;
158 | }
159 | }
160 |
161 | @Override
162 | public IBinder onBind(Intent intent) {
163 | return mBinder;
164 | }
165 |
166 | @Override
167 | public boolean onUnbind(Intent intent) {
168 | // After using a given device, you should make sure that BluetoothGatt.close() is called
169 | // such that resources are cleaned up properly. In this particular example, close() is
170 | // invoked when the UI is disconnected from the Service.
171 | close();
172 | return super.onUnbind(intent);
173 | }
174 |
175 | private final IBinder mBinder = new LocalBinder();
176 |
177 | /**
178 | * Initializes a reference to the local Bluetooth adapter.
179 | *
180 | * @return Return true if the initialization is successful.
181 | */
182 | public boolean initialize() {
183 | // For API level 18 and above, get a reference to BluetoothAdapter through
184 | // BluetoothManager.
185 | if (mBluetoothManager == null) {
186 | mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
187 | if (mBluetoothManager == null) {
188 | Log.e(TAG, "Unable to initialize BluetoothManager.");
189 | return false;
190 | }
191 | }
192 |
193 | mBluetoothAdapter = mBluetoothManager.getAdapter();
194 | if (mBluetoothAdapter == null) {
195 | Log.e(TAG, "Unable to obtain a BluetoothAdapter.");
196 | return false;
197 | }
198 |
199 | return true;
200 | }
201 |
202 | /**
203 | * Connects to the GATT server hosted on the Bluetooth LE device.
204 | *
205 | * @param address The device address of the destination device.
206 | *
207 | * @return Return true if the connection is initiated successfully. The connection result
208 | * is reported asynchronously through the
209 | * {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
210 | * callback.
211 | */
212 | public boolean connect(final String address) {
213 | if (mBluetoothAdapter == null || address == null) {
214 | Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
215 | return false;
216 | }
217 |
218 | // Previously connected device. Try to reconnect.
219 | if (mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress)
220 | && mBluetoothGatt != null) {
221 | Log.d(TAG, "Trying to use an existing mBluetoothGatt for connection.");
222 | if (mBluetoothGatt.connect()) {
223 | mConnectionState = STATE_CONNECTING;
224 | return true;
225 | } else {
226 | return false;
227 | }
228 | }
229 |
230 | final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
231 | if (device == null) {
232 | Log.w(TAG, "Device not found. Unable to connect.");
233 | return false;
234 | }
235 | // We want to directly connect to the device, so we are setting the autoConnect
236 | // parameter to false.
237 | mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
238 | Log.d(TAG, "Trying to create a new connection.");
239 | mBluetoothDeviceAddress = address;
240 | mConnectionState = STATE_CONNECTING;
241 | return true;
242 | }
243 |
244 | /**
245 | * Disconnects an existing connection or cancel a pending connection. The disconnection result
246 | * is reported asynchronously through the
247 | * {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
248 | * callback.
249 | */
250 | public void disconnect() {
251 | if (mBluetoothAdapter == null || mBluetoothGatt == null) {
252 | Log.w(TAG, "BluetoothAdapter not initialized");
253 | return;
254 | }
255 | mBluetoothGatt.disconnect();
256 | // mBluetoothGatt.close();
257 | }
258 |
259 | /**
260 | * After using a given BLE device, the app must call this method to ensure resources are
261 | * released properly.
262 | */
263 | public void close() {
264 | if (mBluetoothGatt == null) {
265 | return;
266 | }
267 | Log.w(TAG, "mBluetoothGatt closed");
268 | mBluetoothDeviceAddress = null;
269 | mBluetoothGatt.close();
270 | mBluetoothGatt = null;
271 | }
272 |
273 | /**
274 | * Request a read on a given {@code BluetoothGattCharacteristic}. The read result is reported
275 | * asynchronously through the {@code BluetoothGattCallback#onCharacteristicRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int)}
276 | * callback.
277 | *
278 | * @param characteristic The characteristic to read from.
279 | */
280 | public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
281 | if (mBluetoothAdapter == null || mBluetoothGatt == null) {
282 | Log.w(TAG, "BluetoothAdapter not initialized");
283 | return;
284 | }
285 | mBluetoothGatt.readCharacteristic(characteristic);
286 | }
287 |
288 | /**
289 | * Enables or disables notification on a give characteristic.
290 | *
291 | * @param characteristic Characteristic to act on.
292 | * @param enabled If true, enable notification. False otherwise.
293 | */
294 | /*
295 | public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
296 | boolean enabled) {
297 | if (mBluetoothAdapter == null || mBluetoothGatt == null) {
298 | Log.w(TAG, "BluetoothAdapter not initialized");
299 | return;
300 | }
301 | mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
302 |
303 |
304 | if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
305 | BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
306 | UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
307 | descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
308 | mBluetoothGatt.writeDescriptor(descriptor);
309 | }
310 | }*/
311 |
312 | /**
313 | * Enable TXNotification
314 | *
315 | * @return
316 | */
317 | public void enableTXNotification()
318 | {
319 |
320 | if (mBluetoothGatt == null) {
321 | showMessage("mBluetoothGatt null" + mBluetoothGatt);
322 | broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
323 | return;
324 | }
325 |
326 | BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
327 | if (RxService == null) {
328 | showMessage("Rx service not found!");
329 | broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
330 | return;
331 | }
332 | BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
333 | if (TxChar == null) {
334 | showMessage("Tx charateristic not found!");
335 | broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
336 | return;
337 | }
338 | mBluetoothGatt.setCharacteristicNotification(TxChar,true);
339 |
340 | BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
341 | descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
342 | mBluetoothGatt.writeDescriptor(descriptor);
343 |
344 | }
345 |
346 | public void writeRXCharacteristic(byte[] value)
347 | {
348 |
349 |
350 | BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
351 | showMessage("mBluetoothGatt null"+ mBluetoothGatt);
352 | if (RxService == null) {
353 | showMessage("Rx service not found!");
354 | broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
355 | return;
356 | }
357 | BluetoothGattCharacteristic RxChar = RxService.getCharacteristic(RX_CHAR_UUID);
358 | if (RxChar == null) {
359 | showMessage("Rx charateristic not found!");
360 | broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
361 | return;
362 | }
363 | RxChar.setValue(value);
364 | boolean status = mBluetoothGatt.writeCharacteristic(RxChar);
365 |
366 | Log.d(TAG, "write TXchar - status=" + status);
367 | }
368 |
369 | private void showMessage(String msg) {
370 | Log.e(TAG, msg);
371 | }
372 | /**
373 | * Retrieves a list of supported GATT services on the connected device. This should be
374 | * invoked only after {@code BluetoothGatt#discoverServices()} completes successfully.
375 | *
376 | * @return A {@code List} of supported services.
377 | */
378 | public List getSupportedGattServices() {
379 | if (mBluetoothGatt == null) return null;
380 |
381 | return mBluetoothGatt.getServices();
382 | }
383 | }
384 |
--------------------------------------------------------------------------------
/5.14_advance_peripheral_uarttrans/src/profile/uarttrans_service.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Filename: serial_port_service.c
3 | *
4 | * Description: This is the simple_peripheral example modified to send
5 | * data over BLE at a high throughput.
6 | *
7 | *
8 | * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
9 | *
10 | *
11 | * Redistribution and use in source and binary forms, with or without
12 | * modification, are permitted provided that the following conditions
13 | * are met:
14 | *
15 | * Redistributions of source code must retain the above copyright
16 | * notice, this list of conditions and the following disclaimer.
17 | *
18 | * Redistributions in binary form must reproduce the above copyright
19 | * notice, this list of conditions and the following disclaimer in the
20 | * documentation and/or other materials provided with the
21 | * distribution.
22 | *
23 | * Neither the name of Texas Instruments Incorporated nor the names of
24 | * its contributors may be used to endorse or promote products derived
25 | * from this software without specific prior written permission.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 | *
39 | */
40 |
41 | /*********************************************************************
42 | * INCLUDES
43 | */
44 | #include
45 | #include
46 | #include "util.h"
47 |
48 | #include "ti/drivers/uart/UARTCC26XX.h"
49 | #include "board.h"
50 | #include "peripheral_uarttrans.h"
51 |
52 | /* This Header file contains all BLE API and icall structure definition */
53 | #include "icall_ble_api.h"
54 |
55 | #include "uarttrans_service.h"
56 | //#include "inc\sdi_task.h"
57 | #include "task_epd.h"
58 | /*********************************************************************
59 | * MACROS
60 | */
61 | #define AUTO_NOTIFICATION FALSE
62 | /*********************************************************************
63 | * CONSTANTS
64 | */
65 |
66 | #define SERVAPP_NUM_ATTR_SUPPORTED 5
67 |
68 | gattAttribute_t SerialPortServiceAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED];
69 | /*********************************************************************
70 | * TYPEDEFS
71 | */
72 |
73 | typedef enum UART_STATUS_CHAR {
74 | FRAMING_ERR_BYTE,
75 | PARITY_ERR_BYTE,
76 | RF_OVERRUN_BYTE
77 | } UART_STATUS_BYTE_DEF;
78 |
79 | /*!
80 | * @brief UART config service settings
81 | *
82 | * This enumeration defines the UART config bits in Byte 2 of config. char.
83 | */
84 | typedef enum UART_CONFIG_CHAR {
85 | UART_CONFIG_START = 0, /*!permissions ) )
387 | {
388 | // Insufficient authorization
389 | return ( ATT_ERR_INSUFFICIENT_AUTHOR );
390 | }
391 |
392 | // Make sure it's not a blob operation (no attributes in the profile are long)
393 | if ( offset > 0 )
394 | {
395 | return ( ATT_ERR_ATTR_NOT_LONG );
396 | }
397 |
398 | if ( pAttr->type.len == ATT_UUID_SIZE )
399 | {
400 | // Get 16-bit UUID from 128-bit UUID
401 | uint16 uuid = BUILD_UINT16( pAttr->type.uuid[12], pAttr->type.uuid[13]);
402 |
403 | switch ( uuid )
404 | {
405 | // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
406 | // gattserverapp handles those reads
407 |
408 | // characteristics SERIALPORTSERVICE_STATUS_UUID and SERIALPORTSERVICE_CONFIG_UUID have read permissions
409 | // characteristic SERIALPORTSERVICE_DATA_UUID does not have read permissions, but because it
410 | // can be sent as a notification, it is included here
411 |
412 | case SERIALPORTSERVICE_DATA_UUID:
413 | *pLen = charDataValueLen;
414 | VOID memcpy( pValue, pAttr->pValue, charDataValueLen );
415 | break;
416 |
417 | default:
418 | // Should never get here! (characteristics 3 and 4 do not have read permissions)
419 | *pLen = 0;
420 | status = ATT_ERR_ATTR_NOT_FOUND;
421 | break;
422 | }
423 | }
424 | else if( pAttr->type.len == ATT_BT_UUID_SIZE)
425 | {
426 | uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
427 | switch ( uuid )
428 | {
429 | default:
430 | // Should never get here!
431 | *pLen = 0;
432 | status = ATT_ERR_ATTR_NOT_FOUND;
433 | break;
434 | }
435 | }
436 | else
437 | {
438 | //neither 16-bit UUID nor 128bit UUID
439 | *pLen = 0;
440 | status = ATT_ERR_INVALID_HANDLE;
441 | }
442 |
443 | return ( status );
444 | }
445 |
446 | /*********************************************************************
447 | * @fn SerialPortService_WriteAttrCB
448 | *
449 | * @brief Validate attribute data prior to a write operation
450 | *
451 | * @param connHandle - connection message was received on
452 | * @param pAttr - pointer to attribute
453 | * @param pValue - pointer to data to be written
454 | * @param len - length of data
455 | * @param offset - offset of the first octet to be written
456 | * @param method - type of write message
457 | *
458 | * @return SUCCESS, blePending or Failure
459 | */
460 | static bStatus_t SerialPortService_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
461 | uint8 *pValue, uint16 len, uint16 offset,
462 | uint8 method )
463 | {
464 | bStatus_t status = SUCCESS;
465 | uint8 notifyApp = 0xFF;
466 |
467 | // If attribute permissions require authorization to write, return error
468 | if ( gattPermitAuthorWrite( pAttr->permissions ) )
469 | {
470 | // Insufficient authorization
471 | return ( ATT_ERR_INSUFFICIENT_AUTHOR );
472 | }
473 |
474 | if ( pAttr->type.len == ATT_UUID_SIZE )
475 | {
476 | // 16-bit UUID
477 | uint16 uuid = BUILD_UINT16( pAttr->type.uuid[12], pAttr->type.uuid[13]);
478 | switch ( uuid )
479 | {
480 | case SERIALPORTSERVICE_DATA_UUID:
481 | if ( offset == 0 )
482 | {
483 | if ( len > SERIALPORTSERVICE_DATA_LEN )
484 | {
485 | status = ATT_ERR_INVALID_VALUE_SIZE;
486 | }
487 | }
488 | else
489 | {
490 | status = ATT_ERR_ATTR_NOT_LONG;
491 | }
492 |
493 | //Write the value
494 | if ( status == SUCCESS )
495 | {
496 | uint8 *pCurValue = (uint8 *)pAttr->pValue;
497 |
498 | //Copy/Store data to the GATT table entry
499 | //memset(pCurValue, 0, SERIALPORTSERVICE_DATA_LEN);
500 | memcpy(pCurValue, pValue, len);
501 |
502 | //Send Data to UART
503 | // SDITask_sendToUART(pCurValue, len);
504 | EPDTask_parseCommand(pCurValue, len);
505 | //uncomment to notify application
506 | //notifyApp = SERIALPORTSERVICE_CHAR_DATA;
507 | }
508 |
509 | break;
510 |
511 | default:
512 | // Should never get here! (characteristics 2 and 4 do not have write permissions)
513 | status = ATT_ERR_ATTR_NOT_FOUND;
514 | break;
515 | }
516 | }
517 | else if (pAttr->type.len == ATT_BT_UUID_SIZE )
518 | {
519 | // 16-bit UUID
520 | uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
521 |
522 | switch ( uuid )
523 | {
524 | case GATT_CLIENT_CHAR_CFG_UUID:
525 | status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
526 | offset, GATT_CLIENT_CFG_NOTIFY );
527 | break;
528 | default:
529 | status = ATT_ERR_ATTR_NOT_FOUND;
530 | break;
531 | }
532 | }
533 | else
534 | {
535 | //neither 16bit UUID nor 128bit UUID
536 | status = ATT_ERR_INVALID_HANDLE;
537 | }
538 |
539 | // If a charactersitic value changed then callback function to notify application of change
540 | if ( (notifyApp != 0xFF ) && SerialPortService_AppCBs && SerialPortService_AppCBs->pfnSerialPortServiceChange )
541 | {
542 | SerialPortService_AppCBs->pfnSerialPortServiceChange( notifyApp );
543 | }
544 |
545 | return ( status );
546 | }
547 |
548 | /*********************************************************************
549 | *********************************************************************/
550 |
--------------------------------------------------------------------------------