Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- struct txschedule {
- uint8_t t0, r0;
- uint8_t t1, r1;
- uint8_t t2, r2;
- uint8_t t3, r3;
- };
- static const struct txschedule series_quarter2[] = {
- { 3, 0, 3, 0, 0, 0, 0, 0 },
- { 4, 1, 3, 0, 4, 0, 0, 0 },
- { 4, 2, 3, 0, 4, 0, 0, 0 },
- { 4, 3, 3, 2, 4, 0, 2, 0 },
- { 4, 4, 3, 3, 4, 2, 2, 0 },
- { 4, 5, 3, 4, 4, 3, 2, 0 },
- { 4, 6, 3, 5, 4, 4, 2, 2 },
- { 4, 7, 3, 6, 4, 5, 2, 4 },
- };
- #ifdef Q
- #undef Q
- #endif
- #define Q(_r) \
- (((_r) == 1.5) ? 0 : (((_r) ==2.25) ? 1 : (((_r) == 3) ? 2 : \
- (((_r) == 4.5) ? 3 : (((_r) == 6) ? 4 : (((_r) == 9) ? 5 : \
- (((_r) == 12) ? 6 : (((_r) == 13.5)? 7 : 0))))))))
- static const struct txschedule series_quarter[] = {
- { 3,Q( 1.5),3,Q(1.5), 0,Q(1.5), 0,Q(1.5) }, /* 1.5Mb/s */
- { 4,Q(2.25),3,Q(1.5), 4,Q(1.5), 0,Q(1.5) }, /*2.25Mb/s */
- { 4,Q( 3),3,Q(1.5), 4,Q(1.5), 0,Q(1.5) }, /* 3Mb/s */
- { 4,Q( 4.5),3,Q( 3), 4,Q(1.5), 2,Q(1.5) }, /* 4.5Mb/s */
- { 4,Q( 6),3,Q(4.5), 4,Q( 3), 2,Q(1.5) }, /* 6Mb/s */
- { 4,Q( 9),3,Q( 6), 4,Q(4.5), 2,Q(1.5) }, /* 9Mb/s */
- { 4,Q( 12),3,Q( 9), 4,Q( 6), 2,Q( 3) }, /* 12Mb/s */
- { 4,Q(13.5),3,Q( 12), 4,Q( 9), 2,Q( 6) } /*13.5Mb/s */
- };
- #undef Q
- int main(void)
- {
- int i;
- printf("static const struct txschedule series_quarter[] = {\n");
- for (i = 0; i < 8; i++)
- {
- printf(" { %2u, %2u, %2u, %2u, %2u, %2u, %2u, %2u },\n",
- series_quarter[i].t0, series_quarter[i].r0,
- series_quarter[i].t1, series_quarter[i].r1,
- series_quarter[i].t2, series_quarter[i].r2,
- series_quarter[i].t3, series_quarter[i].r3);
- if (series_quarter[i].t0 != series_quarter2[i].t0)
- printf("%d-th element t0 does not match\n", i);
- if (series_quarter[i].t1 != series_quarter2[i].t1)
- printf("%d-th element t0 does not match\n", i);
- if (series_quarter[i].t2 != series_quarter2[i].t2)
- printf("%d-th element t0 does not match\n", i);
- if (series_quarter[i].t3 != series_quarter2[i].t3)
- printf("%d-th element t0 does not match\n", i);
- if (series_quarter[i].r0 != series_quarter2[i].r0)
- printf("%d-th element t0 does not match\n", i);
- if (series_quarter[i].r1 != series_quarter2[i].r1)
- printf("%d-th element t0 does not match\n", i);
- if (series_quarter[i].r2 != series_quarter2[i].r2)
- printf("%d-th element t0 does not match\n", i);
- if (series_quarter[i].r3 != series_quarter2[i].r3)
- printf("%d-th element t0 does not match\n", i);
- }
- printf("};\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment