Skip to content
Snippets Groups Projects
Commit 376d2666 authored by Alexander Alashkin's avatar Alexander Alashkin Committed by Cesanta Bot
Browse files

Add PIC32MX/CC3100 mqtt_client example

PUBLISHED_FROM=cda885a9dc5d1203b7b59b13ea7fd7934b31260a
parent d9062263
No related branches found
No related tags found
No related merge requests found
Showing
with 2177 additions and 1 deletion
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# `wildcard ./*/` works in both linux and linux/wine, while `wildcard */` enumerates nothing under wine # `wildcard ./*/` works in both linux and linux/wine, while `wildcard */` enumerates nothing under wine
SUBDIRS = $(sort $(dir $(wildcard ./*/))) SUBDIRS = $(sort $(dir $(wildcard ./*/)))
SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./STM32F4_CC3100/, $(SUBDIRS)) SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./PIC32/ ./STM32F4_CC3100/, $(SUBDIRS))
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
SUBDIRS:=$(filter-out ./load_balancer/ ./netcat/ ./raspberry_pi_mjpeg_led/ ./captive_dns_server/, $(SUBDIRS)) SUBDIRS:=$(filter-out ./load_balancer/ ./netcat/ ./raspberry_pi_mjpeg_led/ ./captive_dns_server/, $(SUBDIRS))
......
#
# There exist several targets which are by default empty and which can be
# used for execution of your targets. These targets are usually executed
# before and after some main targets. They are:
#
# .build-pre: called before 'build' target
# .build-post: called after 'build' target
# .clean-pre: called before 'clean' target
# .clean-post: called after 'clean' target
# .clobber-pre: called before 'clobber' target
# .clobber-post: called after 'clobber' target
# .all-pre: called before 'all' target
# .all-post: called after 'all' target
# .help-pre: called before 'help' target
# .help-post: called after 'help' target
#
# Targets beginning with '.' are not intended to be called on their own.
#
# Main targets can be executed directly, and they are:
#
# build build a specific configuration
# clean remove built files from a configuration
# clobber remove all built files
# all build all configurations
# help print help mesage
#
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
# .help-impl are implemented in nbproject/makefile-impl.mk.
#
# Available make variables:
#
# CND_BASEDIR base directory for relative paths
# CND_DISTDIR default top distribution directory (build artifacts)
# CND_BUILDDIR default top build directory (object files, ...)
# CONF name of current configuration
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
#
# NOCDDL
# Environment
MKDIR=mkdir
CP=cp
CCADMIN=CCadmin
RANLIB=ranlib
# build
build: .build-post
.build-pre:
# Add your pre 'build' code here...
.build-post: .build-impl
# Add your post 'build' code here...
# clean
clean: .clean-post
.clean-pre:
# Add your pre 'clean' code here...
# WARNING: the IDE does not call this target since it takes a long time to
# simply run make. Instead, the IDE removes the configuration directories
# under build and dist directly without calling make.
# This target is left here so people can do a clean when running a clean
# outside the IDE.
.clean-post: .clean-impl
# Add your post 'clean' code here...
# clobber
clobber: .clobber-post
.clobber-pre:
# Add your pre 'clobber' code here...
.clobber-post: .clobber-impl
# Add your post 'clobber' code here...
# all
all: .all-post
.all-pre:
# Add your pre 'all' code here...
.all-post: .all-impl
# Add your post 'all' code here...
# help
help: .help-post
.help-pre:
# Add your pre 'help' code here...
.help-post: .help-impl
# Add your post 'help' code here...
# include project implementation makefile
include nbproject/Makefile-impl.mk
# include project make variables
include nbproject/Makefile-variables.mk
#
#Fri Sep 30 14:33:25 EEST 2016
mx795_CC3100_e16.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=7787462309de955deefcc6f5508f88a9
mx795_CC3100_e16.languagetoolchain.version=1.42
configurations-xml=57b90aa5c34b820a6cb86bde88422e21
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=02b44c60b7ea0aab28d65f169487b894
host.platform=linux
conf.ids=mx795_CC3100_e16
mx795_CC3100_e16.languagetoolchain.dir=/opt/microchip/xc32/v1.42/bin
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
# Project Name
PROJECTNAME=mqtt_client.X
# Active Configuration
DEFAULTCONF=mx795_CC3100_e16
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=mx795_CC3100_e16
# build
.build-impl: .build-pre
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf
# clean
.clean-impl: .clean-pre
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf
# clobber
.clobber-impl: .clobber-pre .depcheck-impl
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=mx795_CC3100_e16 clean
# all
.all-impl: .all-pre .depcheck-impl
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=mx795_CC3100_e16 build
# dependency checking support
.depcheck-impl:
# @echo "# This code depends on make tool being used" >.dep.inc
# @if [ -n "${MAKE_VERSION}" ]; then \
# echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
# echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
# echo "include \$${DEPFILES}" >>.dep.inc; \
# echo "endif" >>.dep.inc; \
# else \
# echo ".KEEP_STATE:" >>.dep.inc; \
# echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
# fi
#
# Generated Makefile - do not edit!
#
#
# This file contains information about the location of compilers and other tools.
# If you commmit this file into your revision control server, you will be able to
# to checkout the project and build it from the command line with make. However,
# if more than one person works on the same project, then this file might show
# conflicts since different users are bound to have compilers in different places.
# In that case you might choose to not commit this file and let MPLAB X recreate this file
# for each user. The disadvantage of not commiting this file is that you must run MPLAB X at
# least once so the file gets created and the project can be built. Finally, you can also
# avoid using this file at all if you are only building from the command line with make.
# You can invoke make with the values of the macros:
# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
#
PATH_TO_IDE_BIN=/opt/microchip/mplabx/v3.40/mplab_ide/platform/../mplab_ide/modules/../../bin/
# Adding MPLAB X bin directory to path.
PATH:=/opt/microchip/mplabx/v3.40/mplab_ide/platform/../mplab_ide/modules/../../bin/:$(PATH)
# Path to java used to run MPLAB X when this makefile was created
MP_JAVA_PATH="/opt/microchip/mplabx/v3.40/sys/java/jre1.8.0_91/bin/"
OS_CURRENT="$(shell uname -s)"
MP_CC="/opt/microchip/xc32/v1.42/bin/xc32-gcc"
MP_CPPC="/opt/microchip/xc32/v1.42/bin/xc32-g++"
# MP_BC is not defined
MP_AS="/opt/microchip/xc32/v1.42/bin/xc32-as"
MP_LD="/opt/microchip/xc32/v1.42/bin/xc32-ld"
MP_AR="/opt/microchip/xc32/v1.42/bin/xc32-ar"
DEP_GEN=${MP_JAVA_PATH}java -jar "/opt/microchip/mplabx/v3.40/mplab_ide/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar"
MP_CC_DIR="/opt/microchip/xc32/v1.42/bin"
MP_CPPC_DIR="/opt/microchip/xc32/v1.42/bin"
# MP_BC_DIR is not defined
MP_AS_DIR="/opt/microchip/xc32/v1.42/bin"
MP_LD_DIR="/opt/microchip/xc32/v1.42/bin"
MP_AR_DIR="/opt/microchip/xc32/v1.42/bin"
# MP_BC_DIR is not defined
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
# mx795_CC3100_e16 configuration
CND_ARTIFACT_DIR_mx795_CC3100_e16=dist/mx795_CC3100_e16/production
CND_ARTIFACT_NAME_mx795_CC3100_e16=mqtt_client.X.production.hex
CND_ARTIFACT_PATH_mx795_CC3100_e16=dist/mx795_CC3100_e16/production/mqtt_client.X.production.hex
CND_PACKAGE_DIR_mx795_CC3100_e16=${CND_DISTDIR}/mx795_CC3100_e16/package
CND_PACKAGE_NAME_mx795_CC3100_e16=mqttclient.x.tar
CND_PACKAGE_PATH_mx795_CC3100_e16=${CND_DISTDIR}/mx795_CC3100_e16/package/mqttclient.x.tar
#!/bin/bash -x
#
# Generated - do not edit!
#
# Macros
TOP=`pwd`
CND_CONF=mx795_CC3100_e16
CND_DISTDIR=dist
TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/mqtt_client.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
OUTPUT_BASENAME=mqtt_client.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
PACKAGE_TOP_DIR=mqttclient.x/
# Functions
function checkReturnCode
{
rc=$?
if [ $rc != 0 ]
then
exit $rc
fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
mkdir -p "$1"
checkReturnCode
if [ "$2" != "" ]
then
chmod $2 "$1"
checkReturnCode
fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
cp "$1" "$2"
checkReturnCode
if [ "$3" != "" ]
then
chmod $3 "$2"
checkReturnCode
fi
}
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/package
rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}
# Copy files and create directories and links
cd "${TOP}"
makeDirectory ${TMPDIR}/mqttclient.x/bin
copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/package/mqttclient.x.tar
cd ${TMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/mqttclient.x.tar *
checkReturnCode
# Cleanup
cd "${TOP}"
rm -rf ${TMPDIR}
#
#Thu Sep 29 17:49:40 EEST 2016
pkobskde/DEVID_MISMATCH=true
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="62">
<projectmakefile>Makefile</projectmakefile>
<defaultConf>0</defaultConf>
<confs>
<conf name="mx795_CC3100_e16" type="2">
<platformToolSN>:=MPLABComm-USB-Microchip:=&lt;vid>04D8:=&lt;pid>8107:=&lt;rev>0002:=&lt;man>Microchip Technology Incorporated:=&lt;prod>Explorer 16/32 PICkit on Board:=&lt;sn>BUR162971352:=&lt;drv>x:=&lt;xpt>h:=end</platformToolSN>
<languageToolchainDir>/opt/microchip/xc32/v1.42/bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>
<placeholder2>place holder 2</placeholder2>
</mdbdebugger>
<runprofile version="6">
<args></args>
<rundir></rundir>
<buildfirst>true</buildfirst>
<console-type>0</console-type>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
</confs>
</configurationDescriptor>
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/home/alex/microchip/harmony/v1_08_01/framework/system/devcon/src/sys_devcon.c</file>
<file>file:/home/alex/microchip/harmony/v1_08_01/framework/system/debug/src/sys_debug.c</file>
<file>file:/home/alex/microchip/harmony/v1_08_01/framework/system/devcon/src/sys_devcon_pic32mx.c</file>
<file>file:/home/alex/CC3100SDK_1.2.0/cc3100-sdk/simplelink/source/spawn.c</file>
<file>file:/home/alex/microchip/harmony/v1_08_01/framework/system/int/src/sys_int_pic32.c</file>
</group>
</open-files>
</project-private>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<Harmony xmlns="Harmony" MHC="true"/>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>mqtt_client</name>
<creation-uuid>e54023e9-3948-44ef-bf6f-29d8b223e555</creation-uuid>
<make-project-type>0</make-project-type>
<c-extensions>c</c-extensions>
<cpp-extensions/>
<header-extensions>h</header-extensions>
<asminc-extensions/>
<sourceEncoding>ISO-8859-1</sourceEncoding>
<make-dep-projects/>
</data>
</configuration>
</project>
#
# Application configuration file generated by
# Microchip Harmony Configurator (MHC) from Harmony version: 1.04
#
mainmenu "MPLAB Harmony & Application Configuration"
menu "Application Configuration"
config APP_INSTANCES
int "Number of Applications"
default 1
range 1 10 # Must limit to 10 or application templates will need to be updated.
config APP_AUTO_GENERATE_CODE # Used by MHC internally to selectively auto-generate app.h, app.c, and main.c
bool
default n
source "$HARMONY_VERSION_PATH/utilities/mhc/config/gencode/framework/global_event/config/global_event_gencode.hconfig"
source "$HARMONY_VERSION_PATH/utilities/mhc/config/app_name_idx_gencode.ftl" 10 instances
menu "Exception Handling"
config USE_EXCEPTION_HANDLER
bool "Use MPLAB Harmony Exception Handler Template?"
default y
---help---
Enter 'Y' if you want to include an exception handler template
(system_exceptions.c) in this system configuration. Enter 'N' if
you do not.
---endhelp---
config EXCEPTION_USE_SYS_DEBUG
bool "Use debug services in exception handler?"
depends on USE_EXCEPTION_HANDLER
default y
---help---
Enter 'Y' if you want the exception handler to use the SYS_DEBUG service to
report exception information. Enter 'N' if you do not.
---endhelp---
config EXCEPTION_BREAKPOINT
bool "Hit breakpoint when an exception occurs?"
depends on USE_EXCEPTION_HANDLER && EXCEPTION_USE_SYS_DEBUG
default y
---help---
Enter 'Y' if you want the exception handler to hit a breakpoint when
an exception occurs. Enter 'N' if you do not.
Note: Only works if debugging is enabled.
---endhelp---
endmenu # Exception Handling
#insert application specific configuration here
endmenu # Application Configuration
source "$HARMONY_VERSION_PATH/config/harmony.hconfig"
/*
* Copyright (c) 2016 Cesanta Software Limited
* All rights reserved
*/
#include "app.h"
#include "system/debug/sys_debug.h"
#include "./../../../../../mongoose.h"
#include "user_params.h"
static struct mg_mgr mgr;
static int msg_id;
struct mg_mqtt_topic_expression topic_expressions[] = {{"/test", 0}};
APP_DATA appData;
void APP_Initialize(void) {
appData.state = APP_STATE_INIT;
DRV_RTCC_Start();
mg_mgr_init(&mgr, NULL);
}
static void ev_handler(struct mg_connection *nc, int ev, void *p);
void APP_Tasks(void) {
/*
* Processing CC3100 Tasks
* It looks like SYS task and might be processed in SYS_Tasks
* But for this demo it is here to make this call
* visible
*/
_SlNonOsMainLoopTask();
/* Check the application's current state. */
switch (appData.state) {
/* Application's initial state. */
case APP_STATE_INIT: {
SYS_PRINT("\n\r*** PIC32 MQTT CLIENT ***\n\r");
SYS_PRINT("\n\rInitializing CC3100\n\r");
int res = sl_Start(NULL, NULL, NULL);
if (res != 0) {
SYS_PRINT("FAILED\n\r");
appData.state = APP_STATE_DONE;
break;
}
SlSecParams_t sec_params;
memset(&sec_params, 0, sizeof(sec_params));
sec_params.Key = NET_PWD;
sec_params.KeyLen = sizeof(NET_PWD) - 1;
sec_params.Type = NET_SECURITY;
SYS_PRINT("Connecting to WiFi\n\r");
sl_WlanConnect(NET_SSID, sizeof(NET_SSID) - 1, 0, &sec_params, NULL);
SYS_PRINT("Initialization done\n\r");
appData.state = APP_STATE_SERVICE_TASKS;
break;
}
case APP_STATE_CONNECT_BROKER: {
if (mg_connect(&mgr, MQTT_BROKER_ADDRESS, ev_handler) == NULL) {
SYS_PRINT("Failed to create connection\n\r");
appData.state = APP_STATE_DONE;
} else {
appData.state = APP_STATE_SERVICE_TASKS;
}
break;
}
case APP_STATE_SERVICE_TASKS: {
static uint32_t prev_poll_time = 0;
uint32_t now = DRV_RTCC_TimeGet();
if (now - prev_poll_time > 100) {
/*
* We cannot call mg_mgr_poll every cycle
* it leads to SPI overload (internaly mg_mgr_poll calls
* CC3100 via SPI
*/
mg_mgr_poll(&mgr, 1);
prev_poll_time = now;
}
break;
}
case APP_STATE_DONE: {
/* Do nothing here */
break;
}
default: {
/* TODO: Handle error in application's state machine. */
break;
}
}
}
void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent) {
switch (pWlanEvent->Event) {
case SL_WLAN_CONNECT_EVENT:
SYS_PRINT("Connected to WiFi\r\n");
break;
case SL_WLAN_DISCONNECT_EVENT:
SYS_PRINT("Disconnected WiFi\r\n");
break;
default:
SYS_PRINT("Got Wlan event %d\r\n", pWlanEvent->Event);
break;
}
}
void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent) {
switch (pNetAppEvent->Event) {
case SL_NETAPP_IPV4_IPACQUIRED_EVENT:
SYS_PRINT("Got IP\r\n");
appData.state = APP_STATE_CONNECT_BROKER;
break;
default:
SYS_PRINT("Got NetApp Event: %d\r\n", pNetAppEvent->Event);
break;
}
}
static void ev_handler(struct mg_connection *nc, int ev, void *p) {
struct mg_mqtt_message *msg = (struct mg_mqtt_message *) p;
static int count1 = 0;
switch (ev) {
case MG_EV_CONNECT:
if (*(int *) p != 0) {
SYS_PRINT("Failed to connect to %s\r\n", MQTT_BROKER_ADDRESS);
} else {
SYS_PRINT("Connected to %s\r\n", MQTT_BROKER_ADDRESS);
}
struct mg_send_mqtt_handshake_opts opts;
memset(&opts, 0, sizeof(opts));
opts.user_name = MQTT_USER_NAME;
opts.password = MQTT_USER_PWD;
mg_set_protocol_mqtt(nc);
mg_send_mqtt_handshake_opt(nc, "PIC32", opts);
break;
case MG_EV_MQTT_CONNACK:
if (msg->connack_ret_code != MG_EV_MQTT_CONNACK_ACCEPTED) {
SYS_PRINT("Got mqtt connection error %d\n\r", msg->connack_ret_code);
} else {
SYS_PRINT("Connected to broker\n\r");
}
SYS_PRINT("Subscribing to /test\n\r");
mg_mqtt_subscribe(nc, topic_expressions,
sizeof(topic_expressions) / sizeof(*topic_expressions),
++msg_id);
nc->flags |= MG_F_USER_1;
break;
case MG_EV_MQTT_SUBACK:
SYS_PRINT("Subscription acknowledged\r\n");
break;
case MG_EV_MQTT_PUBLISH:
SYS_PRINT("Got incoming message %s: %.*s\r\n", msg->topic,
(int) msg->payload.len, msg->payload.p);
break;
case MG_EV_POLL: {
if (nc->flags & MG_F_USER_1) {
char msg[100];
static uint32_t prev_send = 0;
uint32_t now = DRV_RTCC_TimeGet();
if (now - prev_send > 1000) {
int len = snprintf(msg, sizeof(msg), "Current RTC value: %u", now);
SYS_PRINT("Publishing message with RTC value=%u\r\n", now);
mg_mqtt_publish(nc, "/stuff", ++msg_id, MG_MQTT_QOS(0), msg, len);
prev_send = now;
}
}
break;
}
case MG_EV_CLOSE:
SYS_PRINT("Connection to broker is closed\r\n");
appData.state = APP_STATE_DONE;
break;
default:
break;
}
}
/*
* Copyright (c) 2016 Cesanta Software Limited
* All rights reserved
*/
#ifndef _APP_H
#define _APP_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include "system_config.h"
#include "system_definitions.h"
#include "simplelink.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Application states
Summary:
Application states enumeration
Description:
This enumeration defines the valid application states. These states
determine the behavior of the application at various times.
*/
typedef enum {
APP_STATE_INIT = 0,
APP_STATE_SERVICE_TASKS,
APP_STATE_CONNECT_BROKER,
APP_STATE_DONE
} APP_STATES;
// *****************************************************************************
/* Application Data
Summary:
Holds application data
Description:
This structure holds the application's data.
Remarks:
Application strings and buffers are be defined outside this structure.
*/
typedef struct {
/* The application's current state */
APP_STATES state;
} APP_DATA;
/*******************************************************************************
Function:
void APP_Initialize ( void )
Summary:
MPLAB Harmony application initialization routine.
Description:
This function initializes the Harmony application. It places the
application in its initial state and prepares it to run so that its
APP_Tasks function can be called.
Precondition:
All other system initialization routines should be called before calling
this routine (in "SYS_Initialize").
Parameters:
None.
Returns:
None.
Example:
<code>
APP_Initialize();
</code>
Remarks:
This routine must be called from the SYS_Initialize function.
*/
void APP_Initialize(void);
/*******************************************************************************
Function:
void APP_Tasks ( void )
Summary:
MPLAB Harmony Demo application tasks function
Description:
This routine is the Harmony Demo application's tasks function. It
defines the application's state machine and core logic.
Precondition:
The system and application initialization ("SYS_Initialize") should be
called before calling this.
Parameters:
None.
Returns:
None.
Example:
<code>
APP_Tasks();
</code>
Remarks:
This routine must be called from SYS_Tasks() routine.
*/
void APP_Tasks(void);
#ifdef __cplusplus
}
#endif
#endif /* _APP_H */
/*
* Copyright (c) 2016 Cesanta Software Limited
* All rights reserved
*/
#include "app.h"
#include "system/debug/sys_debug.h"
#include "simplelink.h"
#include "user_params.h"
P_EVENT_HANDLER g_cc3100_IRQ_handler = NULL;
void AssertCS() {
PLIB_PORTS_PinClear(PORTS_ID_0, CS_PORT, CS_PIN);
}
void DeassertCS() {
PLIB_PORTS_PinSet(PORTS_ID_0, CS_PORT, CS_PIN);
}
void CC3100_enable() {
PLIB_PORTS_PinSet(PORTS_ID_0, HIB_PORT, HIB_PIN);
}
void CC3100_disable() {
PLIB_PORTS_PinClear(PORTS_ID_0, HIB_PORT, HIB_PIN);
}
Fd_t spi_Open(char *ifName, unsigned long flags) {
CC3100_disable();
return 0;
}
int spi_Write(Fd_t fd, unsigned char *pBuff, int len) {
if (len > 512) {
SYS_PRINT("BUFFER TOO SMALL");
return 0;
}
AssertCS();
uint8_t dummy[512];
DRV_SPI0_BufferAddWriteRead(pBuff, dummy, len);
DRV_SPI_Tasks(sysObj.spiObjectIdx0);
DeassertCS();
return len;
}
int spi_Read(Fd_t fd, unsigned char *pBuff, int len) {
if (len > 512) {
SYS_PRINT("BUFFER TOO SMALL");
return 0;
}
uint8_t dummy[512];
memset(dummy, 0xFF, len);
AssertCS();
DRV_SPI0_BufferAddWriteRead(dummy, pBuff, len);
DRV_SPI_Tasks(sysObj.spiObjectIdx0);
DeassertCS();
return len;
}
int registerInterruptHandler(P_EVENT_HANDLER int_handler, void *pValue) {
(void) pValue;
g_cc3100_IRQ_handler = int_handler;
}
/*
* Copyright (c) 2016 Cesanta Software Limited
* All rights reserved
*/
#include <stddef.h>
#include <stdlib.h>
#include "system/common/sys_module.h"
int main(void) {
/* Initialize all MPLAB Harmony modules, including application(s). */
SYS_Initialize(NULL);
while (1) {
/* Maintain state machines of all polled MPLAB Harmony modules. */
SYS_Tasks();
}
/* Execution should not come here during normal operation */
return (EXIT_FAILURE);
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configuration version="1.0.8.7">
<Designer>
<Assets>
<Settings bpp="16">
<MemoryLocations>
<MemoryLocation address="0" id="default"/>
</MemoryLocations>
</Settings>
</Assets>
<Screens height="200" width="320">
<Screen active="true" background="000000" clearOnShow="true" doubleBuffer="false" export="true" name="Screen1" primary="true" visible="true">
<Objects/>
</Screen>
</Screens>
<Schemes defaultSchemeName="default">
<Scheme name="default">
<Alpha>100</Alpha>
<BackgroundOffset>0,0</BackgroundOffset>
<EmbossSize>3</EmbossSize>
<Colors>
<Primary>FFFFFF</Primary>
<Secondary>404040</Secondary>
<Disabled>C0C0C0</Disabled>
<Background>000000</Background>
<EmbossLight>C0C0C0</EmbossLight>
<EmbossDark>404040</EmbossDark>
<TextPrimary>000000</TextPrimary>
<TextSecondary>FFFFFF</TextSecondary>
<TextDisabled>404040</TextDisabled>
<GradientStart>000000</GradientStart>
<GradientEnd>FFFFFF</GradientEnd>
</Colors>
<FillStyle>Color</FillStyle>
<BackgroundType>None</BackgroundType>
</Scheme>
</Schemes>
</Designer>
<General>
<HarmonyPath path="../../../../../../../microchip/harmony/v1_08_01"/>
<Processor name=""/>
<ForceOptimization flag="true"/>
<MergeStrategy flag="USER_ALL"/>
</General>
<Manifest>
<Files>
<File>
<Name>osal_impl_basic.h</Name>
<Path>Header Files/framework/osal/src</Path>
</File>
<File>
<Name>peripheral_common_32bit.h</Name>
<Path>Header Files/framework/peripheral</Path>
</File>
<File>
<Name>driver_common.h</Name>
<Path>Header Files/framework/driver</Path>
</File>
<File>
<Name>sys_devcon.c</Name>
<Path>Source Files/framework/system/devcon/src</Path>
</File>
<File>
<Name>osal.h</Name>
<Path>Header Files/framework/osal</Path>
</File>
<File>
<Name>sys_ports.h</Name>
<Path>Header Files/framework/system/ports</Path>
</File>
<File>
<Name>driver.h</Name>
<Path>Header Files/framework/driver</Path>
</File>
<File>
<Name>peripheral_common.h</Name>
<Path>Header Files/framework/peripheral</Path>
</File>
<File>
<Name>sys_debug_local.h</Name>
<Path>Header Files/framework/system/debug/src</Path>
</File>
<File>
<Name>sys_common.h</Name>
<Path>Header Files/framework/system/common</Path>
</File>
<File>
<Name>sys_buffer.h</Name>
<Path>Header Files/framework/system/common</Path>
</File>
<File>
<Name>sys_int_pic32.c</Name>
<Path>Source Files/framework/system/int/src</Path>
</File>
<File>
<Name>sys_clk.h</Name>
<Path>Header Files/framework/system/clk</Path>
</File>
<File>
<Name>osal_impl_none.h</Name>
<Path>Header Files/framework/osal/src</Path>
</File>
<File>
<Name>sys_clk_mapping.h</Name>
<Path>Header Files/framework/system/clk</Path>
</File>
<File>
<Name>osal_definitions.h</Name>
<Path>Header Files/framework/osal</Path>
</File>
<File>
<Name>sys_int_mapping.h</Name>
<Path>Header Files/framework/system/int</Path>
</File>
<File>
<Name>gfx_palette.h</Name>
<Path>Header Files/framework/gfx</Path>
</File>
<File>
<Name>sys_int_private.h</Name>
<Path>Header Files/framework/system/int/src</Path>
</File>
<File>
<Name>sys_devcon.h</Name>
<Path>Header Files/framework/system/devcon</Path>
</File>
<File>
<Name>system.h</Name>
<Path>Header Files/framework/system</Path>
</File>
<File>
<Name>sys_debug.c</Name>
<Path>Source Files/framework/system/debug/src</Path>
</File>
<File>
<Name>sys_console.h</Name>
<Path>Header Files/framework/system/console</Path>
</File>
<File>
<Name>sys_debug.h</Name>
<Path>Header Files/framework/system/debug</Path>
</File>
<File>
<Name>sys_module.h</Name>
<Path>Header Files/framework/system/common</Path>
</File>
<File>
<Name>sys_devcon_pic32mx.c</Name>
<Path>Source Files/framework/system/devcon/src</Path>
</File>
<File>
<Name>sys_devcon_local.h</Name>
<Path>Header Files/framework/system/devcon/src</Path>
</File>
<File>
<Name>peripheral.h</Name>
<Path>Header Files/framework/peripheral</Path>
</File>
<File>
<Name>sys_queue.h</Name>
<Path>Header Files/framework/system/common</Path>
</File>
<File>
<Name>sys_console_local.h</Name>
<Path>Header Files/framework/system/console/src</Path>
</File>
<File>
<Name>sys_int.h</Name>
<Path>Header Files/framework/system/int</Path>
</File>
</Files>
<Templates>
<Template>
<Name>sys_console_static.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/system/console/src</Path>
<Checksum>0B506F1F6112899EF538390AD8DBD62F</Checksum>
</Template>
<Template>
<Name>system_definitions.h</Name>
<Path>Header Files/app/system_config/mx795_CC3100_e16</Path>
<Checksum>1F863F474CF6B1EF5BCAEC53DA0A1EB9</Checksum>
</Template>
<Template>
<Name>system_exceptions.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16</Path>
<Checksum>C111969CA43D6CEA1E9E33A6164E7AE0</Checksum>
</Template>
<Template>
<Name>drv_spi_static_local.h</Name>
<Path>Header Files/app/system_config/mx795_CC3100_e16/framework/driver/spi/static/src</Path>
<Checksum>70055803006A2C67E983956B3B3ABD25</Checksum>
</Template>
<Template>
<Name>drv_spi_mapping.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/driver/spi/static/src</Path>
<Checksum>ADEEE2519E932B46D44C41B8F44E1F19</Checksum>
</Template>
<Template>
<Name>drv_usart_static_byte_model.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/driver/usart/src</Path>
<Checksum>F91C429976AC25EB8B3639F0B0356E3B</Checksum>
</Template>
<Template>
<Name>system_init.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16</Path>
<Checksum>34219E31193F143A502765E488BC500E</Checksum>
<ProjectFileChecksum>368F06F4DCF995EE27BD5F31F9034D30</ProjectFileChecksum>
</Template>
<Template>
<Name>drv_usart_static.h</Name>
<Path>Header Files/app/system_config/mx795_CC3100_e16/framework/driver/usart</Path>
<Checksum>AE37BD63B6EC9F6ADD6B8006CE192FCB</Checksum>
</Template>
<Template>
<Name>drv_spi_static_tasks.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/driver/spi/static/src</Path>
<Checksum>8D9BDD4F87493B036E9786F53F65EE82</Checksum>
</Template>
<Template>
<Name>drv_spi_static.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/driver/spi/static/src</Path>
<Checksum>C0323F1E5F9550BF1BC4441ADB9B09D8</Checksum>
</Template>
<Template>
<Name>drv_rtcc_static.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/driver/rtcc/src</Path>
<Checksum>9A5D97DC0EADF32162B4B222AAC95408</Checksum>
</Template>
<Template>
<Name>sys_clk_static.h</Name>
<Path>Header Files/app/system_config/mx795_CC3100_e16/framework/system/clk</Path>
<Checksum>B4BD59D8D7C4DA95DC5E3B57755FD352</Checksum>
</Template>
<Template>
<Name>system_config.h</Name>
<Path>Header Files/app/system_config/mx795_CC3100_e16</Path>
<Checksum>85CDEB06EBF7053ADCB2CB37014D10D1</Checksum>
</Template>
<Template>
<Name>drv_usart_static_local.h</Name>
<Path>Header Files/app/system_config/mx795_CC3100_e16/framework/driver/usart/src</Path>
<Checksum>62F7F49D6A443F111DA38971475472FD</Checksum>
</Template>
<Template>
<Name>system_interrupt.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16</Path>
<Checksum>CACF8AB870174547FD1DC4FE62DECBAD</Checksum>
<ProjectFileChecksum>DB1F2DBEF12282D8AF55C36D1192E873</ProjectFileChecksum>
</Template>
<Template>
<Name>sys_clk_static.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/system/clk/src</Path>
<Checksum>E8C935BED4628875A8C3428DDD07355C</Checksum>
</Template>
<Template>
<Name>drv_spi_static.h</Name>
<Path>Header Files/app/system_config/mx795_CC3100_e16/framework/driver/spi/static</Path>
<Checksum>68B5BA023AB90B18D229B6E7CBF0850C</Checksum>
</Template>
<Template>
<Name>drv_usart_mapping.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/driver/usart/src</Path>
<Checksum>115DDE4372E58D4116BC77DC36FD97DC</Checksum>
</Template>
<Template>
<Name>main.c</Name>
<Path>Source Files/app</Path>
</Template>
<Template>
<Name>drv_spi_static_sys_queue.h</Name>
<Path>Header Files/app/system_config/mx795_CC3100_e16/framework/driver/spi/static/src</Path>
<Checksum>3D489FB0B5415BB6F80FA34FC0CEE9F7</Checksum>
</Template>
<Template>
<Name>drv_spi_static_rm_tasks.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/driver/spi/static/src</Path>
<Checksum>BED98A3F5628502709D95341DC70019B</Checksum>
</Template>
<Template>
<Name>app.c</Name>
<Path>Source Files/app</Path>
</Template>
<Template>
<Name>sys_ports_static.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/system/ports/src</Path>
<Checksum>F693DCC21C702581B107B8A238195A13</Checksum>
</Template>
<Template>
<Name>drv_spi_static_sys_queue.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/driver/spi/static/src</Path>
<Checksum>E06222D2E5F5F69EE3C77ACD6FCC3059</Checksum>
</Template>
<Template>
<Name>system_tasks.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16</Path>
<Checksum>9990FEA6D9BDD86EAA2B873D5A5B9DAC</Checksum>
<ProjectFileChecksum>91547DE270F61E54B606034EBF1BAEC1</ProjectFileChecksum>
</Template>
<Template>
<Name>app.h</Name>
<Path>Header Files/app</Path>
</Template>
<Template>
<Name>drv_rtcc_static.h</Name>
<Path>Header Files/app/system_config/mx795_CC3100_e16/framework/driver/rtcc</Path>
<Checksum>FED59BF02817E49C245011170B963EE2</Checksum>
</Template>
<Template>
<Name>drv_usart_static.c</Name>
<Path>Source Files/app/system_config/mx795_CC3100_e16/framework/driver/usart/src</Path>
<Checksum>BD4DEFD647BB5AF32D1DBF352D6139D5</Checksum>
</Template>
</Templates>
<CompilerItems>
<C32>
<Include value="/home/alex/go/src/cesanta.com/mongoose/examples/PIC32/mqtt_client/firmware/src"/>
<Include value="/home/alex/go/src/cesanta.com/mongoose/examples/PIC32/mqtt_client/firmware/src/system_config/mx795_CC3100_e16"/>
<Include value="/home/alex/go/src/cesanta.com/mongoose/examples/PIC32/mqtt_client/firmware/src/mx795_CC3100_e16"/>
<Include value="/home/alex/microchip/harmony/v1_08_01/framework"/>
<Include value="/home/alex/go/src/cesanta.com/mongoose/examples/PIC32/mqtt_client/firmware/src/system_config/mx795_CC3100_e16/framework"/>
</C32>
</CompilerItems>
<Libraries>
<Library value="../../../../../../../../../microchip/harmony/v1_08_01/framework/tcpip/src/crypto/aes_pic32mx.a"/>
<Library value="../../../../../../../../../microchip/harmony/v1_08_01/bin/framework/peripheral/PIC32MX795F512L_peripherals.a"/>
</Libraries>
</Manifest>
</configuration>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment