Ejemplo n.º 1
0
// ============================================================================
// fVerifySiliconID()
// Returns:
//     0 if successful
//     Si_ID_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fVerifySiliconID(void)
{
	SendVector(id_setup_2, num_bits_id_setup_2);

	fIsError = fDetectHiLoTransition();
	if (fIsError)
	{
#ifdef TX_ON
		UART_PutCRLF();
		UART_CPutString("fDetectHiLoTransition Error");
#endif
		return(SiID_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	SendVector(tsync_enable, num_bits_tsync_enable);

	//Send Read ID vector and get Target ID
	SendVector(read_id_v, 11);      // Read-MSB Vector is the first 11-Bits
	RunClock(2);                    // Two SCLK cycles between write & read
	bTargetID[0] = bReceiveByte();
	RunClock(1);
	SendVector(read_id_v+2, 12);    // 1+11 bits starting from the 3rd byte

	RunClock(2);                    // Read-LSB Command
	bTargetID[1] = bReceiveByte();

	RunClock(1);
	SendVector(read_id_v+4, 1);     // 1 bit starting from the 5th byte

	//read Revision ID from Accumulator A and Accumulator X
	//SendVector(read_id_v+5, 11);	//11 bits starting from the 6th byte
	//RunClock(2);
	//bTargetID[2] = bReceiveByte();	//Read from Acc.X
	//RunClock(1);
	//SendVector(read_id_v+7, 12);    //1+11 bits starting from the 8th byte
	//
	//RunClock(2);
	//bTargetID[3] = bReceiveByte();	//Read from Acc.A
	//
	//RunClock(1);
	//SendVector(read_id_v+4, 1);     //1 bit starting from the 5th byte,

	SendVector(tsync_disable, num_bits_tsync_disable);


#ifdef TX_ON
	// Print READ-ID
	UART_PutCRLF();
	UART_CPutString("Silicon-ID : ");
	UART_PutChar(' ');
	UART_PutHexByte(bTargetID[0]);
	UART_PutChar(' ');
	UART_PutHexByte(bTargetID[1]);
	UART_PutChar(' ');
#endif

#ifdef LCD_ON
	LCD_Char_Position(1, 0);
	LCD_Char_PrintString("ID : ");
	LCD_Char_PrintInt8(bTargetID[0]);
	LCD_Char_PutChar(' ');
	LCD_Char_PrintInt8(bTargetID[1]);
	LCD_Char_PutChar(' ');
#endif

	if (bTargetID[0] == target_id_v[0] && bTargetID[1] == target_id_v[1])
	{
		return(PASS);
	}
	else if (bTargetID[0] == target_id_v2[0] && bTargetID[1] == target_id_v2[1])	
	{
		return(PASS);
	}
	else
	{
		printk("%x %x \n", bTargetID[0], bTargetID[1]);
		return(SiID_ERROR);
	}
}
Ejemplo n.º 2
0
signed char fVerifySiliconID(void)
{
	SendVector(id_setup_2, num_bits_id_setup_2);
	fIsError = fDetectHiLoTransition();
	if (fIsError != 0) {
		#ifdef TX_ON
			TX8SW_PutCRLF();
			TX8SW_CPutString("fDetectHiLoTransition Error");
		#endif

		#ifdef LCD_ON
			LCD_Char_PrintString("fDetectHiLoTransition Error");
		#endif

		return SiID_ERROR;
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

 /*   Send Read ID vector and get Target ID */
	SendVector(read_id_v, 11); /*Read-MSB Vector is the first 11-Bits */
	RunClock(2);  /*Two SCLK cycles between write & read */
	bTargetID[0] = bReceiveByte();
	RunClock(1);
	 /* 1+11 bits starting from the 3rd byte */
	SendVector(read_id_v + 2, 12);
	RunClock(2);                    /* Read-LSB Command */
	bTargetID[1] = bReceiveByte();

	RunClock(1);
	SendVector(read_id_v+4, 1); /*1 bit starting from the 5th byte */


    #ifdef TX_ON
		 /*Print READ-ID */
		TX8SW_PutCRLF();
		TX8SW_CPutString("Silicon-ID : ");
		TX8SW_PutChar(' ');
		TX8SW_PutSHexByte(bTargetID[0]);
		TX8SW_PutChar(' ');
		TX8SW_PutSHexByte(bTargetID[1]);
		TX8SW_PutChar(' ');

		/* See the latest spec. 40-95002, 40-95004, 001-15870, AN2026d*/
		switch (bTargetID[0]) {
		case 0x00:
			TX8SW_CPutString(
				"\r\nPSoC1 = 00xx (including Ovation-ONS)");
			switch (bTargetID[1]) {
			case 0x68:
				TX8SW_CPutString(
					"\r\nCY8C20234 8K, 512B(Quark)");
				TargetDatabufLen = 64;
				NumBanks = 1;
				BlocksPerBank = 128;
				SecurityBytesPerBank = 64;
				break;
			case 0xAD:
				TX8SW_CPutString(
					"\r\nCY8C20446A-24LQXI 16K, 2K(Krypton)");
				TargetDatabufLen = 128;
				NumBanks = 1;
				BlocksPerBank = 128;
				SecurityBytesPerBank = 64;
				break;
			case 0x37:
				TX8SW_CPutString(
					"\r\nCY8C21334 Automotive(Neutron) 8K,512B");
				TargetDatabufLen = 64;
				NumBanks = 1;
				BlocksPerBank = 128;
				SecurityBytesPerBank = 64;
				break;
			case 0x38:
				TX8SW_CPutString(
					"\r\nCY8C21434 Neutron");
				TargetDatabufLen = 64;
				NumBanks = 1;
				BlocksPerBank = 128;
				SecurityBytesPerBank = 64;
				break;
			default:
				break;
			}
			break;
		case 0x01:
			TX8SW_CPutString(
				"\r\nPSoC1 = 01xx(continued family and mask set growth");
			break;
		case 0x02:
			TX8SW_CPutString(
				"\r\nPSoC1 + SmartSense = 02xx");
			break;
		case 0x03:
			TX8SW_CPutString("\r\nUnallocated = 03xx");
			break;
		case 0x04:
			TX8SW_CPutString("\r\nPower PSoC = 04xx");
			break;
		case 0x05:
			TX8SW_CPutString(
				"\r\nTrueTouch Multi-Touch All Points(TMA) = 05xx");
			switch (bTargetID[1]) {
			case 0x9A:
				TX8SW_CPutString(
					"\r\nCY8CTMA340-LQI-01");
				TargetDatabufLen = 128;
				NumBanks = 1;
				BlocksPerBank = 256;
				SecurityBytesPerBank = 64;
				break;
			default:
				break;
			}

			break;
		case 0x06:
			TX8SW_CPutString(
				"\r\nTrueTouch Single Touch(TST) = 06xx");
			break;
		case 0x07:
			TX8SW_CPutString(
				"\r\nTrueTouch Multi-Touch Gesture(TMG) = 07xx");
			break;
		case 0x08:
			TX8SW_CPutString(
				"\r\nPSoC1 Value = 08xx");
			break;
		case 0x09:
			TX8SW_CPutString(
				"\r\nPSoC1 PLC = 09xx");
			break;
		case 0x0A:
			TX8SW_CPutString(
				"\r\nPSoC1 PLC + Ez Color = 0Axx");
			break;
		case 0x0B:
			TX8SW_CPutString(
				"\r\nPSoC1 + SmartSense_EMC = 0Bxx");
			break;
		case 0x0C:
			TX8SW_CPutString(
				"\r\nHaptics Only = 0Cxx");
			break;
		case 0x0D:
			TX8SW_CPutString(
				"\r\nHaptics + TrueTouch Multi-Touch All Points(TMA) = 0Dxx");
			break;
		case 0x0E:
			TX8SW_CPutString(
				"\r\nHaptics + TrueTouch Single Touch(TST = 0Exx");
			break;
		case 0x0F:
			TX8SW_CPutString(
				"\r\nHaptics + TrueTouch Multi-Touch Gesture(TMG) = 0Fxx");
			break;
		default:
			TX8SW_CPutString("\r\nUnknown Silicon ID !!");
			while (1)
				;
			break;
		}
	  #endif

		target_id_v[0] = bTargetID[0];
		target_id_v[1] = bTargetID[1];

	#ifdef LCD_ON
		LCD_Char_Position(1, 0);
		LCD_Char_PrintString("ID : ");
		LCD_Char_PrintInt8(bTargetID[0]);
		LCD_Char_PutChar(' ');
		LCD_Char_PrintInt8(bTargetID[1]);
		LCD_Char_PutChar(' ');
	#endif



	if (bTargetID[0] != target_id_v[0] || bTargetID[1] != target_id_v[1])
		return SiID_ERROR;
	else
		return PASS;
}
Ejemplo n.º 3
0
int main()
{
    uint16 timerPeriod;
    int i;
    uint8 rxBuffer[SPIS_RX_PACKET_SIZE];
    uint8 txBuffer[SPIS_TX_PACKET_SIZE];
    char strBuffer[80];

    CyGlobalIntEnable; /* Enable global interrupts. */
   
    LCD_Char_Start();
    LCD_Char_PrintString(TITLE_STR1);
    LCD_Char_Position(1, 0);
    LCD_Char_PrintString(TITLE_STR2);
    CyDelay(2000);

    IDAC8_Start();
    Opamp_IV_Conv_Start();
    
    LCD_Char_ClearDisplay();
    LCD_Char_PrintString("Initialize OK.");
    CyDelay(1000);
    
    SPIS_Start();

    Timer_Sampling_Start();
    ISR_Timer_Sampling_StartEx(ISR_Saw_handler);
    
    frequency10 = 4400;
    squareDuty = 127;
    waveShape = WAVESHAPE_SAW;
    for(;;)
    {
        Pin_Check1_Write(1);

        if (Pin_SW1_Read() == 0u) {
            waveShape++;
            if (waveShape >= WAVESHAPE_N) {
                waveShape = WAVESHAPE_SQUARE;
            }
            switch (waveShape) {
            case WAVESHAPE_SQUARE:
                ISR_Timer_Sampling_StartEx(ISR_Square_handler);
                break;
            case WAVESHAPE_SAW:
                ISR_Timer_Sampling_StartEx(ISR_Saw_handler);
                break;
            }
        }

        squareDuty += (readRE() << 2);
        
        if (SPIS_RX_PACKET_SIZE <= SPIS_SpiUartGetRxBufferSize()) {
            // RX
            for (i = 0; i < SPIS_RX_PACKET_SIZE; i++) {
                rxBuffer[i] = SPIS_SpiUartReadRxData();
            }
            frequency10 = ((uint16)rxBuffer[1] << 8) | rxBuffer[2];

            // TX
            txBuffer[0] = rxBuffer[0];
            txBuffer[1] = rxBuffer[1];
            txBuffer[2] = rxBuffer[2];
            SPIS_SpiUartPutArray(txBuffer, SPIS_TX_PACKET_SIZE);
        
            // コマンドの実行
            timerPeriod = SAMPLING_CLOCK * 10 / (frequency10 * 256);
            Timer_Sampling_WritePeriod(timerPeriod);
            
            // LCDに表示
            sprintf(strBuffer, "RX: %03u %03u %03u   \r\n", rxBuffer[0], rxBuffer[1], rxBuffer[2]);
            UART_UartPutString(strBuffer);
                
            LCD_Char_ClearDisplay();
            strBuffer[15] = 0;
            LCD_Char_Position(0, 0);
            LCD_Char_PrintString(strBuffer);

            sprintf(strBuffer, "%ld %d %d     ", frequency10, timerPeriod, squareDuty);
            UART_UartPutString(strBuffer);

            LCD_Char_Position(1, 0);
            LCD_Char_PrintString(strBuffer);
        }    
        Pin_Check1_Write(0);
        //CyDelay(200);
    }
}