Skip to content

Commit

Permalink
Add test case for PinProbe and launchpad probe watchdog.
Browse files Browse the repository at this point in the history
- resolves #13
- resolves #14

Contains hard-coded properties because #6, #7, #21 are still missing.
  • Loading branch information
rweickelt committed Mar 2, 2018
1 parent 4cc0fd9 commit 402f572
Show file tree
Hide file tree
Showing 24 changed files with 433 additions and 76 deletions.
5 changes: 3 additions & 2 deletions qbs/modules/simplelink/board/board.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SimpleLinkModule {
name : "board"
property string type
property string installPath : product.simplelink.core.installPath + "/source/ti/boards"
property bool useDefaultConfig: true

Depends { name : "cpp" }
Depends { name : "simplelink.core" }
Expand All @@ -15,12 +16,12 @@ SimpleLinkModule {
]

Group {
name : "board"
name : "board-config"
condition: simplelink.board.useDefaultConfig === true
prefix: product.simplelink.board.installPath + "/" + product.simplelink.board.type + "/"
files : [
"*.h",
product.simplelink.board.type + ".c",
// do not include ccfg.c file
]
}

Expand Down
3 changes: 2 additions & 1 deletion qbs/modules/simplelink/core/core.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Module {
property string installPath
property string deviceFamily : Device.deviceFamilyDir(product.simplelink.core.device)
property string device
property bool useDefaultCcfg: true


Depends { name : "cpp" }
Expand Down Expand Up @@ -57,7 +58,7 @@ Module {
Group {
name : "startup-files"
prefix: simplelink.core.installPath + "/source/ti/devices/" + Device.deviceFamilyDir(simplelink.core.deviceFamily) + "/startup_files/"

condition: simplelink.core.useDefaultCcfg === true
files : [
"ccfg.c"
]
Expand Down
4 changes: 2 additions & 2 deletions share/qst/imports/qst/AbstractConstraint.qml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import QtQuick 2.0
import qst 1.0

/*
Base class for all constraints.
*/
QtObject {
Component {

// Treshold value for validCount before valid is set true
property int maxValidCount : 0
Expand Down
36 changes: 36 additions & 0 deletions share/qst/imports/qst/CounterConstraint.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import qst 1.0
import QtQml 2.0

AbstractConstraint {
property var signal
property int count: 0
property int maxCount: 0

function clear() {
count = 0
}

id: root

// Private implementation
QtObject {
id: implementation
function evaluate() {
if (!enabled) {
return
}

count++
Qst.verify(count <= maxCount, "Property 'count' in CounterConstraint '"
+ name + "' exceeded maxCount (" + maxCount + ")")
}
}

Testcase.onCreated: {
Qst.verify(typeof(signal) !== "undefined", "Property 'signal' in CounterConstraint '"
+ name + "' is undefined.")
Qst.verify(typeof(signal.connect) === "function", "Property 'signal' in CounterConstraint '"
+ name + "' is not a signal.")
signal.connect(implementation.evaluate)
}
}
1 change: 1 addition & 0 deletions share/qst/imports/qst/qmldir
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module qst

AbstractConstraint 1.0 AbstractConstraint.qml
CounterConstraint 1.0 CounterConstraint.qml
DurationConstraint 1.0 DurationConstraint.qml
SignalProbe 1.0 SignalProbe.qml
PropertyValueSequence 1.0 PropertyValueSequence.qml
Expand Down
1 change: 1 addition & 0 deletions share/share.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Product {

files : [
"AbstractConstraint.qml",
"CounterConstraint.qml",
"DurationConstraint.qml",
"PropertyValueSequence.qml",
"Qst.qml",
Expand Down
128 changes: 128 additions & 0 deletions src/launchpad-probe/cc13xx-cc26xx-driver-config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qst project.
**
** Contact: https://github.com/rweickelt/qst
**
** $BEGIN_LICENSE$
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**
** $END_LICENSE$
****************************************************************************/


#include <Board.h>

/*
* =============================== PIN ===============================
*/
#include <ti/drivers/PIN.h>
#include <ti/drivers/pin/PINCC26XX.h>

const PIN_Config BoardGpioInitTable[] = {

CC1310_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
CC1310_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
CC1310_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
CC1310_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
// CC1310_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */
CC1310_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */
CC1310_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */
// CC1310_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
// CC1310_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
// CC1310_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */
PIN_TERMINATE
};

const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
.intPriority = INT_PRI_LEVEL5,
.swiPriority = 1
};

/*
* =============================== Power ===============================
*/
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>

const PowerCC26XX_Config PowerCC26XX_config = {
.policyInitFxn = NULL,
.policyFxn = &PowerCC26XX_standbyPolicy,
.calibrateFxn = &PowerCC26XX_calibrate,
.enablePolicy = true,
.calibrateRCOSC_LF = true,
.calibrateRCOSC_HF = true,
};

/*
* =============================== UART ===============================
*/
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>

UARTCC26XX_Object uartCC26XXObjects[CC1310_LAUNCHXL_UARTCOUNT];

uint8_t uartCC26XXRingBuffer[CC1310_LAUNCHXL_UARTCOUNT][32];

const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1310_LAUNCHXL_UARTCOUNT] = {
{
.baseAddr = UART0_BASE,
.powerMngrId = PowerCC26XX_PERIPH_UART0,
.intNum = INT_UART0_COMB,
.intPriority = ~0,
.swiPriority = 0,
.txPin = CC1310_LAUNCHXL_UART_TX,
.rxPin = CC1310_LAUNCHXL_UART_RX,
.ctsPin = PIN_UNASSIGNED,
.rtsPin = PIN_UNASSIGNED,
.ringBufPtr = uartCC26XXRingBuffer[CC1310_LAUNCHXL_UART0],
.ringBufSize = sizeof(uartCC26XXRingBuffer[CC1310_LAUNCHXL_UART0])
}
};

const UART_Config UART_config[CC1310_LAUNCHXL_UARTCOUNT] = {
{
.fxnTablePtr = &UARTCC26XX_fxnTable,
.object = &uartCC26XXObjects[CC1310_LAUNCHXL_UART0],
.hwAttrs = &uartCC26XXHWAttrs[CC1310_LAUNCHXL_UART0]
},
};

const uint_least8_t UART_count = CC1310_LAUNCHXL_UARTCOUNT;

/*
* =============================== Watchdog ===============================
*/
#include <ti/drivers/Watchdog.h>
#include <ti/drivers/watchdog/WatchdogCC26XX.h>

WatchdogCC26XX_Object watchdogCC26XXObjects[CC1310_LAUNCHXL_WATCHDOGCOUNT];

const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[CC1310_LAUNCHXL_WATCHDOGCOUNT] = {
{
.baseAddr = WDT_BASE,
.reloadValue = 1000 /* Reload value in milliseconds */
},
};

const Watchdog_Config Watchdog_config[CC1310_LAUNCHXL_WATCHDOGCOUNT] = {
{
.fxnTablePtr = &WatchdogCC26XX_fxnTable,
.object = &watchdogCC26XXObjects[CC1310_LAUNCHXL_WATCHDOG0],
.hwAttrs = &watchdogCC26XXHWAttrs[CC1310_LAUNCHXL_WATCHDOG0]
},
};

const uint_least8_t Watchdog_count = CC1310_LAUNCHXL_WATCHDOGCOUNT;
2 changes: 2 additions & 0 deletions src/launchpad-probe/launchpad-probe.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ Project {

simplelink.core.device: "cc1310f128"
simplelink.board.type: "CC1310_LAUNCHXL"
simplelink.board.useDefaultConfig: false

cpp.cxxLanguageVersion: "c++14"

qbs.optimization: "none"

files: [
"arraylist.h",
"cc13xx-cc26xx-driver-config.c",
"interruptlock.h",
"mailbox.h",
"main.cpp",
Expand Down
6 changes: 3 additions & 3 deletions src/launchpad-probe/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum ApplicationEvent {
};

enum {
WatchdogTimeoutMs = 1039 // Reset happens after 2*value. Value has to be a little bit
WatchdogTimeoutMs = 527 // Reset happens after 2*value. Value has to be a little bit
// larger than the kick period to avoid false triggers.
};

Expand Down Expand Up @@ -125,15 +125,15 @@ extern "C" void mainTaskFunction()
else if (events & KickWatchdog)
{
Watchdog_clear(watchdog);
RocTargetController::checkForConnectionTimeout();
}
}
}

int main(void)
{
/* Call driver init functions. */
Board_initGeneral();
Power_init();
PIN_init(BoardGpioInitTable);
Watchdog_init();

BIOS_start();
Expand Down
7 changes: 6 additions & 1 deletion src/launchpad-probe/project.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,10 @@ Program.global.rxMailbox = Mailbox.create(4, 4, mailbox0Params);
var clock0Params = new Clock.Params();
clock0Params.instance.name = "watchdogClock";
clock0Params.period = 517000 / Clock.tickPeriod;
Program.global.watchdogClock = Clock.create("&watchdogClockCallback", 0, clock0Params);
Program.global.watchdogClock = Clock.create("&watchdogClockCallback", 517000 / Clock.tickPeriod, clock0Params);
var clock1Params = new Clock.Params();
clock1Params.instance.name = "watchdogClock";
clock1Params.startFlag = false;
Program.global.checkConnectionClock = Clock.create("&checkConnectionCallback", 600000 / Clock.tickPeriod, clock1Params);
34 changes: 13 additions & 21 deletions src/launchpad-probe/roctargetcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,30 @@
#include <Board.h>
#include <ti/devices/cc13x0/driverlib/sys_ctrl.h>
#include <ti/drivers/PIN.h>
#include <ti/sysbios/knl/Clock.h>

extern PIN_Handle pins;

enum {
WatchdogReloadValue = 2
};
extern const Clock_Handle checkConnectionClock;

namespace {
ArrayList<RocTargetObject*, 32> probes;
uint32_t probeCount = 0;
int watchdogCounter = WatchdogReloadValue;
bool connected = false;
}

void RocTargetController::init()
extern "C" void checkConnectionCallback(UArg arg)
{
}

void RocTargetController::checkForConnectionTimeout()
{
if (!connected)
{
return;
}
if (watchdogCounter > 0)
{
watchdogCounter--;
}
else
(void)arg;
if (connected)
{
SysCtrlSystemReset();
}
}

void RocTargetController::init()
{
}

void RocTargetController::processMessage(const SharedPointer<MessageBuffer>& message)
{
roc::MessageHeader rxRocHeader = message->takeAtFront<roc::MessageHeader>();
Expand All @@ -91,9 +81,10 @@ void RocTargetController::processMessage(const SharedPointer<MessageBuffer>& mes
probes.clear();
probeCount = 0;
sendToHost(roc::StatusOk, roc::Blocking);
watchdogCounter = WatchdogReloadValue;
connected = true;
Clock_start(checkConnectionClock);
PIN_setOutputValue(pins, Board_PIN_GLED, 1);

break;
case roc::Construct:
constructObject(static_cast<roc::ClassId>(rxRocHeader.objectId));
Expand All @@ -117,7 +108,8 @@ void RocTargetController::processMessage(const SharedPointer<MessageBuffer>& mes
sendToHost(roc::StatusOk, roc::Blocking);
break;
case roc::Ping:
watchdogCounter = WatchdogReloadValue;
Clock_stop(checkConnectionClock);
Clock_start(checkConnectionClock);
sendToHost(roc::Pong, roc::NonBlocking);
break;
default:
Expand Down
1 change: 0 additions & 1 deletion src/launchpad-probe/roctargetcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class RocTargetController
{
public:
static void init();
static void checkForConnectionTimeout();
static void processMessage(const SharedPointer<MessageBuffer>& message);
static void sendToHost(uint8_t messageId, roc::BlockingMode blockingMode, uint32_t objectId = 0, const void* data = nullptr,
uint32_t length = 0);
Expand Down
7 changes: 5 additions & 2 deletions src/qst/rochostcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "rochostcontroller.h"
#include "qst.h"

#include <unistd.h>

namespace {
QMap<QString, QPointer<RocHostController> > controllers;
}
Expand Down Expand Up @@ -91,7 +93,7 @@ quint32 RocHostController::registerObject(RocHostObject* object)
if (success)
{
m_state = Connected;
m_pingTimer.start(517);
m_pingTimer.start(ConnectionTimeoutIntervalMs);
}
}
if (m_state != Connected)
Expand Down Expand Up @@ -127,7 +129,8 @@ void RocHostController::unregisterObject(const RocHostObject* object)
if (m_objects.size() == 0)
{
m_pingTimer.stop();
m_state = Standby;
m_socket.disconnectFromTarget();
m_state = Disconnected;
}
}

Expand Down
Loading

0 comments on commit 402f572

Please sign in to comment.