This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL-CC1310: i can't implement i2c slave mode in RTOS

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: SYSBIOS

Tool/software: Code Composer Studio

Hello, I am trying to implement i2c slave mode, but the first problem I find is that when I2CSlaveInit (I2C0_BASE, I2C_SLAVE_ADDR)  function is called,  it does not come out of this, below you can see the code I am using.
Does anyone have an example of i2c slave mode implementation in RTOS?
Awaiting any response, best regards
Luis Valseca

#include "stdlib.h"
/*
* ======== main_tirtos.c ========
*/
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
/* POSIX Header files */
#include <pthread.h>
#include <string.h>
/* RTOS header files */
/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
//#include <ti/drivers/I2C.h>
#include <ti/drivers/dpl/HwiP.h>
// hola papa
/* Example/Board Header files */
#include "Board.h"
#include <stddef.h>
#include "RFQueue.h"
//////////////////////////////
/***** Includes *****/

#include <xdc/std.h>
#include <xdc/cfg/global.h>


#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>//
#include <ti/sysbios/knl/Swi.h>

#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include <ti/drivers/NVS.h>
#include <ti/drivers/PIN.h>

/* BIOS module Headers */

#include <ti/sysbios/knl/Clock.h>

/* Board Header files */
//#include "Board.h"

#include "RFQueue.h"
#include "smartrf_settings/smartrf_settings.h"
//#include DeviceFamily_constructPath(inc/hw_prcm.h)
#include DeviceFamily_constructPath(driverlib/sys_ctrl.h)
#include DeviceFamily_constructPath(driverlib/i2c.h)


#define Board_I2C_SCL0 IOID_4
#define Board_I2C_SDA0 IOID_5

#define I2C_SLAVE_ADDR 0x4c

//defines de gpio
#define DOUT31_0 0x80 //Data Output for DIO 0 to 31 la base es GPIO_BASE
#define DIN31_0 0xC0 //Data Input from DIO 0 to 31 la base es GPIO_BASE
#define DOE31_0 0xd0 // Data Output Enable for DIO 0 to 31 la base es GPIO_BASE
#define BAT 0x28 //voltaje de la bateria la base es AON_BATMON_BASE
#define BATUPD 0x2c //bit 0 status, si 1 bateria ha variado. se limpia escribiendo 1 en bit 0 la base es AON_BATMON_BASE
#define I2CCLK 0x10; //DIO4 al reves que en rfid-uhf
#define I2CDATA 0x20; //DIO5


#define ENABLEIN 0x20000000; //IOCFG

///////////////////////////////
/***** Defines *****/
#define RX_TASK_STACK_SIZE 1024
#define RX_TASK_PRIORITY 2
#define TX_TASK_STACK_SIZE 1024
#define TX_TASK_PRIORITY 2

/* Packet RX Configuration */
#define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */
#define MAX_LENGTH 64 /* Max length byte the radio will accept */
#define NUM_DATA_ENTRIES 2 /* NOTE: Only two data entries supported at the moment */
#define NUM_APPENDED_BYTES 2 /* The Data Entries data field will contain:
* 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
* Max 30 payload bytes
* 1 status byte (RF_cmdPropRx.rxConf.bAppendStatus = 0x1) */

/***** Defines *****/

/* Packet TX Configuration */
#define PAYLOAD_LENGTH 30
#define PACKET_INTERVAL (uint32_t)(4000000*0.5f) /* Set packet interval to 500ms */
// valores variables
//________________________


static void *mainThread(void *arg0);
Void clk0Fxn(UArg arg0);

Clock_Struct clk0Struct, clk1Struct;
Clock_Handle clk2Handle;

Semaphore_Struct sem0Struct;
Semaphore_Handle sem;

uint8_t txCmdHndl;
/***** Variable declarations *****/

Task_Struct txTask; /* not static so you can see in ROV */
/* Task and tast stack */
Task_Struct myTask;
Char myTaskStack[512];
/* Pin driver handles */
PIN_Handle hPins;
PIN_Handle hButtons;
/* Button pin state */
PIN_State buttonState;

/* PIN_Id for active button (in debounce period) */

/* Wake-up Button pin table */

int tiempoprog=0;
/* Stack size in bytes */
#define THREADSTACKSIZE 1536//1024
/////////////////////////
/////////////////////////////////////
// fin valores variables
///////////////////


#define SLEEP_OSC_PD_BM 0x04 // bit mask, power down
#define CLKCON_OSC_BM 0x40 // bit mask, for the system //main:
#define TICKSPD_DIV_1 (0x00 << 3)
#define CLKSPD_DIV_1 (0x00)


/*==== INTERRUPT SERVICE ROUTINES ============================================*/


////////////////////////////////////////////////

/*
* ======== clk0Fxn =======
*/
Void clk0Fxn(UArg arg0)
{
if(tiempoprog)tiempoprog--;
}


/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{

/* Call driver init functions */
GPIO_init();


IOCPinTypeI2c(I2C0_BASE, Board_I2C_SDA0, Board_I2C_SCL0);


I2CSlaveInit(I2C0_BASE,I2C_SLAVE_ADDR); // when go into this funtion, never go out


while(1)
{
asm(" nop");
}


}

//////////////////////
//


/* ======== main ========
*/
int main(void)
{
pthread_t thread;
pthread_attr_t pAttrs;
struct sched_param priParam;
int retc;
int detachState;
/* Call driver init functions */
Board_initGeneral();
// ledPinHandle = PIN_open(&ledPinState, pinTable);

Task_Params taskParams;
Power_init();

/* Get the reason for reset */
uint32_t rSrc = SysCtrlResetSourceGet();

Task_Params_init(&taskParams);
taskParams.stack = myTaskStack;
taskParams.stackSize = sizeof(myTaskStack);
// Task_construct(&myTask, taskFxn, &taskParams, NULL);


/* Set priority and stack size attributes */
pthread_attr_init(&pAttrs);
priParam.sched_priority = 1;

detachState = PTHREAD_CREATE_DETACHED;
retc = pthread_attr_setdetachstate(&pAttrs, detachState);
if (retc != 0) {
/* pthread_attr_setdetachstate() failed */
while (1);
}

pthread_attr_setschedparam(&pAttrs, &priParam);

retc |= pthread_attr_setstacksize(&pAttrs, THREADSTACKSIZE);
if (retc != 0) {
/* pthread_attr_setstacksize() failed */
while (1);
}

retc = pthread_create(&thread, &pAttrs, mainThread, NULL);
if (retc != 0) {
/* pthread_create() failed */
while (1);
}
////////////////////////////
/* Open LED pins */

// Construct BIOS Objects
Clock_Params clkParams;


Clock_Params_init(&clkParams);
clkParams.period = 4000/Clock_tickPeriod;
clkParams.startFlag = TRUE;

// Construct a periodic Clock Instance
Clock_construct(&clk0Struct, (Clock_FuncPtr)clk0Fxn,
4000/Clock_tickPeriod, &clkParams);


clk2Handle = Clock_handle(&clk1Struct);

Clock_start(clk2Handle);

/////////////////////////////
BIOS_start();

return (0);
}