Commit d9062263 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Link MIOT for Linux statically

PUBLISHED_FROM=4f0adab828ebf06dbc3e0c4333bf0053f374b62f
parent da447b10
......@@ -3,7 +3,7 @@
# `wildcard ./*/` works in both linux and linux/wine, while `wildcard */` enumerates nothing under wine
SUBDIRS = $(sort $(dir $(wildcard ./*/)))
SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./PIC32/ ./STM32F4_CC3100/, $(SUBDIRS))
SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./STM32F4_CC3100/, $(SUBDIRS))
ifeq ($(OS), Windows_NT)
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}
<?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);
}
/* clang-format off */
/*******************************************************************************
RTCC Driver Interface Declarations for Static Single Instance Driver
Company:
Microchip Technology Inc.
File Name:
drv_rtcc_static.h
Summary:
RTCC driver interface declarations for the static single instance driver.
Description:
The RTCC device driver provides a simple interface to manage the RTCC
modules on Microchip microcontrollers. This file defines the interface
Declarations for the OC driver.
Remarks:
Static interfaces incorporate the driver instance number within the names
of the routines, eliminating the need for an object ID or object handle.
Static single-open interfaces also eliminate the need for the open handle.
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTOCULAR PURPOSE.
IN NO EVENT SHALL MOCROCHIP OR ITS LOCENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STROCT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVOCES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
//DOM-IGNORE-END
#ifndef _DRV_RTCC_STATIC_H
#define _DRV_RTCC_STATIC_H
// *****************************************************************************
// *****************************************************************************
// Section: Interface Headers for RTCC Instance
// *****************************************************************************
// *****************************************************************************
void DRV_RTCC_Initialize(void);
void DRV_RTCC_Start(void);
void DRV_RTCC_Stop(void);
void DRV_RTCC_ClockOutput(void);
uint32_t DRV_RTCC_TimeGet(void);
uint32_t DRV_RTCC_DateGet(void);
uint32_t DRV_RTCC_AlarmTimeGet(void);
uint32_t DRV_RTCC_AlarmDateGet(void);
#endif // #ifndef _DRV_RTCC_STATIC_H
/*******************************************************************************
End of File
*/
/*******************************************************************************
RTCC Driver Initialization File
File Name:
drv_rtcc_static.c
Summary:
This file contains source code necessary to initialize the RTCC driver.
Description:
RTCC Driver includes initialization and other routines with small footprtint.
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END
// *****************************************************************************
// *****************************************************************************
// Header Includes
// *****************************************************************************
// *****************************************************************************
#include "peripheral/rtcc/plib_rtcc.h"
#include "peripheral/devcon/plib_devcon.h"
// *****************************************************************************
// *****************************************************************************
// Section: RTCC static driver functions
// *****************************************************************************
// *****************************************************************************
void DRV_RTCC_Initialize(void) {
PLIB_DEVCON_SystemUnlock(DEVCON_ID_0); /* Unlock System */
/* Initialize RTCC */
PLIB_RTCC_WriteEnable(RTCC_ID_0); /* Enable writes to RTCC */
PLIB_RTCC_Disable(RTCC_ID_0); /* Disable clock to RTCC */
while (PLIB_RTCC_ClockRunningStatus(RTCC_ID_0))
; /*Check if clock is disabled */
PLIB_RTCC_RTCTimeSet(RTCC_ID_0, 0x23595900); /* Set RTCC time */
PLIB_RTCC_RTCDateSet(RTCC_ID_0, 0x14010100); /* Set RTCC date */
PLIB_RTCC_AlarmDisable(RTCC_ID_0); /* Disable alarm */
while (PLIB_RTCC_AlarmSyncStatusGet(RTCC_ID_0))
; /* Wait for disable */
PLIB_RTCC_AlarmTimeSet(RTCC_ID_0, 0x00000500); /* Set RTCC alarm time */
PLIB_RTCC_AlarmDateSet(RTCC_ID_0, 0x00010100); /* Set RTCC alarm date */
PLIB_RTCC_AlarmMaskModeSelect(
RTCC_ID_0, RTCC_ALARM_EVERY_SECOND); /* Set RTCC alarm mode */
}
void DRV_RTCC_Start(void) {
PLIB_RTCC_Enable(RTCC_ID_0);
}
void DRV_RTCC_Stop(void) {
PLIB_RTCC_Disable(RTCC_ID_0);
}
void DRV_RTCC_ClockOutput(void) {
PLIB_RTCC_ClockOutputEnable(RTCC_ID_0);
}
uint32_t DRV_RTCC_TimeGet(void) {
return PLIB_RTCC_RTCTimeGet(RTCC_ID_0);
}
uint32_t DRV_RTCC_DateGet(void) {
return PLIB_RTCC_RTCDateGet(RTCC_ID_0);
}
uint32_t DRV_RTCC_AlarmTimeGet(void) {
return PLIB_RTCC_AlarmTimeGet(RTCC_ID_0);
}
uint32_t DRV_RTCC_AlarmDateGet(void) {
return PLIB_RTCC_AlarmDateGet(RTCC_ID_0);
}
/*******************************************************************************
End of File
*/
\ No newline at end of file
/* clang-format off */
/*******************************************************************************
SPI Driver Interface Declarations for Static Single Instance Driver
Company:
Microchip Technology Inc.
File Name:
drv_spi_static.h
Summary:
SPI driver interface declarations for the static single instance driver.
Description:
The SPI device driver provides a simple interface to manage the SPI
modules on Microchip microcontrollers. This file defines the interface
Declarations for the SPI static driver.
Remarks:
Static interfaces incorporate the driver instance number within the names
of the routines, eliminating the need for an object ID or object handle.
Static single-open interfaces also eliminate the need for the open handle.
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2015 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
//DOM-IGNORE-END
#ifndef _DRV_SPI_STATIC_H
#define _DRV_SPI_STATIC_H
// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
#include "driver/spi/static/src/drv_spi_static_local.h"
// DOM-IGNORE-BEGIN
#ifdef __cplusplus // Provide C++ Compatibility
extern "C" {
#endif
// DOM-IGNORE-END
// *********************************************************************************************
// *********************************************************************************************
// Section: System Interface Headers for the Instance 0 of SPI static driver
// *********************************************************************************************
// *********************************************************************************************
SYS_MODULE_OBJ DRV_SPI0_Initialize( void );
void DRV_SPI0_Deinitialize ( void );
SYS_STATUS DRV_SPI0_Status ( void );
void DRV_SPI0_Tasks ( void );
// *********************************************************************************************
// *********************************************************************************************
// Section: General Client Interface Headers for the Instance 0 of SPI static driver
// *********************************************************************************************
// *********************************************************************************************
DRV_HANDLE DRV_SPI0_Open ( const SYS_MODULE_INDEX drvIndex, const DRV_IO_INTENT ioIntent );
void DRV_SPI0_Close ( void );
int32_t DRV_SPI0_ClientConfigure ( const DRV_SPI_CLIENT_DATA * cfgData );
// *********************************************************************************************
// *********************************************************************************************
// Section: Read & Write Client Interface Headers for the Instance 0 of SPI static driver
// *********************************************************************************************
// *********************************************************************************************
DRV_SPI_BUFFER_HANDLE DRV_SPI0_BufferAddRead ( void *rxBuffer, size_t size, DRV_SPI_BUFFER_EVENT_HANDLER completeCB, void * context);
DRV_SPI_BUFFER_HANDLE DRV_SPI0_BufferAddWrite ( void *txBuffer, size_t size, DRV_SPI_BUFFER_EVENT_HANDLER completeCB, void * context );
DRV_SPI_BUFFER_HANDLE DRV_SPI0_BufferAddRead2 ( void *rxBuffer, size_t size, DRV_SPI_BUFFER_EVENT_HANDLER completeCB, void * context, DRV_SPI_BUFFER_HANDLE * jobHandle);
DRV_SPI_BUFFER_HANDLE DRV_SPI0_BufferAddWrite2 ( void *txBuffer, size_t size, DRV_SPI_BUFFER_EVENT_HANDLER completeCB, void * context, DRV_SPI_BUFFER_HANDLE * jobHandle );
DRV_SPI_BUFFER_HANDLE DRV_SPI0_BufferAddWriteRead2 ( void *txBuffer, size_t txSize,void *rxBuffer, size_t rxSize, DRV_SPI_BUFFER_EVENT_HANDLER completeCB, void * context, DRV_SPI_BUFFER_HANDLE * jobHandle);
DRV_SPI_BUFFER_EVENT DRV_SPI0_BufferStatus ( DRV_SPI_BUFFER_HANDLE bufferHandle );
/* This API name was present in the old static driver which is maintained for compatibility.
So, giving a new name for the new static driver which is taken care of while mapping */
#define DRV_SPI0_BufferAddWriteReadNew(txbuff, txsize, rxbuff, rxsize, cb, ct ) \
DRV_SPI0_BufferAddWriteRead2((txbuff), (txsize), (rxbuff), (rxsize), (cb), (ct), NULL)
// *********************************************************************************************
// *********************************************************************************************
// Section: Old static driver compatibility APIs, these will be deprecated.
// *********************************************************************************************
// *********************************************************************************************
bool DRV_SPI0_ReceiverBufferIsFull( void );
bool DRV_SPI0_TransmitterBufferIsFull( void );
int32_t DRV_SPI0_BufferAddWriteRead(const void * txBuffer, void * rxBuffer, uint32_t size);
// *********************************************************************************************
// DOM-IGNORE-BEGIN
#ifdef __cplusplus
}
#endif
// DOM-IGNORE-END
#endif // #ifndef _DRV_SPI_STATIC_H
/*******************************************************************************
End of File
*/
/* clang-format off */
/*******************************************************************************
SPI Driver Local Data Structures for static implementation
Company:
Microchip Technology Inc.
File Name:
drv_spi_static_local.h
Summary:
SPI Driver Local Data Structures for static implementation
Description:
Driver Local Data Structures for static implementation
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2015 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute Software
only when embedded on a Microchip microcontroller or digital signal controller
that is integrated into your product or third party product (pursuant to the
sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
//DOM-IGNORE-END
#ifndef _DRV_SPI_STATIC_LOCAL_H
#define _DRV_SPI_STATIC_LOCAL_H
// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
#include "system_config.h"
#include "driver/spi/drv_spi.h"
#include "system/int/sys_int.h"
#include "system/debug/sys_debug.h"
#include "driver/spi/static/src/drv_spi_static_sys_queue.h"
// DOM-IGNORE-BEGIN
#ifdef __cplusplus // Provide C++ Compatibility
extern "C" {
#endif
// DOM-IGNORE-END
// *****************************************************************************
// *****************************************************************************
// Section: Data Type Definitions
// *****************************************************************************
// *****************************************************************************
#define MAX(a,b) ((a<b) ? b : a)
#define MIN(a,b) ((b<a) ? b : a)
#define PLIB_SPI_RX_8BIT_FIFO_SIZE(index) 16
#define PLIB_SPI_RX_8BIT_HW_MARK(index) 8
#define PLIB_SPI_RX_16BIT_FIFO_SIZE(index) 8
#define PLIB_SPI_RX_16BIT_HW_MARK(index) 4
#define PLIB_SPI_RX_32BIT_FIFO_SIZE(index) 4
#define PLIB_SPI_RX_32BIT_HW_MARK(index) 2
#define PLIB_SPI_TX_8BIT_FIFO_SIZE(index) 16
#define PLIB_SPI_TX_8BIT_LW_MARK(index) 8
#define PLIB_SPI_TX_16BIT_FIFO_SIZE(index) 8
#define PLIB_SPI_TX_16BIT_LW_MARK(index) 4
#define PLIB_SPI_TX_32BIT_FIFO_SIZE(index) 4
#define PLIB_SPI_TX_32BIT_LW_MARK(index) 2
struct DRV_SPI_OBJ;
/* SPI Job object. */
typedef struct _DRV_SPI_JOB_OBJECT
{
uint8_t *txBuffer;
uint8_t *rxBuffer;
size_t dataTxed;
size_t dataRxed;
size_t dataLeftToTx;
size_t dummyLeftToTx;
size_t dataLeftToRx;
size_t dummyLeftToRx;
DRV_SPI_BUFFER_EVENT status;
DRV_SPI_BUFFER_EVENT_HANDLER completeCB;
void * context;
}DRV_SPI_JOB_OBJECT;
// *****************************************************************************
/* SPI Static Driver Instance Object
Summary:
Object used to keep any data required for the static SPI driver.
Description:
This object is used to keep track of any data that must be maintained to
manage the SPI static driver.
Remarks:
None.
*/
typedef struct DRV_SPI_OBJ
{
uint8_t numTrfsSmPolled;
bool errEnabled;
DRV_SPI_BUFFER_EVENT_HANDLER operationStarting;
DRV_SPI_BUFFER_EVENT_HANDLER operationEnded;
DRV_SPI_SYS_QUEUE_HANDLE queue;
DRV_SPI_JOB_OBJECT * currentJob;
bool txEnabled;
bool rxEnabled;
uint8_t symbolsInProgress;
} DRV_SPI_OBJ;
// *****************************************************************************
// *****************************************************************************
// Section: Queue related Data Type Definitions
// *****************************************************************************
// *****************************************************************************
typedef struct _DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA
{
struct _DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pNext;
}DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA;
typedef struct _DRV_SPI_SYS_QUEUE_QUEUE_DATA
{
void * pQueueManager;
DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pHead;
DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pTail;
DRV_SPI_SYS_QUEUE_INTERUPT_CHANGE fptrIntChange;
size_t numReserved;
size_t maxElements;
size_t numAlloc;
struct _DRV_SPI_SYS_QUEUE_QUEUE_DATA * pNext;
size_t numEnqueued;
size_t numAllocOps;
size_t numFreeOps;
size_t numDequeueOps;
size_t numEnqueueOps;
size_t numReserveLW;
size_t numAllocHW;
size_t numEnqueuedHW;
size_t outOfMemoryErrors;
}DRV_SPI_SYS_QUEUE_QUEUE_DATA;
typedef struct _DRV_SPI_SYS_QUEUE_QUEUE_MANAGER_DATA
{
DRV_SPI_SYS_QUEUE_QUEUE_DATA * pQueueArea;
DRV_SPI_SYS_QUEUE_QUEUE_DATA * pFreeQueueHead;
DRV_SPI_SYS_QUEUE_QUEUE_DATA * pFreeQueueTail;
DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pElementArea;
DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pFreeElementHead;
DRV_SPI_SYS_QUEUE_FIFO_ELEMENT_DATA * pFreeElementTail;
size_t numReserveElements;
size_t numFreeElements;
size_t numAllocOps;
size_t numFreeOps;
size_t numQueueCreateOps;
size_t numQueueDestroyOps;
size_t freeElementsLW;
size_t reserveElementsLW;
size_t outOfMemoryErrors;
uint8_t numQueues;
uint8_t numQueuesHW;
}DRV_SPI_SYS_QUEUE_QUEUE_MANAGER_DATA;
// *****************************************************************************
// *****************************************************************************
// Section: Local functions.
// *****************************************************************************
// *****************************************************************************
int32_t DRV_SPI0_PolledMasterRM8BitTasks ( struct DRV_SPI_OBJ * dObj );
int32_t DRV_SPI0_PolledErrorTasks(struct DRV_SPI_OBJ * dObj);
int32_t DRV_SPI0_MasterRMSend8BitPolled( struct DRV_SPI_OBJ * dObj );
int32_t DRV_SPI0_MasterRMReceive8BitPolled( struct DRV_SPI_OBJ * dObj );
// DOM-IGNORE-BEGIN
#ifdef __cplusplus
}
#endif
// DOM-IGNORE-END
#endif //#ifndef _DRV_SPI_STATIC_LOCAL_H
/*******************************************************************************
End of File
*/
/* clang-format off */
/*******************************************************************************
SPI Driver Functions for Static Standard Buffer Driver Tasks Functions
Company:
Microchip Technology Inc.
File Name:
drv_spi_static_rm_tasks.c
Summary:
SPI driver tasks functions
Description:
The SPI device driver provides a simple interface to manage the SPI
modules on Microchip microcontrollers. This file contains implemenation
for the SPI driver.
Remarks:
This file is generated from framework/driver/spi/template/drv_spi_static_rm_tasks.c.ftl
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2015 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
//DOM-IGNORE-END
#include "system_config.h"
#include "system_definitions.h"
int32_t DRV_SPI0_MasterRMSend8BitPolled( struct DRV_SPI_OBJ * pDrvObj )
{
register DRV_SPI_JOB_OBJECT * currentJob = pDrvObj->currentJob;
/* Check to see if we have any more bytes to transmit */
if (currentJob->dataLeftToTx + currentJob->dummyLeftToTx == 0)
{
return 0;
}
/* Check to see if the transmit buffer is empty*/
if (!PLIB_SPI_TransmitBufferIsEmpty(SPI_ID_1))
{
return 0;
}
/* Make sure that we don't have something in progress and overrun the RX buffer */
if (pDrvObj->symbolsInProgress != 0)
{
return 0;
}
if (currentJob->dataLeftToTx != 0)
{
/* Transmit the data & update the counts */
PLIB_SPI_BufferWrite(SPI_ID_1, currentJob->txBuffer[currentJob->dataTxed]);
currentJob->dataTxed++;
currentJob->dataLeftToTx--;
}
else
{
/* Transmit the dummy data & update the counts */
PLIB_SPI_BufferWrite(SPI_ID_1, 0xff);
currentJob->dummyLeftToTx--;
}
/* We now have a symbol in progress*/
pDrvObj->symbolsInProgress = 1;
return 0;
}
int32_t DRV_SPI0_MasterRMReceive8BitPolled( struct DRV_SPI_OBJ * pDrvObj )
{
register DRV_SPI_JOB_OBJECT * currentJob = pDrvObj->currentJob;
if (currentJob == NULL)
{
return 0;
}
if (PLIB_SPI_ReceiverBufferIsFull(SPI_ID_1))
{
/* We have data waiting in the SPI buffer */
if (currentJob->dataLeftToRx != 0)
{
/* Receive the data and updates the count */
currentJob->rxBuffer[currentJob->dataRxed] = PLIB_SPI_BufferRead(SPI_ID_1);
currentJob->dataRxed++;
currentJob->dataLeftToRx --;
}
else
{
/* No Data but dummy data: Note: We cannot just clear the
buffer because we have to keep track of how many symbols/units we
have received, and the number may have increased since we checked
how full the buffer is.*/
PLIB_SPI_BufferRead(SPI_ID_1);
//SYS_CONSOLE_MESSAGE("Rd ");
currentJob->dummyLeftToRx--;
}
/* No longer have a symbol in progress */
pDrvObj->symbolsInProgress = 0;
}
return 0;
}
/* clang-format off */
/*******************************************************************************
SPI Driver Queue related local interfaces
Company:
Microchip Technology Inc.
File Name:
drv_spi_static_sys_queue.h
Summary:
Queue related local interface declarations
Description:
Queue related local interface declarations
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2015 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute Software
only when embedded on a Microchip microcontroller or digital signal controller
that is integrated into your product or third party product (pursuant to the
sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
//DOM-IGNORE-END
#ifndef _DRV_SPI_STATIC_SYS_QUEUE_H
#define _DRV_SPI_STATIC_SYS_QUEUE_H
// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
#include "system_config.h"
// DOM-IGNORE-BEGIN
#ifdef __cplusplus // Provide C++ Compatibility
extern "C" {
#endif
// DOM-IGNORE-END
#define _DRV_SPI_QM_SIZE 72
#define _DRV_SPI_Q_SIZE 80
#define _DRV_SPI_QE_SIZE 4
#define DRV_SPI_SYS_QUEUE_BUFFER_SIZE(queues, elementSize, desiredElements) \
( _DRV_SPI_QM_SIZE + \
(_DRV_SPI_Q_SIZE * queues) + \
((elementSize + _DRV_SPI_QE_SIZE) * \
desiredElements) )
// *****************************************************************************
/* SPI Driver Queue Manager Handle
Summary:
Handle identifying the queue manager
Description:
A queue manager handle value is returned by a call to the DRV_SPI_SYS_QUEUE_Initialize() function.
This handle is associated with the buffer passed into the function and it allows the
application to track the queue.
Remarks:
None
*/
typedef uintptr_t DRV_SPI_SYS_QUEUE_MANAGER_HANDLE;
// *****************************************************************************
/* SPI Driver Queue Handle
Summary:
Handle identifying the queue
Description:
A queue handle value is returned by a call to the DRV_SPI_SYS_QUEUE_CreateQueue () function.
This handle is associated with the buffer passed into the the DRV_SPI_SYS_QUEUE_Initialize() function.
Remarks:
None
*/
typedef uintptr_t DRV_SPI_SYS_QUEUE_HANDLE;
typedef enum {
DRV_SPI_SYS_QUEUE_SUCCESS = 0,
DRV_SPI_SYS_QUEUE_OUT_OF_MEMORY = -1,
DRV_SPI_SYS_QUEUE_OUT_OF_QUEUES = -2,
DRV_SPI_SYS_QUEUE_INVALID_PARAMETER = -3,
DRV_SPI_SYS_QUEUE_MAX_ERROR = DRV_SPI_SYS_QUEUE_INVALID_PARAMETER,
}DRV_SPI_SYS_QUEUE_RESULT;
typedef enum {
DRV_SPI_SYS_QUEUE_Unknown = 0,
DRV_SPI_SYS_QUEUE_Fifo = 1,
}DRV_SPI_SYS_QUEUE_Type;
typedef void ( *DRV_SPI_SYS_QUEUE_INTERUPT_CHANGE ) (DRV_SPI_SYS_QUEUE_HANDLE queue, bool mask);
typedef struct _DRV_SPI_SYS_QUEUE_MANAGER_SETUP
{
void * pBuffer;
size_t bufferLen;
uint8_t numQueues;
size_t elementSize;
DRV_SPI_SYS_QUEUE_Type type;
}DRV_SPI_SYS_QUEUE_MANAGER_SETUP;
typedef struct _DRV_SPI_SYS_QUEUE_SETUP
{
size_t reserveElements;
size_t maxElements;
DRV_SPI_SYS_QUEUE_INTERUPT_CHANGE fptrIntChange;
}DRV_SPI_SYS_QUEUE_SETUP;
typedef struct _DRV_SPI_SYS_QUEUE_MANAGER_STATUS
{
size_t numAllocOps;
size_t numFreeOps;
size_t numQueueCreateOps;
size_t numQueueDestroyOps;
size_t numReserveElements;
size_t numFreeElements;
size_t freeElementsLW;
size_t reserveElementsLW;
size_t outOfMemoryErrors;
uint8_t numQueues;
uint8_t numQueuesHW;
} DRV_SPI_SYS_QUEUE_MANAGER_STATUS;
typedef struct _DRV_SPI_SYS_QUEUE_STATUS
{
size_t numAllocOps;
size_t numFreeOps;
size_t numDequeueOps;
size_t numEnqueueOps;
size_t numReserved;
size_t numAlloc;
size_t numEnqueued;
size_t numReserveLW;
size_t numAllocHW;
size_t numEnqueuedHW;
}DRV_SPI_SYS_QUEUE_STATUS;
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_Initialize(DRV_SPI_SYS_QUEUE_MANAGER_SETUP * initParams, DRV_SPI_SYS_QUEUE_MANAGER_HANDLE * handle);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_Deinitialize(DRV_SPI_SYS_QUEUE_MANAGER_HANDLE queueManager);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_CreateQueue(DRV_SPI_SYS_QUEUE_MANAGER_HANDLE queueManager, DRV_SPI_SYS_QUEUE_SETUP * initParams, DRV_SPI_SYS_QUEUE_HANDLE * handle);
DRV_SPI_SYS_QUEUE_HANDLE DRV_SPI_SYS_QUEUE_CreateQueueLock(DRV_SPI_SYS_QUEUE_MANAGER_HANDLE queueManager, DRV_SPI_SYS_QUEUE_SETUP * initParams, DRV_SPI_SYS_QUEUE_HANDLE * queue);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_DestroyQueue(DRV_SPI_SYS_QUEUE_HANDLE queue);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_DestroyQueueLock(DRV_SPI_SYS_QUEUE_HANDLE queue);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_Lock(DRV_SPI_SYS_QUEUE_HANDLE queue);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_Unlock(DRV_SPI_SYS_QUEUE_HANDLE queue);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_AllocElement(DRV_SPI_SYS_QUEUE_HANDLE queue, void ** element);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_AllocElementLock(DRV_SPI_SYS_QUEUE_HANDLE queue, void ** element);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_FreeElement(DRV_SPI_SYS_QUEUE_HANDLE queue, void * element);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_FreeElementLock(DRV_SPI_SYS_QUEUE_HANDLE queue, void * element);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_Enqueue(DRV_SPI_SYS_QUEUE_HANDLE queue, void * element);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_EnqueueLock(DRV_SPI_SYS_QUEUE_HANDLE queue, void * element);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_Dequeue(DRV_SPI_SYS_QUEUE_HANDLE queue, void ** element);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_DequeueLock(DRV_SPI_SYS_QUEUE_HANDLE queue, void ** element);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_Peek(DRV_SPI_SYS_QUEUE_HANDLE queue, void ** element);
bool DRV_SPI_SYS_QUEUE_IsEmpty(DRV_SPI_SYS_QUEUE_HANDLE queue);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_QueueManagerStatus(DRV_SPI_SYS_QUEUE_MANAGER_HANDLE queueManager, DRV_SPI_SYS_QUEUE_MANAGER_STATUS * status);
DRV_SPI_SYS_QUEUE_RESULT DRV_SPI_SYS_QUEUE_QueueStatus(DRV_SPI_SYS_QUEUE_HANDLE queue, DRV_SPI_SYS_QUEUE_STATUS * status);
// DOM-IGNORE-BEGIN
#ifdef __cplusplus
}
#endif
// DOM-IGNORE-END
#endif //_DRV_SPI_STATIC_SYS_QUEUE_H_
/* clang-format off */
/*******************************************************************************
SPI Driver Functions for Static Driver Tasks Functions
Company:
Microchip Technology Inc.
File Name:
drv_spi_static_tasks.c
Summary:
SPI driver tasks functions
Description:
The SPI device driver provides a simple interface to manage the SPI
modules on Microchip microcontrollers. This file contains implemenation
for the SPI driver.
Remarks:
This file is generated from framework/driver/spi/template/drv_spi_static_tasks.c.ftl
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2015 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
//DOM-IGNORE-END
#include "system_config.h"
#include "system_definitions.h"
int32_t DRV_SPI0_PolledMasterRM8BitTasks ( struct DRV_SPI_OBJ * dObj )
{
volatile bool continueLoop;
uint8_t counter = 0;
uint8_t numPolled = dObj->numTrfsSmPolled;
uint8_t result = 0;
do {
DRV_SPI_JOB_OBJECT * currentJob = dObj->currentJob;
/* Check for a new task */
if (dObj->currentJob == NULL)
{
if (DRV_SPI_SYS_QUEUE_DequeueLock(dObj->queue, (void *)&(dObj->currentJob)) != DRV_SPI_SYS_QUEUE_SUCCESS)
{
SYS_ASSERT(false, "\r\nSPI Driver: Error in dequeing.");
return 0;
}
if (dObj->currentJob == NULL)
{
return 0;
}
currentJob = dObj->currentJob;
dObj->symbolsInProgress = 0;
/* Call the operation starting function pointer. This can be used to modify the slave select lines */
if (dObj->operationStarting != NULL)
{
(*dObj->operationStarting)(DRV_SPI_BUFFER_EVENT_PROCESSING, (DRV_SPI_BUFFER_HANDLE)currentJob, currentJob->context);
}
/* List the new job as processing*/
currentJob->status = DRV_SPI_BUFFER_EVENT_PROCESSING;
/* Flush out the Receive buffer */
PLIB_SPI_BufferClear(SPI_ID_1);
}
continueLoop = false;
/* Execute the sub tasks */
if
(currentJob->dataLeftToTx +currentJob->dummyLeftToTx != 0)
{
DRV_SPI0_MasterRMSend8BitPolled(dObj);
}
DRV_SPI0_PolledErrorTasks(dObj);
/* Figure out how many bytes are left to be received */
volatile size_t bytesLeft = currentJob->dataLeftToRx + currentJob->dummyLeftToRx;
// Check to see if we have any data left to receive and update the bytes left.
if (bytesLeft != 0)
{
DRV_SPI0_MasterRMReceive8BitPolled(dObj);
bytesLeft = currentJob->dataLeftToRx + currentJob->dummyLeftToRx;
}
if (bytesLeft == 0)
{
/* Job is complete*/
currentJob->status = DRV_SPI_BUFFER_EVENT_COMPLETE;
/* Call the job complete call back*/
if (currentJob->completeCB != NULL)
{
(*currentJob->completeCB)(DRV_SPI_BUFFER_EVENT_COMPLETE, (DRV_SPI_BUFFER_HANDLE)currentJob, currentJob->context);
}
/* Call the operation complete call back. This is different than the
job complete callback. This can be used to modify the Slave Select line.*/
if (dObj->operationEnded != NULL)
{
(*dObj->operationEnded)(DRV_SPI_BUFFER_EVENT_COMPLETE, (DRV_SPI_BUFFER_HANDLE)currentJob, currentJob->context);
}
/* Return the job back to the free queue*/
if (DRV_SPI_SYS_QUEUE_FreeElementLock(dObj->queue, currentJob) != DRV_SPI_SYS_QUEUE_SUCCESS)
{
SYS_ASSERT(false, "\r\nSPI Driver: Queue free element error.");
return 0;
}
/* Clean up */
dObj->currentJob = NULL;
}
counter ++;
if ((counter < numPolled) && (result != 0))
{
continueLoop = true;
}
} while(continueLoop);
return 0;
}
/* clang-format off */
/*******************************************************************************
USART Driver Interface Declarations for Static Single Instance Driver
Company:
Microchip Technology Inc.
File Name:
drv_usart_static.h
Summary:
USART driver interface declarations for the static single instance driver.
Description:
The USART device driver provides a simple interface to manage the USART
modules on Microchip microcontrollers. This file defines the interface
Declarations for the USART static driver.
Remarks:
Static interfaces incorporate the driver instance number within the names
of the routines, eliminating the need for an object ID or object handle.
Static single-open interfaces also eliminate the need for the open handle.
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2015 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
//DOM-IGNORE-END
#ifndef _DRV_USART_STATIC_H
#define _DRV_USART_STATIC_H
// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
#include "driver/usart/src/drv_usart_static_local.h"
// DOM-IGNORE-BEGIN
#ifdef __cplusplus // Provide C++ Compatibility
extern "C" {
#endif
// DOM-IGNORE-END
// *********************************************************************************************
// *********************************************************************************************
// Section: System Interface Headers for the Instance 0 of USART static driver
// *********************************************************************************************
// *********************************************************************************************
SYS_MODULE_OBJ DRV_USART0_Initialize(void);
void DRV_USART0_Deinitialize(void);
SYS_STATUS DRV_USART0_Status(void);
void DRV_USART0_TasksTransmit(void);
void DRV_USART0_TasksReceive(void);
void DRV_USART0_TasksError(void);
// *********************************************************************************************
// *********************************************************************************************
// Section: General Client Interface Headers for the Instance 0 of USART static driver
// *********************************************************************************************
// *********************************************************************************************
DRV_HANDLE DRV_USART0_Open(const SYS_MODULE_INDEX index, const DRV_IO_INTENT ioIntent);
void DRV_USART0_Close(void);
DRV_USART_CLIENT_STATUS DRV_USART0_ClientStatus(void);
DRV_USART_TRANSFER_STATUS DRV_USART0_TransferStatus(void);
// *********************************************************************************************
// *********************************************************************************************
// Section: Byte Model Client Interface Headers for the Instance 0 of USART static driver
// *********************************************************************************************
// *********************************************************************************************
uint8_t DRV_USART0_ReadByte( void);
void DRV_USART0_WriteByte( const uint8_t byte);
unsigned int DRV_USART0_ReceiverBufferSizeGet(void);
unsigned int DRV_USART0_TransmitBufferSizeGet(void);
bool DRV_USART0_ReceiverBufferIsEmpty( void );
bool DRV_USART0_TransmitBufferIsFull(void);
// *********************************************************************************************
// *********************************************************************************************
// Section: Set up Client Interface Headers for the Instance 0 of USART static driver
// *********************************************************************************************
// *********************************************************************************************
DRV_USART_BAUD_SET_RESULT DRV_USART0_BaudSet(uint32_t baud);
DRV_USART_LINE_CONTROL_SET_RESULT DRV_USART0_LineControlSet(DRV_USART_LINE_CONTROL lineControlMode);
// DOM-IGNORE-BEGIN
#ifdef __cplusplus
}
#endif
// DOM-IGNORE-END
#endif // #ifndef _DRV_USART_STATIC_H
/*******************************************************************************
End of File
*/
/* clang-format off */
/*******************************************************************************
USART driver static implementation of Byte model.
Company:
Microchip Technology Inc.
File Name:
drv_usart_static_byte_model.c
Summary:
Source code for the USART driver static implementation of Byte model.
Description:
This file contains the source code for the static implementation of the
USART driver Byte model.
Remarks:
Static interfaces incorporate the driver instance number within the names
of the routines, eliminating the need for an object ID or object handle.
Static single-open interfaces also eliminate the need for the open handle.
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2015 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
//DOM-IGNORE-END
// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
#include "system_config.h"
#include "system_definitions.h"
// *****************************************************************************
// *****************************************************************************
// Section: Global Data
// *****************************************************************************
// *****************************************************************************
extern DRV_USART_OBJ gDrvUSART0Obj ;
// *****************************************************************************
// *****************************************************************************
// Section: Instance 0 static driver functions
// *****************************************************************************
// *****************************************************************************
uint8_t DRV_USART0_ReadByte(void)
{
uint8_t readValue;
/* Receive one byte */
readValue = PLIB_USART_ReceiverByteReceive(USART_ID_2);
return readValue;
}
void DRV_USART0_WriteByte(const uint8_t byte)
{
/* Wait till TX buffer is available as blocking operation is selected */
while(PLIB_USART_TransmitterBufferIsFull(USART_ID_2));
/* Send one byte */
PLIB_USART_TransmitterByteSend(USART_ID_2, byte);
SYS_INT_SourceEnable(INT_SOURCE_USART_2_TRANSMIT);
}
unsigned int DRV_USART0_ReceiverBufferSizeGet(void)
{
return 8;
}
unsigned int DRV_USART0_TransmitBufferSizeGet(void)
{
return 8;
}
bool DRV_USART0_ReceiverBufferIsEmpty( void )
{
/* Check the status of receiver buffer */
return(!PLIB_USART_ReceiverDataIsAvailable(USART_ID_2));
}
bool DRV_USART0_TransmitBufferIsFull(void)
{
/* Check the status of transmitter buffer */
return(PLIB_USART_TransmitterBufferIsFull(USART_ID_2));
}
/*******************************************************************************
End of File
*/
This diff is collapsed.
/*
* Copyright (c) 2016 Cesanta Software Limited
* All rights reserved
*/
#ifndef _USER_PARAMS_H
#define _USER_PARAMS_H
#define NET_SSID "my_network"
#define NET_PWD "my_password"
#define NET_SECURITY SL_SEC_TYPE_WPA_WPA2
#define MQTT_BROKER_ADDRESS "192.168.1.108:1883"
#define MQTT_USER_NAME NULL
#define MQTT_USER_PWD NULL
#define CS_PORT PORT_CHANNEL_D
#define CS_PIN PORTS_BIT_POS_14
#define HIB_PORT PORT_CHANNEL_D
#define HIB_PIN PORTS_BIT_POS_4
#endif /* _USER_PARAMS_H */
......@@ -468,7 +468,6 @@ unsigned long os_random(void);
#include <simplelink.h>
#include <netapp.h>
#undef timeval
typedef int sock_t;
#define INVALID_SOCKET (-1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment