Hi,
I'm developing for a CC1310 and I'd like my application to control which analog input pins are used by the sensor controller rather than configuring statically in sensor controller studio. Is the following the best way to do that? I'm particularly unsure about selecting dummy pins and overriding scifDriverSetup. My code is based on rfWsnNode_CC1310_LAUNCHXL_tirtos_ccs. I'm running CCS 10.4.0.00006 and Sensor Controller Studio 2.8.0.170.
- In Sensor Controller Studio:
- Under 'task resources', I check 'Analog pins' and select '2 (accessed by lookup table)'.
- Under 'I/O Mapping' I pick two dummy pins to make the sensor compiler happy. They will be ignored during initialization (see below).
- Under 'Constants and Data Structures" I add two variables to 'cfg', called analogId1 and analogId2
- Under 'Execution code', I select the pins using code like 'adcSelectGpioInput(cfg.analogId1)'
- In my application
- I override scifDriverSetup (by copying and modifying) to use my own versions of scifTaskResourceInit and scifTaskResourceUnInit My substituted functions call scifInitIo() with the pins I wish to configure as analog input.
- I set the cfg fields to pass the same analog input ids to the sensor execution code.
So the relevant section of sensor controller initialization looks like (using #define to specify the analog pins):
static void j_scifTaskResourceInit(void) {
scifInitIo(E70_ANALOG_ID1, AUXIOMODE_ANALOG, -1, 0);
scifInitIo(E70_ANALOG_ID2, AUXIOMODE_ANALOG, -1, 0);
}
static void j_scifTaskResourceUninit(void) {
scifUninitIo(E70_ANALOG_ID1, -1);
scifUninitIo(E70_ANALOG_ID2, -1);
}
SCIF_DATA_T j_scifDriverSetup;
void SceAdc_init(uint32_t samplingTime, uint16_t adcThreshold) {
scifOsalInit();
scifOsalRegisterCtrlReadyCallback(ctrlReadyCallback);
scifOsalRegisterTaskAlertCallback(taskAlertCallback);
memcpy(&j_scifDriverSetup, &scifDriverSetup, sizeof(scifDriverSetup));
j_scifDriverSetup.fptrTaskResourceInit = j_scifTaskResourceInit;
j_scifDriverSetup.fptrTaskResourceUninit = j_scifTaskResourceUninit;
scifInit(&j_scifDriverSetup);
scifStartRtcTicksNow(samplingTime);
SCIF_ADC_SAMPLE_CFG_T* pCfg = scifGetTaskStruct(SCIF_ADC_SAMPLE_TASK_ID, SCIF_STRUCT_CFG);
pCfg->analogId1 = E70_ANALOG_ID1;
pCfg->analogId2 = E70_ANALOG_ID2;
}
Thanks for any comments! I'm wondering about the override that I do and also if it's even necessary to select 2 analog pins in the 'task resources' section of the SCS.
-Josh