123456789101112131415161718192021222324252627282930313233 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdint.h>
- #include "bus.h"
- #ifdef __linux__
-
- #define PIN_DATA 0
- #define PIN_CLK 1
- #define PIN_ACK 2
- int main()
- {
- bus_t bus;
- pthread_t thread;
- FILE* file = NULL;
- init_read_pin(PIN_DATA, PIN_CLK, PIN_ACK);
- bus_init_recv(&bus, PIN_DATA, PIN_CLK, PIN_ACK);
- pthread_create(&thread, NULL, bus_recv_thread, &bus);
- while(1)
- {
- uint32_t c;
- bus_read(&bus, &c, 4);
- file=fopen("data", "r+");
- fprintf(file,"%u\n", c);
- fclose(file);
- }
- free_fifo(PIN_DATA, PIN_CLK, PIN_ACK);
- }
- #endif
|