int WRToSD(char cStrings[100])
{
if (SdCard.iSdStatus == SD_INITIALIZED)
{
K_Serial_Print_Wait("WRToSD called\r\n",15,200); // Writes to Serial monitor
SDFile = FS_FOpen(cFileName, "a"); //.bin "wb" AS
iLeng = strlen(cStrings);
nn = FS_FWrite(cStrings, 1, iLeng, SDFile);
FS_FClose(SDFile);
K_Serial_Print_Wait("SD File Closed\r\n",16,200);
if (iLeng != nn)
return 0;
return nn;
}
return -1;
}
void AnalogTestAuto(void)
{
// Test analog inputs
if (pass)
{
LCDPrintAt("Pass", 26,7);
sprintf(SDTextAuto,"Analog test passed\r\n");
K_Serial_Print_Wait(SDTextAuto, strlen(SDTextAuto),200);
K_Resource_Wait(ResourceSPIBus,0); // waits for the resource for indefinite time
K_Serial_Print_Wait("Lock Acquired\r\n",15,200);
WRToSD(SDTextAuto);
K_Resource_Release(SDTextAuto);
K_Serial_Print_Wait("Lock Released\r\n",15,200);
}
else
{
LCDPrintAt("Fail", 26,7);
sprintf(SDTextAuto,"Analog test failed\r\n");
K_Serial_Print_Wait(SDTextAuto, strlen(SDTextAuto),200);
K_Resource_Wait(ResourceSPIBus,0); // waits for the resource for indefinite time
K_Serial_Print_Wait("Lock Acquired\r\n",15,200);
WRToSD(SDTextAuto);
K_Resource_Release(SDTextAuto);
K_Serial_Print_Wait("Lock Released\r\n",15,200);
}
}
void SerialTestAuto(void)
{
// Do Serail testing
if (Pass)
{
LCDPrintAt("Pass", 26,7);
sprintf(SDTextAuto,"Serialtest passed\r\n");
K_Serial_Print_Wait(SDTextAuto, strlen(SDTextAuto),200);
K_Resource_Wait(ResourceSPIBus,0); // waits for the resource for indefinite time
K_Serial_Print_Wait("Lock Acquired\r\n",15,200);
WRToSD(SDTextAuto);
K_Resource_Release(SDTextAuto);
K_Serial_Print_Wait("Lock Released\r\n",15,200);
}
else
{
LCDPrintAt("Fail", 26,7);
sprintf(SDTextAuto,"Serial test failed\r\n");
K_Serial_Print_Wait(SDTextAuto, strlen(SDTextAuto),200);
K_Resource_Wait(ResourceSPIBus,0); // waits for the resource for indefinite time
K_Serial_Print_Wait("Lock Acquired\r\n",15,200);
WRToSD(SDTextAuto);
K_Resource_Release(SDTextAuto);
K_Serial_Print_Wait("Lock Released\r\n",15,200);
}
}
void TestAuto(void) // This function is called in a task.
{
AnalogTestAuto();
SerialTestAuto();
}