diff --git a/EXAMPLES_C++/jetgpio_PWM_example.cpp b/EXAMPLES_C++/jetgpio_PWM_example.cpp index 417d25b..2aae782 100644 --- a/EXAMPLES_C++/jetgpio_PWM_example.cpp +++ b/EXAMPLES_C++/jetgpio_PWM_example.cpp @@ -39,8 +39,7 @@ int main(int argc, char *argv[]) /* PWM frequency set up okay*/ printf("PWM frequency set up okay at pin 32. Return code: %d\n", PWMstat); } -/* Set up PWM duty cycle to approx 50% (0=0% to 256=100%) @ pin 32*/ - + /* Set up PWM duty cycle to approx 50% (0=0% to 256=100%) @ pin 32*/ int PWMstat2 = gpioPWM(32, 127); if (PWMstat2 < 0) @@ -61,7 +60,7 @@ int main(int argc, char *argv[]) sleep(2); x++; } -// Terminating library + // Terminating library gpioTerminate(); printf("PWM stopped, bye!\n"); exit(0); diff --git a/EXAMPLES_C++/jetgpio_edge.cpp b/EXAMPLES_C++/jetgpio_edge.cpp index 43c4a62..5a3df0e 100644 --- a/EXAMPLES_C++/jetgpio_edge.cpp +++ b/EXAMPLES_C++/jetgpio_edge.cpp @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) printf("gpio setting up okay. Return code: %d\n", stat); } -// Now setting up pin 3 to detect edges, rising & falling edge with a 1000 useconds debouncing and when event is detected calling func "calling" + // Now setting up pin 3 to detect edges, rising & falling edge with a 1000 useconds debouncing and when event is detected calling func "calling" int stat2 = gpioSetISRFunc(3, EITHER_EDGE, 1000, ×tamp, &calling); if (stat2 < 0) { @@ -77,13 +77,13 @@ int main(int argc, char *argv[]) printf("gpio edge setting up okay. Return code: %d\n", stat2); } -/* Now wait for the edge to be detected */ + /* Now wait for the edge to be detected */ printf("Capturing edges, press Ctrl-c to terminate\n"); while (interrupt) { // Do some stuff sleep(1); } -// Terminating library + // Terminating library gpioTerminate(); exit(0); } diff --git a/EXAMPLES_C++/jetgpio_example.cpp b/EXAMPLES_C++/jetgpio_example.cpp index 141d6c5..b98b977 100644 --- a/EXAMPLES_C++/jetgpio_example.cpp +++ b/EXAMPLES_C++/jetgpio_example.cpp @@ -24,8 +24,7 @@ int main(int argc, char *argv[]) printf("Jetgpio initialisation OK. Return code: %d\n", Init); } -// Setting up pin 3 as OUTPUT and 7 as INPUT - + // Setting up pin 3 as OUTPUT and 7 as INPUT int stat1 = gpioSetMode(3, JET_OUTPUT); if (stat1 < 0) { @@ -52,8 +51,7 @@ int main(int argc, char *argv[]) printf("gpio setting up okay. Return code: %d\n", stat2); } -// Writing 1 and 0 to pin 3 at 1 second intervals while reading pin 7 - + // Writing 1 and 0 to pin 3 at 1 second intervals while reading pin 7 int x =0; int level = 0; while (x<5) { @@ -70,7 +68,7 @@ int main(int argc, char *argv[]) x++; } -// Terminating library + // Terminating library gpioTerminate(); exit(0); diff --git a/EXAMPLES_C++/jetgpio_i2c_example.cpp b/EXAMPLES_C++/jetgpio_i2c_example.cpp index a821fbf..e7ffdfa 100644 --- a/EXAMPLES_C++/jetgpio_i2c_example.cpp +++ b/EXAMPLES_C++/jetgpio_i2c_example.cpp @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) printf("Jetgpio initialisation OK. Return code: %d\n", Init); } -/* Opening the connection to the I2C slave MPU6050 */ + /* Opening the connection to the I2C slave MPU6050 */ int MPU6050 = i2cOpen(0,0); if (MPU6050 >= 0) @@ -61,17 +61,17 @@ int main(int argc, char *argv[]) printf("Open I2C port failed. Quitting MPU6050 Error code: %d\n", MPU6050); } -/* Wake up the MPU-6050 with slave address 0x68 since it starts in sleep mode */ + /* Wake up the MPU-6050 with slave address 0x68 since it starts in sleep mode */ int writestat = i2cWriteByteData(MPU6050, MPU6050_SLAVE_ADDRESS, PWR_MGMT_1, 0x00); printf("write return: %d\n",writestat); usleep(100000); -/* Now set up the accelerator range to 4G */ + /* Now set up the accelerator range to 4G */ writestat = i2cWriteByteData(MPU6050, MPU6050_SLAVE_ADDRESS, ACCEL_CONFIG, ACCEL_RANGE_4G); printf("write return: %d\n",writestat); usleep(100000); -/* Now set up the gyroscope range to 250 deg/second */ + /* Now set up the gyroscope range to 250 deg/second */ writestat = i2cWriteByteData(MPU6050, MPU6050_SLAVE_ADDRESS, GYRO_CONFIG, GYRO_RANGE_250DEG); printf("write return: %d\n",writestat); usleep(100000); @@ -117,7 +117,7 @@ int main(int argc, char *argv[]) x++; } -/* Closing i2c connection */ + /* Closing i2c connection */ int i2cstat = i2cClose(MPU6050); if (i2cstat >= 0) @@ -131,7 +131,7 @@ int main(int argc, char *argv[]) printf("Closing I2C port failed. Quitting MPU6050 thread Error code: %d\n", i2cstat); } -/* Terminating library */ + /* Terminating library */ gpioTerminate(); exit(0); diff --git a/EXAMPLES_C++/lcd_i2c.cpp b/EXAMPLES_C++/lcd_i2c.cpp index 7bddb2d..e04e23e 100644 --- a/EXAMPLES_C++/lcd_i2c.cpp +++ b/EXAMPLES_C++/lcd_i2c.cpp @@ -105,11 +105,9 @@ int main(int argc, char *argv[]){ } // Closing i2c connection - i2cClose(lcd); // Terminating library - gpioTerminate(); exit(0); diff --git a/EXAMPLES_C++/spi_loop.cpp b/EXAMPLES_C++/spi_loop.cpp index aede4cc..640da34 100644 --- a/EXAMPLES_C++/spi_loop.cpp +++ b/EXAMPLES_C++/spi_loop.cpp @@ -28,13 +28,12 @@ int main(int argc, char *argv[]) printf("Jetgpio initialisation OK. Return code: %d\n", Init); } -/* Port SPI2 pins: 37, 22, 13 & 18 - to perform a simple loop test, pins 22: SPI2_MISO & 37:SPI2_MOSI should be connected - with a short jumper cable, when the cable is disconnected the output on screen will show - all the rx values as zeros - spiOpen() parameters go as follows: spiOpen(port number, speed in Hz, mode, cs pin delay in us, - bits per word, least significant bit first, cs change) -*/ + /* Port SPI2 pins: 37, 22, 13 & 18 + to perform a simple loop test, pins 22: SPI2_MISO & 37:SPI2_MOSI should be connected + with a short jumper cable, when the cable is disconnected the output on screen will show all the rx values as zeros + spiOpen() parameters go as follows: spiOpen(port number, speed in Hz, mode, cs pin delay in us, + bits per word, least significant bit first, cs change) + */ SPI_init = spiOpen(1, 5000000, 0, 0, 8, 1, 1); if (SPI_init < 0) @@ -57,8 +56,7 @@ int main(int argc, char *argv[]) tx[5] = 0xFF; tx[6] = 0x11; -//Transfer data through register numbers for x, y & z axis - + //Transfer data through register numbers for x, y & z axis int i = 0; while (i<20){ @@ -96,10 +94,10 @@ int main(int argc, char *argv[]) sleep(1); } -// Closing spi port + // Closing spi port spiClose(SPI_init); -// Terminating library + // Terminating library gpioTerminate(); exit(0); diff --git a/EXAMPLES_C++/test_PWM.cpp b/EXAMPLES_C++/test_PWM.cpp index 5534655..0d79734 100644 --- a/EXAMPLES_C++/test_PWM.cpp +++ b/EXAMPLES_C++/test_PWM.cpp @@ -47,8 +47,7 @@ int main(int argc, char *argv[]) int level = 0; -// Increase brightness - + // Increase brightness while (x<=256) { usleep(100000); @@ -67,8 +66,8 @@ int main(int argc, char *argv[]) } x = 256; -// Decrease brightness + // Decrease brightness while (x>=0) { usleep(100000); diff --git a/EXAMPLES_C/jetgpio_example.c b/EXAMPLES_C/jetgpio_example.c index 7d45bdf..9865e63 100644 --- a/EXAMPLES_C/jetgpio_example.c +++ b/EXAMPLES_C/jetgpio_example.c @@ -54,8 +54,7 @@ int main(int argc, char *argv[]) printf("gpio setting up okay. Return code: %d\n", stat2); } - // Writing 1 and 0 to pin 3 a 1 second intervals while reading pin 7 - + // Writing 1 and 0 to pin 3 a 1 second intervals while reading pin 7 int x =0; int level = 0; while (x<5) { diff --git a/EXAMPLES_C/test_PWM.c b/EXAMPLES_C/test_PWM.c index 21c8403..0d0cba5 100644 --- a/EXAMPLES_C/test_PWM.c +++ b/EXAMPLES_C/test_PWM.c @@ -50,7 +50,6 @@ int main(int argc, char *argv[]) int level = 0; // Increase brightness - while (x<=256) { usleep(100000); @@ -69,8 +68,8 @@ int main(int argc, char *argv[]) } x = 256; + // Decrease brightness - while (x>=0) { usleep(100000);