Пример #1
0
static void SdCardWaitReady(void)
{
  if( QueryMessageStatus(SD_u32CurrentMsgToken) == COMPLETE )
  {  
    if( *SD_pu8RxBufferParser != 0xFF )
    {
      SD_u32CurrentMsgToken = SspReadByte(SD_Ssp);
      if( !SD_u32CurrentMsgToken )
      {
        /* We didn't get a return token, so abort */
        SD_u8ErrorCode = SD_ERROR_NO_TOKEN;
        SD_pfnStateMachine = SdError;
      }

      AdvanceSD_pu8RxBufferParser(1);
    }
    /* The card is ready for the command */
    else
    {
      SD_u32CurrentMsgToken = SspWriteData(SD_Ssp, SD_CMD_SIZE, SD_NextCommand);
      
      /* Pre-emptively move RxBufferParser so it will point to command response */
      AdvanceSD_pu8RxBufferParser(SD_CMD_SIZE);
    
      /* Set up time-outs and next state */
      SD_u32Timeout = G_u32SystemTime1ms;
      SD_pfnStateMachine = SdCardWaitCommand;
    }
  }
  
  /* Watch for SSP timeout */
  CheckTimeout(SD_SPI_WAIT_TIME_MS);
     
} /* end SdCardWaitReady() */
Пример #2
0
/*----------------------------------------------------------------------------------------------------------------------
Function: SspReadData

Description:
Gets multiple bytes from the slave on the target SSP peripheral.  

Requires:
  - psSspPeripheral_ has been requested and holds a valid pointer to a transmit buffer; even if a transmission is
    in progress, the node in the buffer that is currently being sent will not be destroyed during this function.
  - The chip select line of the SSP device should be asserted
  - u32Size_ is the number of bytes in the data array

Promises:
  - Adds a dummy byte message at psSspPeripheral_->pTransmitBuffer that will be sent by the SSP application
    when it is available and thus clock in the received bytes to the designated Rx buffer.
  - Returns the message token of the dummy message used to read data
*/
u32 SspReadData(SspPeripheralType* psSspPeripheral_, u32 u32Size_)
{
  return( SspWriteData(psSspPeripheral_, u32Size_, &SSP_au8Dummies[0]) );
    
} /* end SspReadData() */