Harmony FS sdcard questions
Hello,
Like many others in this forum, I am struggling with Harmony.
I'm trying to port the sdcard_fat_single_disk demo onto my ChipKit Wifire (MZ) board.
The main problem has to do with the SD detection logic since the ChipKit doesn't have a physical card-detect pin. Anyways, after remapping the RP pins and changing all the drivers to the SPI3 module I still have many questions and I hope someone could help me out.
1.- Is there a way to use the software detect? I
2.- I've measured the SPI2 signals with my scope and they seem to be working well, but (again) the ChipKit has the SD socket connected to the SPI3 module.
The pins are correctly remapped using the library functions.
I've modified the SD Card driver to this:
/*** SDCARD Driver Initialization Data ***/
const DRV_SDCARD_INIT drvSDCardInit =
{
// .spiId = SPI_ID_2,
.spiId = SPI_ID_3,
.spiIndex = 0,
.sdcardSpeedHz = 20000000,
.spiClk = CLK_BUS_PERIPHERAL_2,
.sdCardPinActiveLogic = SDCARD_DETECTION_LOGIC_ACTIVE_LOW,
.cardDetectPort = PORT_CHANNEL_A,
.cardDetectBitPosition = BSP_SWITCH_1, //ChipKit sw1
.writeProtectPort = PORT_CHANNEL_A,
.writeProtectBitPosition = BSP_SWITCH_2,//ChipKit sw2
.chipSelectPort = PORT_CHANNEL_C,
.chipSelectBitPosition = PORTS_BIT_POS_3,
};
Also the SPI Driver & SPI ISRs:
/*** SPI Driver Initialization Data ***/
/*** Index 0 ***/
DRV_SPI_INIT drvSpi0InitData =
{
.spiId = SPI_ID_3,
.taskMode = DRV_SPI_TASK_MODE_ISR,
.spiMode = DRV_SPI_MODE_MASTER,
.allowIdleRun = 0,
.spiProtocolType = DRV_SPI_PROTOCOL_TYPE_STANDARD,
.commWidth = SPI_COMMUNICATION_WIDTH_8BITS,
.spiClk = CLK_BUS_PERIPHERAL_2,
.baudRate = 20000000,
.bufferType = DRV_SPI_BUFFER_TYPE_STANDARD,
.clockMode = DRV_SPI_CLOCK_MODE_IDLE_LOW_EDGE_FALL,
.inputSamplePhase = SPI_INPUT_SAMPLING_PHASE_AT_END,
.txInterruptSource = INT_SOURCE_SPI_3_TRANSMIT,
.rxInterruptSource = INT_SOURCE_SPI_3_RECEIVE,
.errInterruptSource = INT_SOURCE_SPI_3_ERROR,
.queueSize = 10,
.jobQueueReserveSize = 1,
};
void __ISR(_SPI3_RX_VECTOR, ipl3) _IntHandlerSPIRxInstance0(void)
{
DRV_SPI_Tasks(sysObj.spiObjectIdx0);
}
void __ISR(_SPI3_TX_VECTOR, ipl3) _IntHandlerSPITxInstance0(void)
{
DRV_SPI_Tasks(sysObj.spiObjectIdx0);
}
void __ISR(_SPI3_FAULT_VECTOR, ipl3) _IntHandlerSPIFAultInstance0(void)
{
DRV_SPI_Tasks(sysObj.spiObjectIdx0);
}
Is this the correct way of changing the SPI module? Am I missing something?