Revision 4e5429b2
| b/host/apps/omap_debug/usrp-e-ctl.c | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <stdlib.h> |
|
| 3 |
#include <sys/types.h> |
|
| 4 |
#include <fcntl.h> |
|
| 5 |
#include <linux/ioctl.h> |
|
| 6 |
|
|
| 7 |
#include "usrp1_e.h" |
|
| 8 |
|
|
| 9 |
// Usage: usrp1_e_ctl w|r offset number_of_values val1 val2 .... |
|
| 10 |
|
|
| 11 |
int main(int argc, char *argv[]) |
|
| 12 |
{
|
|
| 13 |
int fp, i, cnt, ret; |
|
| 14 |
struct usrp1_e_ctl *ctl_data; |
|
| 15 |
|
|
| 16 |
if (argc < 4) {
|
|
| 17 |
printf("Usage: usrp1_e_ctl w|r offset number_of_values val1 val2 ....\n");
|
|
| 18 |
exit(-1); |
|
| 19 |
} |
|
| 20 |
|
|
| 21 |
cnt = atoi(argv[3]); |
|
| 22 |
|
|
| 23 |
ctl_data = malloc(sizeof(struct usrp1_e_ctl) + cnt*2); |
|
| 24 |
|
|
| 25 |
ctl_data->offset = atoi(argv[2]); |
|
| 26 |
ctl_data->count = cnt; |
|
| 27 |
|
|
| 28 |
printf("Sizeof usrp1_e_ctl struct = %d\n", sizeof(struct usrp1_e_ctl));
|
|
| 29 |
|
|
| 30 |
fp = open("/dev/usrp1_e0", O_RDWR);
|
|
| 31 |
printf("fp = %d\n", fp);
|
|
| 32 |
|
|
| 33 |
if (*argv[1] == 'w') {
|
|
| 34 |
for (i=0; i<cnt; i++) |
|
| 35 |
ctl_data->buf[i] = atoi(argv[4+i]); |
|
| 36 |
|
|
| 37 |
ret = ioctl(fp, USRP1_E_WRITE_CTL, ctl_data); |
|
| 38 |
printf("Return value from write ioctl = %d\n", ret);
|
|
| 39 |
} |
|
| 40 |
|
|
| 41 |
if (*argv[1] == 'r') {
|
|
| 42 |
ret = ioctl(fp, USRP1_E_READ_CTL, ctl_data); |
|
| 43 |
printf("Return value from write ioctl = %d\n", ret);
|
|
| 44 |
|
|
| 45 |
for (i=0; i<ctl_data->count; i++) {
|
|
| 46 |
if (!(i%8)) |
|
| 47 |
printf("\nData at %4d :", i);
|
|
| 48 |
printf(" %5d", ctl_data->buf[i]);
|
|
| 49 |
} |
|
| 50 |
printf("\n");
|
|
| 51 |
} |
|
| 52 |
} |
|
| b/host/apps/omap_debug/usrp-e-ram.c | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <sys/types.h> |
|
| 3 |
#include <fcntl.h> |
|
| 4 |
|
|
| 5 |
int main(int rgc, char *argv[]) |
|
| 6 |
{
|
|
| 7 |
int fp, i, cnt; |
|
| 8 |
unsigned short buf[1024]; |
|
| 9 |
unsigned short buf_rb[1024]; |
|
| 10 |
|
|
| 11 |
fp = open("/dev/usrp1_e0", O_RDWR);
|
|
| 12 |
printf("fp = %d\n", fp);
|
|
| 13 |
|
|
| 14 |
for (i=0; i<1024; i++) |
|
| 15 |
buf[i] = i*256; |
|
| 16 |
write(fp, buf, 2048); |
|
| 17 |
read(fp, buf_rb, 2048); |
|
| 18 |
|
|
| 19 |
printf("Read back %hX %hX\n", buf_rb[0], buf_rb[1]);
|
|
| 20 |
|
|
| 21 |
for (i=0; i<1024; i++) {
|
|
| 22 |
if (buf[i] != buf_rb[i]) |
|
| 23 |
printf("Read - %hX, expected - %hX\n", buf_rb[i], buf[i]);
|
|
| 24 |
} |
|
| 25 |
} |
|
| b/host/apps/omap_debug/usrp-e-read.c | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <sys/types.h> |
|
| 3 |
#include <fcntl.h> |
|
| 4 |
|
|
| 5 |
int main(int rgc, char *argv[]) |
|
| 6 |
{
|
|
| 7 |
int fp, cnt; |
|
| 8 |
short buf[1024]; |
|
| 9 |
|
|
| 10 |
fp = open("/dev/usrp1_e0", O_RDONLY);
|
|
| 11 |
printf("fp = %d\n", fp);
|
|
| 12 |
|
|
| 13 |
do {
|
|
| 14 |
cnt = read(fp, buf, 2048); |
|
| 15 |
// printf("Bytes read - %d\n", cnt);
|
|
| 16 |
} while(1); |
|
| 17 |
printf("Data - %hX\n", buf[0]);
|
|
| 18 |
} |
|
| b/host/apps/omap_debug/usrp-e-rw.c | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <sys/types.h> |
|
| 3 |
#include <fcntl.h> |
|
| 4 |
#include <pthread.h> |
|
| 5 |
#include <stdlib.h> |
|
| 6 |
|
|
| 7 |
struct pkt {
|
|
| 8 |
int checksum; |
|
| 9 |
int seq_num; |
|
| 10 |
short data[1020]; |
|
| 11 |
}; |
|
| 12 |
|
|
| 13 |
static int fp; |
|
| 14 |
|
|
| 15 |
static int calc_checksum(struct pkt *p) |
|
| 16 |
{
|
|
| 17 |
int i, sum; |
|
| 18 |
|
|
| 19 |
i = 0; |
|
| 20 |
sum = 0; |
|
| 21 |
|
|
| 22 |
for (i=0; i<1020; i++) |
|
| 23 |
sum += p->data[i]; |
|
| 24 |
|
|
| 25 |
sum += p->seq_num; |
|
| 26 |
|
|
| 27 |
return sum; |
|
| 28 |
} |
|
| 29 |
|
|
| 30 |
static void *read_thread(void *threadid) |
|
| 31 |
{
|
|
| 32 |
int cnt, prev_seq_num; |
|
| 33 |
struct pkt rx_data; |
|
| 34 |
|
|
| 35 |
printf("Greetings from the reading thread!\n");
|
|
| 36 |
|
|
| 37 |
prev_seq_num = 0; |
|
| 38 |
|
|
| 39 |
while (1) {
|
|
| 40 |
cnt = read(fp, &rx_data, 2048); |
|
| 41 |
|
|
| 42 |
if (rx_data.seq_num != prev_seq_num + 1) |
|
| 43 |
printf("Sequence number fail, current = %d, previous = %d\n",
|
|
| 44 |
rx_data.seq_num, prev_seq_num); |
|
| 45 |
prev_seq_num = rx_data.seq_num; |
|
| 46 |
|
|
| 47 |
if (calc_checksum(&rx_data) != rx_data.checksum) |
|
| 48 |
printf("Checksum fail packet = %d, expected = %d\n",
|
|
| 49 |
calc_checksum(&rx_data), rx_data.checksum); |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
static void *write_thread(void *threadid) |
|
| 55 |
{
|
|
| 56 |
int seq_number, i, cnt; |
|
| 57 |
struct pkt tx_data; |
|
| 58 |
|
|
| 59 |
printf("Greetings from the write thread!\n");
|
|
| 60 |
|
|
| 61 |
for (i=0; i<1020; i++) |
|
| 62 |
tx_data.data[i] = random() >> 16; |
|
| 63 |
|
|
| 64 |
|
|
| 65 |
seq_number = 1; |
|
| 66 |
|
|
| 67 |
while (1) {
|
|
| 68 |
tx_data.seq_num = seq_number++; |
|
| 69 |
tx_data.checksum = calc_checksum(&tx_data); |
|
| 70 |
cnt = write(fp, &tx_data, 2048); |
|
| 71 |
} |
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
|
|
| 75 |
int main(int argc, char *argv[]) |
|
| 76 |
{
|
|
| 77 |
int ret; |
|
| 78 |
pthread_t tx, rx; |
|
| 79 |
long int t; |
|
| 80 |
|
|
| 81 |
fp = open("/dev/usrp1_e0", O_RDWR);
|
|
| 82 |
printf("fp = %d\n", fp);
|
|
| 83 |
|
|
| 84 |
if (pthread_create(&rx, NULL, read_thread, (void *) t)) {
|
|
| 85 |
printf("Failed to create rx thread\n");
|
|
| 86 |
exit(-1); |
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
if (pthread_create(&tx, NULL, write_thread, (void *) t)) {
|
|
| 90 |
printf("Failed to create tx thread\n");
|
|
| 91 |
exit(-1); |
|
| 92 |
} |
|
| 93 |
|
|
| 94 |
sleep(10000); |
|
| 95 |
|
|
| 96 |
printf("Done sleeping\n");
|
|
| 97 |
} |
|
| b/host/apps/omap_debug/usrp-e-spi.c | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <stdlib.h> |
|
| 3 |
#include <sys/types.h> |
|
| 4 |
#include <fcntl.h> |
|
| 5 |
#include <linux/ioctl.h> |
|
| 6 |
|
|
| 7 |
#include "usrp1_e.h" |
|
| 8 |
|
|
| 9 |
// Usage: usrp1_e_spi w|rb slave data |
|
| 10 |
|
|
| 11 |
int main(int argc, char *argv[]) |
|
| 12 |
{
|
|
| 13 |
int fp, slave, data, ret; |
|
| 14 |
struct usrp_e_spi spi_dat; |
|
| 15 |
|
|
| 16 |
if (argc < 4) {
|
|
| 17 |
printf("Usage: usrp1_e_spi w|rb slave data\n");
|
|
| 18 |
exit(-1); |
|
| 19 |
} |
|
| 20 |
|
|
| 21 |
slave = atoi(argv[2]); |
|
| 22 |
data = atoi(argv[3]); |
|
| 23 |
|
|
| 24 |
fp = open("/dev/usrp1_e0", O_RDWR);
|
|
| 25 |
printf("fp = %d\n", fp);
|
|
| 26 |
|
|
| 27 |
spi_dat.slave = slave; |
|
| 28 |
spi_dat.data = data; |
|
| 29 |
spi_dat.length = 2; |
|
| 30 |
spi_dat.flags = 0; |
|
| 31 |
|
|
| 32 |
if (*argv[1] == 'r') {
|
|
| 33 |
spi_dat.readback = 1; |
|
| 34 |
ret = ioctl(fp, USRP_E_SPI, &spi_dat); |
|
| 35 |
printf("Data returned = %d\n", ret);
|
|
| 36 |
} else {
|
|
| 37 |
spi_dat.readback = 0; |
|
| 38 |
ioctl(fp, USRP_E_SPI, &spi_dat); |
|
| 39 |
} |
|
| 40 |
} |
|
| b/host/apps/omap_debug/usrp-e-write.c | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <sys/types.h> |
|
| 3 |
#include <fcntl.h> |
|
| 4 |
|
|
| 5 |
int main(int rgc, char *argv[]) |
|
| 6 |
{
|
|
| 7 |
int fp, i, cnt; |
|
| 8 |
short buf[1024]; |
|
| 9 |
|
|
| 10 |
fp = open("/dev/usrp1_e0", O_WRONLY);
|
|
| 11 |
printf("fp = %d\n", fp);
|
|
| 12 |
|
|
| 13 |
for (i=0; i<1024; i++) {
|
|
| 14 |
buf[i] = i; |
|
| 15 |
} |
|
| 16 |
|
|
| 17 |
// do {
|
|
| 18 |
cnt = write(fp, buf, 2048); |
|
| 19 |
printf("Bytes written - %d\n", cnt);
|
|
| 20 |
// } while (1); |
|
| 21 |
} |
|
| /dev/null | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <stdlib.h> |
|
| 3 |
#include <sys/types.h> |
|
| 4 |
#include <fcntl.h> |
|
| 5 |
#include <linux/ioctl.h> |
|
| 6 |
|
|
| 7 |
#include "usrp1_e.h" |
|
| 8 |
|
|
| 9 |
// Usage: usrp1_e_ctl w|r offset number_of_values val1 val2 .... |
|
| 10 |
|
|
| 11 |
int main(int argc, char *argv[]) |
|
| 12 |
{
|
|
| 13 |
int fp, i, cnt, ret; |
|
| 14 |
struct usrp1_e_ctl *ctl_data; |
|
| 15 |
|
|
| 16 |
if (argc < 4) {
|
|
| 17 |
printf("Usage: usrp1_e_ctl w|r offset number_of_values val1 val2 ....\n");
|
|
| 18 |
exit(-1); |
|
| 19 |
} |
|
| 20 |
|
|
| 21 |
cnt = atoi(argv[3]); |
|
| 22 |
|
|
| 23 |
ctl_data = malloc(sizeof(struct usrp1_e_ctl) + cnt*2); |
|
| 24 |
|
|
| 25 |
ctl_data->offset = atoi(argv[2]); |
|
| 26 |
ctl_data->count = cnt; |
|
| 27 |
|
|
| 28 |
printf("Sizeof usrp1_e_ctl struct = %d\n", sizeof(struct usrp1_e_ctl));
|
|
| 29 |
|
|
| 30 |
fp = open("/dev/usrp1_e0", O_RDWR);
|
|
| 31 |
printf("fp = %d\n", fp);
|
|
| 32 |
|
|
| 33 |
if (*argv[1] == 'w') {
|
|
| 34 |
for (i=0; i<cnt; i++) |
|
| 35 |
ctl_data->buf[i] = atoi(argv[4+i]); |
|
| 36 |
|
|
| 37 |
ret = ioctl(fp, USRP1_E_WRITE_CTL, ctl_data); |
|
| 38 |
printf("Return value from write ioctl = %d\n", ret);
|
|
| 39 |
} |
|
| 40 |
|
|
| 41 |
if (*argv[1] == 'r') {
|
|
| 42 |
ret = ioctl(fp, USRP1_E_READ_CTL, ctl_data); |
|
| 43 |
printf("Return value from write ioctl = %d\n", ret);
|
|
| 44 |
|
|
| 45 |
for (i=0; i<ctl_data->count; i++) {
|
|
| 46 |
if (!(i%8)) |
|
| 47 |
printf("\nData at %4d :", i);
|
|
| 48 |
printf(" %5d", ctl_data->buf[i]);
|
|
| 49 |
} |
|
| 50 |
printf("\n");
|
|
| 51 |
} |
|
| 52 |
} |
|
| /dev/null | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <sys/types.h> |
|
| 3 |
#include <fcntl.h> |
|
| 4 |
|
|
| 5 |
int main(int rgc, char *argv[]) |
|
| 6 |
{
|
|
| 7 |
int fp, i, cnt; |
|
| 8 |
unsigned short buf[1024]; |
|
| 9 |
unsigned short buf_rb[1024]; |
|
| 10 |
|
|
| 11 |
fp = open("/dev/usrp1_e0", O_RDWR);
|
|
| 12 |
printf("fp = %d\n", fp);
|
|
| 13 |
|
|
| 14 |
for (i=0; i<1024; i++) |
|
| 15 |
buf[i] = i*256; |
|
| 16 |
write(fp, buf, 2048); |
|
| 17 |
read(fp, buf_rb, 2048); |
|
| 18 |
|
|
| 19 |
printf("Read back %hX %hX\n", buf_rb[0], buf_rb[1]);
|
|
| 20 |
|
|
| 21 |
for (i=0; i<1024; i++) {
|
|
| 22 |
if (buf[i] != buf_rb[i]) |
|
| 23 |
printf("Read - %hX, expected - %hX\n", buf_rb[i], buf[i]);
|
|
| 24 |
} |
|
| 25 |
} |
|
| /dev/null | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <sys/types.h> |
|
| 3 |
#include <fcntl.h> |
|
| 4 |
|
|
| 5 |
int main(int rgc, char *argv[]) |
|
| 6 |
{
|
|
| 7 |
int fp, cnt; |
|
| 8 |
short buf[1024]; |
|
| 9 |
|
|
| 10 |
fp = open("/dev/usrp1_e0", O_RDONLY);
|
|
| 11 |
printf("fp = %d\n", fp);
|
|
| 12 |
|
|
| 13 |
do {
|
|
| 14 |
cnt = read(fp, buf, 2048); |
|
| 15 |
// printf("Bytes read - %d\n", cnt);
|
|
| 16 |
} while(1); |
|
| 17 |
printf("Data - %hX\n", buf[0]);
|
|
| 18 |
} |
|
| /dev/null | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <sys/types.h> |
|
| 3 |
#include <fcntl.h> |
|
| 4 |
#include <pthread.h> |
|
| 5 |
#include <stdlib.h> |
|
| 6 |
|
|
| 7 |
struct pkt {
|
|
| 8 |
int checksum; |
|
| 9 |
int seq_num; |
|
| 10 |
short data[1020]; |
|
| 11 |
}; |
|
| 12 |
|
|
| 13 |
static int fp; |
|
| 14 |
|
|
| 15 |
static int calc_checksum(struct pkt *p) |
|
| 16 |
{
|
|
| 17 |
int i, sum; |
|
| 18 |
|
|
| 19 |
i = 0; |
|
| 20 |
sum = 0; |
|
| 21 |
|
|
| 22 |
for (i=0; i<1020; i++) |
|
| 23 |
sum += p->data[i]; |
|
| 24 |
|
|
| 25 |
sum += p->seq_num; |
|
| 26 |
|
|
| 27 |
return sum; |
|
| 28 |
} |
|
| 29 |
|
|
| 30 |
static void *read_thread(void *threadid) |
|
| 31 |
{
|
|
| 32 |
int cnt, prev_seq_num; |
|
| 33 |
struct pkt rx_data; |
|
| 34 |
|
|
| 35 |
printf("Greetings from the reading thread!\n");
|
|
| 36 |
|
|
| 37 |
prev_seq_num = 0; |
|
| 38 |
|
|
| 39 |
while (1) {
|
|
| 40 |
cnt = read(fp, &rx_data, 2048); |
|
| 41 |
|
|
| 42 |
if (rx_data.seq_num != prev_seq_num + 1) |
|
| 43 |
printf("Sequence number fail, current = %d, previous = %d\n",
|
|
| 44 |
rx_data.seq_num, prev_seq_num); |
|
| 45 |
prev_seq_num = rx_data.seq_num; |
|
| 46 |
|
|
| 47 |
if (calc_checksum(&rx_data) != rx_data.checksum) |
|
| 48 |
printf("Checksum fail packet = %d, expected = %d\n",
|
|
| 49 |
calc_checksum(&rx_data), rx_data.checksum); |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
static void *write_thread(void *threadid) |
|
| 55 |
{
|
|
| 56 |
int seq_number, i, cnt; |
|
| 57 |
struct pkt tx_data; |
|
| 58 |
|
|
| 59 |
printf("Greetings from the write thread!\n");
|
|
| 60 |
|
|
| 61 |
for (i=0; i<1020; i++) |
|
| 62 |
tx_data.data[i] = random() >> 16; |
|
| 63 |
|
|
| 64 |
|
|
| 65 |
seq_number = 1; |
|
| 66 |
|
|
| 67 |
while (1) {
|
|
| 68 |
tx_data.seq_num = seq_number++; |
|
| 69 |
tx_data.checksum = calc_checksum(&tx_data); |
|
| 70 |
cnt = write(fp, &tx_data, 2048); |
|
| 71 |
} |
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
|
|
| 75 |
int main(int argc, char *argv[]) |
|
| 76 |
{
|
|
| 77 |
int ret; |
|
| 78 |
pthread_t tx, rx; |
|
| 79 |
long int t; |
|
| 80 |
|
|
| 81 |
fp = open("/dev/usrp1_e0", O_RDWR);
|
|
| 82 |
printf("fp = %d\n", fp);
|
|
| 83 |
|
|
| 84 |
if (pthread_create(&rx, NULL, read_thread, (void *) t)) {
|
|
| 85 |
printf("Failed to create rx thread\n");
|
|
| 86 |
exit(-1); |
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
if (pthread_create(&tx, NULL, write_thread, (void *) t)) {
|
|
| 90 |
printf("Failed to create tx thread\n");
|
|
| 91 |
exit(-1); |
|
| 92 |
} |
|
| 93 |
|
|
| 94 |
sleep(10000); |
|
| 95 |
|
|
| 96 |
printf("Done sleeping\n");
|
|
| 97 |
} |
|
| /dev/null | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <stdlib.h> |
|
| 3 |
#include <sys/types.h> |
|
| 4 |
#include <fcntl.h> |
|
| 5 |
#include <linux/ioctl.h> |
|
| 6 |
|
|
| 7 |
#include "usrp1_e.h" |
|
| 8 |
|
|
| 9 |
// Usage: usrp1_e_spi w|rb slave data |
|
| 10 |
|
|
| 11 |
int main(int argc, char *argv[]) |
|
| 12 |
{
|
|
| 13 |
int fp, slave, data, ret; |
|
| 14 |
struct usrp_e_spi spi_dat; |
|
| 15 |
|
|
| 16 |
if (argc < 4) {
|
|
| 17 |
printf("Usage: usrp1_e_spi w|rb slave data\n");
|
|
| 18 |
exit(-1); |
|
| 19 |
} |
|
| 20 |
|
|
| 21 |
slave = atoi(argv[2]); |
|
| 22 |
data = atoi(argv[3]); |
|
| 23 |
|
|
| 24 |
fp = open("/dev/usrp1_e0", O_RDWR);
|
|
| 25 |
printf("fp = %d\n", fp);
|
|
| 26 |
|
|
| 27 |
spi_dat.slave = slave; |
|
| 28 |
spi_dat.data = data; |
|
| 29 |
spi_dat.length = 2; |
|
| 30 |
spi_dat.flags = 0; |
|
| 31 |
|
|
| 32 |
if (*argv[1] == 'r') {
|
|
| 33 |
spi_dat.readback = 1; |
|
| 34 |
ret = ioctl(fp, USRP_E_SPI, &spi_dat); |
|
| 35 |
printf("Data returned = %d\n", ret);
|
|
| 36 |
} else {
|
|
| 37 |
spi_dat.readback = 0; |
|
| 38 |
ioctl(fp, USRP_E_SPI, &spi_dat); |
|
| 39 |
} |
|
| 40 |
} |
|
| /dev/null | ||
|---|---|---|
| 1 |
#include <stdio.h> |
|
| 2 |
#include <sys/types.h> |
|
| 3 |
#include <fcntl.h> |
|
| 4 |
|
|
| 5 |
int main(int rgc, char *argv[]) |
|
| 6 |
{
|
|
| 7 |
int fp, i, cnt; |
|
| 8 |
short buf[1024]; |
|
| 9 |
|
|
| 10 |
fp = open("/dev/usrp1_e0", O_WRONLY);
|
|
| 11 |
printf("fp = %d\n", fp);
|
|
| 12 |
|
|
| 13 |
for (i=0; i<1024; i++) {
|
|
| 14 |
buf[i] = i; |
|
| 15 |
} |
|
| 16 |
|
|
| 17 |
// do {
|
|
| 18 |
cnt = write(fp, buf, 2048); |
|
| 19 |
printf("Bytes written - %d\n", cnt);
|
|
| 20 |
// } while (1); |
|
| 21 |
} |
|
Also available in: Unified diff