void setup() { CardReaderValue.cardStatus = MM_UNDEFINED_ERROR; Serial.begin(115200); Serial.println("Init"); //init Display displayStatus = TFTInit(); switch (displayStatus) { case MM_SUCCESS: DisplayMaster("Display Initialisiert\n", DebugPC); Serial.println("Display Initialisiert"); break; default: DisplayError("Display Init-ERROR!", DebugPC); Serial.println("Display Init-ERROR!"); DebugPC = false; break; } //init GPS p_myGPSData = &myGPSData; initGPS(); //Versuche ein GPS Signal zu bekommen, damit die Logdatei das Datum als Namen bekommt while(p_myGPSData->status != MM_SUCCESS) { DisplayMaster("GPS noch nicht Initialisiert\n", DebugPC); Serial.println("GPS noch nicht Initialisiert"); delay(2500); readGPS(p_myGPSData); } //init CardReader char * FileName = ""; String sFileName = "GPS_Log" + String(myGPSData.year, DEC) + "_" + String(myGPSData.month, DEC)+ "_" + String(myGPSData.day, DEC) + ".txt"; sFileName.toCharArray(FileName, sFileName.length() + 1); CardReaderValue = SDInit(FileName); switch (CardReaderValue.cardStatus) { case MM_SUCCESS: DisplayMaster("CardReader Initialisiert\n", DebugPC); Serial.println("CardReader Initialisiert"); break; default: DisplayError("CardReader Init-ERROR!", DebugPC); Serial.println("CardReader Init-ERROR!"); break; } }
int main() { unsigned long i; unsigned char ucRet = 0; unsigned long ulValueLength; unsigned long ulData[10]; xPWMotorControl(); HD44780Init(); // // Enable Peripheral SPI0 // xSysCtlPeripheralEnable(SYSCTL_PERIPH_ADC); xSPinTypeADC(ADC0, sA0); // // ADC Channel0 convert once, Software tirgger. // xADCConfigure(xADC0_BASE, xADC_MODE_SCAN_CONTINUOUS, ADC_TRIGGER_PROCESSOR); // // Enable the channel0 // xADCStepConfigure(xADC0_BASE, 0, xADC_CTL_CH0); // // Enable the ADC end of conversion interrupt // //xADCIntEnable(xADC0_BASE, xADC_INT_END_CONVERSION); // // install the call back interrupt // //xADCIntCallbackInit(xADC0_BASE, ADCCallback); // // Enable the NVIC ADC interrupt // //xIntEnable(xINT_ADC0); // // Enable the adc // xADCEnable(xADC0_BASE); // // start ADC convert // xADCProcessorTrigger( xADC0_BASE ); HD44780LocationSet(0, 0); HD44780DisplayString("Hello Nuvoton!"); HD44780LocationSet(0, 1); HD44780DisplayString("Hello CooCox! "); SysCtlDelay(10000000); while(1) { SysCtlDelay(1000000); // // Read the convert value // ulValueLength = xADCDataGet(xADC0_BASE, ulData); if (ulData[0] < 0x30100) { HD44780DisplayClear(); HD44780LocationSet(0, 0); HD44780DisplayString("right"); SendData74HC595(0x60); sD11PinTypePWM(); xPWMStart(xPWMB_BASE, xPWM_CHANNEL7); xGPIOSPinWrite(sD3, 1); } else if(ulData[0] < 0x30300) { HD44780DisplayClear(); HD44780LocationSet(0, 0); HD44780DisplayString("up"); ulDuty++; xPWMDutySet(xPWMB_BASE, xPWM_CHANNEL7, ulDuty); sD11PinTypePWM(); xPWMStart(xPWMB_BASE, xPWM_CHANNEL7); xGPIOSPinWrite(sD3, 1); SysCtlDelay(100000); } else if(ulData[0] < 0x30600) { HD44780DisplayClear(); HD44780LocationSet(0, 0); HD44780DisplayString("dowm"); ulDuty--; xPWMDutySet(xPWMB_BASE, xPWM_CHANNEL7, ulDuty); sD11PinTypePWM(); xPWMStart(xPWMB_BASE, xPWM_CHANNEL7); xGPIOSPinWrite(sD3, 1); SysCtlDelay(100000); } else if(ulData[0] < 0x30900) { HD44780DisplayClear(); HD44780LocationSet(0, 0); HD44780DisplayString("left"); SendData74HC595(0x18); sD11PinTypePWM(); xPWMStart(xPWMB_BASE, xPWM_CHANNEL7); xGPIOSPinWrite(sD3, 1); } else if(ulData[0] < 0x30E00) { HD44780DisplayClear(); HD44780LocationSet(0, 0); HD44780DisplayString("select"); SendData74HC595(0x60); sD11PinTypePWM(); xPWMStart(xPWMB_BASE, xPWM_CHANNEL7); xGPIOSPinWrite(sD3, 1); } else { HD44780DisplayClear(); HD44780LocationSet(0, 0); HD44780DisplayString("Nothing"); xPWMStop(xPWMB_BASE, xPWM_CHANNEL7); xGPIOSPinTypeGPIOOutput(sD11); xGPIOSPinTypeGPIOOutput(sD3); xGPIOSPinWrite(sD11, 0); xGPIOSPinWrite(sD3, 0); } if(ulDuty >= 99) { ulDuty = 99; } if(ulDuty <= 1) { ulDuty = 1; } } // // SD Card Init // ucRet = SDInit(); // // write a block to the card // ucRet = SDBlockWrite(pucBuf, 0); // // Re-init the test buffer to 0 // for(i = 0; i < 512; i++) { pucBuf[i] = 0; } // // Read 1 block from the card // ucRet = SDBlockRead(pucBuf, 0); while(1); }