Difference between
modified post 96c3 by Anonymous on Fri 13th Dec 2019 14:57
original post 226d8e2 by Anonymous on Fri 13th Dec 2019 14:55
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | /* | |
| 2 | 2 | * qaweep1.c - Quantron beeper-weeper demo V0.0.1 | |
| 3 | 3 | * | |
| 4 | 4 | * Written by Roland Mainz <r.mainz@eckelmann.de> | |
| 5 | 5 | */ | |
| 6 | 6 | ||
| 7 | 7 | /* | |
| 8 | 8 | * Compile with | |
| 9 | 9 | * $ /opt/OSELAS.Toolchain-2012.12.0/arm-v5te-linux-gnueabi/gcc-4.7.2-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/bin/arm-v5te-linux-gnueabi-gcc -std=gnu99 -g -Wall -fno-use-linker-plugin qaweep1.c | |
| 10 | 10 | */ | |
| 11 | 11 | #include <errno.h> | |
| 12 | 12 | #include <fcntl.h> | |
| 13 | 13 | #include <stdio.h> | |
| 14 | 14 | #include <stdlib.h> | |
| 15 | 15 | #include <sys/stat.h> | |
| 16 | 16 | #include <sys/types.h> | |
| 17 | 17 | #include <unistd.h> | |
| 18 | 18 | ||
| 19 | 19 | #define NUM_ELEMENTS_IN_ARRAY(ar) (sizeof(ar) / sizeof (ar[0])) | |
| 20 | 20 | const double freqs[] = { | |
| 21 | 21 | 440.0000, | |
| 22 | 22 | 466.1638, | |
| 23 | 23 | 493.8833, | |
| 24 | 24 | 523.2511, | |
| 25 | 25 | 554.3653, | |
| 26 | 26 | 587.3295, | |
| 27 | 27 | 622.2540, | |
| 28 | 28 | 659.2551, | |
| 29 | 29 | 698.4565, | |
| 30 | 30 | 739.9888, | |
| 31 | 31 | 783.9909, | |
| 32 | 32 | 830.6094, | |
| 33 | 33 | 880.0000, | |
| 34 | 34 | 932.3275, | |
| 35 | 35 | 987.7666, | |
| 36 | 36 | 1046.502, | |
| 37 | 37 | 1108.731, | |
| 38 | 38 | 1174.659, | |
| 39 | 39 | 1244.508 | |
| 40 | 40 | }; | |
| 41 | 41 | ||
| 42 | 42 | #define MICROSECONDS_PER_SEC (1000000L) | |
| 43 | 43 | ||
| 44 | 44 | static | |
| 45 | 45 | int cycle_loop(int fd, long cycles, long low_delay, long high_delay) | |
| 46 | 46 | { | |
| 47 | - | int retval = 0; | |
| 48 | 47 | int i; | |
| 49 | 48 | ||
| 50 | 49 | for (i = 0; i < cycles; i++) { | |
| 51 | - | if (write(fd, "1", 1) != 1) { | |
| 50 | + | if (write(fd, "1", 1) != 1) | |
| 52 | - | goto exit_ioerr; | |
| 51 | + | return 0; | |
| 54 | 52 | ||
| 55 | 53 | (void)usleep(low_delay); | |
| 56 | 54 | ||
| 57 | - | if (write(fd, "0", 1) != 1) { | |
| 55 | + | if (write(fd, "0", 1) != 1) | |
| 58 | - | goto exit_ioerr; | |
| 56 | + | return 0; | |
| 60 | 57 | ||
| 61 | 58 | (void)usleep(high_delay); | |
| 62 | 59 | } | |
| 63 | 60 | ||
| 64 | - | retval = 1; | |
| 61 | + | return 1; | |
| 62 | + | } | |
| 66 | 63 | ||
| 64 | + | int main(int ac, char *av[]) |
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
eckelmann.kpaste.net RSS