void I2C_StoreCmd(void) { #if PL_HAS_UI unsigned char buf[32]; uint8_t strSize; #if PL_HAS_RUNNER buf[0] = '@'; buf[1] = '\0'; RUNNER_GetCmdString(buf, sizeof(buf)); #elif PL_HAS_SLIDER SLIDER_GetCmdString(buf, sizeof(buf)); #else buf[0] = '\0'; #endif if (buf[0]!='\0') { uint8_t cnt=3; while(cnt>0 && memDevice.u.data.cmdLength!=0) { /* poll cmdLength: this will be set to zero by the master if it is ok to place the string */ FRTOS1_vTaskDelay(50/portTICK_RATE_MS); /* give master some time to clear the flasg */ cnt--; } if (cnt==0) { /* timeout. Will loose that command. Not ideal, but simple :-) */ return; /* get out here */ } strSize = (uint8_t)(UTIL1_strlen(buf)+1); /* size of string including zero byte */ if (strSize>sizeof(memDevice.u.data.cmd)) { strSize = sizeof(memDevice.u.data.cmd); } EnterCritical(); memDevice.u.data.cmdLength = strSize; UTIL1_strcpy(memDevice.u.data.cmd, sizeof(memDevice.u.data.cmd), buf); ExitCritical(); } #endif /* PL_HAS_UI */ }
void I2C_SendCmd(void) { if (sendCmd) { #if PL_HAS_UI word snt; char buf[32]; #if PL_HAS_RUNNER buf[0] = '@'; buf[1] = '\0'; RUNNER_GetCmdString(buf, sizeof(buf)); #else SLIDER_GetCmdString(buf, sizeof(buf)); #endif (void)I2C1_SendBlock(buf, sizeof(buf), &snt); #endif /* PL_HAS_UI */ sendCmd = FALSE; } }