Initial PAL implementation for TI SimpleLink azure-iot-pal-simplelink-2.00 master azure-iot-pal-simplelink-2.00.00.06 azure-iot-pal-simplelink-2.00.00.07
authorVincent Wan <vwan@ti.com>
Fri, 16 Mar 2018 23:49:48 +0000 (16:49 -0700)
committerChris Ring <cring@ti.com>
Fri, 3 Aug 2018 22:07:39 +0000 (15:07 -0700)
This is TI's Platform Adaptation Layer (PAL) for SimpleLink platforms.
It was modeled on other PALs in Microsoft's Azure Github space
(https://github.com/Azure).  Consistent with those projects, the Azure
C IoT SDK is a git submodule in a subdirectory named 'sdk'.

The initial release includes support for TI's CC32XX (WiFi) and
MSP432E4 (Wired) platforms.

Signed-off-by: Chris Ring <cring@ti.com>
58 files changed:
.gitignore [new file with mode: 0644]
.gitmodules [new file with mode: 0644]
LICENSE [new file with mode: 0644]
README.md [new file with mode: 0644]
build_all/Makefile [new file with mode: 0644]
build_all/azureiot.bld [new file with mode: 0644]
build_all/pal/package.bld [new file with mode: 0644]
build_all/pal/package.xdc [new file with mode: 0644]
build_all/products.mak [new file with mode: 0644]
build_all/sdk/package.bld [new file with mode: 0644]
build_all/sdk/package.xdc [new file with mode: 0644]
devdoc/httpapi_sl_requirements.md [new file with mode: 0644]
devdoc/platform_sl_requirements.md [new file with mode: 0644]
devdoc/tlsio_sl_requirements.md [new file with mode: 0644]
pal/inc/cert_sl.h [new file with mode: 0644]
pal/inc/refcount_os.h [new file with mode: 0644]
pal/inc/tlsio_sl.h [new file with mode: 0644]
pal/src/httpapi_sl.c [new file with mode: 0644]
pal/src/platform_sl.c [new file with mode: 0644]
pal/src/threadapi_pthreads_sl.c [new file with mode: 0644]
pal/src/tickcounter_sl.c [new file with mode: 0644]
pal/src/tlsio_sl.c [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/Board.h [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/CC3220SF_LAUNCHXL.c [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/CC3220SF_LAUNCHXL.h [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/network.c [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/network.h [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/startsntp.c [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/tirtos/ccs/CC3220SF_LAUNCHXL_TIRTOS.cmd [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/tirtos/ccs/makedefs [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/tirtos/ccs/makefile [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/tirtos/main_tirtos.c [new file with mode: 0644]
sample/CC3220SF_LAUNCHXL/wificonfig.h [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/Board.h [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/CC3220S_LAUNCHXL.c [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/CC3220S_LAUNCHXL.h [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/network.c [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/network.h [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/startsntp.c [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/tirtos/ccs/CC3220S_LAUNCHXL_TIRTOS.cmd [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/tirtos/ccs/makedefs [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/tirtos/ccs/makefile [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/tirtos/main_tirtos.c [new file with mode: 0644]
sample/CC3220S_LAUNCHXL/wificonfig.h [new file with mode: 0644]
sample/MSP_EXP432E401Y/Board.h [new file with mode: 0644]
sample/MSP_EXP432E401Y/MSP_EXP432E401Y.c [new file with mode: 0644]
sample/MSP_EXP432E401Y/MSP_EXP432E401Y.h [new file with mode: 0644]
sample/MSP_EXP432E401Y/network.c [new file with mode: 0644]
sample/MSP_EXP432E401Y/network.h [new file with mode: 0644]
sample/MSP_EXP432E401Y/startsntp.c [new file with mode: 0644]
sample/MSP_EXP432E401Y/tirtos/ccs/MSP_EXP432E401Y_TIRTOS.cmd [new file with mode: 0644]
sample/MSP_EXP432E401Y/tirtos/ccs/makedefs [new file with mode: 0644]
sample/MSP_EXP432E401Y/tirtos/ccs/makefile [new file with mode: 0644]
sample/MSP_EXP432E401Y/tirtos/main_tirtos.c [new file with mode: 0644]
sample/MSP_EXP432E401Y/tirtos/ndk_tirtos.c [new file with mode: 0644]
sample/simplesample_http.c [new file with mode: 0644]
sample/simplesample_http.h [new file with mode: 0644]
sdk [new submodule]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..b4fcb17
--- /dev/null
@@ -0,0 +1,44 @@
+exports/
+imports/
+product/
+package/
+lib/
+whole_program_debug/
+debug/
+release/
+tdiff,*
+.libraries*
+.generated_files
+.dlls
+.executables
+.interfaces
+.libraries
+.imports
+.imports.xml
+.smmakefirst
+.cg*
+.*tools-*
+.xdcenv.mak
+.bin-files,cmds
+.src-files
+.etc-files
+.test-files
+.all-files
+.lib-files
+.include-files
+package.mak
+Make.log
+coverity.txt
+misra.txt
+*.exe
+TAGS
+*.x86U
+*.o
+*.out
+*.xe*
+*.map
+*.xml
+
+# klocwork-generated directory and files
+kw-test/
+kwout.txt
diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..fcbc6e0
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "sdk"]
+       path = sdk
+       url = https://github.com/Azure/azure-iot-sdk-c.git
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..6f6748c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+    Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..d3429c7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,185 @@
+Run a simple C sample on a SimpleLink device
+===
+---
+# Table of Contents
+
+- [Introduction](#Introduction)
+- [Step 1: Prerequisites](#Step-1-Prerequisites)
+- [Step 2: Build and Run the Sample](#Step-2-Build)
+-   [Next Steps](#NextSteps)
+
+<a name="Introduction"></a>
+# Introduction
+
+**About this document**
+
+This document describes how to connect a TI SimpleLink device to Microsoft Azure using the Azure IoT SDK. This multi-step process includes:
+- Configuring Azure IoT Hub
+- Registering your IoT device
+- Build and deploy Azure IoT SDK on device
+
+The instructions in this file apply specifically to a user who has directly cloned or downloaded the "azure-iot-pal-simplelink" PAL repository. Please note that it is highly recommended to alternatively install the TI Azure SDK Plugin, versus cloning or downloading this repository directly.  The repository by itself only provides a basic example running on TI-RTOS with makefiles for the TI compiler.  Full support for TI, GCC and IAR toolchains and FreeRTOS is provided via the Plugin installation.
+
+If you have installed the Azure SDK Plugin (i.e. did not just clone/download this repository), then please refer to the Quick Start Guide that is included with your Plugin installation (you should be able to access this via the "docs" folder of the Azure SDK Plugin installation). The Quick Start Guide provides more accurate instructions that apply specifically to the Plugin installation.
+
+<a name="Step-1-Prerequisites"></a>
+# Step 1: Prerequisites
+
+- Computer with Git client installed and access to
+  [azure-iot-pal-simplelink](URL TBD) this BitBucket public repository.
+- [CC3220SF Launchpad](http://www.ti.com/tool/cc3220sf-launchxl) or [CC3220S Launchpad](http://www.ti.com/tool/cc3220s-launchxl) or [MSP432E4 Launchpad](http://www.ti.com/tool/MSP-EXP432E401Y)
+- [Setup your IoT hub][lnk-setup-iot-hub]
+- [Provision your device and get its credentials][lnk-manage-iot-hub]
+
+Please ensure that your device has been updated with the latest firmware and or service pack (instructions for updating the firmware and/or service pack are included with the SimpleLink SDK installation).
+
+These instructions refer to the folder that contains the Azure PAL repository on your local machine as `<AZURE_PAL_INSTALL_DIR>`.
+
+While not strictly required, we recommend that you install the following tools from TI in the same directory and that you use directory names without any whitespace. This documentation assumes that you install everything in `C:\ti`.
+
+- Install [Code Composer Studio (CCS) IDE, v8.1 or compatible](http://processors.wiki.ti.com/index.php/Download_CCS)
+
+- Install [Uniflash Tool](http://www.ti.com/tool/Uniflash) 4.1 or later (for SimpleLink CC32XX only)
+
+- Install [TI SimpleLink Wi-Fi CC32XX Software Development Kit 2.20 or later](http://www.ti.com/tool/simplelink-cc3220-sdk) (for SimpleLink CC32XX only)
+
+- Install [TI SimpleLink MSP432E4 Software Development Kit 2.20 or later](http://www.ti.com/tool/simplelink-msp432-sdk) (for SimpleLink MSP432E4 only)
+
+<a name="Step-2-Build"></a>
+# Step 2: Build and Run the sample
+
+<a name="Build-LIBS"></a>
+## Build the Azure PAL and SDK libraries
+1. Edit the `products.mak` file in `<AZURE_PAL_INSTALL_DIR>\build_all` using your favorite text editor. The variables `XDC_INSTALL_DIR` and `SIMPLELINK_<YOUR DEVICE>_SDK_INSTALL_DIR` must point to the locations where you installed these products. The variable `ti.targets.arm.elf.M4` for CC32xx or `ti.targets.arm.elf.M4F` for MSP432E4 should point to the installation location of the TI ARM compiler, which can be found in CCS. After modification, these variable definitions should look similar to the following. Note the use of "/" in the path.
+
+  ```
+  XDC_INSTALL_DIR ?= c:/ti/xdctools_3_50_07_20_core
+  SIMPLELINK_CC32XX_SDK_INSTALL_DIR   ?= C:/ti/simplelink_cc32xx_sdk_2_20_00_10
+  ti.targets.arm.elf.M4  ?= C:/CCSv8.1.0/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS
+  ```
+It is also recommended that you add the xdc tools folder (```C:/ti/xdctools_3_50_07_20_core```) to your path in order to avoid errors related to finding gmake.exe during the build process.
+
+2. Open a Windows command prompt.
+
+3. In the Windows command prompt, run the following commands (be sure to replace the paths with your installation paths).
+
+  ```
+  cd <AZURE_PAL_INSTALL_DIR>\build_all
+  C:\ti\xdctools_3_50_07_20_core\gmake.exe clean
+  C:\ti\xdctools_3_50_07_20_core\gmake.exe all
+  ```
+
+<a name="Build-OS"></a>
+## Build the OS
+1. Update the settings in the imports.mak file of your device's SDK in `<SIMPLELINK_CC32XX_SDK_INSTALL_DIR>` or `<SIMPLELINK_MSP432E4_SDK_INSTALL_DIR>` with the appropriate paths if you have not done so previously.
+
+2. In the Windows command prompt, navigate to the OS directory corresponding to your OS of choice. For example, <SIMPLELINK_CC32XX_SDK_INSTALL_DIR>/kernel/tirtos/builds/CC3220SF_LAUNCHXL/release/ccs for tirtos on CC3220SF.
+
+3. In the Windows command prompt, enter the following commands to build the OS:
+
+  ```
+  C:\ti\xdctools_3_50_07_20_core\gmake.exe clean
+  C:\ti\xdctools_3_50_07_20_core\gmake.exe
+  ```
+
+<a name="Build-SAMPLE"></a>
+## Build a sample application
+The following instructions refer to the simplesample_http sample application, but they could be similarly applied to other sample applications found in the SDK.
+Before building the application, complete the following steps:
+
+1. Open the `simplesample_http.c` file from the directory `<AZURE_PAL_INSTALL_DIR>\sample` in a text editor and replace the value of the "connectionString" variable with the device connection string you noted [earlier](#Step-1-Prerequisites).
+
+2. (For CC32xx only) Open the file `CC3220S_LAUNCHXL/wificonfig.h` or `CC3220SF_LAUNCHXL/wificonfig.h` depending on the LaunchPad you have. Search for "USER STEP" and update the WIFI SSID and SECURITY_KEY macros.
+
+3. In the Windows command prompt, enter the following commands to build the application (replace `CC3220SF_LAUNCHXL` with your platform name):
+
+  ```
+  cd <AZURE_PAL_INSTALL_DIR>\sample\CC3220SF_LAUNCHXL\tirtos\ccs
+  C:\ti\xdctools_3_50_07_20_core\gmake.exe clean
+  C:\ti\xdctools_3_50_07_20_core\gmake.exe all
+  ```
+
+<a name="Flash-SAMPLE"></a>
+## Flash the root certificate
+### For CC32xx devices
+
+> Note: In the sample applications, the root CA certificate - "Baltimore CyberTrust Root" is flashed to CC32XX Launchpad to the location `/cert/ms.pem`. This location must match `SL_SSL_CA_CERT` in `<AZURE_PAL_INSTALL_DIR>\pal\inc\cert_sl.h`, and is used by SimpleLink TLS stack.
+
+Here's why you need the Baltimore root CA - it's the root CA for `*.azure-devices.net`, the IoT Hub endpoint and it's the only way for the device to verify the chain of trust:
+
+![image](https://cloud.githubusercontent.com/assets/6472374/11576321/71207be4-9a1e-11e5-9332-fa99fdbd31f9.png)
+
+The default behavior of the sample application is to automatically write the certificate to flash if it does not exist. This prevents the file from being written unnecessarily to the file system each time the program is run. If you wish to override this behavior, or if you wish to use a new certificate file, you can force the certificate to be flashed by passing "-DOVERWRITE_CERTS" to the compiler in the makefile.
+
+### For MSP432E4 devices
+
+The root CA certificate is simply loaded into memory as a security object with the name `/cert/ms.pem` to match `SL_SSL_CA_CERT` in `<AZURE_PAL_INSTALL_DIR>\pal\inc\cert_sl.h`, and used later when connecting to the IoT Hub endpoint.
+
+<a name="Setup-CCS"></a>
+## Setting Up Code Composer Studio Before Running The Examples
+We show the procedure for CC32xx devices below, but the same procedure can be followed for MSP432E4 by replacing `CC32xx` with `MSP432E4`.
+
+1. Plug the Launchpad into a USB port on your PC
+
+2. Open Code Composer Studio.
+
+3. In Code Composer Studio, open the CCS Debug Perspective - Windows menu -> Open Perspective -> CCS Debug
+
+4. Open the Target Configurations View - Windows menu -> Show View -> Target Configurations
+
+5. Right-click on User Defined. Select New Target Configuration.
+
+6. Use `CC32xx.ccxml` as "File name". Hit Finish.
+
+7. In the Basic window, select "Texas Instruments XDS110 USB Debug Probe" as the "Connection", and then type "CC3220" in the "Board or Device" text field. Check the box next to "CC3220SF" or "CC3220S" (depending on your launchpad). Hit Save.
+
+8. Right-click "CC32xx.ccxml" in the Target Configurations View. Hit Launch Selected Configuration.
+
+9. Under the Debug View, right-click on "Texas Instruments XDS110 USB Debug Probe_0/Cortex_M4_0". Select "Connect Target".
+
+<a name="Run-SAMPLE"></a>
+## Running An Example
+1. Disconnect and reconnect the LaunchPad's USB cable to power cycle the hardware, and then reconnect in CCS.
+
+2. Select Run menu -> Load -> Load Program..., and browse to the file `simplesample_http.out` in `<AZURE_PAL_INSTALL_DIR>\sample\CC3220SF_LAUNCHXL\tirtos\ccs` (replace `CC3220SF_LAUNCHXL` depending on your board). Hit OK. This will load the program onto the board.
+
+3. Run the application by pressing F8. The output will appear in your CCS console window, similar to the following:
+
+```
+Starting the simplesample_http example
+Current time: Fri Jul 20 20:56:27 2018
+
+CC32XX has connected to AP and acquired an IP address.
+IP Address: 192.168.1.172
+Flashing certificate file ...successfully wrote file /cert/ms.pem to flash
+IoTHubClient accepted the message for delivery
+Message Id: 1 Received.
+Result Call Back Called! Result is: IOTHUB_CLIENT_CONFIRMATION_OK
+```
+
+The [Device Explorer](https://github.com/Azure/azure-iot-sdk-csharp/tree/master/tools/DeviceExplorer) can be used to monitor the data sent by the application. Under the "Data" tab in Device Explorer, "Monitor" option should be selected before running the application. Later when the application is run, a message similar to the following message is displayed on "Event Hub Data" window.
+
+```
+5/19/2017 5:26:44 PM> Device: [devicee43522cd755d463b9331e55d1cab2f13], Data:[{"DeviceId":"myFirstDevice", "WindSpeed":12, "Temperature":23.000000, "Humidity":68.000000}]Properties:'temperatureAlert': 'false'
+```
+
+<a name="NextSteps"></a>
+# Next Steps
+
+You have now learned how to run a sample application that collects sensor data and sends it to your IoT hub. To explore how to store, analyze and visualize the data from this application in Azure using a variety of different services, please click on the following lessons:
+
+-   [Manage cloud device messaging with iothub-explorer]
+-   [Save IoT Hub messages to Azure data storage]
+-   [Use Power BI to visualize real-time sensor data from Azure IoT Hub]
+-   [Use Azure Web Apps to visualize real-time sensor data from Azure IoT Hub]
+-   [Weather forecast using the sensor data from your IoT hub in Azure Machine Learning]
+-   [Remote monitoring and notifications with Logic Apps]
+
+[Manage cloud device messaging with iothub-explorer]: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-explorer-cloud-device-messaging
+[Save IoT Hub messages to Azure data storage]: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-store-data-in-azure-table-storage
+[Use Power BI to visualize real-time sensor data from Azure IoT Hub]: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-live-data-visualization-in-power-bi
+[Use Azure Web Apps to visualize real-time sensor data from Azure IoT Hub]: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-live-data-visualization-in-web-apps
+[Weather forecast using the sensor data from your IoT hub in Azure Machine Learning]: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-weather-forecast-machine-learning
+[Remote monitoring and notifications with Logic Apps]: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-monitoring-notifications-with-azure-logic-apps
+[lnk-setup-iot-hub]: ../setup_iothub.md
+[lnk-manage-iot-hub]: ../manage_iot_hub.md
diff --git a/build_all/Makefile b/build_all/Makefile
new file mode 100644 (file)
index 0000000..1474636
--- /dev/null
@@ -0,0 +1,63 @@
+#
+# ==== Makefile ====
+#
+
+#
+# ==== Standard Variables ====
+#
+
+include ./products.mak
+
+#
+# Set XDCOPTIONS.  Use -v for a verbose build.
+#
+#XDCOPTIONS=v
+export XDCOPTIONS
+
+# Set XDCARGS to some of the variables above.  XDCARGS are passed
+# to the XDC build engine... which will load azureiot.bld... which will
+# extract these variables and use them to determine what to build and which
+# toolchains to use.
+XDCARGS= \
+    CC32XXSDK=\"$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)\" \
+    MSP432E4SDK=\"$(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)\" \
+    BIOS=\"$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/kernel/tirtos\" \
+    ti.targets.arm.elf.M4=\"$(ti.targets.arm.elf.M4)\" \
+    iar.targets.arm.M4=\"$(iar.targets.arm.M4)\" \
+    gnu.targets.arm.M4=\"$(gnu.targets.arm.M4)\" \
+    ti.targets.arm.elf.M4F=\"$(ti.targets.arm.elf.M4F)\" \
+    iar.targets.arm.M4F=\"$(iar.targets.arm.M4F)\" \
+    gnu.targets.arm.M4F=\"$(gnu.targets.arm.M4F)\"
+
+# Set XDCPATH to contain necessary repositories.
+ifneq ($(SIMPLELINK_CC32XX_SDK_INSTALL_DIR),)
+XDCPATH = $(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/kernel/tirtos/packages;
+else
+XDCPATH = $(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/kernel/tirtos/packages;
+endif
+
+ifeq (,$(wildcard $(subst ;,,$(XDCPATH))))
+    $(error $(subst ;,,$(XDCPATH)) is not a valid directory. \
+            Please verify the path to the SDK is correct in products.mak.)
+endif
+export XDCPATH
+
+#
+# Set XDC executable command
+# Note that XDCBUILDCFG points to the .bld file which uses
+# the arguments specified by XDCARGS
+#
+XDC = $(XDC_INSTALL_DIR)/xdc $(JOBS) XDCARGS="$(XDCARGS)" XDCBUILDCFG=./azureiot.bld
+XS = $(XDC_INSTALL_DIR)/xs
+
+######################################################
+## Shouldnt have to modify anything below this line ##
+######################################################
+
+all:
+       @echo building packages...
+       @$(XDC) -Pr ..
+
+clean:
+       @echo cleaning packages ...
+       @$(XDC) clean -Pr ..
diff --git a/build_all/azureiot.bld b/build_all/azureiot.bld
new file mode 100644 (file)
index 0000000..f57f2e8
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Generally there is no need to edit this file!
+ *
+ * This file controls which libraries are built, as well as compiler options
+ * to use.
+ */
+
+/*
+ *  ======== azureiot.bld ========
+ *  This script is run prior to all build scripts. It sets host-system-
+ *  independent values for targets and platforms, then it attempts to
+ *  find the host-system-specific user.bld script that sets rootDirs.
+ *
+ *  These settings may be a function of the following global variables:
+ *
+ *      environment a hash table of environment strings
+ *
+ *      arguments   an array of string arguments to the script
+ *                  initialized as follows:
+ *                      arguments[0] - the file name of the script
+ *                      arguments[1] - the first argument specified in XDCARGS
+ *                          :
+ *                      arguments[n] - the n'th argument in XDCARGS
+ *
+ *      Build       an alias for xdc.om.xdc.bld.BuildEnvironment
+ */
+
+var Build = xdc.useModule('xdc.bld.BuildEnvironment');
+var Pkg = xdc.useModule('xdc.bld.PackageContents');
+
+/*
+ * Linux86 => -std=c99 for (at least sscanf() and strtof())
+ */
+var ccOpts = {
+    "ti.targets.arm.elf.M4"           : " -ms -g --c99 -DNO_LOGGING",
+    "ti.targets.arm.elf.M4F"          : " -ms -g --c99 -DNO_LOGGING",
+    "iar.targets.arm.M4"              : "-DNO_LOGGING",
+    "iar.targets.arm.M4F"             : "-DNO_LOGGING",
+    "gnu.targets.arm.M4"              : " -std=c99 -DNO_LOGGING",
+    "gnu.targets.arm.M4F"             : " -std=c99 -DNO_LOGGING",
+};
+
+var lnkOpts = {
+};
+
+/* initialize local vars with those set in products.mak (via XDCARGS) */
+for (arg = 0; arg < arguments.length; arg++) {
+    /* split each arg into its '+' separated parts */
+    var configParts = arguments[arg].split(";");
+    if (ccOpts[configParts[0].split("=")[0]] === undefined) {
+        continue;
+    }
+
+    /*
+     * Get the compiler's installation directory.
+     * For "ti.targets.elf.C674=/vendors/c6x/7.2.0", we get "/vendors/c6x/7.2.0"
+     */
+    var targetName = configParts[0].split("=")[0];
+    var rootDir = configParts[0].split("=")[1];
+
+    /* only build for the specified compilers */
+    if (rootDir == "" || rootDir == undefined) {
+        continue;
+    }
+
+    var target = xdc.useModule(targetName);
+    target.rootDir = rootDir;
+
+    if (ccOpts[targetName] != undefined) {
+        if (targetName.split(".")[0] == "gnu") {
+            /* Removing -Wunused because it is too noisy in Azure SDK */
+            target.ccOpts.prefix = target.ccOpts.prefix.replace("-Wunused", "");
+        }
+
+        target.ccOpts.suffix += ccOpts[targetName];
+    }
+
+    if (lnkOpts[targetName] != undefined) {
+        target.lnkOpts.suffix += lnkOpts[targetName];
+    }
+
+    /* for all the other parts, assign target.<left> = <right> */
+    for (var i = 1; i < configParts.length; i++) {
+        var modCfgParam = configParts[i].split("=")[0];
+        var modCfgValue =
+                configParts[i].substring(configParts[i].indexOf("=") + 1);
+        var modCfgIndex = modCfgParam.split(".");
+        var element = target;
+
+        for (j = 0; j < (modCfgIndex.length -1); j++) {
+                element = element[modCfgIndex[j]];
+        }
+        element[modCfgIndex[j]] = modCfgValue;
+    }
+
+    /* and finally add this target to the Build.targets array */
+    Build.targets.$add(target);
+}
+
+/* lib/ is a generated directory that 'xdc clean' should remove */
+Pkg.generatedFiles.$add("lib/");
+
+/*
+ * Some packages build for 'all profiles' - but that's too much to ship.
+ * Loop over all profiles in all Build.targets and remove everything
+ * except 'release' and 'debug'.
+ */
+for (var t = 0; t < Build.targets.length; t++) {
+    for (prof in Build.targets[t].profiles) {
+        if ((prof != 'release') && (prof != 'debug')) {
+            delete Build.targets[t].profiles[prof];
+        }
+    }
+}
+
+
+/* Utility fxns used by various ti.net pkgs */
+function getLibDirectory(suffix) {
+    var libdir = "";
+
+    switch (suffix) {
+        case "em4":
+            libdir = "lib/ccs/m4";
+            break;
+
+        case "em4f":
+            libdir = "lib/ccs/m4f";
+            break;
+
+        case "rm4":
+            libdir = "lib/iar/m4";
+            break;
+
+        case "rm4f":
+            libdir = "lib/iar/m4f";
+            break;
+
+        case "m4g":
+            libdir = "lib/gcc/m4";
+            break;
+
+        case "m4fg":
+            libdir = "lib/gcc/m4f";
+            break;
+
+        case "v7AF":
+            libdir = "lib/gcc/v7AF";
+            break;
+
+        case "86U":
+            libdir = "lib/gcc/86U";
+            break;
+
+        default:
+            throw("Unhandled target suffix: '" + suffix + "'");
+            break;
+    }
+
+    return (libdir);
+}
+
+function getPosixIncDirectory(suffix) {
+    var incdir = "";
+
+    switch (suffix) {
+        case "em4":
+        case "em4f":
+            incdir = "ccs";
+            break;
+
+        case "rm4":
+        case "rm4f":
+            incdir = "iar";
+            break;
+
+        case "m4g":
+        case "m4fg":
+            incdir = "gcc";
+            break;
+
+        default:
+            throw("Unhandled target suffix: '" + suffix + "'");
+            break;
+    }
+
+    return (incdir);
+}
diff --git a/build_all/pal/package.bld b/build_all/pal/package.bld
new file mode 100644 (file)
index 0000000..2bf3257
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== package.bld ========
+ */
+
+var Build = xdc.useModule('xdc.bld.BuildEnvironment');
+var Pkg = xdc.useModule('xdc.bld.PackageContents');
+
+/* make command to search for the srcs */
+Pkg.makePrologue = "vpath %.c ../../pal/src";
+
+/* lib/ is a generated directory that 'xdc clean' should remove */
+Pkg.generatedFiles.$add("lib/");
+
+var SRCS_PAL = [
+    "httpapi_sl.c",
+    "platform_sl.c",
+    "tlsio_sl.c",
+    "tickcounter_sl.c",
+    "threadapi_pthreads_sl.c"
+]
+
+/* Paths to external source libraries */
+xdcargs = java.lang.System.getenv("XDCARGS").split(" ");
+
+var slIncs = "";
+var incs = "";
+var palIncs = "-I../../pal/inc -I../../sdk/c-utility/inc ";
+
+/* Parse out the XDCARGS options for the include source paths */
+for (x = 0; x < xdcargs.length; x++) {
+    if (xdcargs[x].match(/^CC32XXSDK=/)) {
+        incs = (xdcargs[x] + "").replace(/'/g, '');
+        incs = incs.substring(incs.indexOf('=') + 1);
+        if (incs != "\"\"") {
+            incs += "/source";
+            slIncs = "-I" + incs + " -I" + incs + "/include -I" + incs
+                    + "/ti/net/bsd -I" + incs;
+        }
+    }
+
+    if (xdcargs[x].match(/^MSP432E4SDK=/)) {
+        incs = (xdcargs[x] + "").replace(/'/g, '');
+        incs = incs.substring(incs.indexOf('=') + 1);
+        if (incs != "\"\"") {
+            if (slIncs != "") {
+                throw("Error: Please fill in only one set of variables "
+                        + "in products.mak corresponding to your platform");
+            }
+
+            incs += "/source";
+            slIncs = "-I" + incs + " -I" + incs + "/include -I" + incs
+                    + "/ti/net/bsd -I" + incs;
+        }
+    }
+}
+
+for (var i = 0; i < Build.targets.length; i++) {
+    var target = Build.targets[i];
+    var libdir = getLibDirectory(target.suffix);
+    var extraOpts;
+    var posixIncs;
+
+    for (var profile in target.profiles) {
+        var defs = "";
+        posixIncs = "/ti/posix" + "/" +
+            getPosixIncDirectory(target.suffix) + " ";
+        extraOpts = palIncs;
+        /* Add back unused warnings in PAL */
+        if (target.$name.split(".")[0] == "gnu") {
+            extraOpts += " -Wunused ";
+        }
+        Pkg.addLibrary(libdir + "/pal_sl_" + profile,
+            target, {
+                profile: profile,
+                defs: "-DNET_SL -DREFCOUNT_ATOMIC_DONTCARE " + extraOpts,
+                incs: slIncs + posixIncs,
+                suffix: '.a'
+            }).addObjects(SRCS_PAL);
+    }
+}
diff --git a/build_all/pal/package.xdc b/build_all/pal/package.xdc
new file mode 100644 (file)
index 0000000..431743c
--- /dev/null
@@ -0,0 +1,5 @@
+/*
+ *  ======== package.xdc ========
+ */
+package build_all.pal {
+}
diff --git a/build_all/products.mak b/build_all/products.mak
new file mode 100644 (file)
index 0000000..f7e960b
--- /dev/null
@@ -0,0 +1,33 @@
+#
+#  ======== products.mak ========
+#
+
+######################## All platforms ########################
+XDC_INSTALL_DIR    ?=
+
+######################## Optional ########################
+FREERTOS_INSTALL_DIR   ?=
+
+
+
+################################################################
+# Fill in the variable set corresponding to your platform      #
+# Only one set should be used at a time                        #
+################################################################
+
+##################### For CC32XX ####################
+SIMPLELINK_CC32XX_SDK_INSTALL_DIR   ?=
+
+# Toolchains: Leave assignment empty to disable a toolchain
+ti.targets.arm.elf.M4  ?=
+iar.targets.arm.M4     ?=
+gnu.targets.arm.M4     ?=
+
+
+#################### For MSP432E4 ###################
+SIMPLELINK_MSP432E4_SDK_INSTALL_DIR   ?=
+
+# Toolchains: Leave assignment empty to disable a toolchain
+ti.targets.arm.elf.M4F ?=
+iar.targets.arm.M4F    ?=
+gnu.targets.arm.M4F    ?=
diff --git a/build_all/sdk/package.bld b/build_all/sdk/package.bld
new file mode 100644 (file)
index 0000000..3d270ec
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== package.bld ========
+ */
+
+var Build = xdc.useModule('xdc.bld.BuildEnvironment');
+var Pkg = xdc.useModule('xdc.bld.PackageContents');
+
+/* make command to search for the srcs */
+Pkg.makePrologue = "vpath %.c ../../sdk/c-utility/src " +
+                   "../../sdk/c-utility/adapters " +
+                   "../../sdk/iothub_client/src " +
+                   "../../sdk/serializer/src " +
+                   "../../sdk/deps/parson " +
+                   "../../sdk/umqtt/src";
+
+/* lib/ is a generated directory that 'xdc clean' should remove */
+Pkg.generatedFiles.$add("lib/");
+
+var SRCS_C_UTIL = [
+    "agenttime.c",
+    "base64.c",
+    "buffer.c",
+    "consolelogger.c",
+    "constbuffer.c",
+    "crt_abstractions.c",
+    "doublylinkedlist.c",
+    "gballoc.c",
+    "gb_rand.c",
+    "gb_stdio.c",
+    "gb_time.c",
+    "hmac.c",
+    "hmacsha256.c",
+    "httpapiex.c",
+    "httpapiexsas.c",
+    "httpheaders.c",
+    "lock_pthreads.c",
+    "map.c",
+    "optionhandler.c",
+    "sastoken.c",
+    "sha1.c",
+    "sha224.c",
+    "sha384-512.c",
+    "singlylinkedlist.c",
+    "strings.c",
+    "string_tokenizer.c",
+    "urlencode.c",
+    "usha.c",
+    "utf8_checker.c",
+    "uws_client.c",
+    "uws_frame_encoder.c",
+    "vector.c",
+    "wsio.c",
+    "xio.c",
+    "xlogging.c"
+];
+
+var SRCS_IOTHUB_CLIENT = [
+    "iothub_client.c",
+    "iothub_client_authorization.c",
+    "iothub_client_diagnostic.c",
+    "iothub_client_ll.c",
+    "iothub_client_ll_uploadtoblob.c",
+    "iothub_client_retry_control.c",
+    "iothub_message.c",
+    "iothubtransport.c",
+    "iothubtransporthttp.c",
+    "iothubtransportmqtt.c",
+    "iothubtransport_mqtt_common.c",
+    "version.c",
+    "blob.c"
+];
+
+var SRCS_SERIALIZER = [
+    "agenttypesystem.c",
+    "codefirst.c",
+    "commanddecoder.c",
+    "datamarshaller.c",
+    "datapublisher.c",
+    "dataserializer.c",
+    "iotdevice.c",
+    "jsondecoder.c",
+    "jsonencoder.c",
+    "multitree.c",
+    "methodreturn.c",
+    "schema.c",
+    "schemalib.c",
+    "schemaserializer.c"
+];
+
+var SRCS_UMQTT = [
+    "mqtt_client.c",
+    "mqtt_codec.c",
+    "mqtt_message.c"
+];
+
+
+/* Paths to external source libraries */
+xdcargs = java.lang.System.getenv("XDCARGS").split(" ");
+
+var slIncs = "";
+var incs = "";
+var commonIncs = "-I../../pal/inc -I../../sdk/c-utility/inc ";
+var iotclientIncs = "-I../../sdk/iothub_client/inc -I../../sdk/c-utility/inc -I../../sdk/umqtt/inc "
+    +"-I../../sdk/deps/parson ";
+var serializerIncs = "-I../../sdk/serializer/inc -I../../sdk/c-utility/inc "
+    + "-I../../sdk/iothub_client/inc -I../../sdk/deps/parson ";
+var umqttIncs = "-I../../sdk/umqtt/inc -I../../sdk/c-utility/inc ";
+var pthreadIncs = "";
+
+/* Parse out the XDCARGS options for the include source paths */
+for (x = 0; x < xdcargs.length; x++) {
+    if (xdcargs[x].match(/^CC32XXSDK=/)) {
+        incs = (xdcargs[x] + "").replace(/'/g, '');
+        incs = incs.substring(incs.indexOf('=') + 1);
+        if (incs != "\"\"") {
+            incs += "/source";
+            slIncs = "-I" + incs + " -I" + incs + "/include -I" + incs
+                    + "/ti/net/bsd -I" + incs;
+        }
+    }
+
+    if (xdcargs[x].match(/^MSP432E4SDK=/)) {
+        incs = (xdcargs[x] + "").replace(/'/g, '');
+        incs = incs.substring(incs.indexOf('=') + 1);
+        if (incs != "\"\"") {
+            if (slIncs != "") {
+                throw("Error: Please fill in only one set of variables "
+                        + "in products.mak corresponding to your platform");
+            }
+
+            incs += "/source";
+            slIncs = "-I" + incs + " -I" + incs + "/include -I" + incs
+                    + "/ti/net/bsd -I" + incs;
+        }
+    }
+}
+
+for (var i = 0; i < Build.targets.length; i++) {
+    var target = Build.targets[i];
+    var libdir = getLibDirectory(target.suffix);
+    var extraOpts;
+    var suppressOpts = "";
+    var posixIncs;
+
+    for (var profile in target.profiles) {
+        var defs = "";
+        posixIncs = "/ti/posix" + "/" +
+            getPosixIncDirectory(target.suffix) + " ";
+        if (target.$name.split(".")[0] == "ti") {
+            /*
+             * Suppress these (loud) warnings for TI toolchain:
+             * - last line of file ends without a newline
+             * - variable was declared but never referenced
+             * - variable was set but never used
+             * - enumerated type mixed with another type
+             */
+            suppressOpts = " --diag_suppress=1,179,190,552 ";
+        }
+        else if (target.$name.split(".")[0] == "iar") {
+            /*
+             * Suppress these (loud) warnings for IAR:
+             * - standard C functions being declared deprecated
+             * - pointless integer comparisons with obvious results
+             * - enumerated type mixed with another type
+             * - variable was declared but never referenced
+             */
+            suppressOpts = " --diag_suppress Pa084,Pe177,Pe188,Pe1215 ";
+        }
+
+        extraOpts = suppressOpts + commonIncs + pthreadIncs;
+        Pkg.addLibrary(libdir + "/common_sl_" + profile,
+            target, {
+                profile: profile,
+                defs: "-DNET_SL -DREFCOUNT_ATOMIC_DONTCARE " + extraOpts,
+                incs: slIncs + posixIncs,
+                suffix: '.a'
+            }).addObjects(SRCS_C_UTIL);
+
+        extraOpts = suppressOpts + iotclientIncs + pthreadIncs;
+        Pkg.addLibrary(libdir + "/iotclient_sl_" + profile, target, { profile: profile,
+            defs: "-DNET_SL -DREFCOUNT_ATOMIC_DONTCARE " + extraOpts, incs: slIncs + posixIncs, suffix: '.a'
+        }).addObjects(SRCS_IOTHUB_CLIENT);
+
+        extraOpts = suppressOpts + serializerIncs + pthreadIncs;
+        Pkg.addLibrary(libdir + "/serializer_sl_" + profile, target, { profile: profile,
+            defs: "-DNET_SL -DREFCOUNT_ATOMIC_DONTCARE " + extraOpts, incs: slIncs + posixIncs, suffix: '.a'
+        }).addObjects(SRCS_SERIALIZER);
+
+        extraOpts = suppressOpts + umqttIncs + pthreadIncs;
+        Pkg.addLibrary(libdir + "/umqtt_sl_" + profile, target, { profile: profile,
+            defs: "-DNET_SL -DREFCOUNT_ATOMIC_DONTCARE " + extraOpts, incs: slIncs + posixIncs, suffix: '.a'
+        }).addObjects(SRCS_UMQTT);
+    }
+
+}
diff --git a/build_all/sdk/package.xdc b/build_all/sdk/package.xdc
new file mode 100644 (file)
index 0000000..00aee9f
--- /dev/null
@@ -0,0 +1,5 @@
+/*
+ *  ======== package.xdc ========
+ */
+package build_all.sdk {
+}
diff --git a/devdoc/httpapi_sl_requirements.md b/devdoc/httpapi_sl_requirements.md
new file mode 100644 (file)
index 0000000..de2ce89
--- /dev/null
@@ -0,0 +1,12 @@
+# httpapi_sl
+
+
+## Overview
+
+The httpapi_sl adapter implements an httpapi adapter for SimpleLink platforms from TI.
+
+
+## Base Specification
+
+The httpapi_sl adapter conforms to the
+[httpapi_compact base specification](https://github.com/Azure/azure-c-shared-utility/blob/master/devdoc/httpapi_compact_requirements.md)
diff --git a/devdoc/platform_sl_requirements.md b/devdoc/platform_sl_requirements.md
new file mode 100644 (file)
index 0000000..40916c9
--- /dev/null
@@ -0,0 +1,12 @@
+# platform_sl
+
+
+## Overview
+
+**platform_sl** implements the **platform** adapter for the Azure IoT C SDK. This implementation
+uses a version of the **tlsio** adapter for embedded applications on TI SimpleLink devices.
+
+## Base Specification
+
+The platform_sl adapter conforms to the
+[platform base specification](https://github.com/Azure/azure-c-shared-utility/blob/master/devdoc/platform_requirements.md)
diff --git a/devdoc/tlsio_sl_requirements.md b/devdoc/tlsio_sl_requirements.md
new file mode 100644 (file)
index 0000000..c6072f3
--- /dev/null
@@ -0,0 +1,12 @@
+# tlsio_sl
+
+
+## Overview
+
+The tlsio_sl adapter implements a tlsio adapter for SimpleLink platforms from TI.
+
+
+## Base Specification
+
+The tlsio_sl adapter conforms to the
+[tlsio base specification](https://github.com/Azure/azure-c-shared-utility/blob/master/devdoc/tlsio_requirements.md).
diff --git a/pal/inc/cert_sl.h b/pal/inc/cert_sl.h
new file mode 100644 (file)
index 0000000..d11ecba
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright (c) Texas Instruments. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef CERT_SL_H
+#define CERT_SL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* USER STEP: Flash/load the CA root certificate to this location */
+#define SL_SSL_CA_CERT "/cert/ms.pem"
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* CERT_SL_H */
diff --git a/pal/inc/refcount_os.h b/pal/inc/refcount_os.h
new file mode 100644 (file)
index 0000000..1479d8b
--- /dev/null
@@ -0,0 +1,76 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+// This file gets included into refcount.h as a means of extending the behavior of
+// atomic increment, decrement, and test.
+#ifndef REFCOUNT_OS_H__LINUX
+#define REFCOUNT_OS_H__LINUX
+
+
+// This Linux-specific header offers 3 strategies:
+//   REFCOUNT_ATOMIC_DONTCARE     -- no atomicity guarantee
+//   REFCOUNT_USE_STD_ATOMIC      -- C11 atomicity
+//   REFCOUNT_USE_GNU_C_ATOMIC    -- GNU-specific atomicity
+
+#if defined(__GNUC__)
+#define REFCOUNT_USE_GNU_C_ATOMIC 1
+#endif
+
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ == 201112)
+#define REFCOUNT_USE_STD_ATOMIC 1
+#undef REFCOUNT_USE_GNU_C_ATOMIC
+#endif
+
+// This FREERTOS_ARCH_ESP8266 behavior is deprecated. Microcontrollers
+// using the Azure IoT C SDK should include the c-utility file
+// pal/generic/refcount_os.h instead of this one.
+#if defined(FREERTOS_ARCH_ESP8266)
+#define REFCOUNT_ATOMIC_DONTCARE 1
+#undef REFCOUNT_USE_STD_ATOMIC
+#undef REFCOUNT_USE_GNU_C_ATOMIC
+#endif
+
+#if defined(REFCOUNT_ATOMIC_DONTCARE)
+#define COUNT_TYPE uint32_t
+#elif defined(REFCOUNT_USE_STD_ATOMIC)
+#define COUNT_TYPE _Atomic uint32_t
+#else  // REFCOUNT_USE_GNU_C_ATOMIC
+#define COUNT_TYPE uint32_t
+#endif // defined(REFCOUNT_ATOMIC_DONTCARE)
+
+
+/*the following macros increment/decrement a ref count in an atomic way, depending on the platform*/
+/*The following mechanisms are considered in this order
+REFCOUNT_ATOMIC_DONTCARE does not use atomic operations
+- will result in ++/-- used for increment/decrement.
+C11
+- will result in #include <stdatomic.h>
+- will use atomic_fetch_add/sub;
+- about the return value: "Atomically, the value pointed to by object immediately before the effects"
+gcc
+- will result in no include (for gcc these are intrinsics build in)
+- will use __sync_fetch_and_add/sub
+- about the return value: "... returns the value that had previously been in memory." (https://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/Atomic-Builtins.html#Atomic-Builtins)
+*/
+
+
+/*if macro DEC_REF returns DEC_RETURN_ZERO that means the ref count has reached zero.*/
+#if defined(REFCOUNT_ATOMIC_DONTCARE)
+#define DEC_RETURN_ZERO (0)
+#define INC_REF(type, var) ++((((REFCOUNT_TYPE(type)*)var)->count))
+#define DEC_REF(type, var) --((((REFCOUNT_TYPE(type)*)var)->count))
+
+#elif defined(REFCOUNT_USE_STD_ATOMIC)
+#include <stdatomic.h>
+#define DEC_RETURN_ZERO (1)
+#define INC_REF(type, var) atomic_fetch_add((&((REFCOUNT_TYPE(type)*)var)->count), 1)
+#define DEC_REF(type, var) atomic_fetch_sub((&((REFCOUNT_TYPE(type)*)var)->count), 1)
+
+#elif defined(REFCOUNT_USE_GNU_C_ATOMIC)
+#define DEC_RETURN_ZERO (0)
+#define INC_REF(type, var) __sync_add_and_fetch((&((REFCOUNT_TYPE(type)*)var)->count), 1)
+#define DEC_REF(type, var) __sync_sub_and_fetch((&((REFCOUNT_TYPE(type)*)var)->count), 1)
+
+#endif /*defined(REFCOUNT_USE_GNU_C_ATOMIC)*/
+
+#endif // REFCOUNT_OS_H__LINUX
diff --git a/pal/inc/tlsio_sl.h b/pal/inc/tlsio_sl.h
new file mode 100644 (file)
index 0000000..5bcfee3
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (c) Texas Instruments. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef TLSIO_SL_H
+#define TLSIO_SL_H
+
+#ifdef __cplusplus
+extern "C" {
+#include <cstddef>
+#else
+#include <stddef.h>
+#endif /* __cplusplus */
+
+#include "azure_c_shared_utility/xio.h"
+#include "azure_c_shared_utility/xlogging.h"
+#include "azure_c_shared_utility/optionhandler.h"
+
+extern CONCRETE_IO_HANDLE tlsio_sl_create(void* io_create_parameters);
+extern void tlsio_sl_destroy(CONCRETE_IO_HANDLE tls_io);
+extern int tlsio_sl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context);
+extern int tlsio_sl_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context);
+extern int tlsio_sl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context);
+extern void tlsio_sl_dowork(CONCRETE_IO_HANDLE tls_io);
+extern int tlsio_sl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, const void* value);
+extern OPTIONHANDLER_HANDLE tlsio_sl_retrieveoptions(CONCRETE_IO_HANDLE handle);
+
+extern const IO_INTERFACE_DESCRIPTION* tlsio_sl_get_interface_description(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* TLSIO_SL_H */
diff --git a/pal/src/httpapi_sl.c b/pal/src/httpapi_sl.c
new file mode 100644 (file)
index 0000000..6de6ab6
--- /dev/null
@@ -0,0 +1,492 @@
+// Copyright (c) Texas Instruments. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <ti/net/http/httpclient.h>
+
+#include "cert_sl.h"
+
+#include "azure_c_shared_utility/httpapi.h"
+#include "azure_c_shared_utility/strings.h"
+#include "azure_c_shared_utility/xlogging.h"
+
+#define CONTENT_BUF_LEN     (128 * 10)
+#define HTTP_SECURE_PORT    443
+#define HEADER_TO_STR(x) (headerFieldStr[(x) & (~HTTPClient_REQUEST_HEADER_MASK)])
+
+typedef struct {
+    HTTPClient_Handle cli;
+    char *prefixedHostName;
+    char *x509Certificate;
+    char *x509PrivateKey;
+    bool  isConnected;
+} HTTPAPI_Object;
+
+static const char * headerFieldStr[] = {
+"Age",
+"Allow",
+"Cache-Control",
+"Connection",
+"Content-Encoding",
+"Content-Language",
+"Content-Length",
+"Content-Location",
+"Content-Range",
+"Content-Type",
+"Date",
+"ETag",
+"Expires",
+"Last-Modified",
+"Location",
+"Proxy-Authenticate",
+"Retry-After",
+"Server",
+"Set-Cookie",
+"Trailer",
+"Transfer-Encoding",
+"Upgrade",
+"Vary",
+"Via",
+"Www-Authenticate",
+"Warning",
+"Accept",
+"Accept-Charset",
+"Accept-Encoding",
+"Accept-Language",
+"Authorization",
+"Cookie",
+"Expect",
+"Forwarded",
+"From",
+"Host",
+"If-Match",
+"If-Modified-Since",
+"If-None-Match",
+"If-Range",
+"If-Unmodified-Since",
+"Origin",
+"Proxy-Authorization",
+"Range",
+"TE",
+"User-Agent",
+};
+
+static int16_t stringcasecmp (const char *s1, const char *s2)
+{
+    const unsigned char *p1 = (const unsigned char *) s1;
+    const unsigned char *p2 = (const unsigned char *) s2;
+    int16_t result;
+
+    if (p1 == p2) {
+        return 0;
+    }
+
+    while ((result = tolower(*p1) - tolower(*p2++)) == 0) {
+        if (*p1++ == '\0') {
+            break;
+        }
+    }
+    return result;
+}
+
+static const char* getHttpMethod(HTTPAPI_REQUEST_TYPE requestType)
+{
+    switch (requestType) {
+        case HTTPAPI_REQUEST_GET:
+            return (HTTP_METHOD_GET);
+        case HTTPAPI_REQUEST_POST:
+            return (HTTP_METHOD_POST);
+        case HTTPAPI_REQUEST_PUT:
+            return (HTTP_METHOD_PUT);
+        case HTTPAPI_REQUEST_DELETE:
+            return (HTTP_METHOD_DELETE);
+        default:
+            return (NULL);
+    }
+}
+
+static int splitHeader(char *headerName, char **headerValue)
+{
+    *headerValue = strchr(headerName, ':');
+    if (*headerValue == NULL) {
+         return (-1);
+    }
+
+    **headerValue = '\0';
+    (*headerValue)++;
+    while (**headerValue == ' ') {
+        (*headerValue)++;
+    }
+
+    return (0);
+}
+
+HTTPAPI_RESULT HTTPAPI_Init(void)
+{
+    return (HTTPAPI_OK);
+}
+
+void HTTPAPI_Deinit(void)
+{
+}
+
+HTTP_HANDLE HTTPAPI_CreateConnection(const char* hostName)
+{
+    bool error = false;
+    HTTPAPI_Object * apiH;
+    int16_t statusCode;
+
+    apiH = calloc(sizeof(HTTPAPI_Object), 1);
+    if (!apiH) {
+        LogError("Error creating HTTPAPI object\n");
+        error = true;
+        goto error;
+    }
+
+    apiH->cli = HTTPClient_create(&statusCode, 0);
+    if (statusCode < 0) {
+        LogError("Error creating http client\n");
+        error = true;
+        goto error;
+    }
+
+    apiH->prefixedHostName = malloc(strlen(hostName) + 9);  /* https:// */
+    if (!apiH->prefixedHostName) {
+        LogError("Error creating hostname buffer\n");
+        error = true;
+        goto error;
+    }
+    /*
+     * Microsoft is assuming we would connect through the secured port.
+     * We need to drop a hint for HTTPClient_connect()
+     */
+    strcpy(apiH->prefixedHostName, "https://");
+    strcat(apiH->prefixedHostName, hostName);
+
+error:
+    if (error) {
+        if (apiH->cli != NULL) {
+            HTTPClient_destroy(apiH->cli);
+        }
+        if (apiH->prefixedHostName != NULL) {
+            free(apiH->prefixedHostName);
+        }
+        if (apiH != NULL) {
+            free(apiH);
+            apiH = NULL;
+        }
+    }
+
+    return ((HTTP_HANDLE)apiH);
+}
+
+void HTTPAPI_CloseConnection(HTTP_HANDLE handle)
+{
+    HTTPAPI_Object * apiH = (HTTPAPI_Object *)handle;
+
+    if (apiH->cli != NULL) {
+        if (apiH->isConnected) {
+            HTTPClient_disconnect(apiH->cli);
+        }
+        if (apiH->prefixedHostName != NULL) {
+            free(apiH->prefixedHostName);
+        }
+        if (apiH->x509Certificate != NULL) {
+            free(apiH->x509Certificate);
+        }
+        if (apiH->x509PrivateKey != NULL) {
+            free(apiH->x509PrivateKey);
+        }
+        HTTPClient_destroy(apiH->cli);
+    }
+
+    if (apiH != NULL) {
+        free(apiH);
+    }
+}
+
+HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle,
+        HTTPAPI_REQUEST_TYPE requestType, const char* relativePath,
+        HTTP_HEADERS_HANDLE httpHeadersHandle, const unsigned char* content,
+        size_t contentLength, unsigned int* statusCode,
+        HTTP_HEADERS_HANDLE responseHeadersHandle,
+        BUFFER_HANDLE responseContent)
+{
+    HTTPAPI_Object * apiH = (HTTPAPI_Object *)handle;
+    HTTPClient_Handle cli = apiH->cli;
+    int i;
+    int ret;
+    int offset;
+    size_t cnt;
+    char contentBuf[CONTENT_BUF_LEN] = {0};
+    uint32_t contentBufLen = CONTENT_BUF_LEN;
+    char *hname;
+    char *hvalue;
+    const char *method;
+    bool moreFlag;
+    HTTPClient_extSecParams esParams = {NULL, NULL, SL_SSL_CA_CERT};
+
+    method = getHttpMethod(requestType);
+
+    if ((cli == NULL) || (method == NULL) || (relativePath == NULL)
+            || (statusCode == NULL) || (responseHeadersHandle == NULL)) {
+        LogError("Invalid arguments: handle=%p, requestType=%d, "
+            "relativePath=%p, statusCode=%p, responseHeadersHandle=%p",
+            handle, (int)requestType, relativePath, statusCode,
+            responseHeadersHandle);
+        return (HTTPAPI_INVALID_ARG);
+    }
+    else if (HTTPHeaders_GetHeaderCount(httpHeadersHandle, &cnt)
+            != HTTP_HEADERS_OK) {
+        LogError("Cannot get header count");
+        return (HTTPAPI_QUERY_HEADERS_FAILED);
+    }
+
+    /*
+     * We need to call HTTPClient_connect here as opposed to
+     * HTTPAPI_CreateConnection because we might have set some TLS
+     * options.
+     */
+    if (apiH->isConnected == false) {
+        esParams.clientCert = apiH->x509Certificate;
+        esParams.privateKey = apiH->x509PrivateKey;
+        ret = HTTPClient_connect(apiH->cli, apiH->prefixedHostName,
+                &esParams, 0);
+        if (ret < 0) {
+            LogError("HTTPClient_connect failed, ret=%d", ret);
+            return (HTTPAPI_OPEN_REQUEST_FAILED);
+        }
+        else {
+            apiH->isConnected = true;
+        }
+    }
+
+    /* Send the request headers */
+    while (cnt--) {
+        ret = HTTPHeaders_GetHeader(httpHeadersHandle, cnt, &hname);
+        if (ret != HTTP_HEADERS_OK) {
+            LogError("Cannot get request header %d", cnt);
+            return (HTTPAPI_QUERY_HEADERS_FAILED);
+        }
+
+        ret = splitHeader(hname, &hvalue);
+
+        if (ret == 0) {
+            /*
+             * HOST and Content-Length headers are set by HTTPClient
+             * automatically. Note that Content-Length = 0 never gets sent.
+             */
+            if ((stringcasecmp(hname, "content-length") != 0) &&
+                    (stringcasecmp(hname, "host") != 0)) {
+                ret = HTTPClient_setHeaderByName(cli,
+                        HTTPClient_REQUEST_HEADER_MASK,
+                        hname, hvalue,
+                        strlen(hvalue) + 1, HTTPClient_HFIELD_NOT_PERSISTENT);
+                if (ret < 0) {
+                    LogError("Failed setting request header, ret=%d", ret);
+                }
+            }
+        }
+
+        free(hname);
+        hname = NULL;
+
+        if (ret < 0) {
+            return (HTTPAPI_SEND_REQUEST_FAILED);
+        }
+    }
+
+    /* Send the request */
+    ret = HTTPClient_sendRequest(cli, method,
+            relativePath, (const char *)content, contentLength, 0);
+    if (ret < 0) {
+        LogError("HTTPClient_sendRequest failed, ret=%d", ret);
+        return (HTTPAPI_SEND_REQUEST_FAILED);
+    }
+
+    *statusCode = (unsigned int)ret;
+
+    /* Get the response headers */
+    cnt = 0;
+    offset = 0;
+
+    /*
+     * TODO: If there is more than one header of the same name, is this
+     * an issue with HTTPClient?
+     */
+    for (i = 0; i <= HTTPClient_MAX_RESPONSE_HEADER_FILEDS; i++) {
+        contentBufLen = CONTENT_BUF_LEN;
+        ret = HTTPClient_getHeader(cli, i, contentBuf, &contentBufLen, 0);
+        if (ret == HTTPClient_EGETOPTBUFSMALL) {
+            /* TODO: content buffer is too small. Enlarge and try again?? */
+            LogError("Content buffer is too small for incoming header");
+            ret = HTTPAPI_HTTP_HEADERS_FAILED;
+            goto headersDone;
+        }
+        else if (ret < 0) {
+            LogError("Failed to get header, ret=%d", ret);
+            ret = HTTPAPI_HTTP_HEADERS_FAILED;
+            goto headersDone;
+        }
+        else if (contentBufLen == 0) {
+            /* No data for this header */
+            continue;
+        }
+
+        ret = HTTPHeaders_AddHeaderNameValuePair(responseHeadersHandle,
+                HEADER_TO_STR(i), contentBuf);
+        if (ret != HTTP_HEADERS_OK) {
+            LogError("Adding the response header failed");
+            ret = HTTPAPI_HTTP_HEADERS_FAILED;
+            goto headersDone;
+        }
+        offset = 0;
+    }
+
+headersDone:
+    hname = NULL;
+    if (ret != 0) {
+        return ((HTTPAPI_RESULT)ret);
+    }
+
+    /* Get response body */
+    if (responseContent != NULL) {
+        offset = 0;
+        cnt = 0;
+
+        do {
+            ret = HTTPClient_readResponseBody(cli, contentBuf, CONTENT_BUF_LEN,
+                    &moreFlag);
+
+            if (ret < 0) {
+                LogError("HTTP read response body failed, ret=%d", ret);
+                ret = HTTPAPI_RECEIVE_RESPONSE_FAILED;
+                goto contentDone;
+            }
+
+            if (ret != 0) {
+                cnt = ret;
+                ret = BUFFER_enlarge(responseContent, cnt);
+                if (ret != 0) {
+                    LogError("Failed enlarging response buffer");
+                    ret = HTTPAPI_ALLOC_FAILED;
+                    goto contentDone;
+                }
+
+                ret = BUFFER_content(responseContent,
+                        (const unsigned char **)&hname);
+                if (ret != 0) {
+                    LogError("Failed getting the response buffer content");
+                    ret = HTTPAPI_ALLOC_FAILED;
+                    goto contentDone;
+                }
+
+                memcpy(hname + offset, contentBuf, cnt);
+                offset += cnt;
+            }
+        } while (moreFlag);
+
+    contentDone:
+        if (ret < 0) {
+            BUFFER_unbuild(responseContent);
+            return ((HTTPAPI_RESULT)ret);
+        }
+    }
+
+    return (HTTPAPI_OK);
+}
+
+HTTPAPI_RESULT HTTPAPI_SetOption(HTTP_HANDLE handle, const char* optionName,
+        const void* value)
+{
+    HTTPAPI_RESULT result;
+    HTTPAPI_Object *apiH = (HTTPAPI_Object *)handle;
+    int len;
+
+    if ((apiH == NULL) ||
+            (optionName == NULL) ||
+            (value == NULL)) {
+        result = HTTPAPI_INVALID_ARG;
+    }
+    else if ((strcmp("x509EccCertificate", optionName) == 0) ||
+            (strcmp("x509certificate", optionName) == 0)) {
+        if (apiH->x509Certificate) {
+            free(apiH->x509Certificate);
+        }
+
+        len = strlen((char *)value);
+        apiH->x509Certificate = (char *)malloc((len + 1) * sizeof(char));
+        if (apiH->x509Certificate == NULL) {
+            result = HTTPAPI_ALLOC_FAILED;
+            LogInfo("unable to allocate memory for the client certificate"
+                    " in HTTPAPI_SetOption");
+        }
+        else {
+            strcpy(apiH->x509Certificate, (const char *)value);
+            result = HTTPAPI_OK;
+        }
+    }
+    else if ((strcmp("x509EccAliasKey", optionName) == 0) ||
+            (strcmp("x509privatekey", optionName) == 0)) {
+        if (apiH->x509PrivateKey) {
+            free(apiH->x509PrivateKey);
+        }
+
+        len = strlen((char *)value);
+        apiH->x509PrivateKey = (char *)malloc((len + 1) * sizeof(char));
+        if (apiH->x509PrivateKey == NULL) {
+            result = HTTPAPI_ALLOC_FAILED;
+            LogInfo("unable to allocate memory for the client private key"
+                    " in HTTPAPI_SetOption");
+        }
+        else {
+            strcpy(apiH->x509PrivateKey, (const char*)value);
+            result = HTTPAPI_OK;
+        }
+    }
+    else {
+        result = HTTPAPI_INVALID_ARG;
+        LogInfo("unknown option %s", optionName);
+    }
+
+    return (result);
+}
+
+HTTPAPI_RESULT HTTPAPI_CloneOption(const char* optionName, const void* value,
+        const void** savedValue)
+{
+    HTTPAPI_RESULT result;
+    size_t certLen;
+    char *tempCert;
+
+    if ((optionName == NULL) ||
+            (value == NULL) ||
+            (savedValue == NULL)) {
+        result = HTTPAPI_INVALID_ARG;
+    }
+    else if ((strcmp("x509EccCertificate", optionName) == 0) ||
+            (strcmp("x509certificate", optionName) == 0) ||
+            (strcmp("x509EccAliasKey", optionName) == 0) ||
+            (strcmp("x509privatekey", optionName) == 0)) {
+        certLen = strlen((const char *)value);
+        tempCert = (char *)malloc((certLen + 1) * sizeof(char));
+        if (tempCert == NULL) {
+            result = HTTPAPI_ALLOC_FAILED;
+        }
+        else {
+            strcpy(tempCert, (const char*)value);
+            *savedValue = tempCert;
+            result = HTTPAPI_OK;
+        }
+    }
+    else {
+        result = HTTPAPI_INVALID_ARG;
+        LogInfo("unknown option %s", optionName);
+    }
+
+    return (result);
+}
diff --git a/pal/src/platform_sl.c b/pal/src/platform_sl.c
new file mode 100644 (file)
index 0000000..079adfd
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#include "tlsio_sl.h"
+#include "azure_c_shared_utility/platform.h"
+
+int platform_init(void)
+{
+    return 0;
+}
+
+const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void)
+{
+    return tlsio_sl_get_interface_description();
+}
+
+STRING_HANDLE platform_get_platform_info(void)
+{
+    return STRING_construct("(TI SimpleLink)");
+}
+
+void platform_deinit(void)
+{
+    return;
+}
diff --git a/pal/src/threadapi_pthreads_sl.c b/pal/src/threadapi_pthreads_sl.c
new file mode 100644 (file)
index 0000000..9ce9537
--- /dev/null
@@ -0,0 +1,127 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#include "azure_c_shared_utility/threadapi.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <unistd.h>
+
+#include <pthread.h>
+#include <time.h>
+#include "azure_c_shared_utility/xlogging.h"
+
+DEFINE_ENUM_STRINGS(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
+
+typedef struct THREAD_INSTANCE_TAG
+{
+    pthread_t Pthread_handle;
+    THREAD_START_FUNC ThreadStartFunc;
+    void* Arg;
+} THREAD_INSTANCE;
+
+static void* ThreadWrapper(void* threadInstanceArg)
+{
+    THREAD_INSTANCE* threadInstance = (THREAD_INSTANCE*)threadInstanceArg;
+    int result = threadInstance->ThreadStartFunc(threadInstance->Arg);
+    return (void*)(intptr_t)result;
+}
+
+THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC func, void* arg)
+{
+    THREADAPI_RESULT result;
+
+    if ((threadHandle == NULL) ||
+        (func == NULL))
+    {
+        result = THREADAPI_INVALID_ARG;
+        LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
+    }
+    else
+    {
+        THREAD_INSTANCE* threadInstance = malloc(sizeof(THREAD_INSTANCE));
+        if (threadInstance == NULL)
+        {
+            result = THREADAPI_NO_MEMORY;
+            LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
+        }
+        else
+        {
+            threadInstance->ThreadStartFunc = func;
+            threadInstance->Arg = arg;
+            int createResult = pthread_create(&threadInstance->Pthread_handle, NULL, ThreadWrapper, threadInstance);
+            switch (createResult)
+            {
+            default:
+                free(threadInstance);
+
+                result = THREADAPI_ERROR;
+                LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
+                break;
+
+            case 0:
+                *threadHandle = threadInstance;
+                result = THREADAPI_OK;
+                break;
+
+            case EAGAIN:
+                free(threadInstance);
+
+                result = THREADAPI_NO_MEMORY;
+                LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
+                break;
+            }
+        }
+    }
+
+    return result;
+}
+
+THREADAPI_RESULT ThreadAPI_Join(THREAD_HANDLE threadHandle, int* res)
+{
+    THREADAPI_RESULT result;
+
+    THREAD_INSTANCE* threadInstance = (THREAD_INSTANCE*)threadHandle;
+    if (threadInstance == NULL)
+    {
+        result = THREADAPI_INVALID_ARG;
+        LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
+    }
+    else
+    {
+        void* threadResult;
+        if (pthread_join(threadInstance->Pthread_handle, &threadResult) != 0)
+        {
+            result = THREADAPI_ERROR;
+            LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
+        }
+        else
+        {
+            if (res != NULL)
+            {
+                *res = (int)(intptr_t)threadResult;
+            }
+
+            result = THREADAPI_OK;
+        }
+
+        free(threadInstance);
+    }
+
+    return result;
+}
+
+void ThreadAPI_Exit(int res)
+{
+    pthread_exit((void*)(intptr_t)res);
+}
+
+void ThreadAPI_Sleep(unsigned int milliseconds)
+{
+    time_t seconds = milliseconds / 1000;
+    long nsRemainder = (milliseconds % 1000) * 1000000;
+    struct timespec timeToSleep = { seconds, nsRemainder };
+    clock_nanosleep(CLOCK_MONOTONIC, 0, &timeToSleep, NULL);
+}
diff --git a/pal/src/tickcounter_sl.c b/pal/src/tickcounter_sl.c
new file mode 100644 (file)
index 0000000..d7ebed2
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#include <stdlib.h>
+#include "azure_c_shared_utility/gballoc.h"
+
+#include <stdint.h>
+#include <time.h>
+#include "azure_c_shared_utility/tickcounter.h"
+#include "azure_c_shared_utility/optimize_size.h"
+#include "azure_c_shared_utility/xlogging.h"
+
+#define INVALID_TIME_VALUE      (time_t)(-1)
+typedef struct TICK_COUNTER_INSTANCE_TAG
+{
+    time_t init_time_value;
+    tickcounter_ms_t current_ms;
+} TICK_COUNTER_INSTANCE;
+
+TICK_COUNTER_HANDLE tickcounter_create(void)
+{
+    struct timespec tspec;
+    TICK_COUNTER_INSTANCE* result = (TICK_COUNTER_INSTANCE*)malloc(sizeof(TICK_COUNTER_INSTANCE));
+    if (result != NULL)
+    {
+        clock_gettime(CLOCK_REALTIME, &tspec);
+        result->init_time_value = tspec.tv_sec;
+        if (result->init_time_value == INVALID_TIME_VALUE)
+        {
+            LogError("tickcounter failed: time return INVALID_TIME.");
+            free(result);
+            result = NULL;
+        }
+        else
+        {
+            result->current_ms = 0;
+        }
+    }
+    return result;
+}
+
+void tickcounter_destroy(TICK_COUNTER_HANDLE tick_counter)
+{
+    if (tick_counter != NULL)
+    {
+        free(tick_counter);
+    }
+}
+
+int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_t * current_ms)
+{
+    int result;
+    struct timespec tspec;
+
+    if (tick_counter == NULL || current_ms == NULL)
+    {
+        LogError("tickcounter failed: Invalid Arguments.");
+        result = __FAILURE__;
+    }
+    else
+    {
+        clock_gettime(CLOCK_REALTIME, &tspec);
+        time_t time_value = tspec.tv_sec;
+        if (time_value == INVALID_TIME_VALUE)
+        {
+            result = __FAILURE__;
+        }
+        else
+        {
+            TICK_COUNTER_INSTANCE* tick_counter_instance = (TICK_COUNTER_INSTANCE*)tick_counter;
+            tick_counter_instance->current_ms = (tickcounter_ms_t)(difftime(time_value, tick_counter_instance->init_time_value) * 1000);
+            *current_ms = tick_counter_instance->current_ms;
+            result = 0;
+        }
+    }
+
+    return result;
+}
diff --git a/pal/src/tlsio_sl.c b/pal/src/tlsio_sl.c
new file mode 100644 (file)
index 0000000..216424b
--- /dev/null
@@ -0,0 +1,440 @@
+// Copyright (c) Texas Instruments. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#include <stdlib.h>
+
+#include <errno.h>
+#include <ti/net/slnetsock.h>
+#include <ti/net/slnetif.h>
+#include <ti/net/slnetutils.h>
+#include <ti/net/slneterr.h>
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <netdb.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+
+#include "cert_sl.h"
+#include "tlsio_sl.h"
+
+#include "azure_c_shared_utility/optimize_size.h"
+#include "azure_c_shared_utility/tlsio.h"
+#include "azure_c_shared_utility/crt_abstractions.h"
+#include "azure_c_shared_utility/threadapi.h"
+
+typedef enum TLSIO_STATE_ENUM_TAG
+{
+    TLSIO_STATE_NOT_OPEN,
+    TLSIO_STATE_OPENING,
+    TLSIO_STATE_OPEN,
+    TLSIO_STATE_CLOSING,
+    TLSIO_STATE_ERROR
+} TLSIO_STATE_ENUM;
+
+typedef struct TLS_IO_INSTANCE_TAG
+{
+    ON_BYTES_RECEIVED on_bytes_received;
+    ON_IO_OPEN_COMPLETE on_io_open_complete;
+    ON_IO_CLOSE_COMPLETE on_io_close_complete;
+    ON_IO_ERROR on_io_error;
+    void* on_bytes_received_context;
+    void* on_io_open_complete_context;
+    void* on_io_close_complete_context;
+    void* on_io_error_context;
+    TLSIO_STATE_ENUM tlsio_state;
+    ON_SEND_COMPLETE on_send_complete;
+    void* on_send_complete_callback_context;
+    char* hostname;
+    int port;
+    int sock;
+    SlNetSockSecAttrib_t *sec_attrib_hdl;
+} TLS_IO_INSTANCE;
+
+static const IO_INTERFACE_DESCRIPTION tlsio_sl_interface_description =
+{
+    tlsio_sl_retrieveoptions,
+    tlsio_sl_create,
+    tlsio_sl_destroy,
+    tlsio_sl_open,
+    tlsio_sl_close,
+    tlsio_sl_send,
+    tlsio_sl_dowork,
+    tlsio_sl_setoption
+};
+
+static int getErrno(int ret)
+{
+    if (ret == -1) {
+        return (errno);
+    }
+    else {
+        return (ret);
+    }
+}
+
+static int init_sockaddr(struct sockaddr *addr, int port, const char *hostname)
+{
+    struct sockaddr_in taddr = {0};
+    uint32_t ipAddr;
+    uint16_t addrLen = sizeof(ipAddr);
+
+    if (SlNetUtil_getHostByName(0, (char *)hostname, strlen(hostname),
+            &ipAddr, &addrLen, AF_INET) < 0) {
+        return (-1);
+    }
+
+    taddr.sin_family = AF_INET;
+    taddr.sin_port = htons(port);
+    taddr.sin_addr.s_addr = htonl(ipAddr);
+    *addr = *((struct sockaddr *)&taddr);
+
+    return (0);
+}
+
+OPTIONHANDLER_HANDLE tlsio_sl_retrieveoptions(CONCRETE_IO_HANDLE handle)
+{
+    (void)handle;
+    return NULL;
+}
+
+CONCRETE_IO_HANDLE tlsio_sl_create(void* io_create_parameters)
+{
+    TLSIO_CONFIG* tls_io_config = io_create_parameters;
+    TLS_IO_INSTANCE* result;
+
+    if (tls_io_config == NULL) {
+        LogError("NULL tls_io_config");
+        result = NULL;
+    }
+    else {
+        result = malloc(sizeof(TLS_IO_INSTANCE));
+        if (result == NULL) {
+            LogError("NULL TLS_IO_INSTANCE");
+        }
+        else {
+            memset(result, 0, sizeof(TLS_IO_INSTANCE));
+
+            mallocAndStrcpy_s(&result->hostname, tls_io_config->hostname);
+
+            result->port = tls_io_config->port;
+
+            result->on_bytes_received = NULL;
+            result->on_bytes_received_context = NULL;
+
+            result->on_io_open_complete = NULL;
+            result->on_io_open_complete_context = NULL;
+
+            result->on_io_close_complete = NULL;
+            result->on_io_close_complete_context = NULL;
+
+            result->on_io_error = NULL;
+            result->on_io_error_context = NULL;
+
+            result->on_send_complete = NULL;
+            result->on_send_complete_callback_context = NULL;
+            result->sec_attrib_hdl = SlNetSock_secAttribCreate();
+            result->tlsio_state = TLSIO_STATE_NOT_OPEN;
+        }
+    }
+
+    return result;
+}
+
+void tlsio_sl_destroy(CONCRETE_IO_HANDLE tls_io)
+{
+    TLS_IO_INSTANCE* tls_io_instance = (TLS_IO_INSTANCE*)tls_io;
+
+    if (tls_io == NULL) {
+        LogError("NULL tls_io");
+    }
+    else {
+        if ((tls_io_instance->tlsio_state == TLSIO_STATE_OPENING) ||
+            (tls_io_instance->tlsio_state == TLSIO_STATE_OPEN) ||
+            (tls_io_instance->tlsio_state == TLSIO_STATE_CLOSING)) {
+            LogError("TLS destroyed with a SSL connection still active.");
+        }
+        if (tls_io_instance->hostname != NULL) {
+            free(tls_io_instance->hostname);
+        }
+        if (tls_io_instance->sec_attrib_hdl != NULL) {
+            SlNetSock_secAttribDelete(tls_io_instance->sec_attrib_hdl);
+        }
+        free(tls_io_instance);
+    }
+}
+
+int tlsio_sl_open(CONCRETE_IO_HANDLE tls_io,
+                     ON_IO_OPEN_COMPLETE on_io_open_complete,
+                     void* on_io_open_complete_context,
+                     ON_BYTES_RECEIVED on_bytes_received,
+                     void* on_bytes_received_context,
+                     ON_IO_ERROR on_io_error,
+                     void* on_io_error_context)
+{
+    int                   result = 0;
+    bool                  error = false;
+    int                   status = 0;
+    uint16_t              clientSd;
+    socklen_t             sdlen = sizeof(clientSd);
+    TLS_IO_INSTANCE      *instance = (TLS_IO_INSTANCE*)tls_io;
+
+    if (tls_io == NULL) {
+        LogError("NULL tls_io");
+        result = __FAILURE__;
+        return (result);
+    }
+    else {
+        int ret;
+
+        if (instance->tlsio_state != TLSIO_STATE_NOT_OPEN) {
+            LogError("IO should not be open: %d\n", instance->tlsio_state);
+            result =  __FAILURE__;
+            return (result);
+        }
+        else {
+            instance->on_bytes_received = on_bytes_received;
+            instance->on_bytes_received_context = on_bytes_received_context;
+
+            instance->on_io_open_complete = on_io_open_complete;
+            instance->on_io_open_complete_context = on_io_open_complete_context;
+
+            instance->on_io_error = on_io_error;
+            instance->on_io_error_context = on_io_error_context;
+
+            instance->tlsio_state = TLSIO_STATE_OPENING;
+            instance->sock = -1;
+
+            struct sockaddr sa;
+            ret = init_sockaddr(&sa, instance->port, instance->hostname);
+            if (ret != 0) {
+                LogError("Cannot resolve hostname");
+                error = true;
+                goto cleanup;
+            }
+            else {
+                instance->sock = socket(sa.sa_family, SOCK_STREAM,
+                                        0);
+                if (instance->sock >= 0) {
+                    if (getsockopt(instance->sock, SLNETSOCK_LVL_SOCKET,
+                            SLNETSOCK_OPSOCK_SLNETSOCKSD,
+                            &clientSd, &sdlen) < 0) {
+                        LogError("getsockopt failed");
+                        error = true;
+                        goto cleanup;
+                    }
+
+                    status = SlNetSock_secAttribSet(instance->sec_attrib_hdl,
+                            SLNETSOCK_SEC_ATTRIB_PEER_ROOT_CA, SL_SSL_CA_CERT,
+                            sizeof(SL_SSL_CA_CERT));
+                    if (status < 0) {
+                        LogError("SlNetSock_secAttribCreate failed");
+                        error = true;
+                        goto cleanup;
+                    }
+
+                    status = SlNetSock_startSec(clientSd,
+                            instance->sec_attrib_hdl,
+                            SLNETSOCK_SEC_BIND_CONTEXT_ONLY);
+                    if (status < 0) {
+                        LogError("SlNetSock_startSec failed to bind context");
+                        error = true;
+                        goto cleanup;
+                    }
+
+                    ret = connect(instance->sock, &sa,
+                            sizeof(struct sockaddr_in));
+                    if (ret < 0) {
+                        LogError("Cannot connect");
+                        error = true;
+                        goto cleanup;
+                    }
+                    /* setup for nonblocking */
+                    SlNetSock_Nonblocking_t nb;
+                    nb.nonBlockingEnabled = 1;
+                    setsockopt(instance->sock, SOL_SOCKET,
+                            SO_NONBLOCKING, &nb,
+                            sizeof(nb));
+                }
+                else {
+                    LogError("Cannot open socket");
+                    error = true;
+                    goto cleanup;
+                }
+            }
+
+            status = SlNetSock_startSec(clientSd,
+                    instance->sec_attrib_hdl,
+                    SLNETSOCK_SEC_START_SECURITY_SESSION_ONLY);
+            if (status < 0) {
+                LogError("SlNetSock_startSec failed to start session\n");
+                error = true;
+                goto cleanup;
+            }
+
+            IO_OPEN_RESULT oresult = result == __FAILURE__ ? IO_OPEN_ERROR :
+                                                             IO_OPEN_OK;
+            instance->tlsio_state = TLSIO_STATE_OPEN;
+            instance->on_io_open_complete(instance->on_io_open_complete_context,
+                                          oresult);
+            if (oresult == IO_OPEN_ERROR) {
+                if (on_io_error != NULL) {
+                    (void)on_io_error(on_io_error_context);
+                }
+            }
+        }
+    }
+
+cleanup:
+
+    if (error) {
+        instance->tlsio_state = TLSIO_STATE_NOT_OPEN;
+        result = __FAILURE__;
+        if (instance->sock >= 0) {
+            close(instance->sock);
+        }
+    }
+
+    return result;
+}
+
+int tlsio_sl_close(CONCRETE_IO_HANDLE tls_io,
+                        ON_IO_CLOSE_COMPLETE on_io_close_complete,
+                        void* callback_context)
+{
+    int result = 0;
+
+    if (tls_io == NULL) {
+        result = __FAILURE__;
+    }
+    else {
+        TLS_IO_INSTANCE* instance = (TLS_IO_INSTANCE*)tls_io;
+
+        if ((instance->tlsio_state == TLSIO_STATE_NOT_OPEN) ||
+            (instance->tlsio_state == TLSIO_STATE_CLOSING)) {
+            result = __FAILURE__;
+        }
+        else {
+            instance->tlsio_state = TLSIO_STATE_CLOSING;
+            instance->on_io_close_complete = on_io_close_complete;
+            instance->on_io_close_complete_context = callback_context;
+
+            close(instance->sock);
+
+            instance->tlsio_state = TLSIO_STATE_NOT_OPEN;
+            instance->on_io_close_complete(
+                                       instance->on_io_close_complete_context);
+        }
+    }
+
+    return result;
+}
+
+int tlsio_sl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t size,
+                     ON_SEND_COMPLETE on_send_complete, void* callback_context)
+{
+    int result;
+
+    if (tls_io == NULL) {
+        result = __FAILURE__;
+    }
+    else {
+        TLS_IO_INSTANCE* instance = (TLS_IO_INSTANCE*)tls_io;
+
+        if (instance->tlsio_state != TLSIO_STATE_OPEN) {
+            result = __FAILURE__;
+        }
+        else {
+            const char* buf = (const char*)buffer;
+            instance->on_send_complete = on_send_complete;
+            instance->on_send_complete_callback_context = callback_context;
+
+            result = 0;
+            while (size) {
+                int res = send(instance->sock, buf, size, 0);
+                if ((res < 0) && (errno != EAGAIN)) {
+                    result = __FAILURE__;
+                    break;
+                }
+                else if (((res < 0) && (errno == EAGAIN)) || (res < size)) {
+                    /* no more space left, lets wait for more to become
+                     * available and try again.
+                     */
+                    ThreadAPI_Sleep(10);
+                }
+                if (res > 0) {
+                    size -= res;
+                    buf += res;
+                }
+            }
+            IO_SEND_RESULT oresult = result == __FAILURE__ ? IO_SEND_ERROR :
+                                                             IO_SEND_OK;
+            instance->on_send_complete(
+                          instance->on_send_complete_callback_context, oresult);
+        }
+    }
+
+    return result;
+}
+
+void tlsio_sl_dowork(CONCRETE_IO_HANDLE tls_io)
+{
+    if (tls_io != NULL) {
+        TLS_IO_INSTANCE* tls_io_instance = (TLS_IO_INSTANCE*)tls_io;
+
+        if ((tls_io_instance->tlsio_state != TLSIO_STATE_NOT_OPEN) &&
+            (tls_io_instance->tlsio_state != TLSIO_STATE_ERROR)) {
+            unsigned char buffer[64];
+            int rcv_bytes = 1;
+
+            while (rcv_bytes > 0) {
+                rcv_bytes =  recv(tls_io_instance->sock, buffer,
+                        sizeof(buffer), 0);
+                if (rcv_bytes > 0) {
+                    if (tls_io_instance->on_bytes_received != NULL) {
+                        tls_io_instance->on_bytes_received(
+                                     tls_io_instance->on_bytes_received_context,
+                                     buffer, rcv_bytes);
+                    }
+                }
+            }
+        }
+    }
+}
+
+const IO_INTERFACE_DESCRIPTION* tlsio_sl_get_interface_description(void)
+{
+    return &tlsio_sl_interface_description;
+}
+
+int tlsio_sl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
+        const void* value)
+{
+    int result = 0;
+    TLS_IO_INSTANCE* tls_io_instance = (TLS_IO_INSTANCE*)tls_io;
+
+    /*
+     * We are expecting 'value' to be the name of the secure object/file
+     * containing the certificate/key. This is to allow users the
+     * flexibility of flashing the certificates using Uniflash on
+     * platforms where this is supported, as opposed to necessarily
+     * bundling them into the executable.
+     */
+    if ((strcmp("x509EccCertificate", optionName) == 0) ||
+           (strcmp("x509certificate", optionName) == 0)) {
+        result = SlNetSock_secAttribSet(tls_io_instance->sec_attrib_hdl,
+                SLNETSOCK_SEC_ATTRIB_LOCAL_CERT, (void *)value,
+                strlen(value));
+    }
+    else if ((strcmp("x509EccAliasKey", optionName) == 0) ||
+            (strcmp("x509privatekey", optionName) == 0)) {
+        result = SlNetSock_secAttribSet(tls_io_instance->sec_attrib_hdl,
+                SLNETSOCK_SEC_ATTRIB_PRIVATE_KEY, (void *)value,
+                strlen(value));
+    }
+
+    return result;
+}
diff --git a/sample/CC3220SF_LAUNCHXL/Board.h b/sample/CC3220SF_LAUNCHXL/Board.h
new file mode 100644 (file)
index 0000000..d3eb210
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __BOARD_H
+#define __BOARD_H
+
+#define Board_CC3220SF_LAUNCHXL
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "CC3220SF_LAUNCHXL.h"
+
+#define Board_initGeneral            CC3220SF_LAUNCHXL_initGeneral
+
+#define Board_ADC0                   CC3220SF_LAUNCHXL_ADC0
+#define Board_ADC1                   CC3220SF_LAUNCHXL_ADC1
+
+#define Board_CAPTURE0               CC3220SF_LAUNCHXL_CAPTURE0
+#define Board_CAPTURE1               CC3220SF_LAUNCHXL_CAPTURE1
+
+#define Board_CRYPTO0                CC3220SF_LAUNCHXL_CRYPTO0
+
+#define Board_GPIO_LED_ON            CC3220SF_LAUNCHXL_GPIO_LED_ON
+#define Board_GPIO_LED_OFF           CC3220SF_LAUNCHXL_GPIO_LED_OFF
+#define Board_GPIO_LED0              CC3220SF_LAUNCHXL_GPIO_LED_D7
+/*
+ *  CC3220SF_LAUNCHXL_GPIO_LED_D5 and CC3220SF_LAUNCHXL_GPIO_LED_D6 are shared with the I2C
+ *  and PWM peripherals. In order for those examples to work, these LEDs are
+ *  taken out of gpioPinCOnfig[]
+ */
+#define Board_GPIO_LED1              CC3220SF_LAUNCHXL_GPIO_LED_D7
+#define Board_GPIO_LED2              CC3220SF_LAUNCHXL_GPIO_LED_D7
+
+#define Board_GPIO_BUTTON0           CC3220SF_LAUNCHXL_GPIO_SW2
+#define Board_GPIO_BUTTON1           CC3220SF_LAUNCHXL_GPIO_SW3
+
+#define Board_I2C0                   CC3220SF_LAUNCHXL_I2C0
+#define Board_I2C_TMP                CC3220SF_LAUNCHXL_I2C0
+
+#define Board_I2S0                   CC3220SF_LAUNCHXL_I2S0
+
+#define Board_PWM0                   CC3220SF_LAUNCHXL_PWM6
+#define Board_PWM1                   CC3220SF_LAUNCHXL_PWM7
+
+#define Board_SD0                    CC3220SF_LAUNCHXL_SD0
+
+#define Board_SDFatFS0               CC3220SF_LAUNCHXL_SD0
+
+/* CC3220SF_LAUNCHXL_SPI0 is reserved for the NWP */
+#define Board_SPI0                   CC3220SF_LAUNCHXL_SPI1
+#define Board_SPI_MASTER             CC3220SF_LAUNCHXL_SPI1
+#define Board_SPI_SLAVE              CC3220SF_LAUNCHXL_SPI1
+#define Board_SPI_MASTER_READY       CC3220SF_LAUNCHXL_SPI_MASTER_READY
+#define Board_SPI_SLAVE_READY        CC3220SF_LAUNCHXL_SPI_SLAVE_READY
+
+#define Board_TIMER0                 CC3220SF_LAUNCHXL_TIMER0
+#define Board_TIMER1                 CC3220SF_LAUNCHXL_TIMER1
+#define Board_TIMER2                 CC3220SF_LAUNCHXL_TIMER2
+
+#define Board_UART0                  CC3220SF_LAUNCHXL_UART0
+#define Board_UART1                  CC3220SF_LAUNCHXL_UART1
+
+#define Board_WATCHDOG0              CC3220SF_LAUNCHXL_WATCHDOG0
+
+/* Board specific I2C addresses */
+#define Board_TMP_ADDR               (0x41)
+#define Board_SENSORS_BP_TMP_ADDR    (0x40)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BOARD_H */
diff --git a/sample/CC3220SF_LAUNCHXL/CC3220SF_LAUNCHXL.c b/sample/CC3220SF_LAUNCHXL/CC3220SF_LAUNCHXL.c
new file mode 100644 (file)
index 0000000..3859628
--- /dev/null
@@ -0,0 +1,866 @@
+/*
+ * Copyright (c) 2016-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== CC3220SF_LAUNCHXL.c ========
+ *  This file is responsible for setting up the board specific items for the
+ *  CC3220SF_LAUNCHXL board.
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include <ti/devices/cc32xx/inc/hw_ints.h>
+#include <ti/devices/cc32xx/inc/hw_memmap.h>
+#include <ti/devices/cc32xx/inc/hw_types.h>
+
+#include <ti/devices/cc32xx/driverlib/rom.h>
+#include <ti/devices/cc32xx/driverlib/rom_map.h>
+#include <ti/devices/cc32xx/driverlib/adc.h>
+#include <ti/devices/cc32xx/driverlib/gpio.h>
+#include <ti/devices/cc32xx/driverlib/pin.h>
+#include <ti/devices/cc32xx/driverlib/prcm.h>
+#include <ti/devices/cc32xx/driverlib/spi.h>
+#include <ti/devices/cc32xx/driverlib/sdhost.h>
+#include <ti/devices/cc32xx/driverlib/timer.h>
+#include <ti/devices/cc32xx/driverlib/uart.h>
+#include <ti/devices/cc32xx/driverlib/udma.h>
+#include <ti/devices/cc32xx/driverlib/wdt.h>
+
+#include <ti/drivers/Power.h>
+#include <ti/drivers/power/PowerCC32XX.h>
+
+#include "CC3220SF_LAUNCHXL.h"
+
+/*
+ *  This define determines whether to use the UARTCC32XXDMA driver
+ *  or the UARTCC32XX (no DMA) driver.  Set to 1 to use the UARTCC32XXDMA
+ *  driver.
+ */
+#ifndef TI_DRIVERS_UART_DMA
+#define TI_DRIVERS_UART_DMA 0
+#endif
+
+/*
+ *  =============================== ADC ===============================
+ */
+#include <ti/drivers/ADC.h>
+#include <ti/drivers/adc/ADCCC32XX.h>
+
+ADCCC32XX_Object adcCC3220SObjects[CC3220SF_LAUNCHXL_ADCCOUNT];
+
+const ADCCC32XX_HWAttrsV1 adcCC3220SHWAttrs[CC3220SF_LAUNCHXL_ADCCOUNT] = {
+    {
+        .adcPin = ADCCC32XX_PIN_59_CH_2
+    },
+    {
+        .adcPin = ADCCC32XX_PIN_60_CH_3
+    }
+};
+
+const ADC_Config ADC_config[CC3220SF_LAUNCHXL_ADCCOUNT] = {
+    {
+        .fxnTablePtr = &ADCCC32XX_fxnTable,
+        .object = &adcCC3220SObjects[CC3220SF_LAUNCHXL_ADC0],
+        .hwAttrs = &adcCC3220SHWAttrs[CC3220SF_LAUNCHXL_ADC0]
+    },
+    {
+        .fxnTablePtr = &ADCCC32XX_fxnTable,
+        .object = &adcCC3220SObjects[CC3220SF_LAUNCHXL_ADC1],
+        .hwAttrs = &adcCC3220SHWAttrs[CC3220SF_LAUNCHXL_ADC1]
+    }
+};
+
+const uint_least8_t ADC_count = CC3220SF_LAUNCHXL_ADCCOUNT;
+
+/*
+ *  =============================== Capture ===============================
+ */
+#include <ti/drivers/Capture.h>
+#include <ti/drivers/capture/CaptureCC32XX.h>
+
+CaptureCC32XX_Object captureCC3220SFObjects[CC3220SF_LAUNCHXL_CAPTURECOUNT];
+
+const CaptureCC32XX_HWAttrs captureCC3220SFHWAttrs[CC3220SF_LAUNCHXL_CAPTURECOUNT] =
+{
+      {
+         .capturePin = CaptureCC32XX_PIN_04,
+         .intPriority = ~0
+      },
+      {
+          .capturePin = CaptureCC32XX_PIN_05,
+          .intPriority = ~0
+      },
+};
+
+const Capture_Config Capture_config[CC3220SF_LAUNCHXL_CAPTURECOUNT] = {
+    {
+        .fxnTablePtr = &CaptureCC32XX_fxnTable,
+        .object = &captureCC3220SFObjects[CC3220SF_LAUNCHXL_CAPTURE0],
+        .hwAttrs = &captureCC3220SFHWAttrs[CC3220SF_LAUNCHXL_CAPTURE0]
+    },
+    {
+        .fxnTablePtr = &CaptureCC32XX_fxnTable,
+        .object = &captureCC3220SFObjects[CC3220SF_LAUNCHXL_CAPTURE1],
+        .hwAttrs = &captureCC3220SFHWAttrs[CC3220SF_LAUNCHXL_CAPTURE1]
+    }
+};
+
+const uint_least8_t Capture_count = CC3220SF_LAUNCHXL_CAPTURECOUNT;
+
+/*
+ *  =============================== Crypto ===============================
+ */
+#include <ti/drivers/crypto/CryptoCC32XX.h>
+
+CryptoCC32XX_Object cryptoCC3220SObjects[CC3220SF_LAUNCHXL_CRYPTOCOUNT];
+
+const CryptoCC32XX_Config CryptoCC32XX_config[CC3220SF_LAUNCHXL_CRYPTOCOUNT] = {
+    {
+        .object = &cryptoCC3220SObjects[CC3220SF_LAUNCHXL_CRYPTO0]
+    }
+};
+
+const uint_least8_t CryptoCC32XX_count = CC3220SF_LAUNCHXL_CRYPTOCOUNT;
+
+/*
+ *  =============================== DMA ===============================
+ */
+#include <ti/drivers/dma/UDMACC32XX.h>
+
+#if defined(__TI_COMPILER_VERSION__)
+#pragma DATA_ALIGN(dmaControlTable, 1024)
+#elif defined(__IAR_SYSTEMS_ICC__)
+#pragma data_alignment=1024
+#elif defined(__GNUC__)
+__attribute__ ((aligned (1024)))
+#endif
+static tDMAControlTable dmaControlTable[64];
+
+/*
+ *  ======== dmaErrorFxn ========
+ *  This is the handler for the uDMA error interrupt.
+ */
+static void dmaErrorFxn(uintptr_t arg)
+{
+    int status = MAP_uDMAErrorStatusGet();
+    MAP_uDMAErrorStatusClear();
+
+    /* Suppress unused variable warning */
+    (void)status;
+
+    while (1);
+}
+
+UDMACC32XX_Object udmaCC3220SObject;
+
+const UDMACC32XX_HWAttrs udmaCC3220SHWAttrs = {
+    .controlBaseAddr = (void *)dmaControlTable,
+    .dmaErrorFxn = (UDMACC32XX_ErrorFxn)dmaErrorFxn,
+    .intNum = INT_UDMAERR,
+    .intPriority = (~0)
+};
+
+const UDMACC32XX_Config UDMACC32XX_config = {
+    .object = &udmaCC3220SObject,
+    .hwAttrs = &udmaCC3220SHWAttrs
+};
+
+/*
+ *  =============================== General ===============================
+ */
+/*
+ *  ======== CC3220SF_LAUNCHXL_initGeneral ========
+ */
+void CC3220SF_LAUNCHXL_initGeneral(void)
+{
+    PRCMCC3200MCUInit();
+    Power_init();
+}
+
+/*
+ *  =============================== GPIO ===============================
+ */
+#include <ti/drivers/GPIO.h>
+#include <ti/drivers/gpio/GPIOCC32XX.h>
+
+/*
+ * Array of Pin configurations
+ * NOTE: The order of the pin configurations must coincide with what was
+ *       defined in CC3220SF_LAUNCHXL.h
+ * NOTE: Pins not used for interrupts should be placed at the end of the
+ *       array.  Callback entries can be omitted from callbacks array to
+ *       reduce memory usage.
+ */
+GPIO_PinConfig gpioPinConfigs[] = {
+    /* input pins with callbacks */
+    /* CC3220SF_LAUNCHXL_GPIO_SW2 */
+    GPIOCC32XX_GPIO_13 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING,
+    /* CC3220SF_LAUNCHXL_GPIO_SW3 */
+    GPIOCC32XX_GPIO_22 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING,
+
+    /* CC3220SF_LAUNCHXL_SPI_MASTER_READY */
+    GPIOCC32XX_GPIO_28 | GPIO_DO_NOT_CONFIG,
+    /* CC3220SF_LAUNCHXL_SPI_SLAVE_READY */
+    GPIOCC32XX_GPIO_12 | GPIO_DO_NOT_CONFIG,
+
+    /* output pins */
+    /* CC3220SF_LAUNCHXL_GPIO_LED_D7 */
+    GPIOCC32XX_GPIO_09 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
+
+    /*
+     *  CC3220SF_LAUNCHXL_GPIO_LED_D5 and CC3220SF_LAUNCHXL_GPIO_LED_D6 are shared with the
+     *  I2C and PWM peripherals. In order for those examples to work, these
+     *  LEDs are taken out of gpioPinConfig[]
+     */
+    /* CC3220SF_LAUNCHXL_GPIO_LED_D6 */
+    /* GPIOCC32XX_GPIO_10 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW, */
+    /* CC3220SF_LAUNCHXL_GPIO_LED_D5 */
+    /* GPIOCC32XX_GPIO_11 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW, */
+
+    /* Sharp Display - GPIO configurations will be done in the Display files */
+    GPIOCC32XX_GPIO_12 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
+    GPIOCC32XX_GPIO_06 | GPIO_DO_NOT_CONFIG, /* LCD power control */
+    GPIOCC32XX_GPIO_03 | GPIO_DO_NOT_CONFIG, /*LCD enable */
+};
+
+/*
+ * Array of callback function pointers
+ * NOTE: The order of the pin configurations must coincide with what was
+ *       defined in CC3220SF_LAUNCHXL.h
+ * NOTE: Pins not used for interrupts can be omitted from callbacks array to
+ *       reduce memory usage (if placed at end of gpioPinConfigs array).
+ */
+GPIO_CallbackFxn gpioCallbackFunctions[] = {
+    NULL,  /* CC3220SF_LAUNCHXL_GPIO_SW2 */
+    NULL,  /* CC3220SF_LAUNCHXL_GPIO_SW3 */
+    NULL,  /* CC3220SF_LAUNCHXL_SPI_MASTER_READY */
+    NULL   /* CC3220SF_LAUNCHXL_SPI_SLAVE_READY */
+};
+
+/* The device-specific GPIO_config structure */
+const GPIOCC32XX_Config GPIOCC32XX_config = {
+    .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
+    .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
+    .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
+    .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
+    .intPriority = (~0)
+};
+
+/*
+ *  ============================= Display =============================
+ */
+#include <ti/display/Display.h>
+#include <ti/display/DisplayUart.h>
+#include <ti/display/DisplaySharp.h>
+#define MAXPRINTLEN 1024
+
+#ifndef BOARD_DISPLAY_SHARP_SIZE
+#define BOARD_DISPLAY_SHARP_SIZE    96
+#endif
+
+DisplayUart_Object displayUartObject;
+DisplaySharp_Object displaySharpObject;
+
+static char displayBuf[MAXPRINTLEN];
+static uint_least8_t sharpDisplayBuf[BOARD_DISPLAY_SHARP_SIZE * BOARD_DISPLAY_SHARP_SIZE / 8];
+
+const DisplayUart_HWAttrs displayUartHWAttrs = {
+    .uartIdx = 0,
+    .baudRate = 115200,
+    .mutexTimeout = (unsigned int)(-1),
+    .strBuf = displayBuf,
+    .strBufLen = MAXPRINTLEN
+};
+
+const DisplaySharp_HWAttrsV1 displaySharpHWattrs = {
+    .spiIndex    = CC3220SF_LAUNCHXL_SPI1,
+    .csPin       = CC3220SF_LAUNCHXL_LCD_CS,
+    .powerPin    = CC3220SF_LAUNCHXL_LCD_POWER,
+    .enablePin   = CC3220SF_LAUNCHXL_LCD_ENABLE,
+    .pixelWidth  = BOARD_DISPLAY_SHARP_SIZE,
+    .pixelHeight = BOARD_DISPLAY_SHARP_SIZE,
+    .displayBuf  = sharpDisplayBuf,
+};
+
+#ifndef BOARD_DISPLAY_USE_UART
+#define BOARD_DISPLAY_USE_UART 1
+#endif
+#ifndef BOARD_DISPLAY_USE_UART_ANSI
+#define BOARD_DISPLAY_USE_UART_ANSI 0
+#endif
+#ifndef BOARD_DISPLAY_USE_LCD
+#define BOARD_DISPLAY_USE_LCD 0
+#endif
+
+const Display_Config Display_config[] = {
+    {
+#  if (BOARD_DISPLAY_USE_UART_ANSI)
+        .fxnTablePtr = &DisplayUartAnsi_fxnTable,
+#  else /* Default to minimal UART with no cursor placement */
+        .fxnTablePtr = &DisplayUartMin_fxnTable,
+#  endif
+        .object = &displayUartObject,
+        .hwAttrs = &displayUartHWAttrs
+    },
+#if (BOARD_DISPLAY_USE_LCD)
+    {
+        .fxnTablePtr = &DisplaySharp_fxnTable,
+        .object      = &displaySharpObject,
+        .hwAttrs     = &displaySharpHWattrs
+    },
+#endif
+};
+
+const uint_least8_t Display_count = sizeof(Display_config) / sizeof(Display_Config);
+
+
+
+/*
+ *  =============================== I2C ===============================
+ */
+#include <ti/drivers/I2C.h>
+#include <ti/drivers/i2c/I2CCC32XX.h>
+
+I2CCC32XX_Object i2cCC3220SObjects[CC3220SF_LAUNCHXL_I2CCOUNT];
+
+const I2CCC32XX_HWAttrsV1 i2cCC3220SHWAttrs[CC3220SF_LAUNCHXL_I2CCOUNT] = {
+    {
+        .baseAddr = I2CA0_BASE,
+        .intNum = INT_I2CA0,
+        .intPriority = (~0),
+        .clkPin = I2CCC32XX_PIN_01_I2C_SCL,
+        .dataPin = I2CCC32XX_PIN_02_I2C_SDA
+    }
+};
+
+const I2C_Config I2C_config[CC3220SF_LAUNCHXL_I2CCOUNT] = {
+    {
+        .fxnTablePtr = &I2CCC32XX_fxnTable,
+        .object = &i2cCC3220SObjects[CC3220SF_LAUNCHXL_I2C0],
+        .hwAttrs = &i2cCC3220SHWAttrs[CC3220SF_LAUNCHXL_I2C0]
+    }
+};
+
+const uint_least8_t I2C_count = CC3220SF_LAUNCHXL_I2CCOUNT;
+
+/*
+ *  =============================== I2S ===============================
+ */
+#include <ti/drivers/I2S.h>
+#include <ti/drivers/i2s/I2SCC32XXDMA.h>
+
+I2SCC32XXDMA_Object i2sCC3220SObjects[CC3220SF_LAUNCHXL_I2SCOUNT];
+
+const I2SCC32XXDMA_HWAttrsV1 i2sCC3220SHWAttrs[CC3220SF_LAUNCHXL_I2SCOUNT] = {
+    {
+        .baseAddr = I2S_BASE,
+        .intNum = INT_I2S,
+        .intPriority = (~0),
+        .rxChannelIndex = UDMA_CH4_I2S_RX,
+        .txChannelIndex = UDMA_CH5_I2S_TX,
+        .xr0Pin = I2SCC32XXDMA_PIN_64_McAXR0,
+        .xr1Pin = I2SCC32XXDMA_PIN_50_McAXR1,
+        .clkxPin = I2SCC32XXDMA_PIN_62_McACLKX,
+        .clkPin = I2SCC32XXDMA_PIN_53_McACLK,
+        .fsxPin = I2SCC32XXDMA_PIN_63_McAFSX,
+    }
+};
+
+const I2S_Config I2S_config[CC3220SF_LAUNCHXL_I2SCOUNT] = {
+    {
+        .fxnTablePtr = &I2SCC32XXDMA_fxnTable,
+        .object = &i2sCC3220SObjects[CC3220SF_LAUNCHXL_I2S0],
+        .hwAttrs = &i2sCC3220SHWAttrs[CC3220SF_LAUNCHXL_I2S0]
+    }
+};
+
+const uint_least8_t I2S_count = CC3220SF_LAUNCHXL_I2SCOUNT;
+
+/*
+ *  =============================== Power ===============================
+ */
+/*
+ * This table defines the parking state to be set for each parkable pin
+ * during LPDS. (Device pins must be parked during LPDS to achieve maximum
+ * power savings.)  If the pin should be left unparked, specify the state
+ * PowerCC32XX_DONT_PARK.  For example, for a UART TX pin, the device
+ * will automatically park the pin in a high state during transition to LPDS,
+ * so the Power Manager does not need to explictly park the pin.  So the
+ * corresponding entries in this table should indicate PowerCC32XX_DONT_PARK.
+ */
+PowerCC32XX_ParkInfo parkInfo[] = {
+/*          PIN                    PARK STATE              PIN ALIAS (FUNCTION)
+     -----------------  ------------------------------     -------------------- */
+    {PowerCC32XX_PIN01, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO10              */
+    {PowerCC32XX_PIN02, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO11              */
+    {PowerCC32XX_PIN03, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO12              */
+    {PowerCC32XX_PIN04, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO13              */
+    {PowerCC32XX_PIN05, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO14              */
+    {PowerCC32XX_PIN06, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO15              */
+    {PowerCC32XX_PIN07, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO16              */
+    {PowerCC32XX_PIN08, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO17              */
+    {PowerCC32XX_PIN13, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* FLASH_SPI_DIN       */
+    {PowerCC32XX_PIN15, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO22              */
+    {PowerCC32XX_PIN16, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TDI (JTAG DEBUG)    */
+    {PowerCC32XX_PIN17, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TDO (JTAG DEBUG)    */
+    {PowerCC32XX_PIN19, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TCK (JTAG DEBUG)    */
+    {PowerCC32XX_PIN20, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TMS (JTAG DEBUG)    */
+    {PowerCC32XX_PIN18, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO28              */
+    {PowerCC32XX_PIN21, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* SOP2                */
+    {PowerCC32XX_PIN29, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* ANTSEL1             */
+    {PowerCC32XX_PIN30, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* ANTSEL2             */
+    {PowerCC32XX_PIN45, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* DCDC_ANA2_SW_P      */
+    {PowerCC32XX_PIN50, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO0               */
+    {PowerCC32XX_PIN52, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* RTC_XTAL_N          */
+    {PowerCC32XX_PIN53, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO30              */
+    {PowerCC32XX_PIN55, PowerCC32XX_WEAK_PULL_UP_STD},   /* GPIO1 (XDS_UART_RX) */
+    {PowerCC32XX_PIN57, PowerCC32XX_WEAK_PULL_UP_STD},   /* GPIO2 (XDS_UART_TX) */
+    {PowerCC32XX_PIN58, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO3               */
+    {PowerCC32XX_PIN59, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO4               */
+    {PowerCC32XX_PIN60, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO5               */
+    {PowerCC32XX_PIN61, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO6               */
+    {PowerCC32XX_PIN62, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO7               */
+    {PowerCC32XX_PIN63, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO8               */
+    {PowerCC32XX_PIN64, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO9               */
+};
+
+/*
+ *  This structure defines the configuration for the Power Manager.
+ *
+ *  In this configuration the Power policy is disabled by default (because
+ *  enablePolicy is set to false).  The Power policy can be enabled dynamically
+ *  at runtime by calling Power_enablePolicy(), or at build time, by changing
+ *  enablePolicy to true in this structure.
+ */
+const PowerCC32XX_ConfigV1 PowerCC32XX_config = {
+    .policyInitFxn = &PowerCC32XX_initPolicy,
+    .policyFxn = &PowerCC32XX_sleepPolicy,
+    .enterLPDSHookFxn = NULL,
+    .resumeLPDSHookFxn = NULL,
+    .enablePolicy = false,
+    .enableGPIOWakeupLPDS = true,
+    .enableGPIOWakeupShutdown = true,
+    .enableNetworkWakeupLPDS = true,
+    .wakeupGPIOSourceLPDS = PRCM_LPDS_GPIO13,
+    .wakeupGPIOTypeLPDS = PRCM_LPDS_FALL_EDGE,
+    .wakeupGPIOFxnLPDS = NULL,
+    .wakeupGPIOFxnLPDSArg = 0,
+    .wakeupGPIOSourceShutdown = PRCM_HIB_GPIO13,
+    .wakeupGPIOTypeShutdown = PRCM_HIB_RISE_EDGE,
+    .ramRetentionMaskLPDS = PRCM_SRAM_COL_1 | PRCM_SRAM_COL_2 |
+        PRCM_SRAM_COL_3 | PRCM_SRAM_COL_4,
+    .keepDebugActiveDuringLPDS = false,
+    .ioRetentionShutdown = PRCM_IO_RET_GRP_1,
+    .pinParkDefs = parkInfo,
+    .numPins = sizeof(parkInfo) / sizeof(PowerCC32XX_ParkInfo)
+};
+
+/*
+ *  =============================== PWM ===============================
+ */
+#include <ti/drivers/PWM.h>
+#include <ti/drivers/pwm/PWMTimerCC32XX.h>
+
+PWMTimerCC32XX_Object pwmTimerCC3220SObjects[CC3220SF_LAUNCHXL_PWMCOUNT];
+
+const PWMTimerCC32XX_HWAttrsV2 pwmTimerCC3220SHWAttrs[CC3220SF_LAUNCHXL_PWMCOUNT] = {
+    {    /* CC3220SF_LAUNCHXL_PWM6 */
+        .pwmPin = PWMTimerCC32XX_PIN_01
+    },
+    {    /* CC3220SF_LAUNCHXL_PWM7 */
+        .pwmPin = PWMTimerCC32XX_PIN_02
+    }
+};
+
+const PWM_Config PWM_config[CC3220SF_LAUNCHXL_PWMCOUNT] = {
+    {
+        .fxnTablePtr = &PWMTimerCC32XX_fxnTable,
+        .object = &pwmTimerCC3220SObjects[CC3220SF_LAUNCHXL_PWM6],
+        .hwAttrs = &pwmTimerCC3220SHWAttrs[CC3220SF_LAUNCHXL_PWM6]
+    },
+    {
+        .fxnTablePtr = &PWMTimerCC32XX_fxnTable,
+        .object = &pwmTimerCC3220SObjects[CC3220SF_LAUNCHXL_PWM7],
+        .hwAttrs = &pwmTimerCC3220SHWAttrs[CC3220SF_LAUNCHXL_PWM7]
+    }
+};
+
+const uint_least8_t PWM_count = CC3220SF_LAUNCHXL_PWMCOUNT;
+
+/*
+ *  =============================== SDFatFS ===============================
+ */
+#include <ti/drivers/SD.h>
+#include <ti/drivers/SDFatFS.h>
+
+/*
+ * Note: The SDFatFS driver provides interface functions to enable FatFs
+ * but relies on the SD driver to communicate with SD cards.  Opening a
+ * SDFatFs driver instance will internally try to open a SD driver instance
+ * reusing the same index number (opening SDFatFs driver at index 0 will try to
+ * open SD driver at index 0).  This requires that all SDFatFs driver instances
+ * have an accompanying SD driver instance defined with the same index.  It is
+ * acceptable to have more SD driver instances than SDFatFs driver instances
+ * but the opposite is not supported & the SDFatFs will fail to open.
+ */
+SDFatFS_Object sdfatfsObjects[CC3220SF_LAUNCHXL_SDFatFSCOUNT];
+
+const SDFatFS_Config SDFatFS_config[CC3220SF_LAUNCHXL_SDFatFSCOUNT] = {
+    {
+        .object = &sdfatfsObjects[CC3220SF_LAUNCHXL_SDFatFS0]
+    }
+};
+
+const uint_least8_t SDFatFS_count = CC3220SF_LAUNCHXL_SDFatFSCOUNT;
+
+/*
+ *  =============================== SD ===============================
+ */
+#include <ti/drivers/SD.h>
+#include <ti/drivers/sd/SDHostCC32XX.h>
+
+SDHostCC32XX_Object sdhostCC3220SObjects[CC3220SF_LAUNCHXL_SDCOUNT];
+
+/* SDHost configuration structure, describing which pins are to be used */
+const SDHostCC32XX_HWAttrsV1 sdhostCC3220SHWattrs[CC3220SF_LAUNCHXL_SDCOUNT] = {
+    {
+        .clkRate = 8000000,
+        .intPriority = ~0,
+        .baseAddr = SDHOST_BASE,
+        .rxChIdx = UDMA_CH23_SDHOST_RX,
+        .txChIdx = UDMA_CH24_SDHOST_TX,
+        .dataPin = SDHostCC32XX_PIN_06_SDCARD_DATA,
+        .cmdPin = SDHostCC32XX_PIN_08_SDCARD_CMD,
+        .clkPin = SDHostCC32XX_PIN_07_SDCARD_CLK
+    }
+};
+
+const SD_Config SD_config[CC3220SF_LAUNCHXL_SDCOUNT] = {
+    {
+        .fxnTablePtr = &sdHostCC32XX_fxnTable,
+        .object = &sdhostCC3220SObjects[CC3220SF_LAUNCHXL_SD0],
+        .hwAttrs = &sdhostCC3220SHWattrs[CC3220SF_LAUNCHXL_SD0]
+    },
+};
+
+const uint_least8_t SD_count = CC3220SF_LAUNCHXL_SDCOUNT;
+
+/*
+ *  =============================== SPI ===============================
+ */
+#include <ti/drivers/SPI.h>
+#include <ti/drivers/spi/SPICC32XXDMA.h>
+
+SPICC32XXDMA_Object spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPICOUNT];
+
+#if defined(__TI_COMPILER_VERSION__)
+#pragma DATA_ALIGN(spiCC3220SDMAscratchBuf, 32)
+#elif defined(__IAR_SYSTEMS_ICC__)
+#pragma data_alignment=32
+#elif defined(__GNUC__)
+__attribute__ ((aligned (32)))
+#endif
+uint32_t spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPICOUNT];
+
+const SPICC32XXDMA_HWAttrsV1 spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPICOUNT] = {
+    /* index 0 is reserved for LSPI that links to the NWP */
+    {
+        .baseAddr = LSPI_BASE,
+        .intNum = INT_LSPI,
+        .intPriority = (~0),
+        .spiPRCM = PRCM_LSPI,
+        .csControl = SPI_SW_CTRL_CS,
+        .csPolarity = SPI_CS_ACTIVEHIGH,
+        .pinMode = SPI_4PIN_MODE,
+        .turboMode = SPI_TURBO_OFF,
+        .scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI0],
+        .defaultTxBufValue = 0,
+        .rxChannelIndex = UDMA_CH12_LSPI_RX,
+        .txChannelIndex = UDMA_CH13_LSPI_TX,
+        .minDmaTransferSize = 100,
+        .mosiPin = SPICC32XXDMA_PIN_NO_CONFIG,
+        .misoPin = SPICC32XXDMA_PIN_NO_CONFIG,
+        .clkPin = SPICC32XXDMA_PIN_NO_CONFIG,
+        .csPin = SPICC32XXDMA_PIN_NO_CONFIG
+    },
+    {
+        .baseAddr = GSPI_BASE,
+        .intNum = INT_GSPI,
+        .intPriority = (~0),
+        .spiPRCM = PRCM_GSPI,
+        .csControl = SPI_HW_CTRL_CS,
+        .csPolarity = SPI_CS_ACTIVELOW,
+        .pinMode = SPI_4PIN_MODE,
+        .turboMode = SPI_TURBO_OFF,
+        .scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI1],
+        .defaultTxBufValue = 0,
+        .rxChannelIndex = UDMA_CH6_GSPI_RX,
+        .txChannelIndex = UDMA_CH7_GSPI_TX,
+        .minDmaTransferSize = 10,
+        .mosiPin = SPICC32XXDMA_PIN_07_MOSI,
+        .misoPin = SPICC32XXDMA_PIN_06_MISO,
+        .clkPin = SPICC32XXDMA_PIN_05_CLK,
+        .csPin = SPICC32XXDMA_PIN_08_CS
+    }
+};
+
+const SPI_Config SPI_config[CC3220SF_LAUNCHXL_SPICOUNT] = {
+    {
+        .fxnTablePtr = &SPICC32XXDMA_fxnTable,
+        .object = &spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPI0],
+        .hwAttrs = &spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPI0]
+    },
+    {
+        .fxnTablePtr = &SPICC32XXDMA_fxnTable,
+        .object = &spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPI1],
+        .hwAttrs = &spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPI1]
+    }
+};
+
+const uint_least8_t SPI_count = CC3220SF_LAUNCHXL_SPICOUNT;
+
+/*
+ *  =============================== Timer ===============================
+ */
+#include <ti/drivers/Timer.h>
+#include <ti/drivers/timer/TimerCC32XX.h>
+
+TimerCC32XX_Object timerCC3220SFObjects[CC3220SF_LAUNCHXL_TIMERCOUNT];
+
+const TimerCC32XX_HWAttrs timerCC3220SFHWAttrs[CC3220SF_LAUNCHXL_TIMERCOUNT] = {
+    {
+        .baseAddress = TIMERA0_BASE,
+        .subTimer = TimerCC32XX_timer32,
+        .intNum = INT_TIMERA0A,
+        .intPriority = ~0
+    },
+    {
+        .baseAddress = TIMERA1_BASE,
+        .subTimer = TimerCC32XX_timer16A,
+        .intNum = INT_TIMERA1A,
+        .intPriority = ~0
+    },
+    {
+         .baseAddress = TIMERA1_BASE,
+         .subTimer = TimerCC32XX_timer16B,
+         .intNum = INT_TIMERA1B,
+         .intPriority = ~0
+    },
+};
+
+const Timer_Config Timer_config[CC3220SF_LAUNCHXL_TIMERCOUNT] = {
+    {
+        .fxnTablePtr = &TimerCC32XX_fxnTable,
+        .object = &timerCC3220SFObjects[CC3220SF_LAUNCHXL_TIMER0],
+        .hwAttrs = &timerCC3220SFHWAttrs[CC3220SF_LAUNCHXL_TIMER0]
+    },
+    {
+        .fxnTablePtr = &TimerCC32XX_fxnTable,
+        .object = &timerCC3220SFObjects[CC3220SF_LAUNCHXL_TIMER1],
+        .hwAttrs = &timerCC3220SFHWAttrs[CC3220SF_LAUNCHXL_TIMER1]
+    },
+    {
+        .fxnTablePtr = &TimerCC32XX_fxnTable,
+        .object = &timerCC3220SFObjects[CC3220SF_LAUNCHXL_TIMER2],
+        .hwAttrs = &timerCC3220SFHWAttrs[CC3220SF_LAUNCHXL_TIMER2]
+    },
+};
+
+const uint_least8_t Timer_count = CC3220SF_LAUNCHXL_TIMERCOUNT;
+
+/*
+ *  =============================== UART ===============================
+ */
+#include <ti/drivers/UART.h>
+#if TI_DRIVERS_UART_DMA
+#include <ti/drivers/uart/UARTCC32XXDMA.h>
+
+UARTCC32XXDMA_Object uartCC3220SDmaObjects[CC3220SF_LAUNCHXL_UARTCOUNT];
+
+/* UART configuration structure */
+const UARTCC32XXDMA_HWAttrsV1 uartCC3220SDmaHWAttrs[CC3220SF_LAUNCHXL_UARTCOUNT] = {
+    {
+        .baseAddr = UARTA0_BASE,
+        .intNum = INT_UARTA0,
+        .intPriority = (~0),
+        .flowControl = UARTCC32XXDMA_FLOWCTRL_NONE,
+        .rxChannelIndex = UDMA_CH8_UARTA0_RX,
+        .txChannelIndex = UDMA_CH9_UARTA0_TX,
+        .rxPin = UARTCC32XXDMA_PIN_57_UART0_RX,
+        .txPin = UARTCC32XXDMA_PIN_55_UART0_TX,
+        .ctsPin = UARTCC32XXDMA_PIN_UNASSIGNED,
+        .rtsPin = UARTCC32XXDMA_PIN_UNASSIGNED,
+        .errorFxn = NULL
+    },
+    {
+        .baseAddr = UARTA1_BASE,
+        .intNum = INT_UARTA1,
+        .intPriority = (~0),
+        .flowControl = UARTCC32XXDMA_FLOWCTRL_NONE,
+        .rxChannelIndex = UDMA_CH10_UARTA1_RX,
+        .txChannelIndex = UDMA_CH11_UARTA1_TX,
+        .rxPin = UARTCC32XXDMA_PIN_08_UART1_RX,
+        .txPin = UARTCC32XXDMA_PIN_07_UART1_TX,
+        .ctsPin = UARTCC32XXDMA_PIN_UNASSIGNED,
+        .rtsPin = UARTCC32XXDMA_PIN_UNASSIGNED,
+        .errorFxn = NULL
+    }
+};
+
+const UART_Config UART_config[CC3220SF_LAUNCHXL_UARTCOUNT] = {
+    {
+        .fxnTablePtr = &UARTCC32XXDMA_fxnTable,
+        .object = &uartCC3220SDmaObjects[CC3220SF_LAUNCHXL_UART0],
+        .hwAttrs = &uartCC3220SDmaHWAttrs[CC3220SF_LAUNCHXL_UART0]
+    },
+    {
+        .fxnTablePtr = &UARTCC32XXDMA_fxnTable,
+        .object = &uartCC3220SDmaObjects[CC3220SF_LAUNCHXL_UART1],
+        .hwAttrs = &uartCC3220SDmaHWAttrs[CC3220SF_LAUNCHXL_UART1]
+    }
+};
+
+#else
+#include <ti/drivers/uart/UARTCC32XX.h>
+
+UARTCC32XX_Object uartCC3220SObjects[CC3220SF_LAUNCHXL_UARTCOUNT];
+unsigned char uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UARTCOUNT][32];
+
+/* UART configuration structure */
+const UARTCC32XX_HWAttrsV1 uartCC3220SHWAttrs[CC3220SF_LAUNCHXL_UARTCOUNT] = {
+    {
+        .baseAddr = UARTA0_BASE,
+        .intNum = INT_UARTA0,
+        .intPriority = (~0),
+        .flowControl = UARTCC32XX_FLOWCTRL_NONE,
+        .ringBufPtr  = uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UART0],
+        .ringBufSize = sizeof(uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UART0]),
+        .rxPin = UARTCC32XX_PIN_57_UART0_RX,
+        .txPin = UARTCC32XX_PIN_55_UART0_TX,
+        .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
+        .rtsPin = UARTCC32XX_PIN_UNASSIGNED,
+        .errorFxn = NULL
+    },
+    {
+        .baseAddr = UARTA1_BASE,
+        .intNum = INT_UARTA1,
+        .intPriority = (~0),
+        .flowControl = UARTCC32XX_FLOWCTRL_NONE,
+        .ringBufPtr  = uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UART1],
+        .ringBufSize = sizeof(uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UART1]),
+        .rxPin = UARTCC32XX_PIN_08_UART1_RX,
+        .txPin = UARTCC32XX_PIN_07_UART1_TX,
+        .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
+        .rtsPin = UARTCC32XX_PIN_UNASSIGNED,
+        .errorFxn = NULL
+    }
+};
+
+const UART_Config UART_config[CC3220SF_LAUNCHXL_UARTCOUNT] = {
+    {
+        .fxnTablePtr = &UARTCC32XX_fxnTable,
+        .object = &uartCC3220SObjects[CC3220SF_LAUNCHXL_UART0],
+        .hwAttrs = &uartCC3220SHWAttrs[CC3220SF_LAUNCHXL_UART0]
+    },
+    {
+        .fxnTablePtr = &UARTCC32XX_fxnTable,
+        .object = &uartCC3220SObjects[CC3220SF_LAUNCHXL_UART1],
+        .hwAttrs = &uartCC3220SHWAttrs[CC3220SF_LAUNCHXL_UART1]
+    }
+};
+#endif /* TI_DRIVERS_UART_DMA */
+
+const uint_least8_t UART_count = CC3220SF_LAUNCHXL_UARTCOUNT;
+
+/*
+ *  =============================== Watchdog ===============================
+ */
+#include <ti/drivers/Watchdog.h>
+#include <ti/drivers/watchdog/WatchdogCC32XX.h>
+
+WatchdogCC32XX_Object watchdogCC3220SObjects[CC3220SF_LAUNCHXL_WATCHDOGCOUNT];
+
+const WatchdogCC32XX_HWAttrs watchdogCC3220SHWAttrs[CC3220SF_LAUNCHXL_WATCHDOGCOUNT] = {
+    {
+        .baseAddr = WDT_BASE,
+        .intNum = INT_WDT,
+        .intPriority = (~0),
+        .reloadValue = 80000000 /* 1 second period at default CPU clock freq */
+    }
+};
+
+const Watchdog_Config Watchdog_config[CC3220SF_LAUNCHXL_WATCHDOGCOUNT] = {
+    {
+        .fxnTablePtr = &WatchdogCC32XX_fxnTable,
+        .object = &watchdogCC3220SObjects[CC3220SF_LAUNCHXL_WATCHDOG0],
+        .hwAttrs = &watchdogCC3220SHWAttrs[CC3220SF_LAUNCHXL_WATCHDOG0]
+    }
+};
+
+const uint_least8_t Watchdog_count = CC3220SF_LAUNCHXL_WATCHDOGCOUNT;
+
+/*
+ *  ======== Board_debugHeader ========
+ *  This structure prevents the CC32XXSF bootloader from overwriting the
+ *  internal FLASH; this allows us to flash a program that will not be
+ *  overwritten by the bootloader with the encrypted program saved in
+ *  "secure/serial flash".
+ *
+ *  This structure must be placed at the beginning of internal FLASH (so
+ *  the bootloader is able to recognize that it should not overwrite
+ *  internal FLASH).
+ */
+#if defined (__SF_DEBUG__) || defined(__SF_NODEBUG__)
+#if defined(__TI_COMPILER_VERSION__)
+#pragma DATA_SECTION(Board_debugHeader, ".dbghdr")
+#pragma RETAIN(Board_debugHeader)
+#elif defined(__IAR_SYSTEMS_ICC__)
+#pragma location=".dbghdr"
+#elif defined(__GNUC__)
+__attribute__ ((section (".dbghdr")))
+#endif
+#if defined(__SF_DEBUG__)
+const uint32_t Board_debugHeader[] = {
+    0x5AA5A55A,
+    0x000FF800,
+    0xEFA3247D
+};
+#elif defined (__SF_NODEBUG__)
+const uint32_t Board_debugHeader[] = {
+    0xFFFFFFFF,
+    0xFFFFFFFF,
+    0xFFFFFFFF
+};
+#endif
+#endif
diff --git a/sample/CC3220SF_LAUNCHXL/CC3220SF_LAUNCHXL.h b/sample/CC3220SF_LAUNCHXL/CC3220SF_LAUNCHXL.h
new file mode 100644 (file)
index 0000000..d33152f
--- /dev/null
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2016-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** ============================================================================
+ *  @file       C3220SF_LAUNCHXL.h
+ *
+ *  @brief      CC3220 Board Specific APIs
+ *
+ *  The CC3220SF_LAUNCHXL header file should be included in an application as
+ *  follows:
+ *  @code
+ *  #include <CC3220SF_LAUNCHXL.h>
+ *  @endcode
+ *
+ *  ============================================================================
+ */
+#ifndef __CC3220SF_LAUNCHXL_H
+#define __CC3220SF_LAUNCHXL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CC3220SF_LAUNCHXL_GPIO_LED_OFF (0)
+#define CC3220SF_LAUNCHXL_GPIO_LED_ON  (1)
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_ADCName
+ *  @brief  Enum of ADC names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_ADCName {
+    CC3220SF_LAUNCHXL_ADC0 = 0,
+    CC3220SF_LAUNCHXL_ADC1,
+
+    CC3220SF_LAUNCHXL_ADCCOUNT
+} CC3220SF_LAUNCHXL_ADCName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_CaptureName
+ *  @brief  Enum of Capture names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_CaptureName {
+    CC3220SF_LAUNCHXL_CAPTURE0 = 0,
+    CC3220SF_LAUNCHXL_CAPTURE1,
+
+    CC3220SF_LAUNCHXL_CAPTURECOUNT
+} CC3220SF_LAUNCHXL_CaptureName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_CryptoName
+ *  @brief  Enum of Crypto names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_CryptoName {
+    CC3220SF_LAUNCHXL_CRYPTO0 = 0,
+
+    CC3220SF_LAUNCHXL_CRYPTOCOUNT
+} CC3220SF_LAUNCHXL_CryptoName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_GPIOName
+ *  @brief  Enum of GPIO names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_GPIOName {
+    CC3220SF_LAUNCHXL_GPIO_SW2 = 0,
+    CC3220SF_LAUNCHXL_GPIO_SW3,
+    CC3220SF_LAUNCHXL_SPI_MASTER_READY,
+    CC3220SF_LAUNCHXL_SPI_SLAVE_READY,
+    CC3220SF_LAUNCHXL_GPIO_LED_D7,
+
+    /*
+     *  CC3220SF_LAUNCHXL_GPIO_LED_D5 and CC3220SF_LAUNCHXL_GPIO_LED_D6 are shared with the
+     *  I2C and PWM peripherals. In order for those examples to work, these
+     *  LEDs are  taken out of gpioPinCOnfig[]
+     */
+    /* CC3220SF_LAUNCHXL_GPIO_LED_D6, */
+    /* CC3220SF_LAUNCHXL_GPIO_LED_D5, */
+
+    /* Sharp 96x96 LCD Pins */
+    CC3220SF_LAUNCHXL_LCD_CS,
+    CC3220SF_LAUNCHXL_LCD_POWER,
+    CC3220SF_LAUNCHXL_LCD_ENABLE,
+
+    CC3220SF_LAUNCHXL_GPIOCOUNT
+} CC3220SF_LAUNCHXL_GPIOName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_I2CName
+ *  @brief  Enum of I2C names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_I2CName {
+    CC3220SF_LAUNCHXL_I2C0 = 0,
+
+    CC3220SF_LAUNCHXL_I2CCOUNT
+} CC3220SF_LAUNCHXL_I2CName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_I2SName
+ *  @brief  Enum of I2S names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_I2SName {
+    CC3220SF_LAUNCHXL_I2S0 = 0,
+
+    CC3220SF_LAUNCHXL_I2SCOUNT
+} CC3220SF_LAUNCHXL_I2SName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_PWMName
+ *  @brief  Enum of PWM names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_PWMName {
+    CC3220SF_LAUNCHXL_PWM6 = 0,
+    CC3220SF_LAUNCHXL_PWM7,
+
+    CC3220SF_LAUNCHXL_PWMCOUNT
+} CC3220SF_LAUNCHXL_PWMName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_SDFatFSName
+ *  @brief  Enum of SDFatFS names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_SDFatFSName {
+    CC3220SF_LAUNCHXL_SDFatFS0 = 0,
+
+    CC3220SF_LAUNCHXL_SDFatFSCOUNT
+} CC3220SF_LAUNCHXL_SDFatFSName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_SDName
+ *  @brief  Enum of SD names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_SDName {
+    CC3220SF_LAUNCHXL_SD0 = 0,
+
+    CC3220SF_LAUNCHXL_SDCOUNT
+} CC3220SF_LAUNCHXL_SDName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_SPIName
+ *  @brief  Enum of SPI names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_SPIName {
+    CC3220SF_LAUNCHXL_SPI0 = 0,
+    CC3220SF_LAUNCHXL_SPI1,
+
+    CC3220SF_LAUNCHXL_SPICOUNT
+} CC3220SF_LAUNCHXL_SPIName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_TimerName
+ *  @brief  Enum of Timer names on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_TimerName {
+    CC3220SF_LAUNCHXL_TIMER0 = 0,
+    CC3220SF_LAUNCHXL_TIMER1,
+    CC3220SF_LAUNCHXL_TIMER2,
+
+    CC3220SF_LAUNCHXL_TIMERCOUNT
+} CC3220SF_LAUNCHXL_TimerName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_UARTName
+ *  @brief  Enum of UARTs on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_UARTName {
+    CC3220SF_LAUNCHXL_UART0 = 0,
+    CC3220SF_LAUNCHXL_UART1,
+
+    CC3220SF_LAUNCHXL_UARTCOUNT
+} CC3220SF_LAUNCHXL_UARTName;
+
+/*!
+ *  @def    CC3220SF_LAUNCHXL_WatchdogName
+ *  @brief  Enum of Watchdogs on the CC3220SF_LAUNCHXL dev board
+ */
+typedef enum CC3220SF_LAUNCHXL_WatchdogName {
+    CC3220SF_LAUNCHXL_WATCHDOG0 = 0,
+
+    CC3220SF_LAUNCHXL_WATCHDOGCOUNT
+} CC3220SF_LAUNCHXL_WatchdogName;
+
+/*!
+ *  @brief  Initialize the general board specific settings
+ *
+ *  This function initializes the general board specific settings.
+ */
+extern void CC3220SF_LAUNCHXL_initGeneral(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CC3220SF_LAUNCHXL_H */
diff --git a/sample/CC3220SF_LAUNCHXL/network.c b/sample/CC3220SF_LAUNCHXL/network.c
new file mode 100644 (file)
index 0000000..9fdb03b
--- /dev/null
@@ -0,0 +1,387 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdbool.h>
+
+#include <ti/net/slnetsock.h>
+#include <ti/net/slnetif.h>
+#include <ti/net/slnetutils.h>
+
+#include <ti/drivers/GPIO.h>
+
+#include <ti/drivers/net/wifi/netapp.h>
+#include <ti/drivers/net/wifi/simplelink.h>
+#include <ti/drivers/net/wifi/slnetifwifi.h>
+#include <ti/drivers/net/wifi/wlan.h>
+
+#include <semaphore.h>
+#include <unistd.h>
+
+#include "Board.h"
+#include "wificonfig.h"
+
+/* Network interface priority and name */
+#define SLNET_IF_WIFI_PRIO (5)
+#define SLNET_IF_WIFI_NAME "CC32XX"
+
+static uint32_t deviceConnected = false;
+static uint32_t ipAcquired = false;
+static uint32_t currButton;
+static uint32_t prevButton;
+
+static sem_t sem;
+
+extern void startSNTP(void);
+
+static void initWiFi();
+
+/*
+ *  ======== Network_init =======
+ */
+void Network_init()
+{
+    if (sem_init(&sem, 0, 0) != 0) {
+        /* Error: sem_init failed */
+        while (1);
+    }
+}
+
+/*
+ *  ======== Network_startup =======
+ */
+void Network_startup()
+{
+    int32_t status;
+
+    /* Connect to the Access Point */
+    initWiFi();
+
+    /* Wait for the network stack to initialize and acquire an IP address */
+    sem_wait(&sem);
+
+    /* The network stack is ready. Initialize the socket layer */
+    status = SlNetSock_init(0);
+    if (status != 0) {
+        /* SlNetSock_init failed */
+        while (1);
+    }
+
+    status = SlNetIf_init(0);
+    if (status != 0) {
+        /* SlNetIf_init failed */
+        while (1);
+    }
+
+    status = SlNetUtil_init(0);
+    if (status != 0) {
+        /* SlNetUtil_init failed */
+        while (1);
+    }
+
+    /* Register the WiFi interface with the socket layer */
+    status = SlNetIf_add(SLNETIF_ID_1, SLNET_IF_WIFI_NAME,
+            (const SlNetIf_Config_t *)&SlNetIfConfigWifi, SLNET_IF_WIFI_PRIO);
+    if (status != 0) {
+        /* SlNetIf_add failed */
+        while (1);
+    }
+
+    /* Turn LED OFF. It will be used as a connection indicator */
+    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
+
+    /* Use SNTP to get the current time, as needed for SSL authentication */
+    startSNTP();
+
+    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
+}
+
+/*
+ *  ======== Network_exit =======
+ */
+void Network_exit()
+{
+}
+
+/*
+ *
+ *  SimpleLink Asynchronous Event Handlers -- Start
+ *
+ */
+
+/*
+ *  ======== SimpleLinkHttpServerEventHandler ========
+ */
+void SimpleLinkHttpServerEventHandler(
+        SlNetAppHttpServerEvent_t *pSlHttpServerEvent,
+        SlNetAppHttpServerResponse_t *pSlHttpServerResponse)
+{
+}
+
+/*
+ *  ======== SimpleLinkNetAppRequestEventHandler ========
+ */
+void SimpleLinkNetAppRequestEventHandler(SlNetAppRequest_t *pNetAppRequest,
+        SlNetAppResponse_t *pNetAppResponse)
+{
+}
+
+/*
+ *  ======== SimpleLinkNetAppRequestMemFreeEventHandler ========
+ */
+void SimpleLinkNetAppRequestMemFreeEventHandler(uint8_t *buffer)
+{
+}
+
+/*
+ *  ======== SimpleLinkWlanEventHandler ========
+ *  SimpleLink Host Driver callback for handling WLAN connection or
+ *  disconnection events.
+ */
+void SimpleLinkWlanEventHandler(SlWlanEvent_t *pArgs)
+{
+    switch (pArgs->Id) {
+        case SL_WLAN_EVENT_CONNECT:
+            deviceConnected = true;
+            break;
+
+        case SL_WLAN_EVENT_DISCONNECT:
+            deviceConnected = false;
+            break;
+
+        default:
+            break;
+    }
+}
+
+/*
+ *  ======== SimpleLinkFatalErrorEventHandler ========
+ *  This function handles fatal errors
+ *
+ *  \param[in]  slFatalErrorEvent - Pointer to the fatal error event info
+ *
+ *  \return     None
+ */
+void SimpleLinkFatalErrorEventHandler(SlDeviceFatal_t *slFatalErrorEvent)
+{
+    switch (slFatalErrorEvent->Id) {
+        case SL_DEVICE_EVENT_FATAL_DEVICE_ABORT:
+            /* FATAL ERROR: Abort NWP event detected */
+            while (1);
+
+        case SL_DEVICE_EVENT_FATAL_DRIVER_ABORT:
+            /* FATAL ERROR: Driver Abort detected */
+            while (1);
+
+        case SL_DEVICE_EVENT_FATAL_NO_CMD_ACK:
+            /* FATAL ERROR: No Cmd Ack detected */
+            while (1);
+
+        case SL_DEVICE_EVENT_FATAL_SYNC_LOSS:
+            /* FATAL ERROR: Sync loss detected */
+            while (1);
+
+        case SL_DEVICE_EVENT_FATAL_CMD_TIMEOUT:
+            /* FATAL ERROR: Async event timeout detected */
+            while (1);
+
+        default:
+            /* FATAL ERROR: Unspecified error detected */
+            while (1);
+    }
+}
+
+/*
+ *  ======== SimpleLinkNetAppEventHandler ========
+ *  SimpleLink Host Driver callback for asynchoronous IP address events.
+ */
+void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent)
+{
+    if (pNetAppEvent == NULL) {
+        return;
+    }
+
+    switch (pNetAppEvent->Id) {
+        case SL_NETAPP_EVENT_IPV4_ACQUIRED:
+        case SL_NETAPP_EVENT_IPV6_ACQUIRED:
+            ipAcquired = true;
+
+            /*  Signal that the WiFi stack is ready and has an IP address */
+            sem_post(&sem);
+
+            break;
+
+        default:
+            break;
+    }
+}
+
+/*
+ *  ======== SimpleLinkSockEventHandler ========
+ */
+void SimpleLinkSockEventHandler(SlSockEvent_t *pArgs)
+{
+}
+
+/*
+ *  ======== SimpleLinkGeneralEventHandler ========
+ */
+void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *sockEvent)
+{
+}
+
+/*
+ *  ======== smartConfigFxn ========
+ */
+void smartConfigFxn()
+{
+    uint8_t policyVal;
+
+    /* Set auto connect policy */
+    sl_WlanPolicySet(SL_WLAN_POLICY_CONNECTION,
+            SL_WLAN_CONNECTION_POLICY(1, 0, 0, 0), &policyVal,
+            sizeof(policyVal));
+
+    /* Start SmartConfig using unsecured method. */
+    sl_WlanProvisioning(SL_WLAN_PROVISIONING_CMD_START_MODE_SC, ROLE_STA, 30,
+            NULL, 0);
+}
+
+/*
+ *  ======== setStationMode ========
+ *  Sets the SimpleLink Wi-Fi in station mode and enables DHCP client
+ */
+void setStationMode(void)
+{
+    int           mode;
+    int           response;
+
+    mode = sl_Start(0, 0, 0);
+    if (mode < 0) {
+        /* sl_Start error: Could not initialize SimpleLink Wi-Fi */
+        while(1);
+    }
+
+    /* Change network processor to station mode */
+    if (mode != ROLE_STA) {
+        sl_WlanSetMode(ROLE_STA);
+
+        /* Restart network processor */
+        sl_Stop(200);
+        mode = sl_Start(0, 0, 0);
+        if (mode < 0) {
+            /* Error: Failed to set SimpleLink Wi-Fi to Station mode */
+            while(1);
+        }
+    }
+
+    sl_WlanDisconnect();
+    /* Set auto connect policy */
+    response = sl_WlanPolicySet(SL_WLAN_POLICY_CONNECTION,
+            SL_WLAN_CONNECTION_POLICY(1, 0, 0, 0), NULL, 0);
+    if (response < 0) {
+        /* Error: Failed to set connection policy to auto connect */
+        while (1);
+    }
+
+    /* Enable DHCP client */
+    response = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE, SL_NETCFG_ADDR_DHCP,
+            0, 0);
+
+    if (response < 0) {
+        /* Error: Could not enable DHCP client */
+        while (1);
+    }
+
+    sl_Stop(200);
+
+    /* Set connection variables to initial values */
+    deviceConnected = false;
+    ipAcquired = false;
+}
+
+/*
+ *  ======== wlanConnect =======
+ *  Secure connection parameters
+ */
+static int wlanConnect()
+{
+    SlWlanSecParams_t secParams = {0};
+    int ret = 0;
+
+    secParams.Key = (signed char *)SECURITY_KEY;
+    secParams.KeyLen = strlen((const char *)secParams.Key);
+    secParams.Type = SECURITY_TYPE;
+
+    ret = sl_WlanConnect((signed char*)SSID, strlen((const char*)SSID),
+            NULL, &secParams, NULL);
+
+    return (ret);
+}
+
+/*
+ *  ======== initWiFi =======
+ *  Start the NWP and connect to AP
+ */
+static void initWiFi()
+{
+    setStationMode();
+
+    /* Host driver starts the network processor */
+    if (sl_Start(NULL, NULL, NULL) < 0) {
+        /* Error: Could not initialize WiFi */
+        while (1);
+    }
+
+    if (wlanConnect() < 0) {
+        /* Error: Could not connect to WiFi AP */
+        while (1);
+    }
+
+    /*
+     * Wait for the WiFi to connect to an AP. If a profile for the AP in
+     * use has not been stored yet, press Board_GPIO_BUTTON0 to start
+     * SmartConfig.
+     */
+    while ((deviceConnected != true) || (ipAcquired != true)) {
+        /*
+         *  Start SmartConfig if a button is pressed. This could be done with
+         *  GPIO interrupts, but for simplicity polling is used to check the
+         *  button.
+         */
+        currButton = GPIO_read(Board_GPIO_BUTTON0);
+        if ((currButton == 0) && (prevButton != 0)) {
+            smartConfigFxn();
+        }
+        prevButton = currButton;
+        usleep(50000);
+    }
+}
diff --git a/sample/CC3220SF_LAUNCHXL/network.h b/sample/CC3220SF_LAUNCHXL/network.h
new file mode 100644 (file)
index 0000000..c46de50
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __Network_H
+#define __Network_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <stdint.h>
+
+/*
+ *  ======== Network_init =======
+ *  Initialize the Network module
+ */
+void Network_init();
+
+/*
+ *  ======== Network_startup =======
+ *  Wait for IP address, initialize the socket layer, get time via SNTP
+ */
+void Network_startup();
+
+/*
+ *  ======== Network_exit =======
+ *  Finalize the module
+ */
+void Network_exit();
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/sample/CC3220SF_LAUNCHXL/startsntp.c b/sample/CC3220SF_LAUNCHXL/startsntp.c
new file mode 100644 (file)
index 0000000..8c9efe8
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <ti/net/sntp/sntp.h>
+
+#include <ti/drivers/net/wifi/simplelink.h>
+
+/*
+ * Difference between NTP Epoch (seconds since January 1, 1900 GMT) and UNIX
+ * Epoch (seconds since January 1, 1970 GMT)
+ */
+#define TIME_BASEDIFF ((((uint32_t)70 * 365 + 17) * 24 * 3600))
+
+#define TIME_NTP_TO_UNIX(t) ((t) - TIME_BASEDIFF)
+
+#define NTP_SERVERS 1
+#define NTP_SERVER_PORT 123
+
+/*  Time to wait for reply from server (seconds) */
+#define NTP_REPLY_WAIT_TIME 5
+
+/* Must wait at least 15 sec to retry NTP server (RFC 4330) */
+#define NTP_POLL_TIME 15
+
+/*
+ *  ======== setNwpTime ========
+ *  Set the time on the network processor
+ *
+ *  ts: time in seconds since the Epoch
+ */
+static void setNwpTime(time_t ts)
+{
+    SlDateTime_t dt;
+    struct tm tm;
+
+    /* Convert time since Epoch to local time */
+    tm = *localtime(&ts);
+
+    /* Set system clock on network processor to validate certificate */
+    dt.tm_day  = tm.tm_mday;
+    /* tm.tm_mon is the month since January, so add 1 to get the actual month */
+    dt.tm_mon  = tm.tm_mon + 1;
+    /* tm.tm_year is the year since 1900, so add 1900 to get the actual year */
+    dt.tm_year = tm.tm_year + 1900;
+    dt.tm_hour = tm.tm_hour;
+    dt.tm_min  = tm.tm_min;
+    dt.tm_sec  = tm.tm_sec;
+    sl_DeviceSet(SL_DEVICE_GENERAL, SL_DEVICE_GENERAL_DATE_TIME,
+            sizeof(SlDateTime_t), (unsigned char *)(&dt));
+}
+
+/*
+ *  ======== startSNTP ========
+ */
+void startSNTP(void)
+{
+    uint64_t ntpTimeStamp;
+    uint32_t currentTimeNtp = 0;
+    uint32_t currentTimeUnix = 0;
+    int32_t retval;
+    time_t ts;
+    SlNetSock_Timeval_t timeval;
+    struct timespec tspec;
+
+    /* Set timeout value for NTP server reply */
+    timeval.tv_sec = NTP_REPLY_WAIT_TIME;
+    timeval.tv_usec = 0;
+
+    do {
+        /* Get the time using the built in NTP server list: */
+        retval = SNTP_getTime(NULL, 0, &timeval, &ntpTimeStamp);
+        if (retval != 0) {
+            printf(
+                "startSNTP: couldn't get time (%ld), will retry in %d secs ...\n",
+                retval, NTP_POLL_TIME);
+            sleep(NTP_POLL_TIME);
+            printf("startSNTP: retrying ...\n");
+        }
+
+        /* Save the current (NTP Epoch based) time */
+        currentTimeNtp = ntpTimeStamp >> 32;
+
+    } while (retval < 0);
+
+    /*
+     * Set the time on the application processor. Always pass a time value
+     * based on the UNIX Epoch
+     */
+    currentTimeUnix = TIME_NTP_TO_UNIX(currentTimeNtp);
+    tspec.tv_nsec = 0;
+    tspec.tv_sec = currentTimeUnix;
+    if (clock_settime(CLOCK_REALTIME, &tspec) != 0) {
+        printf("startSNTP: Failed to set current time\n");
+        while(1);
+    }
+
+    /*
+     * Use time.h APIs to set the time on the NWP and display it on the console.
+     * Must call time.h APIs using the appropriate (toolchain dependent) Epoch
+     * time base
+     */
+#if defined(__TI_COMPILER_VERSION__)
+    /* For the TI toolchain, time APIs expect times based on the NTP Epoch */
+    ts = currentTimeNtp;
+#else
+    /* Time APIs for GCC and IAR expect times based on the UNIX Epoch */
+    ts = currentTimeUnix;
+#endif
+
+    /* Set the time on the network processor */
+    setNwpTime(ts);
+
+    /* Print out the time in calendar format: */
+    printf("Current time: %s\n", ctime(&ts));
+}
diff --git a/sample/CC3220SF_LAUNCHXL/tirtos/ccs/CC3220SF_LAUNCHXL_TIRTOS.cmd b/sample/CC3220SF_LAUNCHXL/tirtos/ccs/CC3220SF_LAUNCHXL_TIRTOS.cmd
new file mode 100644 (file)
index 0000000..48ccfab
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== CC3220SF_LAUNCHXL.cmd ========
+ */
+
+/*
+ * The starting address of the application.  Normally the interrupt vectors
+ * must be located at the beginning of the application.
+ */
+#define SRAM_BASE   0x20000000
+#define FLASH_BASE  0x01000800
+
+--stack_size=1024   /* C stack is also used for ISR stack */
+
+HEAPSIZE = 0x8000;  /* Size of heap buffer used by HeapMem */
+
+MEMORY
+{
+    /* Bootloader uses FLASH_HDR during initialization */
+    FLASH_HDR (RX)  : origin = 0x01000000, length = 0x7FF      /* 2 KB */
+    FLASH     (RX)  : origin = 0x01000800, length = 0x0FF800   /* 1022KB */
+    SRAM      (RWX) : origin = 0x20000000, length = 0x00040000 /* 256KB */
+}
+
+/* Section allocation in memory */
+
+SECTIONS
+{
+    .dbghdr     : > FLASH_HDR
+    .text       : > FLASH
+    .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
+    .const      : > FLASH
+    .cinit      : > FLASH
+    .pinit      : > FLASH
+    .init_array : > FLASH
+
+    .data       : > SRAM
+    .bss        : > SRAM
+    .sysmem     : > SRAM
+
+    /* Heap buffer used by HeapMem */
+    .priheap   : {
+        __primary_heap_start__ = .;
+        . += HEAPSIZE;
+        __primary_heap_end__ = .;
+    } > SRAM align 8
+
+    .stack      : > SRAM(HIGH)
+}
diff --git a/sample/CC3220SF_LAUNCHXL/tirtos/ccs/makedefs b/sample/CC3220SF_LAUNCHXL/tirtos/ccs/makedefs
new file mode 100644 (file)
index 0000000..9909eb7
--- /dev/null
@@ -0,0 +1,24 @@
+CODEGEN_INSTALLATION_DIR = $(ti.targets.arm.elf.M4)
+CC = $(ti.targets.arm.elf.M4)/bin/armcl
+LD = $(ti.targets.arm.elf.M4)/bin/armcl -z
+
+KERNEL_BUILD :=  $(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/kernel/tirtos/builds/CC3220SF_LAUNCHXL/release
+
+CONFIGPKG = $(KERNEL_BUILD)/ccs
+
+CFLAGS = -eo=.o -mv7M4 --float_support=vfplib --abi=eabi -me -ms --c99 "-I$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source" "-I$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/posix/ccs" -DSL_FULL -DSL_PLATFORM_MULTI_THREADED -DNET_SL --silicon_version=7M4 --code_state=16 --little_endian --display_error_number --diag_warning=255 --diag_wrap=off --gen_func_subsections=on --float_support=vfplib --symdebug:dwarf
+
+LFLAGS = "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/net/sntp/lib/ccs/m4/sntp_release.a" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/net/lib/ccs/m4/slnetsock_release.a" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/net/http/lib/ccs/m4/httpclient_release.a" -l"$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/drivers/net/wifi/ccs/rtos/simplelink.a" -l"$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/drivers/net/wifi/slnetif/ccs/Release/slnetifwifi.a" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/drivers/lib/drivers_cc32xx.aem4" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/kernel/tirtos/packages/ti/dpl/lib/dpl_cc32xx.aem4" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/devices/cc32xx/driverlib/ccs/Release/driverlib.a" --rom_model --warn_sections -i$(CODEGEN_INSTALLATION_DIR)/lib --reread_libs -llibc.a
+
+%.o : %.c
+       $(CC) $(CFLAGS) -c $<
+
+ifneq (,$(wildcard $(XDC_INSTALL_DIR)/xdc.exe))
+    # use these on Windows
+    RM      = $(XDC_INSTALL_DIR)/bin/rm -f
+    RMDIR   = $(XDC_INSTALL_DIR)/bin/rm -rf
+else
+    # use these on Linux
+    RM      = rm -f
+    RMDIR   = rm -rf
+endif
diff --git a/sample/CC3220SF_LAUNCHXL/tirtos/ccs/makefile b/sample/CC3220SF_LAUNCHXL/tirtos/ccs/makefile
new file mode 100644 (file)
index 0000000..828aa89
--- /dev/null
@@ -0,0 +1,67 @@
+#
+#  Copyright (c) 2017-2018, Texas Instruments Incorporated
+#  All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#  *  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#
+#  *  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+#  *  Neither the name of Texas Instruments Incorporated nor the names of
+#     its contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+#  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+#  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+#  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+TREE_ROOT = ../../../..
+include $(TREE_ROOT)/build_all/products.mak
+include makedefs
+
+CFLAGS :=  -I../.. -I../../.. -I$(TREE_ROOT)/sdk/inc/ -I$(TREE_ROOT)/sdk/certs/ -I$(TREE_ROOT)/sdk/c-utility/inc/ -I$(TREE_ROOT)/sdk/c-utility/inc/azure_c_shared_utility -I$(TREE_ROOT)/sdk/iothub_client/inc -I$(TREE_ROOT)/sdk/serializer/inc -g $(CFLAGS) --cmd_file=$(CONFIGPKG)/compiler.opt
+
+LIBS =  $(TREE_ROOT)/build_all/sdk/lib/ccs/m4/common_sl_release.a \
+    $(TREE_ROOT)/build_all/sdk/lib/ccs/m4/iotclient_sl_release.a \
+    $(TREE_ROOT)/build_all/sdk/lib/ccs/m4/serializer_sl_release.a \
+    $(TREE_ROOT)/build_all/pal/lib/ccs/m4/pal_sl_release.a
+
+VPATH = ..:../..:../../..:$(TREE_ROOT)/sdk/certs
+
+%.o : %.c
+
+%.o : %.c $(CONFIGPKG)/compiler.opt
+       @echo $(CC) $(CFLAGS) -c $<
+       @$(CC) $(CFLAGS) -c $<
+
+all: simplesample_http.out
+
+$(CONFIGPKG)/linker.cmd $(CONFIGPKG)/compiler.opt:
+       @ echo
+       $(error "$(CONFIGPKG) is not built. You can build it by issuing \
+            $(MAKE) in $(CONFIGPKG).")
+       @ echo
+
+simplesample_http.out: main_tirtos.o certs.o startsntp.o simplesample_http.o network.o CC3220SF_LAUNCHXL.o CC3220SF_LAUNCHXL_TIRTOS.cmd $(CONFIGPKG)/linker.cmd $(LIBS)
+       @echo building $@ ..
+       @$(LD) -o $@ $^ -x -m $@.map $(LFLAGS)
+
+clean:
+       @echo cleaning ..
+       @ $(RM) *.o *.out *.map
+       @ $(RMDIR)
diff --git a/sample/CC3220SF_LAUNCHXL/tirtos/main_tirtos.c b/sample/CC3220SF_LAUNCHXL/tirtos/main_tirtos.c
new file mode 100644 (file)
index 0000000..74f8345
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ *  ======== main_tirtos.c ========
+ */
+#include <stdio.h>
+
+#include <ti/sysbios/BIOS.h>
+
+#include <ti/drivers/GPIO.h>
+#include <ti/drivers/SPI.h>
+
+#include <ti/drivers/net/wifi/simplelink.h>
+
+#include <pthread.h>
+
+#include <simplesample_http.h>
+
+#include <ti/net/slnetsock.h>
+#include <ti/net/slnetif.h>
+
+#include "Board.h"
+#include "certs.h"
+#include "network.h"
+
+#define AZURE_IOT_ROOT_CA_FILENAME "/cert/ms.pem"
+/*
+ * The following macro is disabled by default. This is done to prevent the
+ * certificate files from being written to flash every time the program
+ * is run.  If an update to the cert files are needed, just update the
+ * corresponding arrays, and rebuild with this macro defined. Note
+ * you must remember to disable it otherwise the files will keep being
+ * overwritten each time.
+ */
+#ifdef OVERWRITE_CERTS
+static bool overwriteCerts = true;
+#else
+static bool overwriteCerts = false;
+#endif
+
+/*
+ *  ======== flashFile ========
+ *  Flashes file to the SFLASH using SimpleLink WiFi APIs
+ *
+ *  Returns number of bytes written on success or < 0 on failure
+ */
+int flashFile(const char *path, const uint8_t *buffer, uint32_t len)
+{
+    int32_t ret = -1;
+    int32_t fileHandle;
+
+    if (path && buffer) {
+        fileHandle = sl_FsOpen((unsigned char *)path,
+                SL_FS_CREATE | SL_FS_CREATE_SECURE | SL_FS_CREATE_NOSIGNATURE
+                | SL_FS_CREATE_PUBLIC_WRITE | SL_FS_OVERWRITE
+                | SL_FS_CREATE_MAX_SIZE(len), NULL);
+        if (fileHandle > 0) {
+            ret = sl_FsWrite(fileHandle, 0, (unsigned char *)buffer, len);
+            sl_FsClose(fileHandle, NULL, NULL, 0);
+        }
+    }
+
+    return (ret);
+}
+
+/*
+ *  ======== flashCerts ========
+ *  Utility function to flash the contents of a buffer (PEM format) into the
+ *  filename/path specified by certName
+ */
+void flashCerts(uint8_t *certName, uint8_t *buffer, uint32_t bufflen)
+{
+    int status = 0;
+    int16_t slStatus = 0;
+    SlFsFileInfo_t fsFileInfo;
+
+    /* Check if the cert file already exists */
+    slStatus = sl_FsGetInfo(certName, 0, &fsFileInfo);
+
+    /* If the cert doesn't exist, write it (or overwrite if specified to) */
+    if (slStatus == SL_ERROR_FS_FILE_NOT_EXISTS || overwriteCerts == true) {
+
+        printf("Flashing certificate file ...");
+
+        status = flashFile((const char *)certName, buffer, bufflen);
+
+        if (status < 0) {
+            printf("Error: Could not write file %s to flash (%d)\n",
+                    certName, status);
+            while (1);
+        }
+        printf("successfully wrote file %s to flash\n", certName);
+    }
+}
+
+/*
+ *  ======== azureThreadFxn ========
+ */
+void *azureThreadFxn(void *arg0)
+{
+    SlNetCfgIpV4Args_t ipV4;
+    uint16_t           len = sizeof(ipV4);
+    uint16_t           dhcpIsOn;
+
+    printf("Starting the simplesample_http example\n");
+
+    /* Wait for an IP address, initialize the socket layer and get the time */
+    Network_startup();
+
+    /* Retrieve & print the IP address */
+    sl_NetCfgGet(SL_NETCFG_IPV4_STA_ADDR_MODE, &dhcpIsOn, &len,
+            (unsigned char *)&ipV4);
+    printf("CC32XX has connected to AP and acquired an IP address.\n");
+    printf("IP Address: %ld.%ld.%ld.%ld\n", SL_IPV4_BYTE(ipV4.Ip, 3),
+            SL_IPV4_BYTE(ipV4.Ip, 2), SL_IPV4_BYTE(ipV4.Ip, 1),
+            SL_IPV4_BYTE(ipV4.Ip, 0));
+
+    /* Flash Certificate Files */
+    flashCerts((uint8_t *)AZURE_IOT_ROOT_CA_FILENAME, (uint8_t *)certificates,
+            strlen(certificates));
+
+    simplesample_http_run();
+
+    return (NULL);
+}
+
+/*
+ *  ======== main ========
+ */
+int main(int argc, char *argv[])
+{
+    pthread_attr_t pthreadAttrs;
+    pthread_t slThread;
+    pthread_t azureThread;
+    int status;
+
+    Board_initGeneral();
+    GPIO_init();
+    SPI_init();
+    Network_init();
+
+    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
+
+    /* Create the sl_Task thread */
+    pthread_attr_init(&pthreadAttrs);
+
+    status = pthread_attr_setstacksize(&pthreadAttrs, 2048);
+    if (status != 0) {
+        /* Error setting stack size */
+        while (1);
+    }
+
+    status = pthread_create(&slThread, &pthreadAttrs, sl_Task, NULL);
+    if (status != 0) {
+        /* Failed to create sl_Task thread */
+        while (1);
+    }
+
+    /* Create the AZURE thread */
+    status = pthread_attr_setstacksize(&pthreadAttrs, 4096);
+    if (status != 0) {
+        /* Error setting stack size */
+        while (1);
+    }
+
+    status = pthread_create(&azureThread, &pthreadAttrs, azureThreadFxn, NULL);
+    if (status != 0) {
+        /* Failed to create Azure thread */
+        while (1);
+    }
+
+    pthread_attr_destroy(&pthreadAttrs);
+
+    BIOS_start();
+
+    return (0);
+}
diff --git a/sample/CC3220SF_LAUNCHXL/wificonfig.h b/sample/CC3220SF_LAUNCHXL/wificonfig.h
new file mode 100644 (file)
index 0000000..30abbbc
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef WIFICONFIG_H
+#define WIFICONFIG_H
+
+/* USER STEP: Update these macros */
+#define SSID ""
+#define SECURITY_KEY ""
+#define SECURITY_TYPE SL_WLAN_SEC_TYPE_WPA
+
+#endif
diff --git a/sample/CC3220S_LAUNCHXL/Board.h b/sample/CC3220S_LAUNCHXL/Board.h
new file mode 100644 (file)
index 0000000..b0d0db6
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2016-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __BOARD_H
+#define __BOARD_H
+
+#define Board_CC3220S_LAUNCHXL
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "CC3220S_LAUNCHXL.h"
+
+#define Board_initGeneral            CC3220S_LAUNCHXL_initGeneral
+
+/* These #defines allow us to reuse TI-RTOS across other device families */
+
+#define Board_ADC0                   CC3220S_LAUNCHXL_ADC0
+#define Board_ADC1                   CC3220S_LAUNCHXL_ADC1
+
+#define Board_CAPTURE0               CC3220S_LAUNCHXL_CAPTURE0
+#define Board_CAPTURE1               CC3220S_LAUNCHXL_CAPTURE1
+
+#define Board_CRYPTO0                CC3220S_LAUNCHXL_CRYPTO0
+
+#define Board_GPIO_LED_ON            CC3220S_LAUNCHXL_GPIO_LED_ON
+#define Board_GPIO_LED_OFF           CC3220S_LAUNCHXL_GPIO_LED_OFF
+#define Board_GPIO_LED0              CC3220S_LAUNCHXL_GPIO_LED_D7
+/*
+ *  CC3220S_LAUNCHXL_GPIO_LED_D5 and CC3220S_LAUNCHXL_GPIO_LED_D6 are shared with the I2C
+ *  and PWM peripherals. In order for those examples to work, these LEDs are
+ *  taken out of gpioPinCOnfig[]
+ */
+#define Board_GPIO_LED1              CC3220S_LAUNCHXL_GPIO_LED_D7
+#define Board_GPIO_LED2              CC3220S_LAUNCHXL_GPIO_LED_D7
+
+#define Board_GPIO_BUTTON0           CC3220S_LAUNCHXL_GPIO_SW2
+#define Board_GPIO_BUTTON1           CC3220S_LAUNCHXL_GPIO_SW3
+
+#define Board_I2C0                   CC3220S_LAUNCHXL_I2C0
+#define Board_I2C_TMP                CC3220S_LAUNCHXL_I2C0
+
+#define Board_I2S0                   CC3220S_LAUNCHXL_I2S0
+
+#define Board_PWM0                   CC3220S_LAUNCHXL_PWM6
+#define Board_PWM1                   CC3220S_LAUNCHXL_PWM7
+
+#define Board_SD0                    CC3220S_LAUNCHXL_SD0
+
+#define Board_SDFatFS0               CC3220S_LAUNCHXL_SD0
+
+/* CC3220S_LAUNCHXL_SPI0 is reserved for the NWP */
+#define Board_SPI0                   CC3220S_LAUNCHXL_SPI1
+
+#define Board_SPI_MASTER             CC3220S_LAUNCHXL_SPI1
+#define Board_SPI_SLAVE              CC3220S_LAUNCHXL_SPI1
+#define Board_SPI_MASTER_READY       CC3220S_LAUNCHXL_SPI_MASTER_READY
+#define Board_SPI_SLAVE_READY        CC3220S_LAUNCHXL_SPI_SLAVE_READY
+
+#define Board_TIMER0                 CC3220S_LAUNCHXL_TIMER0
+#define Board_TIMER1                 CC3220S_LAUNCHXL_TIMER1
+#define Board_TIMER2                 CC3220S_LAUNCHXL_TIMER2
+
+#define Board_UART0                  CC3220S_LAUNCHXL_UART0
+#define Board_UART1                  CC3220S_LAUNCHXL_UART1
+
+#define Board_WATCHDOG0              CC3220S_LAUNCHXL_WATCHDOG0
+
+/* Board specific I2C addresses */
+#define Board_TMP_ADDR               (0x41)
+#define Board_SENSORS_BP_TMP_ADDR    (0x40)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BOARD_H */
diff --git a/sample/CC3220S_LAUNCHXL/CC3220S_LAUNCHXL.c b/sample/CC3220S_LAUNCHXL/CC3220S_LAUNCHXL.c
new file mode 100644 (file)
index 0000000..00caa76
--- /dev/null
@@ -0,0 +1,829 @@
+/*
+ * Copyright (c) 2016-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== CC3220S_LAUNCHXL.c ========
+ *  This file is responsible for setting up the board specific items for the
+ *  CC3220S_LAUNCHXL board.
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include <ti/devices/cc32xx/inc/hw_ints.h>
+#include <ti/devices/cc32xx/inc/hw_memmap.h>
+#include <ti/devices/cc32xx/inc/hw_types.h>
+
+#include <ti/devices/cc32xx/driverlib/rom.h>
+#include <ti/devices/cc32xx/driverlib/rom_map.h>
+#include <ti/devices/cc32xx/driverlib/adc.h>
+#include <ti/devices/cc32xx/driverlib/gpio.h>
+#include <ti/devices/cc32xx/driverlib/pin.h>
+#include <ti/devices/cc32xx/driverlib/prcm.h>
+#include <ti/devices/cc32xx/driverlib/spi.h>
+#include <ti/devices/cc32xx/driverlib/sdhost.h>
+#include <ti/devices/cc32xx/driverlib/timer.h>
+#include <ti/devices/cc32xx/driverlib/uart.h>
+#include <ti/devices/cc32xx/driverlib/udma.h>
+#include <ti/devices/cc32xx/driverlib/wdt.h>
+
+#include <ti/drivers/Power.h>
+#include <ti/drivers/power/PowerCC32XX.h>
+
+#include "CC3220S_LAUNCHXL.h"
+
+/*
+ *  This define determines whether to use the UARTCC32XXDMA driver
+ *  or the UARTCC32XX (no DMA) driver.  Set to 1 to use the UARTCC32XXDMA
+ *  driver.
+ */
+#ifndef TI_DRIVERS_UART_DMA
+#define TI_DRIVERS_UART_DMA 0
+#endif
+
+/*
+ *  =============================== ADC ===============================
+ */
+#include <ti/drivers/ADC.h>
+#include <ti/drivers/adc/ADCCC32XX.h>
+
+ADCCC32XX_Object adcCC3220SObjects[CC3220S_LAUNCHXL_ADCCOUNT];
+
+const ADCCC32XX_HWAttrsV1 adcCC3220SHWAttrs[CC3220S_LAUNCHXL_ADCCOUNT] = {
+    {
+        .adcPin = ADCCC32XX_PIN_59_CH_2
+    },
+    {
+        .adcPin = ADCCC32XX_PIN_60_CH_3
+    }
+};
+
+const ADC_Config ADC_config[CC3220S_LAUNCHXL_ADCCOUNT] = {
+    {
+        .fxnTablePtr = &ADCCC32XX_fxnTable,
+        .object = &adcCC3220SObjects[CC3220S_LAUNCHXL_ADC0],
+        .hwAttrs = &adcCC3220SHWAttrs[CC3220S_LAUNCHXL_ADC0]
+    },
+    {
+        .fxnTablePtr = &ADCCC32XX_fxnTable,
+        .object = &adcCC3220SObjects[CC3220S_LAUNCHXL_ADC1],
+        .hwAttrs = &adcCC3220SHWAttrs[CC3220S_LAUNCHXL_ADC1]
+    }
+};
+
+const uint_least8_t ADC_count = CC3220S_LAUNCHXL_ADCCOUNT;
+
+/*
+ *  =============================== Capture ===============================
+ */
+#include <ti/drivers/Capture.h>
+#include <ti/drivers/capture/CaptureCC32XX.h>
+
+CaptureCC32XX_Object captureCC3220SObjects[CC3220S_LAUNCHXL_CAPTURECOUNT];
+
+const CaptureCC32XX_HWAttrs captureCC3220SHWAttrs[CC3220S_LAUNCHXL_CAPTURECOUNT] =
+{
+      {
+         .capturePin = CaptureCC32XX_PIN_04,
+         .intPriority = ~0
+      },
+      {
+          .capturePin = CaptureCC32XX_PIN_05,
+          .intPriority = ~0
+      },
+};
+
+const Capture_Config Capture_config[CC3220S_LAUNCHXL_CAPTURECOUNT] = {
+    {
+        .fxnTablePtr = &CaptureCC32XX_fxnTable,
+        .object = &captureCC3220SObjects[CC3220S_LAUNCHXL_CAPTURE0],
+        .hwAttrs = &captureCC3220SHWAttrs[CC3220S_LAUNCHXL_CAPTURE0]
+    },
+    {
+        .fxnTablePtr = &CaptureCC32XX_fxnTable,
+        .object = &captureCC3220SObjects[CC3220S_LAUNCHXL_CAPTURE1],
+        .hwAttrs = &captureCC3220SHWAttrs[CC3220S_LAUNCHXL_CAPTURE1]
+    }
+};
+
+const uint_least8_t Capture_count = CC3220S_LAUNCHXL_CAPTURECOUNT;
+
+/*
+ *  =============================== Crypto ===============================
+ */
+#include <ti/drivers/crypto/CryptoCC32XX.h>
+
+CryptoCC32XX_Object cryptoCC3220SObjects[CC3220S_LAUNCHXL_CRYPTOCOUNT];
+
+const CryptoCC32XX_Config CryptoCC32XX_config[CC3220S_LAUNCHXL_CRYPTOCOUNT] = {
+    {
+        .object = &cryptoCC3220SObjects[CC3220S_LAUNCHXL_CRYPTO0]
+    }
+};
+
+const uint_least8_t CryptoCC32XX_count = CC3220S_LAUNCHXL_CRYPTOCOUNT;
+
+/*
+ *  =============================== DMA ===============================
+ */
+#include <ti/drivers/dma/UDMACC32XX.h>
+
+#if defined(__TI_COMPILER_VERSION__)
+#pragma DATA_ALIGN(dmaControlTable, 1024)
+#elif defined(__IAR_SYSTEMS_ICC__)
+#pragma data_alignment=1024
+#elif defined(__GNUC__)
+__attribute__ ((aligned (1024)))
+#endif
+static tDMAControlTable dmaControlTable[64];
+
+/*
+ *  ======== dmaErrorFxn ========
+ *  This is the handler for the uDMA error interrupt.
+ */
+static void dmaErrorFxn(uintptr_t arg)
+{
+    int status = MAP_uDMAErrorStatusGet();
+    MAP_uDMAErrorStatusClear();
+
+    /* Suppress unused variable warning */
+    (void)status;
+
+    while (1);
+}
+
+UDMACC32XX_Object udmaCC3220SObject;
+
+const UDMACC32XX_HWAttrs udmaCC3220SHWAttrs = {
+    .controlBaseAddr = (void *)dmaControlTable,
+    .dmaErrorFxn = (UDMACC32XX_ErrorFxn)dmaErrorFxn,
+    .intNum = INT_UDMAERR,
+    .intPriority = (~0)
+};
+
+const UDMACC32XX_Config UDMACC32XX_config = {
+    .object = &udmaCC3220SObject,
+    .hwAttrs = &udmaCC3220SHWAttrs
+};
+
+/*
+ *  =============================== General ===============================
+ */
+/*
+ *  ======== CC3220S_LAUNCHXL_initGeneral ========
+ */
+void CC3220S_LAUNCHXL_initGeneral(void)
+{
+    PRCMCC3200MCUInit();
+    Power_init();
+}
+
+/*
+ *  =============================== GPIO ===============================
+ */
+#include <ti/drivers/GPIO.h>
+#include <ti/drivers/gpio/GPIOCC32XX.h>
+
+/*
+ * Array of Pin configurations
+ * NOTE: The order of the pin configurations must coincide with what was
+ *       defined in CC3220S_LAUNCHXL.h
+ * NOTE: Pins not used for interrupts should be placed at the end of the
+ *       array.  Callback entries can be omitted from callbacks array to
+ *       reduce memory usage.
+ */
+GPIO_PinConfig gpioPinConfigs[] = {
+    /* input pins with callbacks */
+    /* CC3220S_LAUNCHXL_GPIO_SW2 */
+    GPIOCC32XX_GPIO_13 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING,
+    /* CC3220S_LAUNCHXL_GPIO_SW3 */
+    GPIOCC32XX_GPIO_22 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING,
+
+    /* CC3220S_LAUNCHXL_SPI_MASTER_READY */
+    GPIOCC32XX_GPIO_28 | GPIO_DO_NOT_CONFIG,
+    /* CC3220S_LAUNCHXL_SPI_SLAVE_READY */
+    GPIOCC32XX_GPIO_12 | GPIO_DO_NOT_CONFIG,
+
+    /* output pins */
+    /* CC3220S_LAUNCHXL_GPIO_LED_D7 */
+    GPIOCC32XX_GPIO_09 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
+
+    /*
+     *  CC3220S_LAUNCHXL_GPIO_LED_D5 and CC3220S_LAUNCHXL_GPIO_LED_D6 are shared with the
+     *  I2C and PWM peripherals. In order for those examples to work, these
+     *  LEDs are taken out of gpioPinConfig[]
+     */
+    /* CC3220S_LAUNCHXL_GPIO_LED_D6 */
+    /* GPIOCC32XX_GPIO_10 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW, */
+    /* CC3220S_LAUNCHXL_GPIO_LED_D5 */
+    /* GPIOCC32XX_GPIO_11 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW, */
+
+    /* Sharp Display - GPIO configurations will be done in the Display files */
+    GPIOCC32XX_GPIO_12 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
+    GPIOCC32XX_GPIO_06 | GPIO_DO_NOT_CONFIG, /* LCD power control */
+    GPIOCC32XX_GPIO_03 | GPIO_DO_NOT_CONFIG, /*LCD enable */
+};
+
+/*
+ * Array of callback function pointers
+ * NOTE: The order of the pin configurations must coincide with what was
+ *       defined in CC3220S_LAUNCHXL.h
+ * NOTE: Pins not used for interrupts can be omitted from callbacks array to
+ *       reduce memory usage (if placed at end of gpioPinConfigs array).
+ */
+GPIO_CallbackFxn gpioCallbackFunctions[] = {
+    NULL,  /* CC3220S_LAUNCHXL_GPIO_SW2 */
+    NULL,  /* CC3220S_LAUNCHXL_GPIO_SW3 */
+    NULL,  /* CC3220S_LAUNCHXL_SPI_MASTER_READY */
+    NULL   /* CC3220S_LAUNCHXL_SPI_SLAVE_READY */
+};
+
+/* The device-specific GPIO_config structure */
+const GPIOCC32XX_Config GPIOCC32XX_config = {
+    .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
+    .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
+    .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
+    .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
+    .intPriority = (~0)
+};
+
+/*
+ *  ============================= Display =============================
+ */
+#include <ti/display/Display.h>
+#include <ti/display/DisplayUart.h>
+#include <ti/display/DisplaySharp.h>
+#define MAXPRINTLEN 1024
+
+#ifndef BOARD_DISPLAY_SHARP_SIZE
+#define BOARD_DISPLAY_SHARP_SIZE    96
+#endif
+
+DisplayUart_Object displayUartObject;
+DisplaySharp_Object displaySharpObject;
+
+static char displayBuf[MAXPRINTLEN];
+static uint_least8_t sharpDisplayBuf[BOARD_DISPLAY_SHARP_SIZE * BOARD_DISPLAY_SHARP_SIZE / 8];
+
+const DisplayUart_HWAttrs displayUartHWAttrs = {
+    .uartIdx = 0,
+    .baudRate = 115200,
+    .mutexTimeout = (unsigned int)(-1),
+    .strBuf = displayBuf,
+    .strBufLen = MAXPRINTLEN
+};
+
+const DisplaySharp_HWAttrsV1 displaySharpHWattrs = {
+    .spiIndex    = CC3220S_LAUNCHXL_SPI1,
+    .csPin       = CC3220S_LAUNCHXL_LCD_CS,
+    .powerPin    = CC3220S_LAUNCHXL_LCD_POWER,
+    .enablePin   = CC3220S_LAUNCHXL_LCD_ENABLE,
+    .pixelWidth  = BOARD_DISPLAY_SHARP_SIZE,
+    .pixelHeight = BOARD_DISPLAY_SHARP_SIZE,
+    .displayBuf  = sharpDisplayBuf,
+};
+
+#ifndef BOARD_DISPLAY_USE_UART
+#define BOARD_DISPLAY_USE_UART 1
+#endif
+#ifndef BOARD_DISPLAY_USE_UART_ANSI
+#define BOARD_DISPLAY_USE_UART_ANSI 0
+#endif
+#ifndef BOARD_DISPLAY_USE_LCD
+#define BOARD_DISPLAY_USE_LCD 0
+#endif
+
+const Display_Config Display_config[] = {
+    {
+#  if (BOARD_DISPLAY_USE_UART_ANSI)
+        .fxnTablePtr = &DisplayUartAnsi_fxnTable,
+#  else /* Default to minimal UART with no cursor placement */
+        .fxnTablePtr = &DisplayUartMin_fxnTable,
+#  endif
+        .object = &displayUartObject,
+        .hwAttrs = &displayUartHWAttrs
+    },
+#if (BOARD_DISPLAY_USE_LCD)
+    {
+        .fxnTablePtr = &DisplaySharp_fxnTable,
+        .object      = &displaySharpObject,
+        .hwAttrs     = &displaySharpHWattrs
+    },
+#endif
+};
+
+const uint_least8_t Display_count = sizeof(Display_config) / sizeof(Display_Config);
+
+/*
+ *  =============================== I2C ===============================
+ */
+#include <ti/drivers/I2C.h>
+#include <ti/drivers/i2c/I2CCC32XX.h>
+
+I2CCC32XX_Object i2cCC3220SObjects[CC3220S_LAUNCHXL_I2CCOUNT];
+
+const I2CCC32XX_HWAttrsV1 i2cCC3220SHWAttrs[CC3220S_LAUNCHXL_I2CCOUNT] = {
+    {
+        .baseAddr = I2CA0_BASE,
+        .intNum = INT_I2CA0,
+        .intPriority = (~0),
+        .clkPin = I2CCC32XX_PIN_01_I2C_SCL,
+        .dataPin = I2CCC32XX_PIN_02_I2C_SDA
+    }
+};
+
+const I2C_Config I2C_config[CC3220S_LAUNCHXL_I2CCOUNT] = {
+    {
+        .fxnTablePtr = &I2CCC32XX_fxnTable,
+        .object = &i2cCC3220SObjects[CC3220S_LAUNCHXL_I2C0],
+        .hwAttrs = &i2cCC3220SHWAttrs[CC3220S_LAUNCHXL_I2C0]
+    }
+};
+
+const uint_least8_t I2C_count = CC3220S_LAUNCHXL_I2CCOUNT;
+
+/*
+ *  =============================== I2S ===============================
+ */
+#include <ti/drivers/I2S.h>
+#include <ti/drivers/i2s/I2SCC32XXDMA.h>
+
+I2SCC32XXDMA_Object i2sCC3220SObjects[CC3220S_LAUNCHXL_I2SCOUNT];
+
+const I2SCC32XXDMA_HWAttrsV1 i2sCC3220SHWAttrs[CC3220S_LAUNCHXL_I2SCOUNT] = {
+    {
+        .baseAddr = I2S_BASE,
+        .intNum = INT_I2S,
+        .intPriority = (~0),
+        .rxChannelIndex = UDMA_CH4_I2S_RX,
+        .txChannelIndex = UDMA_CH5_I2S_TX,
+        .xr0Pin = I2SCC32XXDMA_PIN_64_McAXR0,
+        .xr1Pin = I2SCC32XXDMA_PIN_50_McAXR1,
+        .clkxPin = I2SCC32XXDMA_PIN_62_McACLKX,
+        .clkPin = I2SCC32XXDMA_PIN_53_McACLK,
+        .fsxPin = I2SCC32XXDMA_PIN_63_McAFSX,
+    }
+};
+
+const I2S_Config I2S_config[CC3220S_LAUNCHXL_I2SCOUNT] = {
+    {
+        .fxnTablePtr = &I2SCC32XXDMA_fxnTable,
+        .object = &i2sCC3220SObjects[CC3220S_LAUNCHXL_I2S0],
+        .hwAttrs = &i2sCC3220SHWAttrs[CC3220S_LAUNCHXL_I2S0]
+    }
+};
+
+const uint_least8_t I2S_count = CC3220S_LAUNCHXL_I2SCOUNT;
+
+/*
+ *  =============================== Power ===============================
+ */
+/*
+ * This table defines the parking state to be set for each parkable pin
+ * during LPDS. (Device pins must be parked during LPDS to achieve maximum
+ * power savings.)  If the pin should be left unparked, specify the state
+ * PowerCC32XX_DONT_PARK.  For example, for a UART TX pin, the device
+ * will automatically park the pin in a high state during transition to LPDS,
+ * so the Power Manager does not need to explictly park the pin.  So the
+ * corresponding entries in this table should indicate PowerCC32XX_DONT_PARK.
+ */
+PowerCC32XX_ParkInfo parkInfo[] = {
+/*          PIN                    PARK STATE              PIN ALIAS (FUNCTION)
+     -----------------  ------------------------------     -------------------- */
+    {PowerCC32XX_PIN01, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO10              */
+    {PowerCC32XX_PIN02, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO11              */
+    {PowerCC32XX_PIN03, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO12              */
+    {PowerCC32XX_PIN04, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO13              */
+    {PowerCC32XX_PIN05, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO14              */
+    {PowerCC32XX_PIN06, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO15              */
+    {PowerCC32XX_PIN07, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO16              */
+    {PowerCC32XX_PIN08, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO17              */
+    {PowerCC32XX_PIN13, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* FLASH_SPI_DIN       */
+    {PowerCC32XX_PIN15, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO22              */
+    {PowerCC32XX_PIN16, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TDI (JTAG DEBUG)    */
+    {PowerCC32XX_PIN17, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TDO (JTAG DEBUG)    */
+    {PowerCC32XX_PIN19, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TCK (JTAG DEBUG)    */
+    {PowerCC32XX_PIN20, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TMS (JTAG DEBUG)    */
+    {PowerCC32XX_PIN18, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO28              */
+    {PowerCC32XX_PIN21, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* SOP2                */
+    {PowerCC32XX_PIN29, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* ANTSEL1             */
+    {PowerCC32XX_PIN30, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* ANTSEL2             */
+    {PowerCC32XX_PIN45, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* DCDC_ANA2_SW_P      */
+    {PowerCC32XX_PIN50, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO0               */
+    {PowerCC32XX_PIN52, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* RTC_XTAL_N          */
+    {PowerCC32XX_PIN53, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO30              */
+    {PowerCC32XX_PIN55, PowerCC32XX_WEAK_PULL_UP_STD},   /* GPIO1 (XDS_UART_RX) */
+    {PowerCC32XX_PIN57, PowerCC32XX_WEAK_PULL_UP_STD},   /* GPIO2 (XDS_UART_TX) */
+    {PowerCC32XX_PIN58, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO3               */
+    {PowerCC32XX_PIN59, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO4               */
+    {PowerCC32XX_PIN60, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO5               */
+    {PowerCC32XX_PIN61, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO6               */
+    {PowerCC32XX_PIN62, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO7               */
+    {PowerCC32XX_PIN63, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO8               */
+    {PowerCC32XX_PIN64, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO9               */
+};
+
+/*
+ *  This structure defines the configuration for the Power Manager.
+ *
+ *  In this configuration the Power policy is disabled by default (because
+ *  enablePolicy is set to false).  The Power policy can be enabled dynamically
+ *  at runtime by calling Power_enablePolicy(), or at build time, by changing
+ *  enablePolicy to true in this structure.
+ */
+const PowerCC32XX_ConfigV1 PowerCC32XX_config = {
+    .policyInitFxn = &PowerCC32XX_initPolicy,
+    .policyFxn = &PowerCC32XX_sleepPolicy,
+    .enterLPDSHookFxn = NULL,
+    .resumeLPDSHookFxn = NULL,
+    .enablePolicy = false,
+    .enableGPIOWakeupLPDS = true,
+    .enableGPIOWakeupShutdown = true,
+    .enableNetworkWakeupLPDS = true,
+    .wakeupGPIOSourceLPDS = PRCM_LPDS_GPIO13,
+    .wakeupGPIOTypeLPDS = PRCM_LPDS_FALL_EDGE,
+    .wakeupGPIOFxnLPDS = NULL,
+    .wakeupGPIOFxnLPDSArg = 0,
+    .wakeupGPIOSourceShutdown = PRCM_HIB_GPIO13,
+    .wakeupGPIOTypeShutdown = PRCM_HIB_RISE_EDGE,
+    .ramRetentionMaskLPDS = PRCM_SRAM_COL_1 | PRCM_SRAM_COL_2 |
+        PRCM_SRAM_COL_3 | PRCM_SRAM_COL_4,
+    .keepDebugActiveDuringLPDS = false,
+    .ioRetentionShutdown = PRCM_IO_RET_GRP_1,
+    .pinParkDefs = parkInfo,
+    .numPins = sizeof(parkInfo) / sizeof(PowerCC32XX_ParkInfo)
+};
+
+/*
+ *  =============================== PWM ===============================
+ */
+#include <ti/drivers/PWM.h>
+#include <ti/drivers/pwm/PWMTimerCC32XX.h>
+
+PWMTimerCC32XX_Object pwmTimerCC3220SObjects[CC3220S_LAUNCHXL_PWMCOUNT];
+
+const PWMTimerCC32XX_HWAttrsV2 pwmTimerCC3220SHWAttrs[CC3220S_LAUNCHXL_PWMCOUNT] = {
+    {    /* CC3220S_LAUNCHXL_PWM6 */
+        .pwmPin = PWMTimerCC32XX_PIN_01
+    },
+    {    /* CC3220S_LAUNCHXL_PWM7 */
+        .pwmPin = PWMTimerCC32XX_PIN_02
+    }
+};
+
+const PWM_Config PWM_config[CC3220S_LAUNCHXL_PWMCOUNT] = {
+    {
+        .fxnTablePtr = &PWMTimerCC32XX_fxnTable,
+        .object = &pwmTimerCC3220SObjects[CC3220S_LAUNCHXL_PWM6],
+        .hwAttrs = &pwmTimerCC3220SHWAttrs[CC3220S_LAUNCHXL_PWM6]
+    },
+    {
+        .fxnTablePtr = &PWMTimerCC32XX_fxnTable,
+        .object = &pwmTimerCC3220SObjects[CC3220S_LAUNCHXL_PWM7],
+        .hwAttrs = &pwmTimerCC3220SHWAttrs[CC3220S_LAUNCHXL_PWM7]
+    }
+};
+
+const uint_least8_t PWM_count = CC3220S_LAUNCHXL_PWMCOUNT;
+
+/*
+ *  =============================== SDFatFS ===============================
+ */
+#include <ti/drivers/SD.h>
+#include <ti/drivers/SDFatFS.h>
+
+/*
+ * Note: The SDFatFS driver provides interface functions to enable FatFs
+ * but relies on the SD driver to communicate with SD cards.  Opening a
+ * SDFatFs driver instance will internally try to open a SD driver instance
+ * reusing the same index number (opening SDFatFs driver at index 0 will try to
+ * open SD driver at index 0).  This requires that all SDFatFs driver instances
+ * have an accompanying SD driver instance defined with the same index.  It is
+ * acceptable to have more SD driver instances than SDFatFs driver instances
+ * but the opposite is not supported & the SDFatFs will fail to open.
+ */
+SDFatFS_Object sdfatfsObjects[CC3220S_LAUNCHXL_SDFatFSCOUNT];
+
+const SDFatFS_Config SDFatFS_config[CC3220S_LAUNCHXL_SDFatFSCOUNT] = {
+    {
+        .object = &sdfatfsObjects[CC3220S_LAUNCHXL_SDFatFS0]
+    }
+};
+
+const uint_least8_t SDFatFS_count = CC3220S_LAUNCHXL_SDFatFSCOUNT;
+
+/*
+ *  =============================== SD ===============================
+ */
+#include <ti/drivers/SD.h>
+#include <ti/drivers/sd/SDHostCC32XX.h>
+
+SDHostCC32XX_Object sdhostCC3220SObjects[CC3220S_LAUNCHXL_SDCOUNT];
+
+/* SDHost configuration structure, describing which pins are to be used */
+const SDHostCC32XX_HWAttrsV1 sdhostCC3220SHWattrs[CC3220S_LAUNCHXL_SDCOUNT] = {
+    {
+        .clkRate = 8000000,
+        .intPriority = ~0,
+        .baseAddr = SDHOST_BASE,
+        .rxChIdx = UDMA_CH23_SDHOST_RX,
+        .txChIdx = UDMA_CH24_SDHOST_TX,
+        .dataPin = SDHostCC32XX_PIN_06_SDCARD_DATA,
+        .cmdPin = SDHostCC32XX_PIN_08_SDCARD_CMD,
+        .clkPin = SDHostCC32XX_PIN_07_SDCARD_CLK
+    }
+};
+
+const SD_Config SD_config[CC3220S_LAUNCHXL_SDCOUNT] = {
+    {
+        .fxnTablePtr = &sdHostCC32XX_fxnTable,
+        .object = &sdhostCC3220SObjects[CC3220S_LAUNCHXL_SD0],
+        .hwAttrs = &sdhostCC3220SHWattrs[CC3220S_LAUNCHXL_SD0]
+    },
+};
+
+const uint_least8_t SD_count = CC3220S_LAUNCHXL_SDCOUNT;
+
+/*
+ *  =============================== SPI ===============================
+ */
+#include <ti/drivers/SPI.h>
+#include <ti/drivers/spi/SPICC32XXDMA.h>
+
+SPICC32XXDMA_Object spiCC3220SDMAObjects[CC3220S_LAUNCHXL_SPICOUNT];
+
+#if defined(__TI_COMPILER_VERSION__)
+#pragma DATA_ALIGN(spiCC3220SDMAscratchBuf, 32)
+#elif defined(__IAR_SYSTEMS_ICC__)
+#pragma data_alignment=32
+#elif defined(__GNUC__)
+__attribute__ ((aligned (32)))
+#endif
+uint32_t spiCC3220SDMAscratchBuf[CC3220S_LAUNCHXL_SPICOUNT];
+
+const SPICC32XXDMA_HWAttrsV1 spiCC3220SDMAHWAttrs[CC3220S_LAUNCHXL_SPICOUNT] = {
+    /* index 0 is reserved for LSPI that links to the NWP */
+    {
+        .baseAddr = LSPI_BASE,
+        .intNum = INT_LSPI,
+        .intPriority = (~0),
+        .spiPRCM = PRCM_LSPI,
+        .csControl = SPI_SW_CTRL_CS,
+        .csPolarity = SPI_CS_ACTIVEHIGH,
+        .pinMode = SPI_4PIN_MODE,
+        .turboMode = SPI_TURBO_OFF,
+        .scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220S_LAUNCHXL_SPI0],
+        .defaultTxBufValue = 0,
+        .rxChannelIndex = UDMA_CH12_LSPI_RX,
+        .txChannelIndex = UDMA_CH13_LSPI_TX,
+        .minDmaTransferSize = 100,
+        .mosiPin = SPICC32XXDMA_PIN_NO_CONFIG,
+        .misoPin = SPICC32XXDMA_PIN_NO_CONFIG,
+        .clkPin = SPICC32XXDMA_PIN_NO_CONFIG,
+        .csPin = SPICC32XXDMA_PIN_NO_CONFIG
+    },
+    {
+        .baseAddr = GSPI_BASE,
+        .intNum = INT_GSPI,
+        .intPriority = (~0),
+        .spiPRCM = PRCM_GSPI,
+        .csControl = SPI_HW_CTRL_CS,
+        .csPolarity = SPI_CS_ACTIVELOW,
+        .pinMode = SPI_4PIN_MODE,
+        .turboMode = SPI_TURBO_OFF,
+        .scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220S_LAUNCHXL_SPI1],
+        .defaultTxBufValue = 0,
+        .rxChannelIndex = UDMA_CH6_GSPI_RX,
+        .txChannelIndex = UDMA_CH7_GSPI_TX,
+        .minDmaTransferSize = 10,
+        .mosiPin = SPICC32XXDMA_PIN_07_MOSI,
+        .misoPin = SPICC32XXDMA_PIN_06_MISO,
+        .clkPin = SPICC32XXDMA_PIN_05_CLK,
+        .csPin = SPICC32XXDMA_PIN_08_CS
+    }
+};
+
+const SPI_Config SPI_config[CC3220S_LAUNCHXL_SPICOUNT] = {
+    {
+        .fxnTablePtr = &SPICC32XXDMA_fxnTable,
+        .object = &spiCC3220SDMAObjects[CC3220S_LAUNCHXL_SPI0],
+        .hwAttrs = &spiCC3220SDMAHWAttrs[CC3220S_LAUNCHXL_SPI0]
+    },
+    {
+        .fxnTablePtr = &SPICC32XXDMA_fxnTable,
+        .object = &spiCC3220SDMAObjects[CC3220S_LAUNCHXL_SPI1],
+        .hwAttrs = &spiCC3220SDMAHWAttrs[CC3220S_LAUNCHXL_SPI1]
+    }
+};
+
+const uint_least8_t SPI_count = CC3220S_LAUNCHXL_SPICOUNT;
+
+/*
+ *  =============================== Timer ===============================
+ */
+#include <ti/drivers/Timer.h>
+#include <ti/drivers/timer/TimerCC32XX.h>
+
+TimerCC32XX_Object timerCC3220SObjects[CC3220S_LAUNCHXL_TIMERCOUNT];
+
+const TimerCC32XX_HWAttrs timerCC3220SHWAttrs[CC3220S_LAUNCHXL_TIMERCOUNT] = {
+    {
+        .baseAddress = TIMERA0_BASE,
+        .subTimer = TimerCC32XX_timer32,
+        .intNum = INT_TIMERA0A,
+        .intPriority = ~0
+    },
+    {
+        .baseAddress = TIMERA1_BASE,
+        .subTimer = TimerCC32XX_timer16A,
+        .intNum = INT_TIMERA1A,
+        .intPriority = ~0
+    },
+    {
+         .baseAddress = TIMERA1_BASE,
+         .subTimer = TimerCC32XX_timer16B,
+         .intNum = INT_TIMERA1B,
+         .intPriority = ~0
+    },
+};
+
+const Timer_Config Timer_config[CC3220S_LAUNCHXL_TIMERCOUNT] = {
+    {
+        .fxnTablePtr = &TimerCC32XX_fxnTable,
+        .object = &timerCC3220SObjects[CC3220S_LAUNCHXL_TIMER0],
+        .hwAttrs = &timerCC3220SHWAttrs[CC3220S_LAUNCHXL_TIMER0]
+    },
+    {
+        .fxnTablePtr = &TimerCC32XX_fxnTable,
+        .object = &timerCC3220SObjects[CC3220S_LAUNCHXL_TIMER1],
+        .hwAttrs = &timerCC3220SHWAttrs[CC3220S_LAUNCHXL_TIMER1]
+    },
+    {
+        .fxnTablePtr = &TimerCC32XX_fxnTable,
+        .object = &timerCC3220SObjects[CC3220S_LAUNCHXL_TIMER2],
+        .hwAttrs = &timerCC3220SHWAttrs[CC3220S_LAUNCHXL_TIMER2]
+    },
+};
+
+const uint_least8_t Timer_count = CC3220S_LAUNCHXL_TIMERCOUNT;
+
+/*
+ *  =============================== UART ===============================
+ */
+#include <ti/drivers/UART.h>
+#if TI_DRIVERS_UART_DMA
+#include <ti/drivers/uart/UARTCC32XXDMA.h>
+
+UARTCC32XXDMA_Object uartCC3220SDmaObjects[CC3220S_LAUNCHXL_UARTCOUNT];
+
+/* UART configuration structure */
+const UARTCC32XXDMA_HWAttrsV1 uartCC3220SDmaHWAttrs[CC3220S_LAUNCHXL_UARTCOUNT] = {
+    {
+        .baseAddr = UARTA0_BASE,
+        .intNum = INT_UARTA0,
+        .intPriority = (~0),
+        .flowControl = UARTCC32XXDMA_FLOWCTRL_NONE,
+        .rxChannelIndex = UDMA_CH8_UARTA0_RX,
+        .txChannelIndex = UDMA_CH9_UARTA0_TX,
+        .rxPin = UARTCC32XXDMA_PIN_57_UART0_RX,
+        .txPin = UARTCC32XXDMA_PIN_55_UART0_TX,
+        .ctsPin = UARTCC32XXDMA_PIN_UNASSIGNED,
+        .rtsPin = UARTCC32XXDMA_PIN_UNASSIGNED,
+        .errorFxn = NULL
+    },
+    {
+        .baseAddr = UARTA1_BASE,
+        .intNum = INT_UARTA1,
+        .intPriority = (~0),
+        .flowControl = UARTCC32XXDMA_FLOWCTRL_NONE,
+        .rxChannelIndex = UDMA_CH10_UARTA1_RX,
+        .txChannelIndex = UDMA_CH11_UARTA1_TX,
+        .rxPin = UARTCC32XXDMA_PIN_08_UART1_RX,
+        .txPin = UARTCC32XXDMA_PIN_07_UART1_TX,
+        .ctsPin = UARTCC32XXDMA_PIN_UNASSIGNED,
+        .rtsPin = UARTCC32XXDMA_PIN_UNASSIGNED,
+        .errorFxn = NULL
+    }
+};
+
+const UART_Config UART_config[CC3220S_LAUNCHXL_UARTCOUNT] = {
+    {
+        .fxnTablePtr = &UARTCC32XXDMA_fxnTable,
+        .object = &uartCC3220SDmaObjects[CC3220S_LAUNCHXL_UART0],
+        .hwAttrs = &uartCC3220SDmaHWAttrs[CC3220S_LAUNCHXL_UART0]
+    },
+    {
+        .fxnTablePtr = &UARTCC32XXDMA_fxnTable,
+        .object = &uartCC3220SDmaObjects[CC3220S_LAUNCHXL_UART1],
+        .hwAttrs = &uartCC3220SDmaHWAttrs[CC3220S_LAUNCHXL_UART1]
+    }
+};
+
+#else
+#include <ti/drivers/uart/UARTCC32XX.h>
+
+UARTCC32XX_Object uartCC3220SObjects[CC3220S_LAUNCHXL_UARTCOUNT];
+unsigned char uartCC3220SRingBuffer[CC3220S_LAUNCHXL_UARTCOUNT][32];
+
+/* UART configuration structure */
+const UARTCC32XX_HWAttrsV1 uartCC3220SHWAttrs[CC3220S_LAUNCHXL_UARTCOUNT] = {
+    {
+        .baseAddr = UARTA0_BASE,
+        .intNum = INT_UARTA0,
+        .intPriority = (~0),
+        .flowControl = UARTCC32XX_FLOWCTRL_NONE,
+        .ringBufPtr  = uartCC3220SRingBuffer[CC3220S_LAUNCHXL_UART0],
+        .ringBufSize = sizeof(uartCC3220SRingBuffer[CC3220S_LAUNCHXL_UART0]),
+        .rxPin = UARTCC32XX_PIN_57_UART0_RX,
+        .txPin = UARTCC32XX_PIN_55_UART0_TX,
+        .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
+        .rtsPin = UARTCC32XX_PIN_UNASSIGNED,
+        .errorFxn = NULL
+    },
+    {
+        .baseAddr = UARTA1_BASE,
+        .intNum = INT_UARTA1,
+        .intPriority = (~0),
+        .flowControl = UARTCC32XX_FLOWCTRL_NONE,
+        .ringBufPtr  = uartCC3220SRingBuffer[CC3220S_LAUNCHXL_UART1],
+        .ringBufSize = sizeof(uartCC3220SRingBuffer[CC3220S_LAUNCHXL_UART1]),
+        .rxPin = UARTCC32XX_PIN_08_UART1_RX,
+        .txPin = UARTCC32XX_PIN_07_UART1_TX,
+        .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
+        .rtsPin = UARTCC32XX_PIN_UNASSIGNED,
+        .errorFxn = NULL
+    }
+};
+
+const UART_Config UART_config[CC3220S_LAUNCHXL_UARTCOUNT] = {
+    {
+        .fxnTablePtr = &UARTCC32XX_fxnTable,
+        .object = &uartCC3220SObjects[CC3220S_LAUNCHXL_UART0],
+        .hwAttrs = &uartCC3220SHWAttrs[CC3220S_LAUNCHXL_UART0]
+    },
+    {
+        .fxnTablePtr = &UARTCC32XX_fxnTable,
+        .object = &uartCC3220SObjects[CC3220S_LAUNCHXL_UART1],
+        .hwAttrs = &uartCC3220SHWAttrs[CC3220S_LAUNCHXL_UART1]
+    }
+};
+#endif /* TI_DRIVERS_UART_DMA */
+
+const uint_least8_t UART_count = CC3220S_LAUNCHXL_UARTCOUNT;
+
+/*
+ *  =============================== Watchdog ===============================
+ */
+#include <ti/drivers/Watchdog.h>
+#include <ti/drivers/watchdog/WatchdogCC32XX.h>
+
+WatchdogCC32XX_Object watchdogCC3220SObjects[CC3220S_LAUNCHXL_WATCHDOGCOUNT];
+
+const WatchdogCC32XX_HWAttrs watchdogCC3220SHWAttrs[CC3220S_LAUNCHXL_WATCHDOGCOUNT] = {
+    {
+        .baseAddr = WDT_BASE,
+        .intNum = INT_WDT,
+        .intPriority = (~0),
+        .reloadValue = 80000000 /* 1 second period at default CPU clock freq */
+    }
+};
+
+const Watchdog_Config Watchdog_config[CC3220S_LAUNCHXL_WATCHDOGCOUNT] = {
+    {
+        .fxnTablePtr = &WatchdogCC32XX_fxnTable,
+        .object = &watchdogCC3220SObjects[CC3220S_LAUNCHXL_WATCHDOG0],
+        .hwAttrs = &watchdogCC3220SHWAttrs[CC3220S_LAUNCHXL_WATCHDOG0]
+    }
+};
+
+const uint_least8_t Watchdog_count = CC3220S_LAUNCHXL_WATCHDOGCOUNT;
diff --git a/sample/CC3220S_LAUNCHXL/CC3220S_LAUNCHXL.h b/sample/CC3220S_LAUNCHXL/CC3220S_LAUNCHXL.h
new file mode 100644 (file)
index 0000000..3e9ec59
--- /dev/null
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2016-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** ============================================================================
+ *  @file       C3220S_LAUNCHXL.h
+ *
+ *  @brief      CC3220 Board Specific APIs
+ *
+ *  The CC3220S_LAUNCHXL header file should be included in an application as
+ *  follows:
+ *  @code
+ *  #include <CC3220S_LAUNCHXL.h>
+ *  @endcode
+ *
+ *  ============================================================================
+ */
+#ifndef __CC3220S_LAUNCHXL_H
+#define __CC3220S_LAUNCHXL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CC3220S_LAUNCHXL_GPIO_LED_OFF (0)
+#define CC3220S_LAUNCHXL_GPIO_LED_ON  (1)
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_ADCName
+ *  @brief  Enum of ADC names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_ADCName {
+    CC3220S_LAUNCHXL_ADC0 = 0,
+    CC3220S_LAUNCHXL_ADC1,
+
+    CC3220S_LAUNCHXL_ADCCOUNT
+} CC3220S_LAUNCHXL_ADCName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_CaptureName
+ *  @brief  Enum of Capture names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_CaptureName {
+    CC3220S_LAUNCHXL_CAPTURE0 = 0,
+    CC3220S_LAUNCHXL_CAPTURE1,
+
+    CC3220S_LAUNCHXL_CAPTURECOUNT
+} CC3220S_LAUNCHXL_CaptureName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_CryptoName
+ *  @brief  Enum of Crypto names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_CryptoName {
+    CC3220S_LAUNCHXL_CRYPTO0 = 0,
+
+    CC3220S_LAUNCHXL_CRYPTOCOUNT
+} CC3220S_LAUNCHXL_CryptoName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_GPIOName
+ *  @brief  Enum of GPIO names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_GPIOName {
+    CC3220S_LAUNCHXL_GPIO_SW2 = 0,
+    CC3220S_LAUNCHXL_GPIO_SW3,
+    CC3220S_LAUNCHXL_SPI_MASTER_READY,
+    CC3220S_LAUNCHXL_SPI_SLAVE_READY,
+    CC3220S_LAUNCHXL_GPIO_LED_D7,
+
+    /*
+     *  CC3220S_LAUNCHXL_GPIO_LED_D5 and CC3220S_LAUNCHXL_GPIO_LED_D6 are shared with the
+     *  I2C and PWM peripherals. In order for those examples to work, these
+     *  LEDs are  taken out of gpioPinCOnfig[]
+     */
+    /* CC3220S_LAUNCHXL_GPIO_LED_D6, */
+    /* CC3220S_LAUNCHXL_GPIO_LED_D5, */
+
+    /* Sharp 96x96 LCD Pins */
+    CC3220S_LAUNCHXL_LCD_CS,
+    CC3220S_LAUNCHXL_LCD_POWER,
+    CC3220S_LAUNCHXL_LCD_ENABLE,
+
+    CC3220S_LAUNCHXL_GPIOCOUNT
+} CC3220S_LAUNCHXL_GPIOName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_I2CName
+ *  @brief  Enum of I2C names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_I2CName {
+    CC3220S_LAUNCHXL_I2C0 = 0,
+
+    CC3220S_LAUNCHXL_I2CCOUNT
+} CC3220S_LAUNCHXL_I2CName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_I2SName
+ *  @brief  Enum of I2S names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_I2SName {
+    CC3220S_LAUNCHXL_I2S0 = 0,
+
+    CC3220S_LAUNCHXL_I2SCOUNT
+} CC3220S_LAUNCHXL_I2SName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_PWMName
+ *  @brief  Enum of PWM names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_PWMName {
+    CC3220S_LAUNCHXL_PWM6 = 0,
+    CC3220S_LAUNCHXL_PWM7,
+
+    CC3220S_LAUNCHXL_PWMCOUNT
+} CC3220S_LAUNCHXL_PWMName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_SDFatFSName
+ *  @brief  Enum of SDFatFS names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_SDFatFSName {
+    CC3220S_LAUNCHXL_SDFatFS0 = 0,
+
+    CC3220S_LAUNCHXL_SDFatFSCOUNT
+} CC3220S_LAUNCHXL_SDFatFSName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_SDName
+ *  @brief  Enum of SD names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_SDName {
+    CC3220S_LAUNCHXL_SD0 = 0,
+
+    CC3220S_LAUNCHXL_SDCOUNT
+} CC3220S_LAUNCHXL_SDName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_SPIName
+ *  @brief  Enum of SPI names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_SPIName {
+    CC3220S_LAUNCHXL_SPI0 = 0,
+    CC3220S_LAUNCHXL_SPI1,
+
+    CC3220S_LAUNCHXL_SPICOUNT
+} CC3220S_LAUNCHXL_SPIName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_TimerName
+ *  @brief  Enum of Timer names on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_TimerName {
+    CC3220S_LAUNCHXL_TIMER0 = 0,
+    CC3220S_LAUNCHXL_TIMER1,
+    CC3220S_LAUNCHXL_TIMER2,
+
+    CC3220S_LAUNCHXL_TIMERCOUNT
+} CC3220S_LAUNCHXL_TimerName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_UARTName
+ *  @brief  Enum of UARTs on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_UARTName {
+    CC3220S_LAUNCHXL_UART0 = 0,
+    CC3220S_LAUNCHXL_UART1,
+
+    CC3220S_LAUNCHXL_UARTCOUNT
+} CC3220S_LAUNCHXL_UARTName;
+
+/*!
+ *  @def    CC3220S_LAUNCHXL_WatchdogName
+ *  @brief  Enum of Watchdogs on the CC3220S_LAUNCHXL dev board
+ */
+typedef enum CC3220S_LAUNCHXL_WatchdogName {
+    CC3220S_LAUNCHXL_WATCHDOG0 = 0,
+
+    CC3220S_LAUNCHXL_WATCHDOGCOUNT
+} CC3220S_LAUNCHXL_WatchdogName;
+
+/*!
+ *  @brief  Initialize the general board specific settings
+ *
+ *  This function initializes the general board specific settings.
+ */
+extern void CC3220S_LAUNCHXL_initGeneral(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CC3220S_LAUNCHXL_H */
diff --git a/sample/CC3220S_LAUNCHXL/network.c b/sample/CC3220S_LAUNCHXL/network.c
new file mode 100644 (file)
index 0000000..9fdb03b
--- /dev/null
@@ -0,0 +1,387 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdbool.h>
+
+#include <ti/net/slnetsock.h>
+#include <ti/net/slnetif.h>
+#include <ti/net/slnetutils.h>
+
+#include <ti/drivers/GPIO.h>
+
+#include <ti/drivers/net/wifi/netapp.h>
+#include <ti/drivers/net/wifi/simplelink.h>
+#include <ti/drivers/net/wifi/slnetifwifi.h>
+#include <ti/drivers/net/wifi/wlan.h>
+
+#include <semaphore.h>
+#include <unistd.h>
+
+#include "Board.h"
+#include "wificonfig.h"
+
+/* Network interface priority and name */
+#define SLNET_IF_WIFI_PRIO (5)
+#define SLNET_IF_WIFI_NAME "CC32XX"
+
+static uint32_t deviceConnected = false;
+static uint32_t ipAcquired = false;
+static uint32_t currButton;
+static uint32_t prevButton;
+
+static sem_t sem;
+
+extern void startSNTP(void);
+
+static void initWiFi();
+
+/*
+ *  ======== Network_init =======
+ */
+void Network_init()
+{
+    if (sem_init(&sem, 0, 0) != 0) {
+        /* Error: sem_init failed */
+        while (1);
+    }
+}
+
+/*
+ *  ======== Network_startup =======
+ */
+void Network_startup()
+{
+    int32_t status;
+
+    /* Connect to the Access Point */
+    initWiFi();
+
+    /* Wait for the network stack to initialize and acquire an IP address */
+    sem_wait(&sem);
+
+    /* The network stack is ready. Initialize the socket layer */
+    status = SlNetSock_init(0);
+    if (status != 0) {
+        /* SlNetSock_init failed */
+        while (1);
+    }
+
+    status = SlNetIf_init(0);
+    if (status != 0) {
+        /* SlNetIf_init failed */
+        while (1);
+    }
+
+    status = SlNetUtil_init(0);
+    if (status != 0) {
+        /* SlNetUtil_init failed */
+        while (1);
+    }
+
+    /* Register the WiFi interface with the socket layer */
+    status = SlNetIf_add(SLNETIF_ID_1, SLNET_IF_WIFI_NAME,
+            (const SlNetIf_Config_t *)&SlNetIfConfigWifi, SLNET_IF_WIFI_PRIO);
+    if (status != 0) {
+        /* SlNetIf_add failed */
+        while (1);
+    }
+
+    /* Turn LED OFF. It will be used as a connection indicator */
+    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
+
+    /* Use SNTP to get the current time, as needed for SSL authentication */
+    startSNTP();
+
+    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
+}
+
+/*
+ *  ======== Network_exit =======
+ */
+void Network_exit()
+{
+}
+
+/*
+ *
+ *  SimpleLink Asynchronous Event Handlers -- Start
+ *
+ */
+
+/*
+ *  ======== SimpleLinkHttpServerEventHandler ========
+ */
+void SimpleLinkHttpServerEventHandler(
+        SlNetAppHttpServerEvent_t *pSlHttpServerEvent,
+        SlNetAppHttpServerResponse_t *pSlHttpServerResponse)
+{
+}
+
+/*
+ *  ======== SimpleLinkNetAppRequestEventHandler ========
+ */
+void SimpleLinkNetAppRequestEventHandler(SlNetAppRequest_t *pNetAppRequest,
+        SlNetAppResponse_t *pNetAppResponse)
+{
+}
+
+/*
+ *  ======== SimpleLinkNetAppRequestMemFreeEventHandler ========
+ */
+void SimpleLinkNetAppRequestMemFreeEventHandler(uint8_t *buffer)
+{
+}
+
+/*
+ *  ======== SimpleLinkWlanEventHandler ========
+ *  SimpleLink Host Driver callback for handling WLAN connection or
+ *  disconnection events.
+ */
+void SimpleLinkWlanEventHandler(SlWlanEvent_t *pArgs)
+{
+    switch (pArgs->Id) {
+        case SL_WLAN_EVENT_CONNECT:
+            deviceConnected = true;
+            break;
+
+        case SL_WLAN_EVENT_DISCONNECT:
+            deviceConnected = false;
+            break;
+
+        default:
+            break;
+    }
+}
+
+/*
+ *  ======== SimpleLinkFatalErrorEventHandler ========
+ *  This function handles fatal errors
+ *
+ *  \param[in]  slFatalErrorEvent - Pointer to the fatal error event info
+ *
+ *  \return     None
+ */
+void SimpleLinkFatalErrorEventHandler(SlDeviceFatal_t *slFatalErrorEvent)
+{
+    switch (slFatalErrorEvent->Id) {
+        case SL_DEVICE_EVENT_FATAL_DEVICE_ABORT:
+            /* FATAL ERROR: Abort NWP event detected */
+            while (1);
+
+        case SL_DEVICE_EVENT_FATAL_DRIVER_ABORT:
+            /* FATAL ERROR: Driver Abort detected */
+            while (1);
+
+        case SL_DEVICE_EVENT_FATAL_NO_CMD_ACK:
+            /* FATAL ERROR: No Cmd Ack detected */
+            while (1);
+
+        case SL_DEVICE_EVENT_FATAL_SYNC_LOSS:
+            /* FATAL ERROR: Sync loss detected */
+            while (1);
+
+        case SL_DEVICE_EVENT_FATAL_CMD_TIMEOUT:
+            /* FATAL ERROR: Async event timeout detected */
+            while (1);
+
+        default:
+            /* FATAL ERROR: Unspecified error detected */
+            while (1);
+    }
+}
+
+/*
+ *  ======== SimpleLinkNetAppEventHandler ========
+ *  SimpleLink Host Driver callback for asynchoronous IP address events.
+ */
+void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent)
+{
+    if (pNetAppEvent == NULL) {
+        return;
+    }
+
+    switch (pNetAppEvent->Id) {
+        case SL_NETAPP_EVENT_IPV4_ACQUIRED:
+        case SL_NETAPP_EVENT_IPV6_ACQUIRED:
+            ipAcquired = true;
+
+            /*  Signal that the WiFi stack is ready and has an IP address */
+            sem_post(&sem);
+
+            break;
+
+        default:
+            break;
+    }
+}
+
+/*
+ *  ======== SimpleLinkSockEventHandler ========
+ */
+void SimpleLinkSockEventHandler(SlSockEvent_t *pArgs)
+{
+}
+
+/*
+ *  ======== SimpleLinkGeneralEventHandler ========
+ */
+void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *sockEvent)
+{
+}
+
+/*
+ *  ======== smartConfigFxn ========
+ */
+void smartConfigFxn()
+{
+    uint8_t policyVal;
+
+    /* Set auto connect policy */
+    sl_WlanPolicySet(SL_WLAN_POLICY_CONNECTION,
+            SL_WLAN_CONNECTION_POLICY(1, 0, 0, 0), &policyVal,
+            sizeof(policyVal));
+
+    /* Start SmartConfig using unsecured method. */
+    sl_WlanProvisioning(SL_WLAN_PROVISIONING_CMD_START_MODE_SC, ROLE_STA, 30,
+            NULL, 0);
+}
+
+/*
+ *  ======== setStationMode ========
+ *  Sets the SimpleLink Wi-Fi in station mode and enables DHCP client
+ */
+void setStationMode(void)
+{
+    int           mode;
+    int           response;
+
+    mode = sl_Start(0, 0, 0);
+    if (mode < 0) {
+        /* sl_Start error: Could not initialize SimpleLink Wi-Fi */
+        while(1);
+    }
+
+    /* Change network processor to station mode */
+    if (mode != ROLE_STA) {
+        sl_WlanSetMode(ROLE_STA);
+
+        /* Restart network processor */
+        sl_Stop(200);
+        mode = sl_Start(0, 0, 0);
+        if (mode < 0) {
+            /* Error: Failed to set SimpleLink Wi-Fi to Station mode */
+            while(1);
+        }
+    }
+
+    sl_WlanDisconnect();
+    /* Set auto connect policy */
+    response = sl_WlanPolicySet(SL_WLAN_POLICY_CONNECTION,
+            SL_WLAN_CONNECTION_POLICY(1, 0, 0, 0), NULL, 0);
+    if (response < 0) {
+        /* Error: Failed to set connection policy to auto connect */
+        while (1);
+    }
+
+    /* Enable DHCP client */
+    response = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE, SL_NETCFG_ADDR_DHCP,
+            0, 0);
+
+    if (response < 0) {
+        /* Error: Could not enable DHCP client */
+        while (1);
+    }
+
+    sl_Stop(200);
+
+    /* Set connection variables to initial values */
+    deviceConnected = false;
+    ipAcquired = false;
+}
+
+/*
+ *  ======== wlanConnect =======
+ *  Secure connection parameters
+ */
+static int wlanConnect()
+{
+    SlWlanSecParams_t secParams = {0};
+    int ret = 0;
+
+    secParams.Key = (signed char *)SECURITY_KEY;
+    secParams.KeyLen = strlen((const char *)secParams.Key);
+    secParams.Type = SECURITY_TYPE;
+
+    ret = sl_WlanConnect((signed char*)SSID, strlen((const char*)SSID),
+            NULL, &secParams, NULL);
+
+    return (ret);
+}
+
+/*
+ *  ======== initWiFi =======
+ *  Start the NWP and connect to AP
+ */
+static void initWiFi()
+{
+    setStationMode();
+
+    /* Host driver starts the network processor */
+    if (sl_Start(NULL, NULL, NULL) < 0) {
+        /* Error: Could not initialize WiFi */
+        while (1);
+    }
+
+    if (wlanConnect() < 0) {
+        /* Error: Could not connect to WiFi AP */
+        while (1);
+    }
+
+    /*
+     * Wait for the WiFi to connect to an AP. If a profile for the AP in
+     * use has not been stored yet, press Board_GPIO_BUTTON0 to start
+     * SmartConfig.
+     */
+    while ((deviceConnected != true) || (ipAcquired != true)) {
+        /*
+         *  Start SmartConfig if a button is pressed. This could be done with
+         *  GPIO interrupts, but for simplicity polling is used to check the
+         *  button.
+         */
+        currButton = GPIO_read(Board_GPIO_BUTTON0);
+        if ((currButton == 0) && (prevButton != 0)) {
+            smartConfigFxn();
+        }
+        prevButton = currButton;
+        usleep(50000);
+    }
+}
diff --git a/sample/CC3220S_LAUNCHXL/network.h b/sample/CC3220S_LAUNCHXL/network.h
new file mode 100644 (file)
index 0000000..c46de50
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __Network_H
+#define __Network_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <stdint.h>
+
+/*
+ *  ======== Network_init =======
+ *  Initialize the Network module
+ */
+void Network_init();
+
+/*
+ *  ======== Network_startup =======
+ *  Wait for IP address, initialize the socket layer, get time via SNTP
+ */
+void Network_startup();
+
+/*
+ *  ======== Network_exit =======
+ *  Finalize the module
+ */
+void Network_exit();
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/sample/CC3220S_LAUNCHXL/startsntp.c b/sample/CC3220S_LAUNCHXL/startsntp.c
new file mode 100644 (file)
index 0000000..8c9efe8
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <ti/net/sntp/sntp.h>
+
+#include <ti/drivers/net/wifi/simplelink.h>
+
+/*
+ * Difference between NTP Epoch (seconds since January 1, 1900 GMT) and UNIX
+ * Epoch (seconds since January 1, 1970 GMT)
+ */
+#define TIME_BASEDIFF ((((uint32_t)70 * 365 + 17) * 24 * 3600))
+
+#define TIME_NTP_TO_UNIX(t) ((t) - TIME_BASEDIFF)
+
+#define NTP_SERVERS 1
+#define NTP_SERVER_PORT 123
+
+/*  Time to wait for reply from server (seconds) */
+#define NTP_REPLY_WAIT_TIME 5
+
+/* Must wait at least 15 sec to retry NTP server (RFC 4330) */
+#define NTP_POLL_TIME 15
+
+/*
+ *  ======== setNwpTime ========
+ *  Set the time on the network processor
+ *
+ *  ts: time in seconds since the Epoch
+ */
+static void setNwpTime(time_t ts)
+{
+    SlDateTime_t dt;
+    struct tm tm;
+
+    /* Convert time since Epoch to local time */
+    tm = *localtime(&ts);
+
+    /* Set system clock on network processor to validate certificate */
+    dt.tm_day  = tm.tm_mday;
+    /* tm.tm_mon is the month since January, so add 1 to get the actual month */
+    dt.tm_mon  = tm.tm_mon + 1;
+    /* tm.tm_year is the year since 1900, so add 1900 to get the actual year */
+    dt.tm_year = tm.tm_year + 1900;
+    dt.tm_hour = tm.tm_hour;
+    dt.tm_min  = tm.tm_min;
+    dt.tm_sec  = tm.tm_sec;
+    sl_DeviceSet(SL_DEVICE_GENERAL, SL_DEVICE_GENERAL_DATE_TIME,
+            sizeof(SlDateTime_t), (unsigned char *)(&dt));
+}
+
+/*
+ *  ======== startSNTP ========
+ */
+void startSNTP(void)
+{
+    uint64_t ntpTimeStamp;
+    uint32_t currentTimeNtp = 0;
+    uint32_t currentTimeUnix = 0;
+    int32_t retval;
+    time_t ts;
+    SlNetSock_Timeval_t timeval;
+    struct timespec tspec;
+
+    /* Set timeout value for NTP server reply */
+    timeval.tv_sec = NTP_REPLY_WAIT_TIME;
+    timeval.tv_usec = 0;
+
+    do {
+        /* Get the time using the built in NTP server list: */
+        retval = SNTP_getTime(NULL, 0, &timeval, &ntpTimeStamp);
+        if (retval != 0) {
+            printf(
+                "startSNTP: couldn't get time (%ld), will retry in %d secs ...\n",
+                retval, NTP_POLL_TIME);
+            sleep(NTP_POLL_TIME);
+            printf("startSNTP: retrying ...\n");
+        }
+
+        /* Save the current (NTP Epoch based) time */
+        currentTimeNtp = ntpTimeStamp >> 32;
+
+    } while (retval < 0);
+
+    /*
+     * Set the time on the application processor. Always pass a time value
+     * based on the UNIX Epoch
+     */
+    currentTimeUnix = TIME_NTP_TO_UNIX(currentTimeNtp);
+    tspec.tv_nsec = 0;
+    tspec.tv_sec = currentTimeUnix;
+    if (clock_settime(CLOCK_REALTIME, &tspec) != 0) {
+        printf("startSNTP: Failed to set current time\n");
+        while(1);
+    }
+
+    /*
+     * Use time.h APIs to set the time on the NWP and display it on the console.
+     * Must call time.h APIs using the appropriate (toolchain dependent) Epoch
+     * time base
+     */
+#if defined(__TI_COMPILER_VERSION__)
+    /* For the TI toolchain, time APIs expect times based on the NTP Epoch */
+    ts = currentTimeNtp;
+#else
+    /* Time APIs for GCC and IAR expect times based on the UNIX Epoch */
+    ts = currentTimeUnix;
+#endif
+
+    /* Set the time on the network processor */
+    setNwpTime(ts);
+
+    /* Print out the time in calendar format: */
+    printf("Current time: %s\n", ctime(&ts));
+}
diff --git a/sample/CC3220S_LAUNCHXL/tirtos/ccs/CC3220S_LAUNCHXL_TIRTOS.cmd b/sample/CC3220S_LAUNCHXL/tirtos/ccs/CC3220S_LAUNCHXL_TIRTOS.cmd
new file mode 100644 (file)
index 0000000..bc5ec58
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2016-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== CC3220S_LAUNCHXL.cmd ========
+ */
+
+/*
+ * The starting address of the application.  Normally the interrupt vectors
+ * must be located at the beginning of the application.
+ */
+#define SRAM_BASE 0x20004000
+#define SRAM0_BASE 0x20000000
+
+--stack_size=1024   /* C stack is also used for ISR stack */
+
+HEAPSIZE = 0x8000;  /* Size of heap buffer used by HeapMem */
+
+MEMORY
+{
+    SRAM0 (RWX) : origin = 0x20000000, length = 0x4000
+    SRAM  (RWX) : origin = 0x20004000, length = 0x00040000 - 0x4000
+}
+
+/* Section allocation in memory */
+
+SECTIONS
+{
+    .text       : > SRAM
+    .bss        : > SRAM
+    .TI.ramfunc : > SRAM
+    .data       : > SRAM
+    .const      : > SRAM
+
+    .sysmem     : > SRAM
+    .cinit      : > SRAM
+    .pinit      : > SRAM
+    .init_array : > SRAM
+
+    /* Heap buffer used by HeapMem */
+    .priheap    : {
+        __primary_heap_start__ = .;
+        . += HEAPSIZE;
+        __primary_heap_end__ = .;
+    } > SRAM align 8
+
+    .stack      : > SRAM0(HIGH)
+}
diff --git a/sample/CC3220S_LAUNCHXL/tirtos/ccs/makedefs b/sample/CC3220S_LAUNCHXL/tirtos/ccs/makedefs
new file mode 100644 (file)
index 0000000..d020f29
--- /dev/null
@@ -0,0 +1,24 @@
+CODEGEN_INSTALLATION_DIR = $(ti.targets.arm.elf.M4)
+CC = $(ti.targets.arm.elf.M4)/bin/armcl
+LD = $(ti.targets.arm.elf.M4)/bin/armcl -z
+
+KERNEL_BUILD :=  $(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/kernel/tirtos/builds/CC3220S_LAUNCHXL/release
+
+CONFIGPKG = $(KERNEL_BUILD)/ccs
+
+CFLAGS = -eo=.o -mv7M4 --float_support=vfplib --abi=eabi -me -ms --c99 "-I$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source" "-I$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/posix/ccs" -DSL_FULL -DSL_PLATFORM_MULTI_THREADED -DNET_SL --silicon_version=7M4 --code_state=16 --little_endian --display_error_number --diag_warning=255 --diag_wrap=off --gen_func_subsections=on --float_support=vfplib --symdebug:dwarf
+
+LFLAGS = "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/net/sntp/lib/ccs/m4/sntp_release.a" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/net/lib/ccs/m4/slnetsock_release.a" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/net/http/lib/ccs/m4/httpclient_release.a" -l"$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/drivers/net/wifi/ccs/rtos/simplelink.a" -l"$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/drivers/net/wifi/slnetif/ccs/Release/slnetifwifi.a" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/drivers/lib/drivers_cc32xx.aem4" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/kernel/tirtos/packages/ti/dpl/lib/dpl_cc32xx.aem4" "-l$(SIMPLELINK_CC32XX_SDK_INSTALL_DIR)/source/ti/devices/cc32xx/driverlib/ccs/Release/driverlib.a" --rom_model --warn_sections -i$(CODEGEN_INSTALLATION_DIR)/lib --reread_libs -llibc.a
+
+%.o : %.c
+       $(CC) $(CFLAGS) -c $<
+
+ifneq (,$(wildcard $(XDC_INSTALL_DIR)/xdc.exe))
+    # use these on Windows
+    RM      = $(XDC_INSTALL_DIR)/bin/rm -f
+    RMDIR   = $(XDC_INSTALL_DIR)/bin/rm -rf
+else
+    # use these on Linux
+    RM      = rm -f
+    RMDIR   = rm -rf
+endif
diff --git a/sample/CC3220S_LAUNCHXL/tirtos/ccs/makefile b/sample/CC3220S_LAUNCHXL/tirtos/ccs/makefile
new file mode 100644 (file)
index 0000000..a08756f
--- /dev/null
@@ -0,0 +1,67 @@
+#
+#  Copyright (c) 2017-2018, Texas Instruments Incorporated
+#  All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#  *  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#
+#  *  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+#  *  Neither the name of Texas Instruments Incorporated nor the names of
+#     its contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+#  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+#  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+#  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+TREE_ROOT = ../../../..
+include $(TREE_ROOT)/build_all/products.mak
+include makedefs
+
+CFLAGS :=  -I../.. -I../../.. -I$(TREE_ROOT)/sdk/inc/ -I$(TREE_ROOT)/sdk/certs/ -I$(TREE_ROOT)/sdk/c-utility/inc/ -I$(TREE_ROOT)/sdk/c-utility/inc/azure_c_shared_utility -I$(TREE_ROOT)/sdk/iothub_client/inc -I$(TREE_ROOT)/sdk/serializer/inc -g $(CFLAGS) --cmd_file=$(CONFIGPKG)/compiler.opt
+
+LIBS =  $(TREE_ROOT)/build_all/sdk/lib/ccs/m4/common_sl_release.a \
+    $(TREE_ROOT)/build_all/sdk/lib/ccs/m4/iotclient_sl_release.a \
+    $(TREE_ROOT)/build_all/sdk/lib/ccs/m4/serializer_sl_release.a \
+    $(TREE_ROOT)/build_all/pal/lib/ccs/m4/pal_sl_release.a
+
+VPATH = ..:../..:../../..:$(TREE_ROOT)/sdk/certs
+
+%.o : %.c
+
+%.o : %.c $(CONFIGPKG)/compiler.opt
+       @echo $(CC) $(CFLAGS) -c $<
+       @$(CC) $(CFLAGS) -c $<
+
+all: simplesample_http.out
+
+$(CONFIGPKG)/linker.cmd $(CONFIGPKG)/compiler.opt:
+       @ echo
+       $(error "$(CONFIGPKG) is not built. You can build it by issuing \
+            $(MAKE) in $(CONFIGPKG).")
+       @ echo
+
+simplesample_http.out: main_tirtos.o certs.o startsntp.o simplesample_http.o network.o CC3220S_LAUNCHXL.o CC3220S_LAUNCHXL_TIRTOS.cmd $(CONFIGPKG)/linker.cmd $(LIBS)
+       @echo building $@ ..
+       @$(LD) -o $@ $^ -x -m $@.map $(LFLAGS)
+
+clean:
+       @echo cleaning ..
+       @ $(RM) *.o *.out *.map
+       @ $(RMDIR)
diff --git a/sample/CC3220S_LAUNCHXL/tirtos/main_tirtos.c b/sample/CC3220S_LAUNCHXL/tirtos/main_tirtos.c
new file mode 100644 (file)
index 0000000..74f8345
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ *  ======== main_tirtos.c ========
+ */
+#include <stdio.h>
+
+#include <ti/sysbios/BIOS.h>
+
+#include <ti/drivers/GPIO.h>
+#include <ti/drivers/SPI.h>
+
+#include <ti/drivers/net/wifi/simplelink.h>
+
+#include <pthread.h>
+
+#include <simplesample_http.h>
+
+#include <ti/net/slnetsock.h>
+#include <ti/net/slnetif.h>
+
+#include "Board.h"
+#include "certs.h"
+#include "network.h"
+
+#define AZURE_IOT_ROOT_CA_FILENAME "/cert/ms.pem"
+/*
+ * The following macro is disabled by default. This is done to prevent the
+ * certificate files from being written to flash every time the program
+ * is run.  If an update to the cert files are needed, just update the
+ * corresponding arrays, and rebuild with this macro defined. Note
+ * you must remember to disable it otherwise the files will keep being
+ * overwritten each time.
+ */
+#ifdef OVERWRITE_CERTS
+static bool overwriteCerts = true;
+#else
+static bool overwriteCerts = false;
+#endif
+
+/*
+ *  ======== flashFile ========
+ *  Flashes file to the SFLASH using SimpleLink WiFi APIs
+ *
+ *  Returns number of bytes written on success or < 0 on failure
+ */
+int flashFile(const char *path, const uint8_t *buffer, uint32_t len)
+{
+    int32_t ret = -1;
+    int32_t fileHandle;
+
+    if (path && buffer) {
+        fileHandle = sl_FsOpen((unsigned char *)path,
+                SL_FS_CREATE | SL_FS_CREATE_SECURE | SL_FS_CREATE_NOSIGNATURE
+                | SL_FS_CREATE_PUBLIC_WRITE | SL_FS_OVERWRITE
+                | SL_FS_CREATE_MAX_SIZE(len), NULL);
+        if (fileHandle > 0) {
+            ret = sl_FsWrite(fileHandle, 0, (unsigned char *)buffer, len);
+            sl_FsClose(fileHandle, NULL, NULL, 0);
+        }
+    }
+
+    return (ret);
+}
+
+/*
+ *  ======== flashCerts ========
+ *  Utility function to flash the contents of a buffer (PEM format) into the
+ *  filename/path specified by certName
+ */
+void flashCerts(uint8_t *certName, uint8_t *buffer, uint32_t bufflen)
+{
+    int status = 0;
+    int16_t slStatus = 0;
+    SlFsFileInfo_t fsFileInfo;
+
+    /* Check if the cert file already exists */
+    slStatus = sl_FsGetInfo(certName, 0, &fsFileInfo);
+
+    /* If the cert doesn't exist, write it (or overwrite if specified to) */
+    if (slStatus == SL_ERROR_FS_FILE_NOT_EXISTS || overwriteCerts == true) {
+
+        printf("Flashing certificate file ...");
+
+        status = flashFile((const char *)certName, buffer, bufflen);
+
+        if (status < 0) {
+            printf("Error: Could not write file %s to flash (%d)\n",
+                    certName, status);
+            while (1);
+        }
+        printf("successfully wrote file %s to flash\n", certName);
+    }
+}
+
+/*
+ *  ======== azureThreadFxn ========
+ */
+void *azureThreadFxn(void *arg0)
+{
+    SlNetCfgIpV4Args_t ipV4;
+    uint16_t           len = sizeof(ipV4);
+    uint16_t           dhcpIsOn;
+
+    printf("Starting the simplesample_http example\n");
+
+    /* Wait for an IP address, initialize the socket layer and get the time */
+    Network_startup();
+
+    /* Retrieve & print the IP address */
+    sl_NetCfgGet(SL_NETCFG_IPV4_STA_ADDR_MODE, &dhcpIsOn, &len,
+            (unsigned char *)&ipV4);
+    printf("CC32XX has connected to AP and acquired an IP address.\n");
+    printf("IP Address: %ld.%ld.%ld.%ld\n", SL_IPV4_BYTE(ipV4.Ip, 3),
+            SL_IPV4_BYTE(ipV4.Ip, 2), SL_IPV4_BYTE(ipV4.Ip, 1),
+            SL_IPV4_BYTE(ipV4.Ip, 0));
+
+    /* Flash Certificate Files */
+    flashCerts((uint8_t *)AZURE_IOT_ROOT_CA_FILENAME, (uint8_t *)certificates,
+            strlen(certificates));
+
+    simplesample_http_run();
+
+    return (NULL);
+}
+
+/*
+ *  ======== main ========
+ */
+int main(int argc, char *argv[])
+{
+    pthread_attr_t pthreadAttrs;
+    pthread_t slThread;
+    pthread_t azureThread;
+    int status;
+
+    Board_initGeneral();
+    GPIO_init();
+    SPI_init();
+    Network_init();
+
+    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
+
+    /* Create the sl_Task thread */
+    pthread_attr_init(&pthreadAttrs);
+
+    status = pthread_attr_setstacksize(&pthreadAttrs, 2048);
+    if (status != 0) {
+        /* Error setting stack size */
+        while (1);
+    }
+
+    status = pthread_create(&slThread, &pthreadAttrs, sl_Task, NULL);
+    if (status != 0) {
+        /* Failed to create sl_Task thread */
+        while (1);
+    }
+
+    /* Create the AZURE thread */
+    status = pthread_attr_setstacksize(&pthreadAttrs, 4096);
+    if (status != 0) {
+        /* Error setting stack size */
+        while (1);
+    }
+
+    status = pthread_create(&azureThread, &pthreadAttrs, azureThreadFxn, NULL);
+    if (status != 0) {
+        /* Failed to create Azure thread */
+        while (1);
+    }
+
+    pthread_attr_destroy(&pthreadAttrs);
+
+    BIOS_start();
+
+    return (0);
+}
diff --git a/sample/CC3220S_LAUNCHXL/wificonfig.h b/sample/CC3220S_LAUNCHXL/wificonfig.h
new file mode 100644 (file)
index 0000000..30abbbc
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef WIFICONFIG_H
+#define WIFICONFIG_H
+
+/* USER STEP: Update these macros */
+#define SSID ""
+#define SECURITY_KEY ""
+#define SECURITY_TYPE SL_WLAN_SEC_TYPE_WPA
+
+#endif
diff --git a/sample/MSP_EXP432E401Y/Board.h b/sample/MSP_EXP432E401Y/Board.h
new file mode 100644 (file)
index 0000000..774fcef
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __BOARD_H
+#define __BOARD_H
+
+#define Board_MSP_EXP432E401Y
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "MSP_EXP432E401Y.h"
+
+#define Board_initGeneral           MSP_EXP432E401Y_initGeneral
+
+#define Board_ADC0                  MSP_EXP432E401Y_ADC0
+#define Board_ADC1                  MSP_EXP432E401Y_ADC1
+
+#define Board_ADCBUF0               MSP_EXP432E401Y_ADCBUF0
+#define Board_ADCBUF0CHANNEL0       MSP_EXP432E401Y_ADCBUF0CHANNEL0
+#define Board_ADCBUF0CHANNEL1       MSP_EXP432E401Y_ADCBUF0CHANNEL1
+#define Board_ADCBUF0CHANNEL2       MSP_EXP432E401Y_ADCBUF0CHANNEL2
+#define Board_ADCBUF0CHANNEL3       MSP_EXP432E401Y_ADCBUF0CHANNEL3
+#define Board_ADCBUF0CHANNEL4       MSP_EXP432E401Y_ADCBUF0CHANNEL4
+
+#define Board_GPIO_LED_ON           MSP_EXP432E401Y_GPIO_LED_ON
+#define Board_GPIO_LED_OFF          MSP_EXP432E401Y_GPIO_LED_OFF
+#define Board_GPIO_LED0             MSP_EXP432E401Y_GPIO_D1
+#define Board_GPIO_LED1             MSP_EXP432E401Y_GPIO_D2
+#define Board_GPIO_LED2             MSP_EXP432E401Y_GPIO_D2
+#define Board_GPIO_BUTTON0          MSP_EXP432E401Y_GPIO_USR_SW1
+#define Board_GPIO_BUTTON1          MSP_EXP432E401Y_GPIO_USR_SW2
+
+#define Board_I2C0                  MSP_EXP432E401Y_I2C0
+#define Board_I2C_TMP               MSP_EXP432E401Y_I2C0
+#define Board_I2C_TPL0401           MSP_EXP432E401Y_I2C7
+
+#define Board_NVSINTERNAL           MSP_EXP432E401Y_NVSMSP432E40
+
+#define Board_PWM0                  MSP_EXP432E401Y_PWM0
+
+#define Board_SD0                   MSP_EXP432E401Y_SDSPI0
+
+#define Board_SDFatFS0              MSP_EXP432E401Y_SDSPI0
+
+#define Board_SPI0                  MSP_EXP432E401Y_SPI2
+#define Board_SPI1                  MSP_EXP432E401Y_SPI3
+
+#define Board_SPI_MASTER            MSP_EXP432E401Y_SPI2
+#define Board_SPI_SLAVE             MSP_EXP432E401Y_SPI2
+#define Board_SPI_MASTER_READY      MSP_EXP432E401Y_SPI_MASTER_READY
+#define Board_SPI_SLAVE_READY       MSP_EXP432E401Y_SPI_SLAVE_READY
+
+#define Board_TIMER0                MSP_EXP432E401Y_TIMER0
+#define Board_TIMER1                MSP_EXP432E401Y_TIMER1
+#define Board_TIMER2                MSP_EXP432E401Y_TIMER2
+
+#define Board_UART0                 MSP_EXP432E401Y_UART0
+
+#define Board_WATCHDOG0             MSP_EXP432E401Y_WATCHDOG0
+
+/* Board specific I2C addresses */
+#define Board_TMP_ADDR              (0x40)
+#define Board_SENSORS_BP_TMP_ADDR   Board_TMP_ADDR
+#define Board_TPL0401_ADDR          (0x40)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BOARD_H */
diff --git a/sample/MSP_EXP432E401Y/MSP_EXP432E401Y.c b/sample/MSP_EXP432E401Y/MSP_EXP432E401Y.c
new file mode 100644 (file)
index 0000000..e94f9c4
--- /dev/null
@@ -0,0 +1,802 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== MSP_EXP432E401Y.c ========
+ *  This file is responsible for setting up the board specific items for the
+ *  MSP_EXP432E401Y board.
+ */
+#include <stdint.h>
+#include <stdlib.h>
+
+#ifndef __MSP432E401Y__
+#define __MSP432E401Y__
+#endif
+
+#include <ti/devices/msp432e4/inc/msp432.h>
+
+#include <ti/devices/msp432e4/driverlib/adc.h>
+#include <ti/devices/msp432e4/driverlib/interrupt.h>
+#include <ti/devices/msp432e4/driverlib/pwm.h>
+#include <ti/devices/msp432e4/driverlib/sysctl.h>
+#include <ti/devices/msp432e4/driverlib/udma.h>
+
+#include <ti/drivers/Power.h>
+
+#include "MSP_EXP432E401Y.h"
+
+/*
+ *  =============================== ADC ===============================
+ */
+#include <ti/drivers/ADC.h>
+#include <ti/drivers/adc/ADCMSP432E4.h>
+
+/* ADC objects */
+ADCMSP432E4_Object adcMSP432E4Objects[MSP_EXP432E401Y_ADCCOUNT];
+
+/* ADC configuration structure */
+const ADCMSP432E4_HWAttrsV1 adcMSP432E4HWAttrs[MSP_EXP432E401Y_ADCCOUNT] = {
+    {
+        .adcPin = ADCMSP432E4_PE_3_A0,
+        .refVoltage = ADCMSP432E4_VREF_INTERNAL,
+        .adcModule = ADCMSP432E4_MOD0,
+        .adcSeq = ADCMSP432E4_SEQ0
+    },
+    {
+        .adcPin = ADCMSP432E4_PE_2_A1,
+        .refVoltage = ADCMSP432E4_VREF_INTERNAL,
+        .adcModule = ADCMSP432E4_MOD1,
+        .adcSeq = ADCMSP432E4_SEQ0
+    }
+};
+
+const ADC_Config ADC_config[MSP_EXP432E401Y_ADCCOUNT] = {
+    {
+        .fxnTablePtr = &ADCMSP432E4_fxnTable,
+        .object = &adcMSP432E4Objects[MSP_EXP432E401Y_ADC0],
+        .hwAttrs = &adcMSP432E4HWAttrs[MSP_EXP432E401Y_ADC0]
+    },
+    {
+        .fxnTablePtr = &ADCMSP432E4_fxnTable,
+        .object = &adcMSP432E4Objects[MSP_EXP432E401Y_ADC1],
+        .hwAttrs = &adcMSP432E4HWAttrs[MSP_EXP432E401Y_ADC1]
+    }
+};
+
+const uint_least8_t ADC_count = MSP_EXP432E401Y_ADCCOUNT;
+
+/*
+ *  =============================== ADCBuf ===============================
+ */
+#include <ti/drivers/ADCBuf.h>
+#include <ti/drivers/adcbuf/ADCBufMSP432E4.h>
+
+/* ADC objects */
+ADCBufMSP432E4_Object adcbufMSP432E4Objects[MSP_EXP432E401Y_ADCBUFCOUNT];
+
+ADCBufMSP432E4_Channels adcBuf0MSP432E4Channels[MSP_EXP432E401Y_ADCBUF0CHANNELCOUNT] = {
+    {
+        .adcPin = ADCBufMSP432E4_PE_3_A0,
+        .adcSequence = ADCBufMSP432E4_Seq_0,
+        .adcInputMode = ADCBufMSP432E4_SINGLE_ENDED,
+        .adcDifferentialPin = ADCBufMSP432E4_PIN_NONE,
+        .adcInternalSource = ADCBufMSP432E4_INTERNAL_SOURCE_MODE_OFF,
+        .refVoltage = 3300000
+    },
+    {
+        .adcPin = ADCBufMSP432E4_PE_2_A1,
+        .adcSequence = ADCBufMSP432E4_Seq_1,
+        .adcInputMode = ADCBufMSP432E4_SINGLE_ENDED,
+        .adcDifferentialPin = ADCBufMSP432E4_PIN_NONE,
+        .adcInternalSource = ADCBufMSP432E4_INTERNAL_SOURCE_MODE_OFF,
+        .refVoltage = 3300000
+    },
+    {
+        .adcPin = ADCBufMSP432E4_PIN_NONE,
+        .adcSequence = ADCBufMSP432E4_Seq_0,
+        .adcInputMode = ADCBufMSP432E4_SINGLE_ENDED,
+        .adcDifferentialPin = ADCBufMSP432E4_PIN_NONE,
+        .adcInternalSource = ADCBufMSP432E4_TEMPERATURE_MODE,
+        .refVoltage = 3300000
+    },
+    {
+        .adcPin = ADCBufMSP432E4_PE_3_A0,
+        .adcSequence = ADCBufMSP432E4_Seq_0,
+        .adcInputMode = ADCBufMSP432E4_DIFFERENTIAL,
+        .adcDifferentialPin = ADCBufMSP432E4_PE_2_A1,
+        .adcInternalSource = ADCBufMSP432E4_INTERNAL_SOURCE_MODE_OFF,
+        .refVoltage = 3300000
+    },
+    {
+        .adcPin = ADCBufMSP432E4_PE_2_A1,
+        .adcSequence = ADCBufMSP432E4_Seq_0,
+        .adcInputMode = ADCBufMSP432E4_SINGLE_ENDED,
+        .adcDifferentialPin = ADCBufMSP432E4_PIN_NONE,
+        .adcInternalSource = ADCBufMSP432E4_INTERNAL_SOURCE_MODE_OFF,
+        .refVoltage = 3300000
+    }
+};
+
+/* ADC sequencer priorities for SS0-SS3, set to 0-3 to initialize sequencer */
+static ADCBufMSP432E4_SequencePriorities seqPriorities[ADCBufMSP432E4_SEQUENCER_COUNT] = {
+    ADCBufMSP432E4_Priority_0,
+    ADCBufMSP432E4_Seq_Disable,
+    ADCBufMSP432E4_Seq_Disable,
+    ADCBufMSP432E4_Seq_Disable
+};
+
+/* ADC sequencer tigger source for SS0-SS3*/
+static ADCBufMSP432E4_TriggerSource triggerSource[ADCBufMSP432E4_SEQUENCER_COUNT] = {
+    ADCBufMSP432E4_TIMER_TRIGGER,
+    ADCBufMSP432E4_TIMER_TRIGGER,
+    ADCBufMSP432E4_TIMER_TRIGGER,
+    ADCBufMSP432E4_TIMER_TRIGGER
+};
+
+/* ADC configuration structure */
+const ADCBufMSP432E4_HWAttrsV1 adcbufMSP432E4HWAttrs[MSP_EXP432E401Y_ADCBUFCOUNT] = {
+    {
+        .intPriority = ~0,
+        .adcBase = ADC0_BASE,
+        .channelSetting = adcBuf0MSP432E4Channels,
+        .sequencePriority = seqPriorities,
+        .adcTriggerSource = triggerSource,
+        .modulePhase =  ADCBufMSP432E4_Phase_Delay_0,
+        .refSource = ADCBufMSP432E4_VREF_INTERNAL,
+        .useDMA = 1,
+        .adcTimerSource = TIMER1_BASE,
+    }
+};
+
+const ADCBuf_Config ADCBuf_config[MSP_EXP432E401Y_ADCBUFCOUNT] = {
+    {
+        .fxnTablePtr = &ADCBufMSP432E4_fxnTable,
+        .object = &adcbufMSP432E4Objects[MSP_EXP432E401Y_ADCBUF0],
+        .hwAttrs = &adcbufMSP432E4HWAttrs[MSP_EXP432E401Y_ADCBUF0]
+    }
+};
+
+const uint_least8_t ADCBuf_count = MSP_EXP432E401Y_ADCBUFCOUNT;
+
+/*
+ *  ============================= Display =============================
+ */
+#include <ti/display/Display.h>
+#include <ti/display/DisplayUart.h>
+#include <ti/display/DisplaySharp.h>
+#define MAXPRINTLEN 1024
+
+#ifndef BOARD_DISPLAY_SHARP_SIZE
+#define BOARD_DISPLAY_SHARP_SIZE    96
+#endif
+
+DisplayUart_Object displayUartObject;
+DisplaySharp_Object    displaySharpObject;
+
+static char displayBuf[MAXPRINTLEN];
+static uint_least8_t sharpDisplayBuf[BOARD_DISPLAY_SHARP_SIZE * BOARD_DISPLAY_SHARP_SIZE / 8];
+
+
+const DisplayUart_HWAttrs displayUartHWAttrs = {
+    .uartIdx = MSP_EXP432E401Y_UART0,
+    .baudRate = 115200,
+    .mutexTimeout = (unsigned int)(-1),
+    .strBuf = displayBuf,
+    .strBufLen = MAXPRINTLEN
+};
+
+const DisplaySharp_HWAttrsV1 displaySharpHWattrs = {
+    .spiIndex    = MSP_EXP432E401Y_SPI2,
+    .csPin       = MSP_EXP432E401Y_LCD_CS,
+    .powerPin    = MSP_EXP432E401Y_LCD_POWER,
+    .enablePin   = MSP_EXP432E401Y_LCD_ENABLE,
+    .pixelWidth  = BOARD_DISPLAY_SHARP_SIZE,
+    .pixelHeight = BOARD_DISPLAY_SHARP_SIZE,
+    .displayBuf  = sharpDisplayBuf,
+};
+
+#ifndef BOARD_DISPLAY_USE_UART
+#define BOARD_DISPLAY_USE_UART 1
+#endif
+#ifndef BOARD_DISPLAY_USE_UART_ANSI
+#define BOARD_DISPLAY_USE_UART_ANSI 0
+#endif
+#ifndef BOARD_DISPLAY_USE_LCD
+#define BOARD_DISPLAY_USE_LCD 0
+#endif
+
+/*
+ * This #if/#else is needed to workaround a problem with the
+ * IAR compiler. The IAR compiler doesn't like the empty array
+ * initialization. (IAR Error[Pe1345])
+ */
+ #if (BOARD_DISPLAY_USE_UART || BOARD_DISPLAY_USE_LCD)
+const Display_Config Display_config[] = {
+    {
+#  if (BOARD_DISPLAY_USE_UART_ANSI)
+        .fxnTablePtr = &DisplayUartAnsi_fxnTable,
+#  else /* Default to minimal UART with no cursor placement */
+        .fxnTablePtr = &DisplayUartMin_fxnTable,
+#  endif
+        .object = &displayUartObject,
+        .hwAttrs = &displayUartHWAttrs
+    },
+#endif
+#if (BOARD_DISPLAY_USE_LCD)
+    {
+        .fxnTablePtr = &DisplaySharp_fxnTable,
+        .object      = &displaySharpObject,
+        .hwAttrs     = &displaySharpHWattrs
+    },
+#endif
+};
+
+const uint_least8_t Display_count = sizeof(Display_config) / sizeof(Display_Config);
+
+/*
+ *  =============================== DMA ===============================
+ */
+#include <ti/drivers/dma/UDMAMSP432E4.h>
+
+#if defined(__TI_COMPILER_VERSION__)
+#pragma DATA_ALIGN(dmaControlTable, 1024)
+#elif defined(__IAR_SYSTEMS_ICC__)
+#pragma data_alignment=1024
+#elif defined(__GNUC__)
+__attribute__ ((aligned (1024)))
+#endif
+static tDMAControlTable dmaControlTable[64];
+
+/*
+ *  ======== dmaErrorFxn ========
+ *  This is the handler for the uDMA error interrupt.
+ */
+static void dmaErrorFxn(uintptr_t arg)
+{
+    int status = uDMAErrorStatusGet();
+    uDMAErrorStatusClear();
+
+    /* Suppress unused variable warning */
+    (void)status;
+
+    while (1);
+}
+
+UDMAMSP432E4_Object udmaMSP432E4Object;
+
+const UDMAMSP432E4_HWAttrs udmaMSP432E4HWAttrs = {
+    .controlBaseAddr = (void *)dmaControlTable,
+    .dmaErrorFxn = (UDMAMSP432E4_ErrorFxn)dmaErrorFxn,
+    .intNum = INT_UDMAERR,
+    .intPriority = (~0)
+};
+
+const UDMAMSP432E4_Config UDMAMSP432E4_config = {
+    .object = &udmaMSP432E4Object,
+    .hwAttrs = &udmaMSP432E4HWAttrs
+};
+
+/*
+ *  =============================== General ===============================
+ */
+/*
+ *  ======== MSP_EXP432E401Y_initGeneral ========
+ */
+void MSP_EXP432E401Y_initGeneral(void)
+{
+    Power_init();
+
+    /* Grant the DMA access to all FLASH memory */
+    FLASH_CTRL->PP |= FLASH_PP_DFA;
+
+    /* Region start address - match FLASH start address */
+    FLASH_CTRL->DMAST = 0x00000000;
+
+    /*
+     * Access to FLASH is granted to the DMA in 2KB regions.  The value
+     * assigned to DMASZ is the amount of 2KB regions to which the DMA will
+     * have access.  The value can be determined via the following:
+     *     2 * (num_regions + 1) KB
+     *
+     * To grant full access to entire 1MB of FLASH:
+     *     2 * (511 + 1) KB = 1024 KB (1 MB)
+     */
+    FLASH_CTRL->DMASZ = 511;
+}
+
+/*
+ *  =============================== EMAC ===============================
+ */
+/* minimize scope of ndk/inc/stk_main.h -- this eliminates TIPOSIX path dependencies */
+#define NDK_NOUSERAPIS 1
+#include <ti/drivers/emac/EMACMSP432E4.h>
+
+/*
+ *  Required by the Networking Stack (NDK). This array must be NULL terminated.
+ *  This can be removed if NDK is not used.
+ *  Double curly braces are needed to avoid GCC bug #944572
+ *  https://bugs.launchpad.net/gcc-linaro/+bug/944572
+ */
+NIMU_DEVICE_TABLE_ENTRY NIMUDeviceTable[2] = {
+    {
+        /* Default: use Ethernet driver */
+        .init = EMACMSP432E4_NIMUInit
+    },
+    {NULL}
+};
+
+/*
+ *  Ethernet MAC address
+ *  NOTE: By default (i.e. when each octet is 0xff), the driver reads the MAC
+ *        address that's stored in flash. To override this behavior, manually
+ *        set the octets of the MAC address you wish to use into the array here:
+ */
+unsigned char macAddress[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+/* EMAC configuration structure */
+const EMACMSP432E4_HWAttrs EMACMSP432E4_hwAttrs = {
+    .baseAddr = EMAC0_BASE,
+    .intNum = INT_EMAC0,
+    .intPriority = (~0),
+    .led0Pin = EMACMSP432E4_PF0_EN0LED0,
+    .led1Pin = EMACMSP432E4_PF4_EN0LED1,
+    .macAddress = macAddress
+};
+
+/*
+ *  =============================== GPIO ===============================
+ */
+#include <ti/drivers/GPIO.h>
+#include <ti/drivers/gpio/GPIOMSP432E4.h>
+
+/*
+ * Array of Pin configurations
+ * NOTE: The order of the pin configurations must coincide with what was
+ *       defined in MSP_EXP432E401Y.h
+ * NOTE: Pins not used for interrupts should be placed at the end of the
+ *       array.  Callback entries can be omitted from callbacks array to
+ *       reduce memory usage.
+ */
+GPIO_PinConfig gpioPinConfigs[] = {
+    /* Input pins */
+    /* MSP_EXP432E401Y_USR_SW1 */
+    GPIOMSP432E4_PJ0 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
+    /* MSP_EXP432E401Y_USR_SW2 */
+    GPIOMSP432E4_PJ1 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
+
+    /* MSP_EXP432E401Y_SPI_MASTER_READY */
+    GPIOMSP432E4_PM3 | GPIO_DO_NOT_CONFIG,
+    /* MSP_EXP432E401Y_SPI_SLAVE_READY */
+    GPIOMSP432E4_PL0 | GPIO_DO_NOT_CONFIG,
+
+    /* Output pins */
+    /* MSP_EXP432E401Y_USR_D1 */
+    GPIOMSP432E4_PN1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
+    /* MSP_EXP432E401Y_USR_D2 */
+    GPIOMSP432E4_PN0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
+
+    /* MSP_EXP432E401Y_SDSPI_CS */
+    GPIOMSP432E4_PC7 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_HIGH,
+
+    /* Sharp Display - GPIO configurations will be done in the Display files */
+    GPIOMSP432E4_PE5 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
+    GPIOMSP432E4_PC6 | GPIO_DO_NOT_CONFIG, /* LCD power control */
+    GPIOMSP432E4_PE4 | GPIO_DO_NOT_CONFIG, /*LCD enable */
+};
+
+/*
+ * Array of callback function pointers
+ * NOTE: The order of the pin configurations must coincide with what was
+ *       defined in MSP_EXP432E401Y.h
+ * NOTE: Pins not used for interrupts can be omitted from callbacks array to
+ *       reduce memory usage (if placed at end of gpioPinConfigs array).
+ */
+GPIO_CallbackFxn gpioCallbackFunctions[] = {
+    NULL,  /* MSP_EXP432E401Y_USR_SW1 */
+    NULL,  /* MSP_EXP432E401Y_USR_SW2 */
+    NULL,  /* MSP_EXP432E401Y_SPI_MASTER_READY */
+    NULL   /* MSP_EXP432E401Y_SPI_SLAVE_READY */
+};
+
+/* The device-specific GPIO_config structure */
+const GPIOMSP432E4_Config GPIOMSP432E4_config = {
+    .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
+    .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
+    .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
+    .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
+    .intPriority = (~0)
+};
+
+/*
+ *  =============================== I2C ===============================
+ */
+#include <ti/drivers/I2C.h>
+#include <ti/drivers/i2c/I2CMSP432E4.h>
+
+I2CMSP432E4_Object i2cMSP432E4Objects[MSP_EXP432E401Y_I2CCOUNT];
+
+const I2CMSP432E4_HWAttrs i2cMSP432E4HWAttrs[MSP_EXP432E401Y_I2CCOUNT] = {
+    {
+        .baseAddr = I2C0_BASE,
+        .intNum = INT_I2C0,
+        .intPriority = (~0),
+        .sclPin = I2CMSP432E4_PB2_I2C0SCL,
+        .sdaPin = I2CMSP432E4_PB3_I2C0SDA,
+        .masterCode = 0x08
+    },
+    {
+        .baseAddr = I2C7_BASE,
+        .intNum = INT_I2C7,
+        .intPriority = (~0),
+        .sclPin = I2CMSP432E4_PD0_I2C7SCL,
+        .sdaPin = I2CMSP432E4_PD1_I2C7SDA,
+        .masterCode = 0x09
+    }
+};
+
+const I2C_Config I2C_config[MSP_EXP432E401Y_I2CCOUNT] = {
+    {
+        .fxnTablePtr = &I2CMSP432E4_fxnTable,
+        .object = &i2cMSP432E4Objects[MSP_EXP432E401Y_I2C0],
+        .hwAttrs = &i2cMSP432E4HWAttrs[MSP_EXP432E401Y_I2C0]
+    },
+    {
+        .fxnTablePtr = &I2CMSP432E4_fxnTable,
+        .object = &i2cMSP432E4Objects[MSP_EXP432E401Y_I2C7],
+        .hwAttrs = &i2cMSP432E4HWAttrs[MSP_EXP432E401Y_I2C7]
+    },
+};
+
+const uint_least8_t I2C_count = MSP_EXP432E401Y_I2CCOUNT;
+
+/*
+ *  =============================== NVS ===============================
+ */
+#include <ti/drivers/NVS.h>
+#include <ti/drivers/nvs/NVSMSP432E4.h>
+
+#define SECTORSIZE       (0x4000)
+#define NVS_REGIONS_BASE (0xE0000)
+#define REGIONSIZE       (SECTORSIZE * 8)
+
+/*
+ * Reserve flash sectors for NVS driver use
+ * by placing an uninitialized byte array
+ * at the desired flash address.
+ */
+#if defined(__TI_COMPILER_VERSION__)
+
+/*
+ * Place uninitialized array at NVS_REGIONS_BASE
+ */
+#pragma LOCATION(flashBuf, NVS_REGIONS_BASE);
+#pragma NOINIT(flashBuf);
+static char flashBuf[REGIONSIZE];
+
+#elif defined(__IAR_SYSTEMS_ICC__)
+
+/*
+ * Place uninitialized array at NVS_REGIONS_BASE
+ */
+static __no_init char flashBuf[REGIONSIZE] @ NVS_REGIONS_BASE;
+
+#elif defined(__GNUC__)
+
+/*
+ * Place the flash buffers in the .nvs section created in the gcc linker file.
+ * The .nvs section enforces alignment on a sector boundary but may
+ * be placed anywhere in flash memory.  If desired the .nvs section can be set
+ * to a fixed address by changing the following in the gcc linker file:
+ *
+ * .nvs (FIXED_FLASH_ADDR) (NOLOAD) : AT (FIXED_FLASH_ADDR) {
+ *      *(.nvs)
+ * } > REGION_TEXT
+ */
+__attribute__ ((section (".nvs")))
+static char flashBuf[REGIONSIZE];
+
+#endif
+
+NVSMSP432E4_Object nvsMSP432E4Objects[MSP_EXP432E401Y_NVSCOUNT];
+
+const NVSMSP432E4_HWAttrs nvsMSP432E4HWAttrs[MSP_EXP432E401Y_NVSCOUNT] = {
+    {
+        .regionBase = (void *) flashBuf,
+        .regionSize = REGIONSIZE,
+    },
+};
+
+const NVS_Config NVS_config[MSP_EXP432E401Y_NVSCOUNT] = {
+    {
+        .fxnTablePtr = &NVSMSP432E4_fxnTable,
+        .object = &nvsMSP432E4Objects[MSP_EXP432E401Y_NVSMSP432E40],
+        .hwAttrs = &nvsMSP432E4HWAttrs[MSP_EXP432E401Y_NVSMSP432E40],
+    },
+};
+
+const uint_least8_t NVS_count = MSP_EXP432E401Y_NVSCOUNT;
+
+/*
+ *  =============================== Power ===============================
+ */
+#include <ti/drivers/power/PowerMSP432E4.h>
+const PowerMSP432E4_Config PowerMSP432E4_config = {
+    .policyFxn = &PowerMSP432E4_sleepPolicy,
+    .enablePolicy = true
+};
+
+/*
+ *  =============================== PWM ===============================
+ */
+#include <ti/drivers/PWM.h>
+#include <ti/drivers/pwm/PWMMSP432E4.h>
+
+PWMMSP432E4_Object pwmMSP432E4Objects[MSP_EXP432E401Y_PWMCOUNT];
+
+const PWMMSP432E4_HWAttrs pwmMSP432E4HWAttrs[MSP_EXP432E401Y_PWMCOUNT] = {
+    {
+        .pwmBaseAddr = PWM0_BASE,
+        .pwmOutput = PWM_OUT_0,
+        .pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN,
+        .pinConfig = PWMMSP432E4_PF0_M0PWM0
+    }
+};
+
+const PWM_Config PWM_config[MSP_EXP432E401Y_PWMCOUNT] = {
+    {
+        .fxnTablePtr = &PWMMSP432E4_fxnTable,
+        .object = &pwmMSP432E4Objects[MSP_EXP432E401Y_PWM0],
+        .hwAttrs = &pwmMSP432E4HWAttrs[MSP_EXP432E401Y_PWM0]
+    },
+};
+
+const uint_least8_t PWM_count = MSP_EXP432E401Y_PWMCOUNT;
+
+/*
+ *  =============================== SDFatFS ===============================
+ */
+#include <ti/drivers/SD.h>
+#include <ti/drivers/SDFatFS.h>
+
+/*
+ * Note: The SDFatFS driver provides interface functions to enable FatFs
+ * but relies on the SD driver to communicate with SD cards.  Opening a
+ * SDFatFs driver instance will internally try to open a SD driver instance
+ * reusing the same index number (opening SDFatFs driver at index 0 will try to
+ * open SD driver at index 0).  This requires that all SDFatFs driver instances
+ * have an accompanying SD driver instance defined with the same index.  It is
+ * acceptable to have more SD driver instances than SDFatFs driver instances
+ * but the opposite is not supported & the SDFatFs will fail to open.
+ */
+SDFatFS_Object sdfatfsObjects[MSP_EXP432E401Y_SDFatFSCOUNT];
+
+const SDFatFS_Config SDFatFS_config[MSP_EXP432E401Y_SDFatFSCOUNT] = {
+    {
+        .object = &sdfatfsObjects[MSP_EXP432E401Y_SDFatFS0]
+    }
+};
+
+const uint_least8_t SDFatFS_count = MSP_EXP432E401Y_SDFatFSCOUNT;
+
+/*
+ *  =============================== SD ===============================
+ */
+#include <ti/drivers/SD.h>
+#include <ti/drivers/sd/SDSPI.h>
+
+SDSPI_Object sdspiObjects[MSP_EXP432E401Y_SDCOUNT];
+
+const SDSPI_HWAttrs sdspiHWAttrs[MSP_EXP432E401Y_SDCOUNT] = {
+    {
+        .spiIndex = MSP_EXP432E401Y_SPI2,
+        .spiCsGpioIndex = MSP_EXP432E401Y_SDSPI_CS
+    }
+};
+
+const SD_Config SD_config[MSP_EXP432E401Y_SDCOUNT] = {
+    {
+        .fxnTablePtr = &SDSPI_fxnTable,
+        .object = &sdspiObjects[MSP_EXP432E401Y_SDSPI0],
+        .hwAttrs = &sdspiHWAttrs[MSP_EXP432E401Y_SDSPI0]
+    },
+};
+
+const uint_least8_t SD_count = MSP_EXP432E401Y_SDCOUNT;
+
+/*
+ *  =============================== SPI ===============================
+ */
+#include <ti/drivers/SPI.h>
+#include <ti/drivers/spi/SPIMSP432E4DMA.h>
+
+SPIMSP432E4DMA_Object spiMSP432E4DMAObjects[MSP_EXP432E401Y_SPICOUNT];
+
+/*
+ * NOTE: The SPI instances below can be used by the SD driver to communicate
+ * with a SD card via SPI.  The 'defaultTxBufValue' fields below are set to
+ * (~0) to satisfy the SDSPI driver requirement.
+ */
+const SPIMSP432E4DMA_HWAttrs spiMSP432E4DMAHWAttrs[MSP_EXP432E401Y_SPICOUNT] = {
+    {
+        .baseAddr = SSI2_BASE,
+        .intNum = INT_SSI2,
+        .intPriority = (~0),
+        .defaultTxBufValue = (~0),
+        .rxDmaChannel = UDMA_CH12_SSI2RX,
+        .txDmaChannel = UDMA_CH13_SSI2TX,
+        .minDmaTransferSize = 10,
+        .clkPinMask = SPIMSP432E4_PD3_SSI2CLK,
+        .fssPinMask = SPIMSP432E4_PD2_SSI2FSS,
+        .xdat0PinMask = SPIMSP432E4_PD1_SSI2XDAT0,
+        .xdat1PinMask = SPIMSP432E4_PD0_SSI2XDAT1
+    },
+    {
+        .baseAddr = SSI3_BASE,
+        .intNum = INT_SSI3,
+        .intPriority = (~0),
+        .defaultTxBufValue = (~0),
+        .minDmaTransferSize = 10,
+        .rxDmaChannel = UDMA_CH14_SSI3RX,
+        .txDmaChannel = UDMA_CH15_SSI3TX,
+        .clkPinMask = SPIMSP432E4_PQ0_SSI3CLK,
+        .fssPinMask = SPIMSP432E4_PQ1_SSI3FSS,
+        .xdat0PinMask = SPIMSP432E4_PQ2_SSI3XDAT0,
+        .xdat1PinMask = SPIMSP432E4_PQ3_SSI3XDAT1
+    }
+};
+
+const SPI_Config SPI_config[MSP_EXP432E401Y_SPICOUNT] = {
+    {
+        .fxnTablePtr = &SPIMSP432E4DMA_fxnTable,
+        .object = &spiMSP432E4DMAObjects[MSP_EXP432E401Y_SPI2],
+        .hwAttrs = &spiMSP432E4DMAHWAttrs[MSP_EXP432E401Y_SPI2]
+    },
+    {
+        .fxnTablePtr = &SPIMSP432E4DMA_fxnTable,
+        .object = &spiMSP432E4DMAObjects[MSP_EXP432E401Y_SPI3],
+        .hwAttrs = &spiMSP432E4DMAHWAttrs[MSP_EXP432E401Y_SPI3]
+    },
+};
+
+const uint_least8_t SPI_count = MSP_EXP432E401Y_SPICOUNT;
+
+/*
+ *  =============================== Timer ===============================
+ */
+#include <ti/drivers/Timer.h>
+#include <ti/drivers/timer/TimerMSP432E4.h>
+
+TimerMSP432E4_Object timerMSP432E4Objects[MSP_EXP432E401Y_TIMERCOUNT];
+
+const TimerMSP432E4_HWAttrs timerMSP432E4HWAttrs[MSP_EXP432E401Y_TIMERCOUNT] = {
+    {
+        .baseAddress = TIMER2_BASE,
+        .subTimer = TimerMSP432E4_timer32,
+        .intNum = INT_TIMER2A,
+        .intPriority = ~0
+    },
+    {
+        .baseAddress = TIMER1_BASE,
+        .subTimer = TimerMSP432E4_timer16A,
+        .intNum = INT_TIMER1A,
+        .intPriority = ~0
+    },
+    {
+         .baseAddress = TIMER1_BASE,
+         .subTimer = TimerMSP432E4_timer16B,
+         .intNum = INT_TIMER1B,
+         .intPriority = ~0
+    },
+};
+
+const Timer_Config Timer_config[MSP_EXP432E401Y_TIMERCOUNT] = {
+    {
+        .fxnTablePtr = &TimerMSP432E4_fxnTable,
+        .object = &timerMSP432E4Objects[MSP_EXP432E401Y_TIMER0],
+        .hwAttrs = &timerMSP432E4HWAttrs[MSP_EXP432E401Y_TIMER0]
+    },
+    {
+        .fxnTablePtr = &TimerMSP432E4_fxnTable,
+        .object = &timerMSP432E4Objects[MSP_EXP432E401Y_TIMER1],
+        .hwAttrs = &timerMSP432E4HWAttrs[MSP_EXP432E401Y_TIMER1]
+    },
+    {
+        .fxnTablePtr = &TimerMSP432E4_fxnTable,
+        .object = &timerMSP432E4Objects[MSP_EXP432E401Y_TIMER2],
+        .hwAttrs = &timerMSP432E4HWAttrs[MSP_EXP432E401Y_TIMER2]
+    },
+};
+
+const uint_least8_t Timer_count = MSP_EXP432E401Y_TIMERCOUNT;
+
+/*
+ *  =============================== UART ===============================
+ */
+#include <ti/drivers/UART.h>
+#include <ti/drivers/uart/UARTMSP432E4.h>
+
+UARTMSP432E4_Object uartMSP432E4Objects[MSP_EXP432E401Y_UARTCOUNT];
+unsigned char uartMSP432E4RingBuffer[MSP_EXP432E401Y_UARTCOUNT][32];
+
+/* UART configuration structure */
+const UARTMSP432E4_HWAttrs uartMSP432E4HWAttrs[MSP_EXP432E401Y_UARTCOUNT] = {
+    {
+        .baseAddr = UART0_BASE,
+        .intNum = INT_UART0,
+        .intPriority = (~0),
+        .flowControl = UARTMSP432E4_FLOWCTRL_NONE,
+        .ringBufPtr  = uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART0],
+        .ringBufSize = sizeof(uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART0]),
+        .rxPin = UARTMSP432E4_PA0_U0RX,
+        .txPin = UARTMSP432E4_PA1_U0TX,
+        .ctsPin = UARTMSP432E4_PIN_UNASSIGNED,
+        .rtsPin = UARTMSP432E4_PIN_UNASSIGNED,
+        .errorFxn = NULL
+    }
+};
+
+const UART_Config UART_config[MSP_EXP432E401Y_UARTCOUNT] = {
+    {
+        .fxnTablePtr = &UARTMSP432E4_fxnTable,
+        .object = &uartMSP432E4Objects[MSP_EXP432E401Y_UART0],
+        .hwAttrs = &uartMSP432E4HWAttrs[MSP_EXP432E401Y_UART0]
+    }
+};
+
+const uint_least8_t UART_count = MSP_EXP432E401Y_UARTCOUNT;
+
+/*
+ *  =============================== Watchdog ===============================
+ */
+#include <ti/drivers/Watchdog.h>
+#include <ti/drivers/watchdog/WatchdogMSP432E4.h>
+
+WatchdogMSP432E4_Object watchdogMSP432E4Objects[MSP_EXP432E401Y_WATCHDOGCOUNT];
+
+const WatchdogMSP432E4_HWAttrs watchdogMSP432E4HWAttrs[MSP_EXP432E401Y_WATCHDOGCOUNT] = {
+    {
+        .baseAddr = WATCHDOG0_BASE,
+        .intNum = INT_WATCHDOG,
+        .intPriority = (~0),
+        .reloadValue = 80000000 /* 1 second period at default CPU clock freq */
+    },
+};
+
+const Watchdog_Config Watchdog_config[MSP_EXP432E401Y_WATCHDOGCOUNT] = {
+    {
+        .fxnTablePtr = &WatchdogMSP432E4_fxnTable,
+        .object = &watchdogMSP432E4Objects[MSP_EXP432E401Y_WATCHDOG0],
+        .hwAttrs = &watchdogMSP432E4HWAttrs[MSP_EXP432E401Y_WATCHDOG0]
+    },
+};
+
+const uint_least8_t Watchdog_count = MSP_EXP432E401Y_WATCHDOGCOUNT;
diff --git a/sample/MSP_EXP432E401Y/MSP_EXP432E401Y.h b/sample/MSP_EXP432E401Y/MSP_EXP432E401Y.h
new file mode 100644 (file)
index 0000000..005cb82
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** ============================================================================
+ *  @file       MSP_EXP432E401Y.h
+ *
+ *  @brief      MSP_EXP432E401Y Board Specific APIs
+ *
+ *  The MSP_EXP432E401Y header file should be included in an application as
+ *  follows:
+ *  @code
+ *  #include <MSP_EXP432E401Y.h>
+ *  @endcode
+ *
+ *  ============================================================================
+ */
+
+#ifndef __MSP_EXP432E401Y_H
+#define __MSP_EXP432E401Y_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* LEDs on MSP_EXP432E401Y are active high. */
+#define MSP_EXP432E401Y_GPIO_LED_OFF (0)
+#define MSP_EXP432E401Y_GPIO_LED_ON  (1)
+
+/*!
+ *  @def    MSP_EXP432E401Y_ADCName
+ *  @brief  Enum of ADC channels on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_ADCName {
+    MSP_EXP432E401Y_ADC0 = 0,
+    MSP_EXP432E401Y_ADC1,
+
+    MSP_EXP432E401Y_ADCCOUNT
+} MSP_EXP432E401Y_ADCName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_ADCBufName
+ *  @brief  Enum of ADC hardware peripherals on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_ADCBufName {
+    MSP_EXP432E401Y_ADCBUF0 = 0,
+
+    MSP_EXP432E401Y_ADCBUFCOUNT
+} MSP_EXP432E401Y_ADCBufName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_ADCBuf0ChannelName
+ *  @brief  Enum of ADCBuf channels on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_ADCBuf0ChannelName {
+    MSP_EXP432E401Y_ADCBUF0CHANNEL0 = 0,
+    MSP_EXP432E401Y_ADCBUF0CHANNEL1,
+    MSP_EXP432E401Y_ADCBUF0CHANNEL2,
+    MSP_EXP432E401Y_ADCBUF0CHANNEL3,
+    MSP_EXP432E401Y_ADCBUF0CHANNEL4,
+
+    MSP_EXP432E401Y_ADCBUF0CHANNELCOUNT
+} MSP_EXP432E401Y_ADCBuf0ChannelName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_GPIOName
+ *  @brief  Enum of LED names on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_GPIOName {
+    MSP_EXP432E401Y_GPIO_USR_SW1 = 0,
+    MSP_EXP432E401Y_GPIO_USR_SW2,
+    MSP_EXP432E401Y_SPI_MASTER_READY,
+    MSP_EXP432E401Y_SPI_SLAVE_READY,
+    MSP_EXP432E401Y_GPIO_D1,
+    MSP_EXP432E401Y_GPIO_D2,
+
+    MSP_EXP432E401Y_SDSPI_CS,
+
+    /* Sharp 96x96 LCD Pins */
+    MSP_EXP432E401Y_LCD_CS,
+    MSP_EXP432E401Y_LCD_POWER,
+    MSP_EXP432E401Y_LCD_ENABLE,
+
+    MSP_EXP432E401Y_GPIOCOUNT
+} MSP_EXP432E401Y_GPIOName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_I2CName
+ *  @brief  Enum of I2C names on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_I2CName {
+    MSP_EXP432E401Y_I2C0 = 0,
+    MSP_EXP432E401Y_I2C7,
+
+    MSP_EXP432E401Y_I2CCOUNT
+} MSP_EXP432E401Y_I2CName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_NVSName
+ *  @brief  Enum of NVS names on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_NVSName {
+    MSP_EXP432E401Y_NVSMSP432E40 = 0,
+
+    MSP_EXP432E401Y_NVSCOUNT
+} MSP_EXP432E401Y_NVSName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_PWMName
+ *  @brief  Enum of PWM names on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_PWMName {
+    MSP_EXP432E401Y_PWM0 = 0,
+
+    MSP_EXP432E401Y_PWMCOUNT
+} MSP_EXP432E401Y_PWMName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_SDFatFSName
+ *  @brief  Enum of SDFatFS names on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_SDFatFSName {
+    MSP_EXP432E401Y_SDFatFS0 = 0,
+
+    MSP_EXP432E401Y_SDFatFSCOUNT
+} MSP_EXP432E401Y_SDFatFSName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_SDName
+ *  @brief  Enum of SD names on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_SDName {
+    MSP_EXP432E401Y_SDSPI0 = 0,
+
+    MSP_EXP432E401Y_SDCOUNT
+} MSP_EXP432E401Y_SDName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_SPIName
+ *  @brief  Enum of SPI names on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_SPIName {
+    MSP_EXP432E401Y_SPI2 = 0,
+    MSP_EXP432E401Y_SPI3,
+
+    MSP_EXP432E401Y_SPICOUNT
+} MSP_EXP432E401Y_SPIName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_TimerName
+ *  @brief  Enum of Timer names on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_TimerName {
+    MSP_EXP432E401Y_TIMER0 = 0,
+    MSP_EXP432E401Y_TIMER1,
+    MSP_EXP432E401Y_TIMER2,
+
+    MSP_EXP432E401Y_TIMERCOUNT
+} MSP_EXP432E401Y_TimerName;
+
+/*!
+ *  @def    MSP_EXP432E401Y_UARTName
+ *  @brief  Enum of UARTs on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_UARTName {
+    MSP_EXP432E401Y_UART0 = 0,
+
+    MSP_EXP432E401Y_UARTCOUNT
+} MSP_EXP432E401Y_UARTName;
+
+/*
+ *  @def    MSP_EXP432E401Y_WatchdogName
+ *  @brief  Enum of Watchdogs on the MSP_EXP432E401Y dev board
+ */
+typedef enum MSP_EXP432E401Y_WatchdogName {
+    MSP_EXP432E401Y_WATCHDOG0 = 0,
+
+    MSP_EXP432E401Y_WATCHDOGCOUNT
+} MSP_EXP432E401Y_WatchdogName;
+
+/*!
+ *  @brief  Initialize the general board specific settings
+ *
+ *  This function initializes the general board specific settings.
+ *  This includes:
+ *     - Enable clock sources for peripherals
+ */
+extern void MSP_EXP432E401Y_initGeneral(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MSP_EXP432E401Y_H */
diff --git a/sample/MSP_EXP432E401Y/network.c b/sample/MSP_EXP432E401Y/network.c
new file mode 100644 (file)
index 0000000..92d266e
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdbool.h>
+
+#include <ti/net/slnetsock.h>
+#include <ti/net/slnetif.h>
+#include <ti/ndk/slnetif/slnetifndk.h>
+#include <ti/net/slnetutils.h>
+
+#include <ti/drivers/GPIO.h>
+
+#include <semaphore.h>
+
+#include "Board.h"
+
+/* Network interface priority and name */
+#define NDK_ETH_IF_PRI (5)
+#define NDK_ETH_IF_NAME "eth0"
+
+static sem_t sem;
+
+extern void startSNTP(void);
+
+/*
+ *  ======== netIPAddrHook ========
+ *  User defined NDK network IP address hook
+ */
+void netIPAddrHook(uint32_t IPAddr, unsigned int IfIdx, unsigned int fAdd)
+{
+    if (fAdd) {
+        /* Signal that the NDK stack is ready and has an IP address */
+        sem_post(&sem);
+    }
+}
+
+/*
+ *  ======== netOpenHook ========
+ *  User defined NDK network open hook
+ */
+void netOpenHook()
+{
+}
+
+/*
+ *  ======== Network_init =======
+ */
+void Network_init()
+{
+    if (sem_init(&sem, 0, 0) != 0) {
+        /* Error: sem_init failed */
+        while (1);
+    }
+}
+
+/*
+ *  ======== Network_startup =======
+ */
+void Network_startup()
+{
+    int32_t status;
+
+    /* Wait for the network stack to initialize and acquire an IP address */
+    sem_wait(&sem);
+
+    /* The network stack is ready. Initialize the socket layer */
+    status = SlNetSock_init(0);
+    if (status != 0) {
+        /* SlNetSock_init failed */
+        while (1);
+    }
+
+    status = SlNetIf_init(0);
+    if (status != 0) {
+        /* SlNetIf_init failed */
+        while (1);
+    }
+
+    status = SlNetUtil_init(0);
+    if (status != 0) {
+        /* SlNetUtil_init failed */
+        while (1);
+    }
+
+    /* Register the NDK ethernet interface with the socket layer */
+    status = SlNetIf_add(SLNETIF_ID_2, NDK_ETH_IF_NAME,
+            (const SlNetIf_Config_t *)&SlNetIfConfigNDKSec, NDK_ETH_IF_PRI);
+    if (status != 0) {
+        /* SlNetIf_add failed */
+        while (1);
+    }
+
+    /* Turn LED OFF. It will be used as a connection indicator */
+    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
+
+    /* Use SNTP to get the current time, as needed for SSL authentication */
+    startSNTP();
+
+    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
+}
+
+/*
+ *  ======== Network_exit =======
+ */
+void Network_exit()
+{
+}
diff --git a/sample/MSP_EXP432E401Y/network.h b/sample/MSP_EXP432E401Y/network.h
new file mode 100644 (file)
index 0000000..c46de50
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __Network_H
+#define __Network_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <stdint.h>
+
+/*
+ *  ======== Network_init =======
+ *  Initialize the Network module
+ */
+void Network_init();
+
+/*
+ *  ======== Network_startup =======
+ *  Wait for IP address, initialize the socket layer, get time via SNTP
+ */
+void Network_startup();
+
+/*
+ *  ======== Network_exit =======
+ *  Finalize the module
+ */
+void Network_exit();
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/sample/MSP_EXP432E401Y/startsntp.c b/sample/MSP_EXP432E401Y/startsntp.c
new file mode 100644 (file)
index 0000000..8933a0c
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <ti/net/sntp/sntp.h>
+
+/*
+ * Difference between NTP Epoch (seconds since January 1, 1900 GMT) and UNIX
+ * Epoch (seconds since January 1, 1970 GMT)
+ */
+#define TIME_BASEDIFF ((((uint32_t)70 * 365 + 17) * 24 * 3600))
+
+#define TIME_NTP_TO_UNIX(t) ((t) - TIME_BASEDIFF)
+
+#define NTP_SERVERS 1
+#define NTP_SERVER_PORT 123
+
+/*  Time to wait for reply from server (seconds) */
+#define NTP_REPLY_WAIT_TIME 5
+
+/* Must wait at least 15 sec to retry NTP server (RFC 4330) */
+#define NTP_POLL_TIME 15
+
+/*
+ *  ======== startSNTP ========
+ */
+void startSNTP(void)
+{
+    uint64_t ntpTimeStamp;
+    uint32_t currentTimeNtp = 0;
+    uint32_t currentTimeUnix = 0;
+    int32_t retval;
+    time_t ts;
+    SlNetSock_Timeval_t timeval;
+    struct timespec tspec;
+
+    /* Set timeout value for NTP server reply */
+    timeval.tv_sec = NTP_REPLY_WAIT_TIME;
+    timeval.tv_usec = 0;
+
+    do {
+        /* Get the time using the built in NTP server list: */
+        retval = SNTP_getTime(NULL, 0, &timeval, &ntpTimeStamp);
+        if (retval != 0) {
+            printf(
+                "startSNTP: couldn't get time (%ld), will retry in %d secs ...\n",
+                retval, NTP_POLL_TIME);
+            sleep(NTP_POLL_TIME);
+            printf("startSNTP: retrying ...\n");
+        }
+
+        /* Save the current (NTP Epoch based) time */
+        currentTimeNtp = ntpTimeStamp >> 32;
+
+    } while (retval < 0);
+
+     /* Set the time. Always pass a time value based on the UNIX Epoch */
+    currentTimeUnix = TIME_NTP_TO_UNIX(currentTimeNtp);
+    tspec.tv_nsec = 0;
+    tspec.tv_sec = currentTimeUnix;
+    if (clock_settime(CLOCK_REALTIME, &tspec) != 0) {
+        printf("startSNTP: Failed to set current time\n");
+        while(1);
+    }
+
+    /*
+     * Use time.h APIs to get the time and display it on the console.
+     * Must call time.h APIs using the appropriate (toolchain dependent) Epoch
+     * time base
+     */
+#if defined(__TI_COMPILER_VERSION__)
+    /* For the TI toolchain, time APIs expect times based on the NTP Epoch */
+    ts = currentTimeNtp;
+#else
+    /* Time APIs for GCC and IAR expect times based on the UNIX Epoch */
+    ts = currentTimeUnix;
+#endif
+
+    /* Print out the time in calendar format: */
+    printf("Current time: %s\n", ctime(&ts));
+}
diff --git a/sample/MSP_EXP432E401Y/tirtos/ccs/MSP_EXP432E401Y_TIRTOS.cmd b/sample/MSP_EXP432E401Y/tirtos/ccs/MSP_EXP432E401Y_TIRTOS.cmd
new file mode 100644 (file)
index 0000000..0542b3d
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ *  ======== MSP_EXP432E401Y.cmd ========
+ *  Define the memory block start/length for the MSP_EXP432E401Y M4
+ */
+--stack_size=1024   /* C stack is also used for ISR stack */
+
+HEAPSIZE = 0x20000;  /* Size of heap buffer used by HeapMem */
+
+MEMORY
+{
+    FLASH (RX) : origin = 0x00000000, length = 0x00100000
+    SRAM (RWX) : origin = 0x20000000, length = 0x00040000
+}
+
+/* Section allocation in memory */
+
+SECTIONS
+{
+    .text   :   > FLASH
+    .const  :   > FLASH
+    .cinit  :   > FLASH
+    .pinit  :   > FLASH
+    .init_array : > FLASH
+
+    .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
+    .data   :   > SRAM
+    .bss    :   > SRAM
+    .sysmem :   > SRAM
+
+    /* Heap buffer used by HeapMem */
+    .priheap   : {
+        __primary_heap_start__ = .;
+        . += HEAPSIZE;
+        __primary_heap_end__ = .;
+    } > SRAM align 8
+
+    .stack  :   > SRAM (HIGH)
+}
diff --git a/sample/MSP_EXP432E401Y/tirtos/ccs/makedefs b/sample/MSP_EXP432E401Y/tirtos/ccs/makedefs
new file mode 100644 (file)
index 0000000..e11d6a9
--- /dev/null
@@ -0,0 +1,24 @@
+CODEGEN_INSTALLATION_DIR = $(ti.targets.arm.elf.M4F)
+CC = $(ti.targets.arm.elf.M4F)/bin/armcl
+LD = $(ti.targets.arm.elf.M4F)/bin/armcl -z
+
+KERNEL_BUILD :=  $(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/kernel/tirtos/builds/MSP_EXP432E401Y/release
+
+CONFIGPKG = $(KERNEL_BUILD)/ccs
+
+CFLAGS = -eo=.o -mv7M4 --float_support=FPv4SPD16 --abi=eabi -me -ms --c99 "-I$(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/source" "-I$(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/source/third_party/CMSIS/Include" "-I$(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/source/ti/posix/ccs" -DSL_FULL -DSL_PLATFORM_MULTI_THREADED -DNET_SL --silicon_version=7M4 --code_state=16 --advice:power=none --little_endian --display_error_number --diag_warning=255 --diag_wrap=off --gen_func_subsections=on --symdebug:dwarf
+
+LFLAGS = "-i$(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/source" "-l$(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/source/ti/net/sntp/lib/ccs/m4f/sntp_release.a" "-l$(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/source/ti/net/lib/ccs/m4f/slnetsock_release.a" "-l$(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/source/ti/net/http/lib/ccs/m4f/httpclient_release.a" "-lti/ndk/slnetif/lib/slnetifndk.aem4f" "-lthird_party/mbedtls/ti/lib/ccs/m4f/mbedtls.a" "-lti/ndk/hal/timer_bios/lib/hal_timer.aem4f" "-lti/ndk/hal/eth_stub/lib/hal_eth_stub.aem4f" "-lti/ndk/tools/cgi/lib/cgi.aem4f" "-lti/ndk/tools/hdlc/lib/hdlc.aem4f" "-lti/ndk/tools/console/lib/console_min_ipv4.aem4f" "-lti/ndk/netctrl/lib/netctrl_min_ipv4.aem4f" "-lti/ndk/nettools/lib/nettool_ipv4.aem4f" "-lti/ndk/hal/ser_stub/lib/hal_ser_stub.aem4f" "-lti/ndk/tools/servers/lib/servers_min_ipv4.aem4f" "-lti/ndk/hal/userled_stub/lib/hal_userled_stub.aem4f" "-lti/ndk/stack/lib/stk.aem4f" "-lti/ndk/os/lib/os.aem4f" "-lti/drivers/lib/drivers_msp432e4.aem4f" "-l$(SIMPLELINK_MSP432E4_SDK_INSTALL_DIR)/kernel/tirtos/packages/ti/dpl/lib/dpl_msp432e4.aem4f" "-lti/devices/msp432e4/driverlib/lib/ccs/m4f/msp432e4_driverlib.a" --rom_model --warn_sections -i$(CODEGEN_INSTALLATION_DIR)/lib --reread_libs -llibc.a
+
+%.o : %.c
+       $(CC) $(CFLAGS) -c $<
+
+ifneq (,$(wildcard $(XDC_INSTALL_DIR)/xdc.exe))
+    # use these on Windows
+    RM      = $(XDC_INSTALL_DIR)/bin/rm -f
+    RMDIR   = $(XDC_INSTALL_DIR)/bin/rm -rf
+else
+    # use these on Linux
+    RM      = rm -f
+    RMDIR   = rm -rf
+endif
diff --git a/sample/MSP_EXP432E401Y/tirtos/ccs/makefile b/sample/MSP_EXP432E401Y/tirtos/ccs/makefile
new file mode 100644 (file)
index 0000000..414a079
--- /dev/null
@@ -0,0 +1,67 @@
+#
+#  Copyright (c) 2018, Texas Instruments Incorporated
+#  All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#  *  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#
+#  *  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+#  *  Neither the name of Texas Instruments Incorporated nor the names of
+#     its contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+#  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+#  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+#  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+TREE_ROOT = ../../../..
+include $(TREE_ROOT)/build_all/products.mak
+include makedefs
+
+CFLAGS :=  -I../.. -I../../.. -I$(TREE_ROOT)/sdk/inc/ -I$(TREE_ROOT)/sdk/certs/ -I$(TREE_ROOT)/sdk/c-utility/inc/ -I$(TREE_ROOT)/sdk/c-utility/inc/azure_c_shared_utility -I$(TREE_ROOT)/sdk/iothub_client/inc -I$(TREE_ROOT)/sdk/serializer/inc -g $(CFLAGS) --cmd_file=$(CONFIGPKG)/compiler.opt
+
+LIBS =  $(TREE_ROOT)/build_all/sdk/lib/ccs/m4f/common_sl_release.a \
+    $(TREE_ROOT)/build_all/sdk/lib/ccs/m4f/iotclient_sl_release.a \
+    $(TREE_ROOT)/build_all/sdk/lib/ccs/m4f/serializer_sl_release.a \
+    $(TREE_ROOT)/build_all/pal/lib/ccs/m4f/pal_sl_release.a
+
+VPATH = ..:../..:../../..:$(TREE_ROOT)/sdk/certs
+
+%.o : %.c
+
+%.o : %.c $(CONFIGPKG)/compiler.opt
+       @echo $(CC) $(CFLAGS) -c $<
+       @$(CC) $(CFLAGS) -c $<
+
+all: simplesample_http.out
+
+$(CONFIGPKG)/linker.cmd $(CONFIGPKG)/compiler.opt:
+       @ echo
+       $(error "$(CONFIGPKG) is not built. You can build it by issuing \
+            $(MAKE) in $(CONFIGPKG).")
+       @ echo
+
+simplesample_http.out: main_tirtos.o ndk_tirtos.o certs.o startsntp.o simplesample_http.o network.o MSP_EXP432E401Y.o MSP_EXP432E401Y_TIRTOS.cmd $(CONFIGPKG)/linker.cmd $(LIBS)
+       @echo building $@ ..
+       @$(LD) -o $@ $^ -x -m $@.map $(LFLAGS)
+
+clean:
+       @echo cleaning ..
+       @ $(RM) *.o *.out *.map
+       @ $(RMDIR)
diff --git a/sample/MSP_EXP432E401Y/tirtos/main_tirtos.c b/sample/MSP_EXP432E401Y/tirtos/main_tirtos.c
new file mode 100644 (file)
index 0000000..85a6442
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ *  ======== main_tirtos.c ========
+ */
+#include <stdio.h>
+
+#include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/knl/Task.h>
+
+#include <ti/drivers/GPIO.h>
+
+#include <pthread.h>
+
+#include <simplesample_http.h>
+
+#include <ti/ndk/inc/netmain.h>
+#include <ti/net/slnetsock.h>
+#include <ti/net/slnetif.h>
+
+#include "Board.h"
+#include "certs.h"
+#include "network.h"
+
+#define AZURE_IOT_ROOT_CA_OBJNAME "/cert/ms.pem"
+
+extern void ti_ndk_config_Global_startupFxn();
+
+/*
+ *  ======== azureThreadFxn ========
+ */
+void *azureThreadFxn(void *arg0)
+{
+    int32_t status;
+
+    /* Open an NDK file descriptor session */
+    fdOpenSession(Task_self());
+
+    printf("Starting the simplesample_http example\n");
+
+    /* Wait for an IP address, initialize the socket layer and get the time */
+    Network_startup();
+
+    /* Load certificates */
+    status = SlNetIf_loadSecObj(SLNETIF_SEC_OBJ_TYPE_CERTIFICATE,
+            AZURE_IOT_ROOT_CA_OBJNAME, strlen(AZURE_IOT_ROOT_CA_OBJNAME),
+            (uint8_t *)certificates, strlen(certificates) + 1, SLNETIF_ID_2);
+    if (status < 0) {
+        printf("Failed to load certificate object\n");
+        while (1);
+    }
+
+    simplesample_http_run();
+
+    /* Close the NDK file descriptor session */
+    fdCloseSession(Task_self());
+
+    return (NULL);
+}
+
+/*
+ *  ======== main ========
+ */
+int main(int argc, char *argv[])
+{
+    pthread_attr_t pthreadAttrs;
+    pthread_t azureThread;
+    int status;
+
+    Board_initGeneral();
+    GPIO_init();
+    Network_init();
+
+    ti_ndk_config_Global_startupFxn();
+
+    /* Create the AZURE thread */
+    pthread_attr_init(&pthreadAttrs);
+
+    status = pthread_attr_setstacksize(&pthreadAttrs, 8192);
+    if (status != 0) {
+        /* Error setting stack size */
+        while (1);
+    }
+
+    status = pthread_create(&azureThread, &pthreadAttrs, azureThreadFxn, NULL);
+    if (status != 0) {
+        /* Failed to create AZURE thread */
+        while (1);
+    }
+
+    pthread_attr_destroy(&pthreadAttrs);
+
+    BIOS_start();
+
+    return (0);
+}
diff --git a/sample/MSP_EXP432E401Y/tirtos/ndk_tirtos.c b/sample/MSP_EXP432E401Y/tirtos/ndk_tirtos.c
new file mode 100644 (file)
index 0000000..eac5da0
--- /dev/null
@@ -0,0 +1,375 @@
+/*
+ * Copyright (c) 2017-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== ndk_tirtos.c ========
+ */
+
+#include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/knl/Task.h>
+
+#include <ti/ndk/inc/netmain.h>
+#include <ti/ndk/inc/os/oskern.h>
+
+#include <signal.h>
+#include <time.h>
+#include <stdio.h>
+
+/* Socket file descriptor table */
+#define MAXSOCKETS 10
+uint32_t ti_ndk_socket_max_fd = MAXSOCKETS;
+void *ti_ndk_socket_fdtable[MAXSOCKETS];
+
+/* NDK memory manager page size and number of pages [used by mmAlloc()] */
+#define RAW_PAGE_SIZE 3072
+#define RAW_PAGE_COUNT 6
+
+const int ti_ndk_config_Global_rawPageSize  = RAW_PAGE_SIZE;
+const int ti_ndk_config_Global_rawPageCount = RAW_PAGE_COUNT;
+
+/* P.I.T. (page information table) */
+#ifdef __ti__
+#pragma DATA_SECTION(ti_ndk_config_Global_pit, ".bss:NDK_MMBUFFER");
+#pragma DATA_SECTION(ti_ndk_config_Global_pitBuffer, ".bss:NDK_MMBUFFER");
+PITENTRY ti_ndk_config_Global_pit[RAW_PAGE_COUNT];
+unsigned char ti_ndk_config_Global_pitBuffer[RAW_PAGE_SIZE * RAW_PAGE_COUNT];
+#elif defined (__IAR_SYSTEMS_ICC__)
+PITENTRY ti_ndk_config_Global_pit[RAW_PAGE_COUNT];
+unsigned char ti_ndk_config_Global_pitBuffer[RAW_PAGE_SIZE * RAW_PAGE_COUNT];
+#else
+PITENTRY ti_ndk_config_Global_pit[RAW_PAGE_COUNT]
+        __attribute__ ((section(".bss:NDK_MMBUFFER")));
+unsigned char ti_ndk_config_Global_pitBuffer[RAW_PAGE_SIZE * RAW_PAGE_COUNT]
+        __attribute__ ((section(".bss:NDK_MMBUFFER")));
+#endif
+
+/* Memory bucket sizes */
+#define SMALLEST 48
+#define LARGEST (RAW_PAGE_SIZE)
+
+const int ti_ndk_config_Global_smallest = SMALLEST;
+const int ti_ndk_config_Global_largest  = LARGEST;
+
+/* Memory Slot Tracking */
+uint32_t ti_ndk_config_Global_Id2Size[] =
+        {SMALLEST, 96, 128, 256, 512, 1536, LARGEST};
+
+/*
+ *  Local Packet Buffer Pool Definitions
+ *
+ *  The below variables/defines are used to override the defaults that are set
+ *  in the Packet Buffer Manager (PBM) file src/stack/pbm/pbm_data.c
+ */
+
+/*
+ *  Number of buffers in PBM packet buffer free pool
+ *
+ *  The number of buffers in the free pool can have a significant effect
+ *  on performance, especially in UDP packet loss. Increasing this number
+ *  will increase the size of the static packet pool use for both sending
+ *  and receiving packets.
+ */
+#define PKT_NUM_FRAMEBUF 10
+
+/* Size of Ethernet frame buffer */
+#define PKT_SIZE_FRAMEBUF   1536
+
+const int ti_ndk_config_Global_numFrameBuf = PKT_NUM_FRAMEBUF;
+const int ti_ndk_config_Global_sizeFrameBuf = PKT_SIZE_FRAMEBUF;
+
+/* Data space for packet buffers */
+#ifdef __ti__
+#pragma DATA_ALIGN(ti_ndk_config_Global_pBufMem, 128);
+#pragma DATA_SECTION(ti_ndk_config_Global_pBufMem, ".bss:NDK_PACKETMEM");
+unsigned char
+        ti_ndk_config_Global_pBufMem[PKT_NUM_FRAMEBUF * PKT_SIZE_FRAMEBUF];
+#elif defined (__IAR_SYSTEMS_ICC__)
+#pragma data_alignment = 128
+unsigned char
+        ti_ndk_config_Global_pBufMem[PKT_NUM_FRAMEBUF * PKT_SIZE_FRAMEBUF];
+#else
+unsigned char ti_ndk_config_Global_pBufMem[PKT_NUM_FRAMEBUF * PKT_SIZE_FRAMEBUF]
+        __attribute__ ((aligned(128), section(".bss:NDK_PACKETMEM")));
+#endif
+
+#ifdef __ti__
+#pragma DATA_ALIGN(ti_ndk_config_Global_pHdrMem, 128);
+#pragma DATA_SECTION(ti_ndk_config_Global_pHdrMem, ".bss:NDK_PACKETMEM");
+unsigned char ti_ndk_config_Global_pHdrMem[PKT_NUM_FRAMEBUF * sizeof(PBM_Pkt)];
+#elif defined (__IAR_SYSTEMS_ICC__)
+#pragma data_alignment = 128
+unsigned char ti_ndk_config_Global_pHdrMem[PKT_NUM_FRAMEBUF * sizeof(PBM_Pkt)];
+#else
+unsigned char ti_ndk_config_Global_pHdrMem[PKT_NUM_FRAMEBUF * sizeof(PBM_Pkt)]
+        __attribute__ ((aligned(128), section(".bss:NDK_PACKETMEM")));
+#endif
+
+/* Our NETCTRL callback functions */
+static void networkOpen();
+static void networkClose();
+static void networkIPAddr(uint32_t IPAddr, uint32_t IfIdx, uint32_t fAdd);
+static char *hostName = "tisoc";
+
+extern void llTimerTick();
+
+/*
+ *  ======== networkOpen ========
+ *  This function is called after the configuration has booted
+ */
+static void networkOpen()
+{
+    extern void netOpenHook();
+
+    /* call user defined network open hook */
+    netOpenHook();
+}
+
+/*
+ *  ======== networkClose ========
+ *  This function is called when the network is shutting down,
+ *  or when it no longer has any IP addresses assigned to it.
+ */
+static void networkClose()
+{
+    /* call user defined network close hook */
+}
+
+/*
+ *  ======== networkIPAddr ========
+ *  This function is called whenever an IP address binding is
+ *  added or removed from the system.
+ */
+static void networkIPAddr(uint32_t IPAddr, uint32_t IfIdx, uint32_t fAdd)
+{
+    uint32_t IPTmp;
+
+    if (fAdd) {
+        printf("Network Added: ");
+    }
+    else {
+        printf("Network Removed: ");
+    }
+
+    /* print the IP address that was added/removed */
+    IPTmp = NDK_ntohl(IPAddr);
+    printf("If-%ld:%d.%d.%d.%d\n", IfIdx,
+            (uint8_t)(IPTmp>>24)&0xFF, (uint8_t)(IPTmp>>16)&0xFF,
+            (uint8_t)(IPTmp>>8)&0xFF, (uint8_t)IPTmp&0xFF);
+
+    extern void netIPAddrHook();
+
+    /* call user defined network IP address hook */
+    netIPAddrHook(IPAddr, IfIdx, fAdd);
+}
+
+/*
+ *  ======== serviceReport ========
+ *  Function for reporting service status updates.
+ */
+static char *taskName[] = {"Telnet", "HTTP", "NAT", "DHCPS", "DHCPC", "DNS"};
+static char *reportStr[] = {"", "Running", "Updated", "Complete", "Fault"};
+static char *statusStr[] =
+        {"Disabled", "Waiting", "IPTerm", "Failed","Enabled"};
+static void serviceReport(uint32_t item, uint32_t status, uint32_t report,
+        void *h)
+{
+    printf("Service Status: %-9s: %-9s: %-9s: %03ld\n",
+            taskName[item - 1], statusStr[status], reportStr[report / 256],
+            report & 0xFF);
+}
+
+/*
+ *  ======== initTcp ========
+ *  Configure the stack's TCP settings
+ */
+static void initTcp(void *hCfg)
+{
+    int transmitBufSize = 1024;
+    int receiveBufSize = 1024;
+    int receiveBufLimit = 2048;
+
+    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPTXBUF, CFG_ADDMODE_UNIQUE,
+            sizeof(uint32_t), (unsigned char *)&transmitBufSize, NULL);
+    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXBUF, CFG_ADDMODE_UNIQUE,
+            sizeof(uint32_t), (unsigned char *)&receiveBufSize, NULL);
+    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKTCPRXLIMIT, CFG_ADDMODE_UNIQUE,
+            sizeof(uint32_t), (unsigned char *)&receiveBufLimit, NULL);
+}
+
+/*
+ *  ======== initIp ========
+ *  Configure the stack's IP settings
+ */
+static void initIp(void *hCfg)
+{
+    CI_SERVICE_DHCPC dhcpc;
+    unsigned char DHCP_OPTIONS[] = { DHCPOPT_SUBNET_MASK };
+
+    /* Add global hostname to hCfg (to be claimed in all connected domains) */
+    CfgAddEntry(hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
+            strlen(hostName), (unsigned char *)hostName, NULL);
+
+    /* Use DHCP to obtain IP address on interface 1 */
+    memset(&dhcpc, 0, sizeof(dhcpc));
+    dhcpc.cisargs.Mode   = CIS_FLG_IFIDXVALID;
+    dhcpc.cisargs.IfIdx  = 1;
+    dhcpc.cisargs.pCbSrv = &serviceReport;
+    dhcpc.param.pOptions = DHCP_OPTIONS;
+    dhcpc.param.len = 1;
+    CfgAddEntry(hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 0,
+            sizeof(dhcpc), (unsigned char *)&dhcpc, NULL);
+}
+
+/*
+ *  ======== initUdp ========
+ *  Configure the stack's UDP settings
+ */
+void initUdp(void *hCfg)
+{
+    int receiveBufSize = 2048;
+
+    CfgAddEntry(hCfg, CFGTAG_IP, CFGITEM_IP_SOCKUDPRXLIMIT, CFG_ADDMODE_UNIQUE,
+            sizeof(uint32_t), (unsigned char *)&receiveBufSize, NULL);
+}
+
+/*
+ *  ======== ndkStackThread ========
+ *  NDK stack's main thread function
+ */
+static void ndkStackThread(uintptr_t arg0, uintptr_t arg1)
+{
+    void *hCfg;
+    int rc;
+    timer_t ndkHeartBeat;
+    struct sigevent sev;
+    struct itimerspec its;
+    struct itimerspec oldIts;
+    int ndkHeartBeatCount = 0;
+
+    /* create the NDK timer tick */
+    sev.sigev_notify = SIGEV_SIGNAL;
+    sev.sigev_value.sival_ptr = &ndkHeartBeatCount;
+    sev.sigev_notify_attributes = NULL;
+    sev.sigev_notify_function = &llTimerTick;
+
+    rc = timer_create(CLOCK_MONOTONIC, &sev, &ndkHeartBeat);
+    if (rc != 0) {
+        printf("ndkStackThread: failed to create timer (%d)\n", rc);
+    }
+
+    /* start the NDK 100ms timer */
+    its.it_interval.tv_sec = 0;
+    its.it_interval.tv_nsec = 100000000;
+    its.it_value.tv_sec = 0;
+    its.it_value.tv_nsec = 100000000;
+
+    rc = timer_settime(ndkHeartBeat, 0, &its, NULL);
+    if (rc != 0) {
+        printf("ndkStackThread: failed to set time (%d)\n", rc);
+    }
+
+    rc = NC_SystemOpen(NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT);
+    if (rc) {
+        printf("ndkStackThread: NC_SystemOpen Failed (%d)\n", rc);
+    }
+
+    /* create and build the system configuration from scratch. */
+    hCfg = CfgNew();
+    if (!hCfg) {
+        printf("ndkStackThread: Unable to create configuration\n");
+        goto main_exit;
+    }
+
+    /* IP, TCP, and UDP config */
+    initIp(hCfg);
+    initTcp(hCfg);
+    initUdp(hCfg);
+
+    /* config low priority tasks stack size */
+    rc = 2048;
+    CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKLOW, CFG_ADDMODE_UNIQUE,
+            sizeof(uint32_t), (unsigned char *)&rc, NULL);
+
+    /* config norm priority tasks stack size */
+    rc = 2048;
+    CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKNORM, CFG_ADDMODE_UNIQUE,
+            sizeof(uint32_t), (unsigned char *)&rc, NULL);
+
+    /* config high priority tasks stack size */
+    rc = 2048;
+    CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKHIGH, CFG_ADDMODE_UNIQUE,
+            sizeof(uint32_t), (unsigned char *)&rc, NULL);
+
+    do
+    {
+        rc = NC_NetStart(hCfg, networkOpen, networkClose, networkIPAddr);
+    } while(rc > 0);
+
+    /* Shut down the stack */
+    CfgFree(hCfg);
+
+main_exit:
+    NC_SystemClose();
+
+    /* stop and delete the NDK heartbeat */
+    its.it_value.tv_sec = 0;
+    its.it_value.tv_nsec = 0;
+
+    rc = timer_settime(ndkHeartBeat, 0, &its, &oldIts);
+
+    rc = timer_delete(ndkHeartBeat);
+
+    printf("ndkStackThread: exiting ...\n");
+}
+
+/*
+ * ======== ti_ndk_config_Global_startupFxn ========
+ * Called to start up the NDK. In BIOS, this can be called as a BIOS startup
+ * function, or from main(). In FreeRTOS, this should be called from main().
+ */
+void ti_ndk_config_Global_startupFxn()
+{
+    Task_Params params;
+    Task_Handle ndkThread;
+
+    Task_Params_init(&params);
+    params.instance->name = "ndkStackThread";
+    params.priority = 5;
+    params.stackSize = 2048;
+
+    ndkThread = Task_create((Task_FuncPtr)ndkStackThread, &params, NULL);
+
+    if (!ndkThread) {
+        /* Error: could not create NDK stack thread */
+        while(1);
+    }
+}
diff --git a/sample/simplesample_http.c b/sample/simplesample_http.c
new file mode 100644 (file)
index 0000000..c8e87e3
--- /dev/null
@@ -0,0 +1,259 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#include <stdlib.h>
+
+#include <stdio.h>
+#include <stdint.h>
+
+/* This sample uses the _LL APIs of iothub_client for example purposes.
+That does not mean that HTTP only works with the _LL APIs.
+Simply changing the using the convenience layer (functions not having _LL)
+and removing calls to _DoWork will yield the same results. */
+
+#include "azure_c_shared_utility/threadapi.h"
+#include "azure_c_shared_utility/platform.h"
+#include "serializer.h"
+#include "iothub_client_ll.h"
+#include "iothubtransporthttp.h"
+
+#ifdef MBED_BUILD_TIMESTAMP
+#define SET_TRUSTED_CERT_IN_SAMPLES
+#endif // MBED_BUILD_TIMESTAMP
+
+#ifdef SET_TRUSTED_CERT_IN_SAMPLES
+#include "certs.h"
+#endif // SET_TRUSTED_CERT_IN_SAMPLES
+
+/*String containing Hostname, Device Id & Device Key in the format:             */
+/*  "HostName=<host_name>;DeviceId=<device_id>;SharedAccessKey=<device_key>"    */
+static const char* connectionString = "[device connection string]";
+
+// Define the Model
+BEGIN_NAMESPACE(WeatherStation);
+
+DECLARE_MODEL(ContosoAnemometer,
+WITH_DATA(ascii_char_ptr, DeviceId),
+WITH_DATA(int, WindSpeed),
+WITH_DATA(float, Temperature),
+WITH_DATA(float, Humidity),
+WITH_ACTION(TurnFanOn),
+WITH_ACTION(TurnFanOff),
+WITH_ACTION(SetAirResistance, int, Position)
+);
+
+END_NAMESPACE(WeatherStation);
+
+static char propText[1024];
+
+EXECUTE_COMMAND_RESULT TurnFanOn(ContosoAnemometer* device)
+{
+    (void)device;
+    (void)printf("Turning fan on.\r\n");
+    return EXECUTE_COMMAND_SUCCESS;
+}
+
+EXECUTE_COMMAND_RESULT TurnFanOff(ContosoAnemometer* device)
+{
+    (void)device;
+    (void)printf("Turning fan off.\r\n");
+    return EXECUTE_COMMAND_SUCCESS;
+}
+
+EXECUTE_COMMAND_RESULT SetAirResistance(ContosoAnemometer* device, int Position)
+{
+    (void)device;
+    (void)printf("Setting Air Resistance Position to %d.\r\n", Position);
+    return EXECUTE_COMMAND_SUCCESS;
+}
+
+void sendCallback(IOTHUB_CLIENT_CONFIRMATION_RESULT result, void* userContextCallback)
+{
+    unsigned int messageTrackingId = (unsigned int)(uintptr_t)userContextCallback;
+
+    (void)printf("Message Id: %u Received.\r\n", messageTrackingId);
+
+    (void)printf("Result Call Back Called! Result is: %s \r\n", ENUM_TO_STRING(IOTHUB_CLIENT_CONFIRMATION_RESULT, result));
+}
+
+static void sendMessage(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, const unsigned char* buffer, size_t size)
+{
+    static unsigned int messageTrackingId;
+    IOTHUB_MESSAGE_HANDLE messageHandle = IoTHubMessage_CreateFromByteArray(buffer, size);
+    if (messageHandle == NULL)
+    {
+        printf("unable to create a new IoTHubMessage\r\n");
+    }
+    else
+    {
+        if (IoTHubClient_LL_SendEventAsync(iotHubClientHandle, messageHandle, sendCallback, (void*)(uintptr_t)messageTrackingId) != IOTHUB_CLIENT_OK)
+        {
+            printf("failed to hand over the message to IoTHubClient");
+        }
+        else
+        {
+            printf("IoTHubClient accepted the message for delivery\r\n");
+        }
+        IoTHubMessage_Destroy(messageHandle);
+    }
+    free((void*)buffer);
+    messageTrackingId++;
+}
+
+/*this function "links" IoTHub to the serialization library*/
+static IOTHUBMESSAGE_DISPOSITION_RESULT IoTHubMessage(IOTHUB_MESSAGE_HANDLE message, void* userContextCallback)
+{
+    IOTHUBMESSAGE_DISPOSITION_RESULT result;
+    const unsigned char* buffer;
+    size_t size;
+    if (IoTHubMessage_GetByteArray(message, &buffer, &size) != IOTHUB_MESSAGE_OK)
+    {
+        printf("unable to IoTHubMessage_GetByteArray\r\n");
+        result = IOTHUBMESSAGE_ABANDONED;
+    }
+    else
+    {
+        /*buffer is not zero terminated*/
+        char* temp = malloc(size + 1);
+        if (temp == NULL)
+        {
+            printf("failed to malloc\r\n");
+            result = IOTHUBMESSAGE_ABANDONED;
+        }
+        else
+        {
+            EXECUTE_COMMAND_RESULT executeCommandResult;
+
+            (void)memcpy(temp, buffer, size);
+            temp[size] = '\0';
+            executeCommandResult = EXECUTE_COMMAND(userContextCallback, temp);
+            result =
+                (executeCommandResult == EXECUTE_COMMAND_ERROR) ? IOTHUBMESSAGE_ABANDONED :
+                (executeCommandResult == EXECUTE_COMMAND_SUCCESS) ? IOTHUBMESSAGE_ACCEPTED :
+                IOTHUBMESSAGE_REJECTED;
+            free(temp);
+        }
+    }
+    return result;
+}
+
+void simplesample_http_run(void)
+{
+    if (platform_init() != 0)
+    {
+        printf("Failed to initialize the platform.\r\n");
+    }
+    else
+    {
+        if (serializer_init(NULL) != SERIALIZER_OK)
+        {
+            (void)printf("Failed on serializer_init\r\n");
+        }
+        else
+        {
+            IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle = IoTHubClient_LL_CreateFromConnectionString(connectionString, HTTP_Protocol);
+            int avgWindSpeed = 10;
+            float minTemperature = 20.0;
+            float minHumidity = 60.0;
+
+            srand((unsigned int)time(NULL));
+
+            if (iotHubClientHandle == NULL)
+            {
+                (void)printf("Failed on IoTHubClient_LL_Create\r\n");
+            }
+            else
+            {
+                // Because it can poll "after 9 seconds" polls will happen
+                // effectively at ~10 seconds.
+                // Note that for scalabilty, the default value of minimumPollingTime
+                // is 25 minutes. For more information, see:
+                // https://azure.microsoft.com/documentation/articles/iot-hub-devguide/#messaging
+                unsigned int minimumPollingTime = 9;
+                ContosoAnemometer* myWeather;
+
+                if (IoTHubClient_LL_SetOption(iotHubClientHandle, "MinimumPollingTime", &minimumPollingTime) != IOTHUB_CLIENT_OK)
+                {
+                    printf("failure to set option \"MinimumPollingTime\"\r\n");
+                }
+
+#ifdef SET_TRUSTED_CERT_IN_SAMPLES
+                // For mbed add the certificate information
+                if (IoTHubClient_LL_SetOption(iotHubClientHandle, "TrustedCerts", certificates) != IOTHUB_CLIENT_OK)
+                {
+                    (void)printf("failure to set option \"TrustedCerts\"\r\n");
+                }
+#endif // SET_TRUSTED_CERT_IN_SAMPLES
+
+                myWeather = CREATE_MODEL_INSTANCE(WeatherStation, ContosoAnemometer);
+                if (myWeather == NULL)
+                {
+                    (void)printf("Failed on CREATE_MODEL_INSTANCE\r\n");
+                }
+                else
+                {
+                    if (IoTHubClient_LL_SetMessageCallback(iotHubClientHandle, IoTHubMessage, myWeather) != IOTHUB_CLIENT_OK)
+                    {
+                        printf("unable to IoTHubClient_SetMessageCallback\r\n");
+                    }
+                    else
+                    {
+                        myWeather->DeviceId = "myFirstDevice";
+                        myWeather->WindSpeed = avgWindSpeed + (rand() % 4 + 2);
+                        myWeather->Temperature = minTemperature + (rand() % 10);
+                        myWeather->Humidity = minHumidity + (rand() % 20);
+                        {
+                            unsigned char* destination;
+                            size_t destinationSize;
+                            if (SERIALIZE(&destination, &destinationSize, myWeather->DeviceId, myWeather->WindSpeed, myWeather->Temperature, myWeather->Humidity) != CODEFIRST_OK)
+                            {
+                                (void)printf("Failed to serialize\r\n");
+                            }
+                            else
+                            {
+                                IOTHUB_MESSAGE_HANDLE messageHandle = IoTHubMessage_CreateFromByteArray(destination, destinationSize);
+                                if (messageHandle == NULL)
+                                {
+                                    printf("unable to create a new IoTHubMessage\r\n");
+                                }
+                                else
+                                {
+                                    MAP_HANDLE propMap = IoTHubMessage_Properties(messageHandle);
+                                    (void)sprintf_s(propText, sizeof(propText), myWeather->Temperature > 28 ? "true" : "false");
+                                    if (Map_AddOrUpdate(propMap, "temperatureAlert", propText) != MAP_OK)
+                                    {
+                                        printf("ERROR: Map_AddOrUpdate Failed!\r\n");
+                                    }
+
+                                    if (IoTHubClient_LL_SendEventAsync(iotHubClientHandle, messageHandle, sendCallback, (void*)1) != IOTHUB_CLIENT_OK)
+                                    {
+                                        printf("failed to hand over the message to IoTHubClient");
+                                    }
+                                    else
+                                    {
+                                        printf("IoTHubClient accepted the message for delivery\r\n");
+                                    }
+
+                                    IoTHubMessage_Destroy(messageHandle);
+                                }
+                                free(destination);
+                            }
+                        }
+
+                        /* wait for commands */
+                        while (1)
+                        {
+                            IoTHubClient_LL_DoWork(iotHubClientHandle);
+                            ThreadAPI_Sleep(100);
+                        }
+                    }
+
+                    DESTROY_MODEL_INSTANCE(myWeather);
+                }
+                IoTHubClient_LL_Destroy(iotHubClientHandle);
+            }
+            serializer_deinit();
+        }
+        platform_deinit();
+    }
+}
diff --git a/sample/simplesample_http.h b/sample/simplesample_http.h
new file mode 100644 (file)
index 0000000..baf6975
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef SIMPLESAMPLEHTTP_H
+#define SIMPLESAMPLEHTTP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    void simplesample_http_run(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SIMPLESAMPLEHTTP_H */
diff --git a/sdk b/sdk
new file mode 160000 (submodule)
index 0000000..564a9f4
--- /dev/null
+++ b/sdk
@@ -0,0 +1 @@
+Subproject commit 564a9f4563f1187140a286057f344a75616a4269