尊敬的TI工程师您好
我是LAUNCHXL-CC3235S,我烧录的使out of box 例程,我在代码中设置了断点,经编译查看,读出的加速度x轴数据、加速度y轴数据、加速度z轴数据为什么都是-1呢?
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.
我只是把out of box例程的link_local_task.c文件有调整。
调整的地方有:
void * linkLocalTask(void *pvParameters) { mq_attr attr; int32_t msgqRetVal; I2C_Params i2cParams; uint8_t abb; uint8_t abc; char tempStr[8]; char tempStre[8]; int8_t xValRead, yValRead, zValRead; int16_t value = 0; int16_t valueee = 0; float fTempRead; /* initializes I2C */ I2C_Params_init(&i2cParams); i2cParams.bitRate = I2C_400kHz; i2cHandle = I2C_open(CONFIG_I2C_0, &i2cParams); if(i2cHandle == NULL) { UART_PRINT("[Link local task] Error Initializing I2C\n\r"); } /* Setup mutex operations for sensors reading */ sensorLockObj = malloc(sizeof(pthread_mutex_t)); if(sensorLockObj == NULL) { UART_PRINT("[Link local task] could not Setup mutex operations for sensors reading\n\r"); while(1) { ; } } pthread_mutex_init(sensorLockObj, (pthread_mutexattr_t*)NULL); UART_PRINT("aaaaaaaaaaaaaa\n\r"); abb=accelarometerReading(); if(abb != 0) /* leave previous values */ { UART_PRINT("nnnnnnnnnnnnnnnnn\n\r"); } else { value =yValRead ; itoa(yValRead, tempStr); //把整形转字符型函数 UART_PRINT(tempStr,8); //打印字符函数 } #if 0 abc= temperatureReading(); if(abc != 0) /* leave previous values */ { UART_PRINT("nnnnnnnnnnnnnnnnnnnnnnnnnnn\n\r"); } else { valueee =(int)fTempRead ; itoa((int)fTempRead, tempStre); //把整形转字符型函数 UART_PRINT(tempStre,8); //打印字符函数 } #endif /* initializes mailbox for http messages */ attr.mq_maxmsg = 10; /* queue size */ attr.mq_msgsize = sizeof(SlNetAppRequest_t*); /* Size of message */ linkLocalMQueue = mq_open("linklocal msg q", O_CREAT, 0, &attr); if(((int)linkLocalMQueue) <= 0) { UART_PRINT("[Link local task] could not create msg queue\n\r"); while(1) { ; } } initLinkLocalDB(); /* waits for valid local connection - via provisioning task */ sem_wait(&Provisioning_ControlBlock.provisioningDoneSignal); while(1) { SlNetAppRequest_t *netAppRequest; msgqRetVal = mq_receive(linkLocalMQueue, (char *)&netAppRequest, sizeof(SlNetAppRequest_t*), NULL); if(msgqRetVal < 0) { UART_PRINT( "[Link local task] could not receive element from msg \ queue\n\r"); while(1) { ; } } INFO_PRINT( "[Link local task] NetApp Request Received - handle from main " "context AppId = %d, Type = %d, Handle = %d\n\r", netAppRequest->AppId, netAppRequest->Type, netAppRequest->Handle); INFO_PRINT("[Link local task] Metadata len = %d\n\r", netAppRequest->requestData.MetadataLen); if((netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_GET) || (netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_DELETE)) { if(netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_GET) { UART_PRINT("[Link local task] HTTP GET Request\n\r"); } else { UART_PRINT("[Link local task] HTTP DELETE Request\n\r"); } httpGetHandler(netAppRequest); } else if((netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_POST) || (netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_PUT)) { if(netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_POST) { UART_PRINT("[Link local task] HTTP POST Request\n\r"); } else { UART_PRINT("[Link local task] HTTP PUT Request\n\r"); } INFO_PRINT( "[Link local task] Data received, len = %d, flags= %x\n\r", netAppRequest->requestData.PayloadLen, netAppRequest->requestData.Flags); httpPostHandler(netAppRequest); } if(netAppRequest->requestData.MetadataLen > 0) { free (netAppRequest->requestData.pMetadata); } if(netAppRequest->requestData.PayloadLen > 0) { free (netAppRequest->requestData.pPayload); } free (netAppRequest); } } static void reverse(char s[]) { int i, j; char c; for (i = 0, j = strlen(s)-1; i<j; i++, j--) { c = s[i]; s[i] = s[j]; s[j] = c; } } static void itoa(int n, char s[]) { int i, sign; if ((sign = n) < 0) /* record sign */ n = -n; /* make n positive */ i = 0; do { /* generate digits in reverse order */ s[i++] = n % 10 + '0'; /* get next digit */ } while ((n /= 10) > 0); /* delete it */ if (sign < 0) s[i++] = '-'; s[i] = '\0'; reverse(s); }
注意,在link_local_task.c文件的前面要对两个函数定义下:static void itoa(int n,char s[]);
static void reverse(char s[]);
程序烧进去后,某一个姿态数据 和 温度分别为 -1、 0,不知道问题出在哪里?