Example #1
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_SPIJNI
 * Method:    spiClose
 * Signature: (B)V
 */
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiClose
  (JNIEnv *, jclass, jbyte port)
{
	SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiClose";
	SPIJNI_LOG(logDEBUG) << "Port = " << (jint) port;
	spiClose(port);
}
Example #2
0
int main(int argc, char *argv[])
{
   int loops=LOOPS;
   int speed=SPEED;
   int bytes=BYTES;
   int i;
   int h;
   double start, diff, sps;
   unsigned char buf[16384];

   if (argc > 1) bytes = atoi(argv[1]);
   if ((bytes < 1) || (bytes > 16383)) bytes = BYTES;

   if (argc > 2) speed = atoi(argv[2]);
   if ((speed < 32000) || (speed > 32000000)) speed = SPEED;

   if (argc > 3) loops = atoi(argv[3]);
   if ((loops < 1) || (loops > 10000000)) loops = LOOPS;

   if (gpioInitialise() < 0) return 1;

   h = spiOpen(0, speed, 0);

   if (h < 0) return 2;

   start = time_time();

   for (i=0; i<loops; i++)
   {
      spiXfer(h, buf, buf, bytes);
   }

   diff = time_time() - start;

   printf("sps=%.1f: %d bytes @ %d bps (loops=%d time=%.1f)\n",
      (double)loops / diff, bytes, speed, loops, diff);

   spiClose(h);

   gpioTerminate();

   return 0;
}
/*
 * Class:     io_silverspoon_bulldog_linux_jni_NativeSpi
 * Method:    spiClose
 * Signature: (I)I
 */
JNIEXPORT jint JNICALL Java_io_silverspoon_bulldog_linux_jni_NativeSpi_spiClose
  (JNIEnv * env, jclass clazz, jint fileDescriptor) {
	return spiClose(fileDescriptor);
}