コード例 #1
0
ファイル: ccspi.cpp プロジェクト: pscholl/CC3000Patch
void SpiWriteDataSynchronous(unsigned char *data, unsigned short size)
{
  unsigned char dummy;
  
  //DEBUGPRINT_F("\tCC3000: SpiWriteDataSynchronous Start\n\r");

  uint8_t loc;
  for (loc = 0; loc < size; loc ++) 
  {
    dummy = SPI.transfer(data[loc]);
#if (DEBUG_MODE == 1)
      if (!(loc==size-1))
      {
        //DEBUGPRINT_F(" ");
        DEBUGPRINT_HEX(data[loc]); 
      }
      else
      {
        //DEBUGPRINT_F(" ");
        DEBUGPRINT_HEX(data[loc]);
      }
#endif
  }
  
  //DEBUGPRINT_F("\n\r\tCC3000: SpiWriteDataSynchronous End\n\r");
}
コード例 #2
0
//*****************************************************************************
//
//!  simple_link_recv
//!
//!  @param sd       socket handle
//!  @param buf      read buffer
//!  @param len      buffer length
//!  @param flags    indicates blocking or non-blocking operation
//!  @param from     pointer to an address structure indicating source address
//!  @param fromlen  source address structure size
//!
//!  @return         Return the number of bytes received, or -1 if an error
//!                  occurred
//!
//!  @brief          Read data from socket
//!                  Return the length of the message on successful completion.
//!                  If a message is too long to fit in the supplied buffer,
//!                  excess bytes may be discarded depending on the type of
//!                  socket the message is received from
//
//*****************************************************************************
int
simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from,
                socklen_t *fromlen, long opcode)
{
	unsigned char *ptr, *args;
	tBsdReadReturnParams tSocketReadEvent;
	
	ptr = tSLInformation.pucTxCommandBuffer;
	args = (ptr + HEADERS_SIZE_CMD);
	
	// Fill in HCI packet structure
	args = UINT32_TO_STREAM(args, sd);
	args = UINT32_TO_STREAM(args, len);
	args = UINT32_TO_STREAM(args, flags);

	// Generate the read command, and wait for the 
	hci_command_send(opcode,  ptr, SOCKET_RECV_FROM_PARAMS_LEN);
	
	// Since we are in blocking state - wait for event complete
	SimpleLinkWaitEvent(opcode, &tSocketReadEvent);

	DEBUGPRINT_F("\n\r\tRecv'd data... Socket #");
	DEBUGPRINT_DEC(tSocketReadEvent.iSocketDescriptor);
	DEBUGPRINT_F(" Bytes: 0x");
	DEBUGPRINT_HEX(tSocketReadEvent.iNumberOfBytes);
	DEBUGPRINT_F(" Flags: 0x");
	DEBUGPRINT_HEX(tSocketReadEvent.uiFlags);
	DEBUGPRINT_F("\n\r");

	// In case the number of bytes is more then zero - read data
	if (tSocketReadEvent.iNumberOfBytes > 0)
	{
		// Wait for the data in a synchronous way. Here we assume that the bug is 
		// big enough to store also parameters of receive from too....
	  SimpleLinkWaitData((unsigned char *)buf, (unsigned char *)from, (unsigned char *)fromlen);
	}
	
	errno = tSocketReadEvent.iNumberOfBytes;

#if (DEBUG_MODE == 1)
	for (uint8_t i=0; i<errno; i++) {
	  uart_putchar(((unsigned char *)buf)[i]);
	}
#endif
	
	return(tSocketReadEvent.iNumberOfBytes);
}
コード例 #3
0
void SpiReadDataSynchronous(unsigned char *data, unsigned short size)
{
  unsigned short i = 0;
  
  DEBUGPRINT_F("\tCC3000: SpiReadDataSynchronous\n\r");
  SPI.setDataMode(SPI_MODE1);
  for (i = 0; i < size; i ++)
  {
    data[i] = SPI.transfer(0x03);
    DEBUGPRINT_F("  ");
    DEBUGPRINT_HEX(data[i]);
  }
  DEBUGPRINT_F("\n\r");
}
コード例 #4
0
void SpiWriteDataSynchronous(unsigned char *data, unsigned short size)
{
  DEBUGPRINT_F("\tCC3000: SpiWriteDataSynchronous Start\n\r");

  unsigned short loc;
  for (loc = 0; loc < size; loc ++) 
  {
      theCcspi->transfer(data[loc]);
#if (DEBUG_MODE == 1)
      if (!(loc==size-1))
      {
        DEBUGPRINT_F(" ");
        DEBUGPRINT_HEX(data[loc]); 
      }
      else
      {
        DEBUGPRINT_F(" ");
        DEBUGPRINT_HEX(data[loc]);
      }
#endif
  }
  
  DEBUGPRINT_F("\n\r\tCC3000: SpiWriteDataSynchronous End\n\r");
}