Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1350
Tool/software: Code Composer Studio
Hello guys,
I am struggling to make some changes to the TI 15.4 Stack Sensor (&collector) example code. I am trying to get the TIDA 00489 code to work in framework of this example, because in the end the code has to run on the TIDA Board!. Therefor I try to make as few changes as possible to get it work and afterwards I wanna "clean up" the code. Hence I only had to change the sensor.c file to get all the functionality. Here is what I changed. Note, that I deleted most of the original code in this code snipped for better comprehensibility, this is indicated by "...deleted".
/******************************************************************************
Includes
*****************************************************************************/
//_______________MY CHANGE START__________________
#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h>
#include <ti/drivers/I2C.h>
#include <ti/drivers/PIN.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include <driverlib/sys_ctrl.h>
#include <TIDA-00489_Board.h> <--- not sure if I better copy the relevant stuff into the provided board_gpio.c file (same for the TIDA-00489_Board.c).
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
//_______________MY CHANGE END__________________
#include <string.h>
#include <stdint.h>
#include "util.h"
#include "api_mac.h"
#include "jdllc.h"
#include "ssf.h"
#include "smsgs.h"
#include "sensor.h"
#include "config.h"
#include "board_led.h"
#include "icall.h"
#ifdef FEATURE_NATIVE_OAD
#include "oad_client.h"
#ifdef DeviceFamily_CC13X2
#include <common/cc26xx/flash_interface/flash_interface.h>
#endif /* DeviceFamily_CC13X2 */
#endif /* FEATURE_NATIVE_OAD */
#ifdef MBEDTLS_CLIENT_NODE
#include "keymsg.h"
#include "tls_event.h"
#endif
/******************************************************************************
Constants and definitions
*****************************************************************************/
//_______________MY CHANGE START__________________
#define PIR_SETTLE_TIME 5000 // 5 seconds
//_______________MY CHANGE END__________________
...deleted
/******************************************************************************
Global variables
*****************************************************************************/
//_______________MY CHANGE START__________________
/* move counter */
extern uint8_t move;
//_______________MY CHANGE END__________________
/* Task pending events */
uint16_t Sensor_events = 0;
/*! Sensor statistics */
Smsgs_msgStatsField_t Sensor_msgStats =
{ 0 };
extern bool initBroadcastMsg;
extern bool parentFound;
#ifdef POWER_MEAS
/*! Power Meas Stats fields */
Smsgs_powerMeastatsField_t Sensor_pwrMeasStats =
{ 0 };
#endif
/******************************************************************************
Local variables
*****************************************************************************/
//_______________MY CHANGE START__________________
static Semaphore_Struct radioSyncTxSem;
static Semaphore_Handle radioSyncTxSemHandle;
static Clock_Struct radioSyncTxClock;
static Clock_Handle radioSyncTxClockHandle;
/* Wake-up pin table (NOT IN USE, because no deep_sleep)
PIN_Config PinTableWakeUp[] = {
Board_PIR_Out_Lo | PIN_INPUT_EN | PIN_PULLDOWN | PINCC26XX_WAKEUP_POSEDGE,
Board_PIR_Out_Hi | PIN_INPUT_EN | PIN_PULLDOWN | PINCC26XX_WAKEUP_POSEDGE,
PIN_TERMINATE // Terminate list
}; */
/* Pin interrupt */ // Die genannten Pins werden Input enabled, kein Pull Up oder Down, und aufwachen bei positiver Flanke
PIN_Config intrPinTable[] = {
Board_PIR_Out_Lo | PIN_INPUT_EN | PIN_NOPULL | PIN_HYSTERESIS,
Board_PIR_Out_Hi | PIN_INPUT_EN | PIN_NOPULL | PIN_HYSTERESIS,
PIN_TERMINATE
};
PIN_Handle intr_handle; // Pin_State benötigt ein "Handle" und dieses wird hier definiert
PIN_State intr_state;
//_______________MY CHANGE END__________________
...deleted
/******************************************************************************
Local function prototypes
*****************************************************************************/
//_______________MY CHANGE START__________________
/* Static TIDA Functions */
static void initializeTIDATask(void)
static void radioSyncTxClockCallback(UArg a0)
void intr_HwiFxn(PIN_Handle hPin, PIN_Id pinId)
//_______________MY CHANGE END__________________
static void initializeClocks(void);
static void dataCnfCB(ApiMac_mcpsDataCnf_t *pDataCnf);
static void dataIndCB(ApiMac_mcpsDataInd_t *pDataInd);
static uint8_t getMsduHandle(Smsgs_cmdIds_t msgType);
static void processSensorMsgEvt(void);
#if SENSOR_TEST_RAMP_DATA_SIZE
static void processSensorRampMsgEvt(void);
#endif
static bool sendSensorMessage(ApiMac_sAddr_t *pDstAddr,
Smsgs_sensorMsg_t *pMsg);
static void processConfigRequest(ApiMac_mcpsDataInd_t *pDataInd);
static void processBroadcastCtrlMsg(ApiMac_mcpsDataInd_t *pDataInd);
static bool sendConfigRsp(ApiMac_sAddr_t *pDstAddr, Smsgs_configRspMsg_t *pMsg);
static uint16_t validateFrameControl(uint16_t frameControl);
static void jdllcJoinedCb(ApiMac_deviceDescriptor_t *pDevInfo,
Llc_netInfo_t *pStartedInfo);
static void jdllcDisassocIndCb(ApiMac_sAddrExt_t *extAddress,
ApiMac_disassocateReason_t reason);
static void jdllcDisassocCnfCb(ApiMac_sAddrExt_t *extAddress,
ApiMac_status_t status);
static void jdllcStateChangeCb(Jdllc_states_t state);
static void readSensors(void);
/******************************************************************************
Callback tables
*****************************************************************************/
...deleted
/******************************************************************************
Public Functions
*****************************************************************************/
//_______________MY CHANGE START__________________
static void initializeTIDATask(void) // sollte man so lassen können
{
/* Setup clock used for TIDA */
Clock_Params radioSyncTxClockParams;
Clock_Params_init(&radioSyncTxClockParams);
radioSyncTxClockParams.startFlag = 0;
radioSyncTxClockParams.period = 0; /* One-off clock */
Clock_construct(&radioSyncTxClock, radioSyncTxClockCallback, 0, &radioSyncTxClockParams);
radioSyncTxClockHandle = Clock_handle(&radioSyncTxClock);
/* Create semaphore for TIDA */ //
Semaphore_Params radioSyncTxParams;
Semaphore_Params_init(&radioSyncTxParams);
Semaphore_construct(&radioSyncTxSem, 0, &radioSyncTxParams);
radioSyncTxSemHandle = Semaphore_handle(&radioSyncTxSem);
}
/* Callback Function of the clock, continuing the pended task */
static void radioSyncTxClockCallback(UArg a0)
{
Semaphore_post(radioSyncTxSemHandle);
}
/* Interrupt Function!!! */
void intr_HwiFxn(PIN_Handle hPin, PIN_Id pinId)
{
if(pinId == Board_PIR_Out_Lo || pinId == Board_PIR_Out_Hi)
{
move = move + 1; //Instead of resetting the clock, add to the move variable
}
}
//_______________MY CHANGE END__________________
/*!
Initialize this application.
Public function defined in sensor.h
*/
void Sensor_init(void)
{
//_______________MY CHANGE START__________________
/* TIDA specific Sempahore and Clock initialize */
initializeTIDATask();
/* Backdoor access */
uint8_t modeValue = PIN_getInputValue(Board_Mode); // Der Wert am Pin wird eingelesen, ist er 1 = high, so wird das Modul in den Shutdown Modus gefahren
if(modeValue == 1)
{
Power_shutdown(NULL);
//Trap code here
while(1);
}
while(1)
{
//Wait for sensor to start up and settle
Clock_setTimeout(radioSyncTxClockHandle, PIR_SETTLE_TIME);
Clock_start(radioSyncTxClockHandle);
Semaphore_pend(radioSyncTxSemHandle, BIOS_WAIT_FOREVER);
//Check value of comparators. If not low, wait for more time
uint8_t pirLowValue = PIN_getInputValue(Board_PIR_Out_Lo);
uint8_t pirHighValue = PIN_getInputValue(Board_PIR_Out_Hi);
if(pirLowValue == 0 && pirHighValue == 0) // Wenn beide low sind, sende das "Testpacket"
{
break;
}
}
/*** Pin interrupt ***/
// Configure GPIO interrupt
intr_handle = PIN_open(&intr_state, intrPinTable);
PIN_registerIntCb(intr_handle, &intr_HwiFxn);
PIN_setConfig(intr_handle, PIN_BM_IRQ, Board_PIR_Out_Lo | PIN_IRQ_POSEDGE); // IRQ bei positiver Flanke ausgelöst
PIN_setConfig(intr_handle, PIN_BM_IRQ, Board_PIR_Out_Hi | PIN_IRQ_POSEDGE); // IRQ bei positiver Flanke ausgelöst
//_______________MY CHANGE END__________________
/********** Original Function of Sensor Example from now on********/
uint32_t frameCounter = 0;
/* Initialize the sensor's structures */
memset(&configSettings, 0, sizeof(Smsgs_configReqMsg_t));
#if defined(TEMP_SENSOR)
configSettings.frameControl |= Smsgs_dataFields_tempSensor;
#endif
...deleted
/*!
* @brief Manually read the sensors
*/
static void readSensors(void)
{
//_______________MY CHANGE START__________________
/* #if defined(TEMP_SENSOR)
// Read the temp sensor values
tempSensor.ambienceTemp = Ssf_readTempSensor();
tempSensor.objectTemp = tempSensor.ambienceTemp;
#endif */
tempSensor.objectTemp = move;
/* Reset move counter */
move = 0;
}
//_______________MY CHANGE END_________________
I now wanna know, if
- How and whereshould I adapt the GPIO settings from the TIDA-Board.c looking like
- Board_PIR_Out_Lo IOID_16
- Board_PIR_Out_Hi IOID_17
- Board_Mode IOID_3 into the correct syntax?
- -> In the Sensor example it is #include "boards/CC13X0_LAUNCHXL/Board.h" used, e.g. #define Board_DIO16_TDO CC1350_LAUNCHXL_DIO16_TDO
In the Main.c file there is a line: PIN_init(BoardGpioInitTable); I defined a global function in board_gpio.h: extern PIN_Config BoardGpioInitTable[]; and the table itsself is defined in board_gpio.c
//______________MY CODE START______________
PIN_Config BoardGpioInitTable[] =
{
Board_PIR_Out_Lo | PIN_INPUT_EN | PIN_NOPULL | PIN_HYSTERESIS, /* PIR low */
Board_PIR_Out_Hi | PIN_INPUT_EN | PIN_NOPULL | PIN_HYSTERESIS, /* PIR high */
Board_Mode | PIN_INPUT_EN | PIN_NOPULL | PIN_HYSTERESIS, /* Backdoor to prevent shutdown */
//Board_TEST26 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* Testpoint, DIO_26 */
//Board_TEST27 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* Testpoint, DIO_27 */
//Board_TEST28 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* Testpoint, DIO_28 */
//Board_TEST29 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* Testpoint, DIO_29 */
PIN_TERMINATE /* Terminate list */
};
//______________MY CODE END______________
3. What else do I have to do, to assign and define the PINs correctly?!
4. Is the timer and the semaphore transferred correctly?
5. Is the HWi set and configured correctly? In the callback function I only want to count up the "move" variable, which will later be substituting the "temperature" value.
I hope you guys can help me out once again. Thank you for the support!
Kind regards
Stefan