This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| flink_lib:high_level_example [2016/02/25 13:32] – external edit 127.0.0.1 | flink_lib:high_level_example [2020/05/26 17:14] (current) – ursgraf | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| #include < | #include < | ||
| #include < | #include < | ||
| + | #include < | ||
| #include < | #include < | ||
| - | + | ||
| - | #define DEFAULT_DEV "/ | + | |
| int main(void) { | int main(void) { | ||
| + | char* | ||
| flink_dev* | flink_dev* | ||
| flink_subdev* subdev; | flink_subdev* subdev; | ||
| char* | char* | ||
| - | | + | |
| uint32_t | uint32_t | ||
| int error = 0; | int error = 0; | ||
| - | + | ||
| // Open flink device | // Open flink device | ||
| - | dev = flink_open(DEFAULT_DEV ); | + | dev = flink_open(DEFAULT_DEV); |
| if(dev == NULL) { | if(dev == NULL) { | ||
| fprintf(stderr, | fprintf(stderr, | ||
| return -1; | return -1; | ||
| } | } | ||
| - | + | ||
| // Get a pointer to the choosen subdevice | // Get a pointer to the choosen subdevice | ||
| - | subdev = flink_get_subdevice_by_id(dev, subdevice_id ); | + | subdev = flink_get_subdevice_by_unique_id(dev, subdevice_id ); |
| if(subdev == NULL) { | if(subdev == NULL) { | ||
| fprintf(stderr, | fprintf(stderr, | ||
| return -1; | return -1; | ||
| } | } | ||
| - | + | ||
| // Set I/O direction to output | // Set I/O direction to output | ||
| error = flink_dio_set_direction(subdev, | error = flink_dio_set_direction(subdev, | ||
| if(error != 0) { | if(error != 0) { | ||
| - | | + | |
| return -1; | return -1; | ||
| } | } | ||
| - | + | ||
| - | // Write ' | + | // toggle an output |
| - | error = flink_dio_set_value(subdev, | + | |
| - | if(error != 0) { | + | for (int count = 0; count < 200; count++) { |
| - | | + | |
| - | return -1; | + | if(error != 0) { |
| + | | ||
| + | return -1; | ||
| + | } | ||
| + | usleep(100000); | ||
| + | out = !out; | ||
| } | } | ||
| - | + | ||
| // Close flink device | // Close flink device | ||
| flink_close(dev); | flink_close(dev); | ||
| - | | + | |
| return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
| } | } | ||
| </ | </ | ||