I am trying to interface an SD card with LPC1768 using SPI protocol.I am using File system middleware provided in ARM MDK which uses CMSIS SPI DRIVER API as the lowest layer to communicate with the hardware.The following code is to initialize and mount the memory card drive.It is expected to receive a fsOK status for successful mounting but instead, the fmount function doesn't return any status or error code and nothing happens, as far as switch case instruction is concerned.
What could be the problem ?
void init_filesystem (void) { stat1=finit("M0:"); if(stat==fsOK) { LPC_GPIO1->FIOPIN=0XFFFFFFFF; stat2==fmount("M0:"); switch(stat2) { case fsOK: LPC_GPIO2->FIOPIN=0X00000001; break; case fsError: LPC_GPIO2->FIOPIN=0X00000002; break; case fsNoMedia : LPC_GPIO2->FIOPIN=0X00000004; break; case fsNoFileSystem : LPC_GPIO2->FIOPIN=0X00000008; break; case fsNoFreeSpace : LPC_GPIO2->FIOPIN=0X00000010; break; case fsFileNotFound : LPC_GPIO2->FIOPIN=0X00000020; break; case fsDirNotEmpty: LPC_GPIO2->FIOPIN=0X00000040; break; case fsTooManyOpenFiles: LPC_GPIO2->FIOPIN=0X00000080; break; case fsUnsupported: LPC_GPIO2->FIOPIN=0X00000100; break; case fsAccessDenied: LPC_GPIO2->FIOPIN=0X00000200; break; case InvalidParameter; LPC_GPIO2->FIOPIN=0X00000400; break; case fsInvalidDrive : LPC_GPIO2->FIOPIN=0X00000800; break; case fsInvalidPath : LPC_GPIO2->FIOPIN=0X00001000; break; case fsUninitializedDrive : LPC_GPIO2->FIOPIN=0X00002000; break; \ case fsDriverError: LPC_GPIO2->FIOPIN=0X00004000; break; case fsMediaError : LPC_GPIO2->FIOPIN=0X00008000; break; } } }
Yes, I have made sure that controller pins are outputs.I haven't shown that part in this initialization function.
I will flip the I/O by myself.I just wanted to know the syntax of defining an exception handler.