Wednesday, January 3, 2018

How to create a new task in TI RTOS to use ICall service like osal_snv_write and osal_snv_read.

The following steps show you how to create a new task in TI RTOS to use ICall service like osal_snv_write and osal_snv_read. I will use ProjectZero in TI BLE Stack 2.2.1 as an example running on LAUNCHXL-CC2650 to do it.

1. Increase OSAL_MAX_NUM_PROXY_TASKS in BLE Stack project osal.c and rebuild Stack project to download it to your LAUNCHXL-CC2650.

2. Increase ICALL_MAX_NUM_TASKS and ICALL_MAX_NUM_ENTITIES in ProjectZero application Predefined Symbols.

3. Add the following Test_createTask function in ProjectZero.c and claim function prototype "extern void Test_createTask(void);" in ProjectZero.h

// Task configuration
#define TEST_TASK_STACK_SIZE                   800
Task_Struct testTask;
Char testTaskStack[TEST_TASK_STACK_SIZE ];

void Test_createTask(void)
  Task_Params taskParams;

  // Configure task
  taskParams.stack = testTaskStack;
  taskParams.stackSize = TEST_TASK_STACK_SIZE ;
  taskParams.priority = 2;

  Task_construct(&testTask, TestFunction, &taskParams, NULL);

4. Add the following TestFunction function in ProjectZero.c

// Entity ID globally used to check for source and/or destination of messages
static ICall_EntityID testEntity;
// Semaphore globally used to post events to the application thread
static ICall_Semaphore testsem;

uint8 status_snv;
uint8 write_buffer[10];
uint8 read_buffer[10];

static void TestFunction(UArg a0, UArg a1)

  ICall_registerApp(&testEntity, &testsem);
      write_buffer[0] = 0x12;
      write_buffer[1] = 0x12;
      write_buffer[2] = 0x12;
      write_buffer[3] = 0x12;

      status_snv = osal_snv_write(0x80,10, (uint8_t *)write_buffer );

      //Do ADC Polling and Data processing
      read_buffer[0] = 0x0;
      read_buffer[1] = 0x0;
      read_buffer[2] = 0x0;
      read_buffer[3] = 0x0;

      status_snv = osal_snv_read(0x80,10, (uint8_t *)read_buffer );

5. Call "Test_createTask();" right after "ProjectZero_createTask();" to create TestFunction task to use ICall service for osal_snv_write/osal_snv_read.

1 comment:

  1. sir if i follow this method i am getting this error please help me out
    Description Resource Path Location Type
    #130-D a block-scope function may only have extern storage class ProjectZero.c /ProjectZeroApp_CC2650LAUNCHXL/Application line 329 C/C++ Problem