IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Commit Details
Date: | 2011-01-20 23:32:40 (13 years 2 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 705864d0763fbeb1d6716c3ce8aa27726f0ec21f |
Message: | atrf-txrx: new option -r to select data rate - atrf-txrx.c (set_rate, main): allow setting a non-standard high data rate on the AT86RF231 - atrf-txrx.c (usage, main): added option -r to select the data rate |
Files: |
tools/atrf-txrx/atrf-txrx.c (8 diffs) |
Change Details
tools/atrf-txrx/atrf-txrx.c | ||
---|---|---|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
128 | static void set_rate(struct atrf_dsc *dsc, uint8_t rate) | |
129 | { | |
130 | if (!rate) | |
131 | return; | |
132 | switch (atrf_identify(dsc)) { | |
133 | case artf_at86rf230: | |
134 | fprintf(stderr, "AT86RF230 only supports 250 kbps\n"); | |
135 | break; | |
136 | case artf_at86rf231: | |
137 | atrf_reg_write(dsc, REG_TRX_CTRL_2, rate); | |
138 | break; | |
139 | default: | |
140 | abort(); | |
141 | } | |
142 | } | |
143 | ||
144 | ||
128 | 145 | static void set_power(struct atrf_dsc *dsc, double power, int crc) |
129 | 146 | { |
130 | 147 | const double *tx_pwr; |
... | ... | |
141 | 158 | default: |
142 | 159 | abort(); |
143 | 160 | } |
144 | ||
161 | ||
145 | 162 | for (n = 0; n != sizeof(tx_pwr_230)/sizeof(*tx_pwr_230)-1; n++) |
146 | 163 | if (tx_pwr[n] <= power) |
147 | 164 | break; |
... | ... | |
568 | 585 | " wave in MHz: -2, -0.5, or +0.5\n" |
569 | 586 | " command shell command to run while transmitting (default: wait for\n" |
570 | 587 | " SIGINT instead)\n\n" |
571 | " common options: [-c channel|-f freq] [-C mhz] [-o file] [-p power] " | |
572 | "[-t trim]\n" | |
588 | " common options: [-c channel|-f freq] [-C mhz] [-o file] [-p power]\n" | |
589 | " [-r rate] [-t trim]\n" | |
573 | 590 | " -c channel channel number, 11 to 26 (default %d)\n" |
574 | 591 | " -C mhz output clock at 1, 2, 4, 8, or 16 MHz (default: off)\n" |
575 | 592 | " -f freq frequency in MHz, 2405 to 2480 (default %d)\n" |
576 | 593 | " -o file write received data to a file in pcap format\n" |
577 | 594 | " -p power transmit power, -17.2 to 3.0 dBm (default %.1f)\n" |
595 | " -r rate data rate, 250k, 500k, 1M, or 2M (default: 250k)\n" | |
578 | 596 | " -t trim trim capacitor, 0 to 15 (default 0)\n" |
579 | 597 | , name, name, name, name, |
580 | 598 | DEFAULT_CHANNEL, 2405+5*(DEFAULT_CHANNEL-11), DEFAULT_POWER); |
... | ... | |
592 | 610 | } mode = mode_msg; |
593 | 611 | int channel = DEFAULT_CHANNEL; |
594 | 612 | double power = DEFAULT_POWER; |
613 | uint8_t rate = OQPSK_DATA_RATE_250; | |
595 | 614 | int trim = 0, times = 1; |
596 | 615 | uint8_t cont_tx = 0; |
597 | 616 | double pause_s = 0; |
... | ... | |
602 | 621 | const char *pcap_file = NULL; |
603 | 622 | struct atrf_dsc *dsc; |
604 | 623 | |
605 | while ((c = getopt(argc, argv, "c:C:f:o:p:E:Pt:T:")) != EOF) | |
624 | while ((c = getopt(argc, argv, "c:C:f:o:p:r:E:Pt:T:")) != EOF) | |
606 | 625 | switch (c) { |
607 | 626 | case 'c': |
608 | 627 | channel = strtoul(optarg, &end, 0); |
... | ... | |
629 | 648 | if (*end) |
630 | 649 | usage(*argv); |
631 | 650 | break; |
651 | case 'r': | |
652 | if (!strcmp(optarg, "250k")) | |
653 | rate = OQPSK_DATA_RATE_250; | |
654 | else if (!strcmp(optarg, "500k")) | |
655 | rate = OQPSK_DATA_RATE_500; | |
656 | else if (!strcmp(optarg, "1M")) | |
657 | rate = OQPSK_DATA_RATE_1000; | |
658 | else if (!strcmp(optarg, "2M")) | |
659 | rate = OQPSK_DATA_RATE_2000; | |
660 | else | |
661 | usage(*argv); | |
662 | break; | |
632 | 663 | case 't': |
633 | 664 | trim = strtoul(optarg, &end, 0); |
634 | 665 | if (*end) |
... | ... | |
677 | 708 | case 0: |
678 | 709 | dsc = init_txrx(trim, clkm); |
679 | 710 | set_channel(dsc, channel); |
711 | set_rate(dsc, rate); | |
680 | 712 | switch (mode) { |
681 | 713 | case mode_msg: |
682 | 714 | receive(dsc, pcap_file); |
... | ... | |
716 | 748 | case 1: |
717 | 749 | dsc = init_txrx(trim, clkm); |
718 | 750 | set_channel(dsc, channel); |
751 | set_rate(dsc, rate); | |
719 | 752 | switch (mode) { |
720 | 753 | case mode_msg: |
721 | 754 | set_power(dsc, power, 1); |