4 * Simple test for the SPI bus on the Gertboard
7 * D/A port 0 jumpered to A/D port 0.
9 * We output a sine wave on D/A port 0 and sample A/D port 0. We then
10 * copy this value to D/A port 1 and use a 'scope on both D/A ports
11 * to check all's well.
21 #include <gertboard.h>
29 printf ("Raspberry Pi Gertboard SPI test program\n") ;
31 if (gertboardSPISetup () == -1)
36 for (angle = 0 ; angle < 360 ; ++angle)
38 h1 = (int)rint (sin ((double)angle * M_PI / 180.0) * 127.0 + 128.0) ;
39 gertboardAnalogWrite (0, h1) ;
41 x1 = gertboardAnalogRead (0) ;
42 gertboardAnalogWrite (1, x1 >> 2) ; // 10-bit A/D, 8-bit D/A