/*
 * Example1.java - TAC, 05/20/2000
 */

/* Copyright (C) 1999, 2000 Dallas Semiconductor Corporation.
 * All rights Reserved. Printed in U.S.A.
 * This software is protected by copyright laws of
 * the United States and of foreign countries.
 * This material may also be protected by patent laws of the United States
 * and of foreign countries.
 * This software is furnished under a license agreement and/or a
 * nondisclosure agreement and may only be used or copied in accordance
 * with the terms of those agreements.
 * The mere transfer of this software does not imply any licenses
 * of trade secrets, proprietary technology, copyrights, patents,
 * trademarks, maskwork rights, or any other form of intellectual
 * property whatsoever. Dallas Semiconductor retains all ownership rights.
 */
/*
 $Workfile: spi400test.java $
 $Revision: 8 $
 $Date: 03/22/03 4:25a $
 $Author: N.Z.Gustavson $
 $Modtime: 7/14/03 10:56a $
*/

import com.dalsemi.system.*;

/**

 */
public class spi400test
{

  public static void main(String[] args)
  {
    System.out.println("Starting DS400em spi test");

    try
    {
      // attempt to load our native library
      int cpuType = TINIOS.getCPU();   // Get CPU type


      byte[] b = new byte[40];

      int  i = 678;
      long l = 12345L;




      //create a txrx buffer
      byte[] buffer = new byte[2];
      buffer[0] = (byte) 0xaa;
      buffer[1] = (byte) 0x88;
      //open the spi device with no clock divider, spi cs 3 on CPOL=0 CPHA=1
      SPI400EM port = new SPI400EM(false, 0,false, true);
      //trancieve the buffer
      port.xmit(buffer,0,buffer.length);

      port.xmit(buffer,0,buffer.length);
      //print recieved buffer to the screen
      System.out.println("SPI method returned: "+buffer[0]+","+buffer[1]);


    }
    catch(Throwable t)
    {
      System.out.println(t);
    }

    System.out.println("Exiting DS400em SPI test");
  }
}
