コード例 #1
0
ファイル: Events.c プロジェクト: zhangsaisai/SEMG
/*
** ===================================================================
**     Event       :  TI1_OnInterrupt (module Events)
**
**     Component   :  TI1 [TimerInt]
**     Description :
**         When a timer interrupt occurs this event is called (only
**         when the component is enabled - <Enable> and the events are
**         enabled - <EnableEvent>). This event is enabled only if a
**         <interrupt service/event> is enabled.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
void TI1_OnInterrupt(void)
{
  /* Write your code here ... */
	  int i ;
	  i = 0;
	
	  /* Master sends message 1  */ 
	  printf("\n\nMaster: Sending command...\n");
	  PCS_ClrVal(NULL);
	  for(i=0;i<10;i++){} //Delay
	  master_send[0] = 0x01;
	  SM1_SendBlock(SM1_DeviceData, master_send, COMM_SIZE); 
	  for(i=0;i<100000;i++){} //Delay
	  PCS_SetVal(NULL);
	  
	  /* Master sends dummy message to receive response from slave */
	  printf("\n\nMaster: Sending data...\n");
	  PCS_ClrVal(NULL);
	  for(i=0;i<10;i++){} //Delay
	  master_send[0] = 0x03; 
	  SM1_SendBlock(SM1_DeviceData, master_send, DATA_SIZE);   
	  SM1_ReceiveBlock(SM1_DeviceData, master_receive, DATA_SIZE);
	  for(i=0;i<100000;i++){} //Delay
	  //MasterReceivedFlg = FALSE;
	  //while(!MasterReceivedFlg);
	  PCS_SetVal(NULL);
	  MasterReceivedFlg = FALSE;
}
コード例 #2
0
ファイル: w5100.c プロジェクト: appserver/mcuoneclipse
static void SPIWriteByte(unsigned char write) {
  unsigned char dummy;

  W5100_DataReceivedFlag = FALSE;
  (void)SM1_ReceiveBlock(SM1_DeviceData, &dummy, sizeof(dummy));
  (void)SM1_SendBlock(SM1_DeviceData, &write, sizeof(write));
  while(!W5100_DataReceivedFlag){}
}
コード例 #3
0
ファイル: VS1053.c プロジェクト: ADeadCat/mcuoneclipse
static void VS_SPI_WRITE(unsigned char write) {
  unsigned char dummy;

  VS_SPIDataReceivedFlag = FALSE;
  (void)SM1_ReceiveBlock(SM1_DeviceData, &dummy, sizeof(dummy));
  (void)SM1_SendBlock(SM1_DeviceData, &write, sizeof(write));
  while(!VS_SPIDataReceivedFlag){}
}
コード例 #4
0
ファイル: w5100.c プロジェクト: appserver/mcuoneclipse
static uint8_t SPIReadByte(void) {
  uint8_t val, write = 0xff; /* dummy */
  
  W5100_DataReceivedFlag = FALSE;
  (void)SM1_ReceiveBlock(SM1_DeviceData, &val, 1);
  (void)SM1_SendBlock(SM1_DeviceData, &write, 1);
  while(!W5100_DataReceivedFlag){}
  return val;
}
コード例 #5
0
/**
*  @brief  Spi read
*
*  SPI read function. Without toggling CS.
*
*  @param  Pointer to input buffer.
*  @param  Number of bytes to read
*
*  @return Number of bytes that were read successfully
*/
unsigned int SPI_Read( char* recvbyte, char size){

	SMasterLdd1_TDeviceDataPtr DeviceDataPrv = SMasterLdd1_DeviceDataPtr;

	if (!size)
		return 0;

	SM1_ReceiveBlock(DeviceDataPrv, recvbyte, size);
	SM1_SendBlock(DeviceDataPrv, recvbyte, size);

	while (DeviceDataPrv->InpRecvDataNum != size)
		;

	return size;
}
コード例 #6
0
ファイル: ProcessorExpert.c プロジェクト: zhangsaisai/SEMG
int main(void)
{
  /* Write your local variable definition here */
  uint8_t MasterReceiveFlag = FALSE; 
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  masterDevData = SM1_Init(&MasterReceiveFlag);

  //printf("PTD3 and PTE1\n\r");
  //printf("PTD2 and PTE3\n\r");
  //printf("PTD1 and PTE2\n\r");
  //printf("PTD0 and PTE4\n\r");
  //printf("\n\r"); 
  
  
  //Put request for reading from SPI
  //SS1_ReceiveBlock(slaveDevData, (LDD_TData*)buffSlave, sizeof(buffSlave)); 
  
  for(;;)
  {
	  
	  while(read_data)
	  {
	  //when slave receive the data , "SM1_ReceiveBlock" is not necessary
	  //Prepare master for dummy data from slave
	  //SM1_ReceiveBlock(masterDevData, (LDD_TData*)&buffDummy, sizeof(buffDummy)); 
	
	  //Master sends request to slave
	  SM1_SendBlock(masterDevData, (LDD_TData*)msgMaster, sizeof(msgMaster) );
	
	  //To provide clock for slave, master sends anything that is as long as expected answer from slave. length(msgDummy) = length(msgSlave)
	  SM1_SendBlock(masterDevData, (LDD_TData*)msgDummy, sizeof(msgDummy) );  
	
	  
	  //Put request for reading from SPI
	  err = SM1_ReceiveBlock(masterDevData, (LDD_TData*)buffMaster, sizeof(buffMaster)); 
	  if (err != ERR_OK) { 
		  //printf(" ERROR requesting read operation (master).\n\r");
	  }
	  
	  
	  //Master waits for data from slave
	  MasterReceiveFlag = FALSE;
	  while(!MasterReceiveFlag);
	  //Compare sent and received message
	  //printf("Data path slave -> master: ");
	  if (strcmp((char*)buffMaster, (char*)msgSlave) == 0) { 
		printf("Result: PASSED\n\r");	
	  } else {
		printf("Result: FAILED !!!\n\r");
	  }
	  
	  read_data = 0;
	  //printf("+++ Step 1 - end +++\n\r");
	  

	  
	  }
	  
	  
  }
  
  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
コード例 #7
0
ファイル: VS1053.c プロジェクト: ADeadCat/mcuoneclipse
static void VS_SPI_WRITE_READ(unsigned char write, unsigned char *readP) {
  VS_SPIDataReceivedFlag = FALSE;
  (void)SM1_ReceiveBlock(SM1_DeviceData, readP, 1);
  (void)SM1_SendBlock(SM1_DeviceData, &write, 1);
  while(!VS_SPIDataReceivedFlag){}
}