Other Parts Discussed in Thread: CC2650
Hello TI community,
In order to monitor the output of my solar panel, I'm using Sensor Controler Studio with the Analog Light Sensor project.
I've modified the project to fit my board (a 4x4 CC2650), and it works well we I test the task in scs.
No the problems came when I want to integrate the tasks in CCS. I generate the files:
scif.c
scif.h
scif_framework.c
scif_framework.h
scif_osal_tirtos.c
scif_osal_tirtos.h
I put them in my project, and I use the main_tirtos of the example, that looks like this :
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Semaphore.h>
//#include <ti/drivers/UART.h>
#include "scif_framework.h"
#include "scif_osal_tirtos.h"
#include "string.h"
#include "stdio.h"
//#include "ex_include_tirtos.h"
#include "scif.h"
#include "adcmeasure.h"
//#define SCIF_INCLUDE_OSAL_C_FILE
#define BV(n) (1 << (n))
// Display error message if the SCIF driver has been generated with incorrect operating system setting
#ifndef SCIF_OSAL_TIRTOS_H
#error "SCIF driver has incorrect operating system configuration for this example. Please change to 'TI-RTOS' in the Sensor Controller Studio project panel and re-generate the driver."
#endif
// Display error message if the SCIF driver has been generated with incorrect target chip package
#ifndef SCIF_TARGET_CHIP_PACKAGE_QFN32_4X4_RSM
#error "SCIF driver has incorrect target chip package configuration for this example. Please change to 'QFN48 4x4 RSM' in the Sensor Controller Studio project panel and re-generate the driver."
#endif
// Task data
Task_Struct myTask;
Char myTaskStack[512];
// Semaphore used to wait for Sensor Controller task ALERT event
static Semaphore_Struct semScTaskAlert;
void scCtrlReadyCallback(void) {
} // scCtrlReadyCallback
void scTaskAlertCallback(void) {
// Wake up the OS task
Semaphore_post(Semaphore_handle(&semScTaskAlert));
} // scTaskAlertCallback
//PIN_Config pLedPinTable[] = {
// Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
// Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
// Board_LED3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
// Board_LED4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
// PIN_TERMINATE
//};
//PIN_State ledPinState;
void taskFxn(UArg a0, UArg a1) {
// PIN_Handle hLedPins;
// // Enable LED pins
// hLedPins = PIN_open(&ledPinState, pLedPinTable);
// Initialize the Sensor Controller
scifOsalInit();
scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback);
scifOsalRegisterTaskAlertCallback(scTaskAlertCallback);
scifInit(&scifDriverSetup);
// Set the Sensor Controller task tick interval to 1 second
scifStartRtcTicksNow(0x00010000);
// Configure and start the Sensor Controller's Analog Light Sensor task (not to be confused with OS tasks)
scifTaskData.analogLightSensor.cfg.hysteresis = 16;
scifTaskData.analogLightSensor.cfg.pBinThresholds[0] = 0;
scifTaskData.analogLightSensor.cfg.pBinThresholds[1] = 400;
scifTaskData.analogLightSensor.cfg.pBinThresholds[2] = 600;
scifTaskData.analogLightSensor.cfg.pBinThresholds[3] = 800;
scifTaskData.analogLightSensor.cfg.pBinThresholds[4] = 1000;
scifTaskData.analogLightSensor.cfg.pBinThresholds[5] = 4095;
scifStartTasksNbl(BV(SCIF_ANALOG_LIGHT_SENSOR_TASK_ID));
// Main loop
while (1) {
// Wait for an ALERT callback
Semaphore_pend(Semaphore_handle(&semScTaskAlert), BIOS_WAIT_FOREVER);
// Clear the ALERT interrupt source
scifClearAlertIntSource();
// Find the ADC bin value (can access directly since it is a single, single-buffered value, and
// we always want the latest value)
uint16_t bin = scifTaskData.analogLightSensor.output.bin;
// // Disable all LEDs and then enable as many as indicated by the current bin
// PIN_setOutputValue(hLedPins, Board_LED1, (bin >= 1));
// PIN_setOutputValue(hLedPins, Board_LED2, (bin >= 2));
// PIN_setOutputValue(hLedPins, Board_LED3, (bin >= 3));
// PIN_setOutputValue(hLedPins, Board_LED4, (bin >= 4));
// Acknowledge the alert event
scifAckAlertEvents();
}
} // taskFxn
void task_adc_init(void)
{
Task_Params taskParams;
// Initialize the PIN driver
PIN_init(BoardGpioInitTable);
// Configure the OS task
Task_Params_init(&taskParams);
taskParams.stack = myTaskStack;
taskParams.stackSize = sizeof(myTaskStack);
taskParams.priority = 3;
Task_construct(&myTask, taskFxn, &taskParams, NULL);
// Create the semaphore used to wait for Sensor Controller ALERT events
Semaphore_Params semParams;
Semaphore_Params_init(&semParams);
semParams.mode = Semaphore_Mode_BINARY;
Semaphore_construct(&semScTaskAlert, 0, &semParams);
}
But it won't compile because scifOsalInit() is not declared because it's protected by the #ifdef SCIF_INCLUDE_OSAL_C_FILE line at he top of scif_osal_tirtos.c
But SCIF_INCLUDE_OSAL_C_FILE is declared in scif_framework.c with the following lines.
/// Import OSAL
#define SCIF_INCLUDE_OSAL_C_FILE
#include "scif_osal_tirtos.c"
I don't understand, these file are automatically generated, but they cause problems to each others... TI-RTOS is selected in SCS, so I don't kwon wath could be the cause of my problem...
Regards,
Alban