Description
Source
Call Graph
Start Line: 161
unsigned char AT26_SendCommand(At26 *pAt26, unsigned char cmd, unsigned char cmdSize, unsigned char *pData, unsigned int dataSize, unsigned int address, SpidCallback callback, void *pArgument)
{
SpidCmd *pCommand;
SANITY_CHECK(pAt26);
// Check if the SPI driver is available
if (AT26_IsBusy(pAt26)) {
return AT26_ERROR_BUSY;
}
// Store command and address in command buffer
pAt26->pCmdBuffer[0] = (cmd & 0x000000FF)
| ((address & 0x0000FF) << 24)
| ((address & 0x00FF00) << 8)
| ((address & 0xFF0000) >> 8);
// Update the SPI transfer descriptor
pCommand = &(pAt26->command);
pCommand->cmdSize = cmdSize;
pCommand->pData = pData;
pCommand->dataSize = dataSize;
pCommand->callback = callback;
pCommand->pArgument = pArgument;
// Start the SPI transfer
if (SPID_SendCommand(pAt26->pSpid, pCommand)) {
return AT26_ERROR_SPI;
}
return 0;
}