Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 449 → Rev 450

/trunk/Hex-Files/settings.ini
File deleted
/trunk/fat16.c
673,7 → 673,7
file = &FilePointer[0];
 
// try to initialize the sd-card.
if(SD_SUCCESS != SDC_Init())
if(SD_SUCCESS != SDC_Init(1))
{
UART1_PutString("SD-Card could not be initialized.");
result = 1;
/trunk/main.h
14,7 → 14,7
 
#define VERSION_MAJOR 0
#define VERSION_MINOR 30
#define VERSION_PATCH 6
#define VERSION_PATCH 7
// 0 = A
// 1 = B
// 2 = C
/trunk/sdc.c
368,7 → 368,6
return SDC_GetData(CMD_SEND_CSD, 0UL, pCSD, 16);
}
 
 
//________________________________________________________________________________________________________________________________________
// Funtion: SDC_Init(void);
//
378,21 → 377,24
// Returnvalue: the function returns 0 if the initialisation was successfull otherwise the function returns an errorcode.
//________________________________________________________________________________________________________________________________________
 
SD_Result_t SDC_Init(void)
SD_Result_t SDC_Init(unsigned char print)
{
u32 timeout = 0;
u16 speed;
u8 rsp[6]; // SD-SPI response buffer
SD_Result_t result = SD_ERROR_UNKNOWN;
if(SPI_Speed < 500) SPI_Speed = 500; // nur zur Sicherheit
speed = SPI_Speed; // weil das bei SSC_Init() auf 400 gesetzt werden würde
 
//SDCardWriteRetryCounterMax = 0;
if(SD_SWITCH) // init only if the SD-Switch is indicating a card in the slot
{
UART1_PutString("\r\n SSC init...");
if(print) UART1_PutString("\r\n SSC init...");
SSC_Init();
UART1_PutString("ok");
if(print) UART1_PutString("ok");
 
UART1_PutString("\r\n SDC init...");
if(print) UART1_PutString("\r\n SDC init...");
SDCardInfo.Valid = 0;
/* The host shall supply power to the card so that the voltage is reached to Vdd_min within 250ms and
start to supply at least 74 SD clocks to the SD card with keeping cmd line to high. In case of SPI
530,7 → 532,9
SSC_Disable(); // set SD_CS high
// here is the right place to inrease the SPI baud rate to maximum
 
SSC_Speed(2000);
SSC_Speed(speed);
if(print) { sprintf(text,"\r\n Setting SPI speed to %d ", SPI_Speed);UART1_PutString(text); }
SSC_Enable(); // set SD_CS high
 
// read CID register
538,10 → 542,11
if(result != SD_SUCCESS)
{
UART1_PutString(" Set interface to low speed...");
if(print) UART1_PutString(" failed - Set interface to low speed...");
SSC_Disable(); // set SD_CS high
// here is the right place to inrease the SPI baud rate to maximum
SSC_Speed(1000);
SPI_Speed = 1000;
SSC_Speed(SPI_Speed);
SSC_Enable(); // set SD_CS high
result = SDC_GetCID((u8 *)&SDCardInfo.CID);
}
561,7 → 566,7
goto end;
}
UART1_PutString("ok\r\n");
if(print) UART1_PutString("ok\r\n");
u8 c_size_mult, read_bl_len;
u32 c_size;
608,7 → 613,7
break;
}
switch(SDCardInfo.Version)
if(print) switch(SDCardInfo.Version)
{
case VER_1X:
UART1_PutString(" SD-CARD V1.x");
618,11 → 623,14
default:
break;
}
u16 mb_size = (u16)(SDCardInfo.Capacity/(1024L*1024L));
sprintf(text, "\r\n Capacity = %i MB", mb_size);
UART1_PutString(text);
if(print)
{
u16 mb_size = (u16)(SDCardInfo.Capacity/(1024L*1024L));
sprintf(text, "\r\n Capacity = %i MB", mb_size);
UART1_PutString(text);
}
SDC_PrintCID((u8 *)&SDCardInfo.CID);
if(print) SDC_PrintCID((u8 *)&SDCardInfo.CID);
SDCardInfo.Valid = 1;
// jump point for error condition before
end:
767,12 → 775,25
//SSC_Disable(); // disable CS
if(result != SD_SUCCESS)
{
sprintf(text,"Error %02X writing data to sd card (R=%02X).\r\n", result, rsp);
 
sprintf(text,"\r\nError %02X writing data to sd card (R=%02X)", result, rsp);
UART1_PutString(text);
retryCounter++;
}
else break; // Success -> end retry loop
 
if(SPI_Speed > 1000)
{
SPI_Speed -= 200;
sprintf(text," new Speed = %d", SPI_Speed);
UART1_PutString(text);
}
SDC_Init(0);
}
else
{
if(retryCounter == 1) UART1_PutString(" Problem solved\r\n");
break; // Success -> end retry loop
}
 
}
if (retryCounter > SDCardWriteRetryCounterMax)
{ SDCardWriteRetryCounterMax = retryCounter;
/trunk/sdc.h
25,7 → 25,7
SD_ERROR_UNKNOWN
} SD_Result_t;
 
SD_Result_t SDC_Init(void);
SD_Result_t SDC_Init(unsigned char print);
SD_Result_t SDC_GetSector (u32 ,u8 *);
SD_Result_t SDC_PutSector (u32, const u8 *);
SD_Result_t SDC_Deinit(void);
/trunk/spi_slave.c
693,10 → 693,9
 
/*
//+++++++++++++++++++++++++++++++++++++++++++++++++++
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++
// in SPI Einkommentieren, falls der Flug simultert werden soll
/*
 
if(Parameter.User8 < 100) FC.StatusFlags = 0;
else
if(Parameter.User8 < 150) FC.StatusFlags = FC_STATUS_START;
703,8 → 702,8
else FC.StatusFlags = FC_STATUS_FLY | FC_STATUS_MOTOR_RUN;
BL_MinOfMaxPWM = 255;
NaviData.FCStatusFlags = FC.StatusFlags;
//+++++++++++++++++++++++++++++++++++++++++++++++++++
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++
 
GPS_Navigation(&GPSData, &(ToFlightCtrl.GPSStick));
ClearFCStatusFlags = 1;
/trunk/ssc.c
78,7 → 78,7
//________________________________________________________________________________________________________________________________________
 
 
 
u16 SPI_Speed = 2000;
//________________________________________________________________________________________________________________________________________
// Function: SSC_Enable(void);
//
123,6 → 123,8
{
SSP_InitTypeDef SSP_InitStructure;
 
SPI_Speed = speed;
 
SSP_Cmd(SSP1, DISABLE);
SSP_DeInit(SSP1);
SSP_StructInit(&SSP_InitStructure);
/trunk/ssc.h
19,4 → 19,6
void SSC_ClearRxFifo(void);
void SSC_Speed(u32);
 
extern u16 SPI_Speed;
 
#endif //_SSC_H