Guest User

Untitled

a guest
Apr 6th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. struct txschedule {
  5.     uint8_t t0, r0;
  6.     uint8_t t1, r1;
  7.     uint8_t t2, r2;
  8.     uint8_t t3, r3;
  9. };
  10.  
  11. static const struct txschedule series_quarter2[] = {
  12.   {  3,  0,  3,  0,  0,  0,  0,  0 },
  13.   {  4,  1,  3,  0,  4,  0,  0,  0 },
  14.   {  4,  2,  3,  0,  4,  0,  0,  0 },
  15.   {  4,  3,  3,  2,  4,  0,  2,  0 },
  16.   {  4,  4,  3,  3,  4,  2,  2,  0 },
  17.   {  4,  5,  3,  4,  4,  3,  2,  0 },
  18.   {  4,  6,  3,  5,  4,  4,  2,  2 },
  19.   {  4,  7,  3,  6,  4,  5,  2,  4 },
  20. };
  21.  
  22.  
  23. #ifdef Q
  24. #undef Q
  25. #endif
  26. #define Q(_r) \
  27.   (((_r) == 1.5) ? 0 : (((_r) ==2.25) ? 1 : (((_r) == 3) ? 2 : \
  28.   (((_r) == 4.5) ? 3 : (((_r) ==  6)  ? 4 : (((_r) == 9) ? 5 : \
  29.   (((_r) == 12)  ? 6 : (((_r) == 13.5)? 7 : 0))))))))
  30. static const struct txschedule series_quarter[] = {
  31.   { 3,Q( 1.5),3,Q(1.5), 0,Q(1.5), 0,Q(1.5) },  /* 1.5Mb/s */
  32.   { 4,Q(2.25),3,Q(1.5), 4,Q(1.5), 0,Q(1.5) },  /*2.25Mb/s */
  33.   { 4,Q(   3),3,Q(1.5), 4,Q(1.5), 0,Q(1.5) },  /*   3Mb/s */
  34.   { 4,Q( 4.5),3,Q(  3), 4,Q(1.5), 2,Q(1.5) },  /* 4.5Mb/s */
  35.   { 4,Q(   6),3,Q(4.5), 4,Q(  3), 2,Q(1.5) },  /*   6Mb/s */
  36.   { 4,Q(   9),3,Q(  6), 4,Q(4.5), 2,Q(1.5) },  /*   9Mb/s */
  37.   { 4,Q(  12),3,Q(  9), 4,Q(  6), 2,Q(  3) },  /*  12Mb/s */
  38.   { 4,Q(13.5),3,Q( 12), 4,Q(  9), 2,Q(  6) }  /*13.5Mb/s */
  39. };
  40. #undef Q
  41.  
  42. int main(void)
  43. {
  44.     int i;
  45.  
  46.     printf("static const struct txschedule series_quarter[] = {\n");
  47.     for (i = 0; i < 8; i++)
  48.     {
  49.         printf("  { %2u, %2u, %2u, %2u, %2u, %2u, %2u, %2u },\n",
  50.                series_quarter[i].t0, series_quarter[i].r0,
  51.                series_quarter[i].t1, series_quarter[i].r1,
  52.                series_quarter[i].t2, series_quarter[i].r2,
  53.                series_quarter[i].t3, series_quarter[i].r3);
  54.  
  55.         if (series_quarter[i].t0 != series_quarter2[i].t0)
  56.             printf("%d-th element t0 does not match\n", i);
  57.  
  58.         if (series_quarter[i].t1 != series_quarter2[i].t1)
  59.             printf("%d-th element t0 does not match\n", i);
  60.  
  61.         if (series_quarter[i].t2 != series_quarter2[i].t2)
  62.             printf("%d-th element t0 does not match\n", i);
  63.  
  64.         if (series_quarter[i].t3 != series_quarter2[i].t3)
  65.             printf("%d-th element t0 does not match\n", i);
  66.  
  67.         if (series_quarter[i].r0 != series_quarter2[i].r0)
  68.             printf("%d-th element t0 does not match\n", i);
  69.  
  70.         if (series_quarter[i].r1 != series_quarter2[i].r1)
  71.             printf("%d-th element t0 does not match\n", i);
  72.  
  73.         if (series_quarter[i].r2 != series_quarter2[i].r2)
  74.             printf("%d-th element t0 does not match\n", i);
  75.  
  76.         if (series_quarter[i].r3 != series_quarter2[i].r3)
  77.             printf("%d-th element t0 does not match\n", i);
  78.     }
  79.     printf("};\n");
  80.  
  81.     return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment