1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
/* automatically generated by rust-bindgen */

pub const TASK_PRIORITY_DEFAULT: u32 = 8;
pub const TASK_STACK_DEPTH_DEFAULT: u32 = 8192;
pub const adi_port_config_e_E_ADI_ANALOG_IN: adi_port_config_e = 0;
pub const adi_port_config_e_E_ADI_ANALOG_OUT: adi_port_config_e = 1;
pub const adi_port_config_e_E_ADI_DIGITAL_IN: adi_port_config_e = 2;
pub const adi_port_config_e_E_ADI_DIGITAL_OUT: adi_port_config_e = 3;
pub const adi_port_config_e_E_ADI_SMART_BUTTON: adi_port_config_e = 2;
pub const adi_port_config_e_E_ADI_SMART_POT: adi_port_config_e = 0;
pub const adi_port_config_e_E_ADI_LEGACY_BUTTON: adi_port_config_e = 2;
pub const adi_port_config_e_E_ADI_LEGACY_POT: adi_port_config_e = 0;
pub const adi_port_config_e_E_ADI_LEGACY_LINE_SENSOR: adi_port_config_e = 0;
pub const adi_port_config_e_E_ADI_LEGACY_LIGHT_SENSOR: adi_port_config_e = 0;
pub const adi_port_config_e_E_ADI_LEGACY_GYRO: adi_port_config_e = 10;
pub const adi_port_config_e_E_ADI_LEGACY_ACCELEROMETER: adi_port_config_e = 0;
pub const adi_port_config_e_E_ADI_LEGACY_SERVO: adi_port_config_e = 12;
pub const adi_port_config_e_E_ADI_LEGACY_PWM: adi_port_config_e = 13;
pub const adi_port_config_e_E_ADI_LEGACY_ENCODER: adi_port_config_e = 14;
pub const adi_port_config_e_E_ADI_LEGACY_ULTRASONIC: adi_port_config_e = 15;
pub const adi_port_config_e_E_ADI_TYPE_UNDEFINED: adi_port_config_e = 255;
pub const adi_port_config_e_E_ADI_ERR: adi_port_config_e = 2147483647;
/// Represents the port type for an ADI port.
pub type adi_port_config_e = u32;
/// Represents the port type for an ADI port.
pub use self::adi_port_config_e as adi_port_config_e_t;
extern "C" {
    /// Gets the configuration for the given ADI port.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///        The ADI port number (from 1-8, 'a'-'h', 'A'-'H') for which to
    /// return
    ///        the configuration
    ///
    /// \return The ADI configuration for the given port
    pub fn ext_adi_port_get_config(smart_port: u8, adi_port: u8) -> adi_port_config_e_t;
}
extern "C" {
    /// Gets the value for the given ADI port.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port number (from 1-8, 'a'-'h', 'A'-'H') for which to
    /// return
    ///        the configuration
    ///
    /// \return The value stored for the given port
    pub fn ext_adi_port_get_value(smart_port: u8, adi_port: u8) -> i32;
}
extern "C" {
    /// Configures an ADI port to act as a given sensor type.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
    /// \param type
    ///        The configuration type for the port
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_port_set_config(smart_port: u8, adi_port: u8, type_: adi_port_config_e_t)
        -> i32;
}
extern "C" {
    /// Sets the value for the given ADI port.
    ///
    /// This only works on ports configured as outputs, and the behavior will
    /// change
    /// depending on the configuration of the port.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port number (from 1-8, 'a'-'h', 'A'-'H') for which the
    /// value
    ///        will be set
    /// \param value
    ///        The value to set the ADI port to
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_port_set_value(smart_port: u8, adi_port: u8, value: i32) -> i32;
}
extern "C" {
    /// Calibrates the analog sensor on the specified port and returns the new
    /// calibration value.
    ///
    /// This method assumes that the true sensor value is not actively changing
    /// at
    /// this time and computes an average from approximately 500 samples, 1 ms
    /// apart,
    /// for a 0.5 s period of calibration. The average value thus calculated is
    /// returned and stored for later calls to the adi_analog_read_calibrated()
    /// and
    /// adi_analog_read_calibrated_HR() functions. These functions will return
    /// the difference between this value and the current sensor value when
    /// called.
    ///
    /// Do not use this function when the sensor value might be unstable
    /// (gyro rotation, accelerometer movement).
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port to calibrate (from 1-8, 'a'-'h', 'A'-'H')
    ///
    /// \return The average sensor value computed by this function
    pub fn ext_adi_analog_calibrate(smart_port: u8, adi_port: u8) -> i32;
}
extern "C" {
    /// Gets the 12-bit value of the specified port.
    ///
    /// The value returned is undefined if the analog pin has been switched to a
    /// different mode.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an analog input
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port (from 1-8, 'a'-'h', 'A'-'H') for which the value will
    /// be
    ///        returned
    ///
    /// \return The analog sensor value, where a value of 0 reflects an input
    /// voltage
    /// of nearly 0 V and a value of 4095 reflects an input voltage of nearly 5
    /// V
    pub fn ext_adi_analog_read(smart_port: u8, adi_port: u8) -> i32;
}
extern "C" {
    /// Gets the 12 bit calibrated value of an analog input port.
    ///
    /// The adi_analog_calibrate() function must be run first. This function is
    /// inappropriate for sensor values intended for integration, as round-off
    /// error
    /// can accumulate causing drift over time. Use
    /// adi_analog_read_calibrated_HR()
    /// instead.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an analog input
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port (from 1-8, 'a'-'h', 'A'-'H') for which the value will
    /// be
    ///        returned
    ///
    /// \return The difference of the sensor value from its calibrated default
    /// from
    /// -4095 to 4095
    pub fn ext_adi_analog_read_calibrated(smart_port: u8, adi_port: u8) -> i32;
}
extern "C" {
    /// Gets the 16 bit calibrated value of an analog input port.
    ///
    /// The adi_analog_calibrate() function must be run first. This is intended
    /// for
    /// integrated sensor values such as gyros and accelerometers to reduce
    /// drift due
    /// to round-off, and should not be used on a sensor such as a line tracker
    /// or potentiometer.
    ///
    /// The value returned actually has 16 bits of "precision", even though the
    /// ADC
    /// only reads 12 bits, so that error induced by the average value being
    /// between
    /// two values when integrated over time is trivial. Think of the value as
    /// the
    /// true value times 16.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an analog input
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port (from 1-8, 'a'-'h', 'A'-'H') for which the value will
    /// be
    ///        returned
    ///
    /// \return The difference of the sensor value from its calibrated default
    /// from
    /// -16384 to 16384
    pub fn ext_adi_analog_read_calibrated_HR(smart_port: u8, adi_port: u8) -> i32;
}
extern "C" {
    /// Gets the digital value (1 or 0) of a port configured as a digital input.
    ///
    /// If the port is configured as some other mode, the digital value which
    /// reflects the current state of the port is returned, which may or may not
    /// differ from the currently set value. The return value is undefined for
    /// ports
    /// configured as any mode other than a Digital Input.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as a digital input
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port to read (from 1-8, 'a'-'h', 'A'-'H')
    ///
    /// \return True if the pin is HIGH, or false if it is LOW
    pub fn ext_adi_digital_read(smart_port: u8, adi_port: u8) -> i32;
}
extern "C" {
    /// Gets a rising-edge case for a digital button press.
    ///
    /// This function is not thread-safe.
    /// Multiple tasks polling a single button may return different results
    /// under the
    /// same circumstances, so only one task should call this function for any
    /// given
    /// button. E.g., Task A calls this function for buttons 1 and 2. Task B may
    /// call
    /// this function for button 3, but should not for buttons 1 or 2. A typical
    /// use-case for this function is to call inside opcontrol to detect new
    /// button
    /// presses, and not in any other tasks.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as a digital input
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port to read (from 1-8, 'a'-'h', 'A'-'H')
    ///
    /// \return 1 if the button is pressed and had not been pressed
    /// the last time this function was called, 0 otherwise.
    pub fn ext_adi_digital_get_new_press(smart_port: u8, adi_port: u8) -> i32;
}
extern "C" {
    /// Sets the digital value (1 or 0) of a port configured as a digital
    /// output.
    ///
    /// If the port is configured as some other mode, behavior is undefined.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as a digital output
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
    /// \param value
    ///        An expression evaluating to "true" or "false" to set the output
    /// to
    ///        HIGH or LOW respectively, or the constants HIGH or LOW themselves
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_digital_write(smart_port: u8, adi_port: u8, value: bool) -> i32;
}
extern "C" {
    /// Configures the port as an input or output with a variety of settings.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
    /// \param mode
    ///        One of INPUT, INPUT_ANALOG, INPUT_FLOATING, OUTPUT, or OUTPUT_OD
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_pin_mode(smart_port: u8, adi_port: u8, mode: u8) -> i32;
}
extern "C" {
    /// Sets the speed of the motor on the given port.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an motor
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
    /// \param speed
    ///        The new signed speed; -127 is full reverse and 127 is full
    /// forward,
    ///        with 0 being off
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_motor_set(smart_port: u8, adi_port: u8, speed: i8) -> i32;
}
extern "C" {
    /// Gets the last set speed of the motor on the given port.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an motor
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port to get (from 1-8, 'a'-'h', 'A'-'H')
    ///
    /// \return The last set speed of the motor on the given port
    pub fn ext_adi_motor_get(smart_port: u8, adi_port: u8) -> i32;
}
extern "C" {
    /// Stops the motor on the given port.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an motor
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///	      The ADI port to set (from 1-8, 'a'-'h', 'A'-'H')
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_motor_stop(smart_port: u8, adi_port: u8) -> i32;
}
/// Reference type for an initialized encoder.
///
/// This merely contains the port number for the encoder, unlike its use as an
/// object to store encoder data in PROS 2.
pub type ext_adi_encoder_t = i32;
extern "C" {
    /// Gets the number of ticks recorded by the encoder.
    ///
    /// There are 360 ticks in one revolution.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an encoder
    ///
    /// \param enc
    ///        The adi_encoder_t object from adi_encoder_init() to read
    ///
    /// \return The signed and cumulative number of counts since the last start
    /// or
    /// reset
    pub fn ext_adi_encoder_get(enc: ext_adi_encoder_t) -> i32;
}
extern "C" {
    /// Creates an encoder object and configures the specified ports
    /// accordingly.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an encoder
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port_top
    ///        The "top" wire from the encoder sensor with the removable cover
    /// side
    ///        up. This should be in port 1, 3, 5, or 7 ('A', 'C', 'E', or 'G').
    /// \param adi_port_bottom
    ///        The "bottom" wire from the encoder sensor
    /// \param reverse
    ///        If "true", the sensor will count in the opposite direction
    ///
    /// \return An adi_encoder_t object to be stored and used for later calls to
    /// encoder functions
    pub fn ext_adi_encoder_init(
        smart_port: u8,
        adi_port_top: u8,
        adi_port_bottom: u8,
        reverse: bool,
    ) -> ext_adi_encoder_t;
}
extern "C" {
    /// Sets the encoder value to zero.
    ///
    /// It is safe to use this method while an encoder is enabled. It is not
    /// necessary to call this method before stopping or starting an encoder.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an encoder
    ///
    /// \param enc
    ///        The adi_encoder_t object from adi_encoder_init() to reset
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_encoder_reset(enc: ext_adi_encoder_t) -> i32;
}
extern "C" {
    /// Disables the encoder and voids the configuration on its ports.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an encoder
    ///
    /// \param enc
    ///        The adi_encoder_t object from adi_encoder_init() to stop
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_encoder_shutdown(enc: ext_adi_encoder_t) -> i32;
}
/// Reference type for an initialized ultrasonic.
///
/// This merely contains the port number for the ultrasonic, unlike its use as
/// an
/// object to store encoder data in PROS 2.
pub type ext_adi_ultrasonic_t = i32;
extern "C" {
    /// Gets the current ultrasonic sensor value in centimeters.
    ///
    /// If no object was found, zero is returned. If the ultrasonic sensor was
    /// never
    /// started, the return value is undefined. Round and fluffy objects can
    /// cause
    /// inaccurate values to be returned.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an ultrasonic
    ///
    /// \param ult
    ///        The adi_ultrasonic_t object from adi_ultrasonic_init() to read
    ///
    /// \return The distance to the nearest object in m^-4 (10000 indicates 1
    /// meter),
    /// measured from the sensor's mounting points.
    pub fn ext_adi_ultrasonic_get(ult: ext_adi_ultrasonic_t) -> i32;
}
extern "C" {
    /// Creates an ultrasonic object and configures the specified ports
    /// accordingly.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an ultrasonic
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port_ping
    ///        The port connected to the orange OUTPUT cable. This should be in
    /// port
    ///        1, 3, 5, or 7 ('A', 'C', 'E', 'G').
    /// \param adi_port_echo
    ///        The port connected to the yellow INPUT cable. This should be in
    /// the
    ///        next highest port following port_ping.
    ///
    /// \return An adi_ultrasonic_t object to be stored and used for later calls
    /// to
    /// ultrasonic functions
    pub fn ext_adi_ultrasonic_init(
        smart_port: u8,
        adi_port_ping: u8,
        adi_port_echo: u8,
    ) -> ext_adi_ultrasonic_t;
}
extern "C" {
    /// Disables the ultrasonic sensor and voids the configuration on its ports.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as an ultrasonic
    ///
    /// \param ult
    ///        The adi_ultrasonic_t object from adi_ultrasonic_init() to stop
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_ultrasonic_shutdown(ult: ext_adi_ultrasonic_t) -> i32;
}
/// Reference type for an initialized gyroscope.
///
/// This merely contains the port number for the gyroscope, unlike its use as an
/// object to store gyro data in PROS 2.
///
/// (Might Be useless with the wire expander.)
pub type ext_adi_gyro_t = i32;
extern "C" {
    /// Gets the current gyro angle in tenths of a degree. Unless a multiplier
    /// is
    /// applied to the gyro, the return value will be a whole number
    /// representing
    /// the number of degrees of rotation times 10.
    ///
    /// There are 360 degrees in a circle, thus the gyro will return 3600 for
    /// one
    /// whole rotation.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as a gyro
    ///
    /// \param gyro
    ///        The adi_gyro_t object for which the angle will be returned
    ///
    /// \return The gyro angle in degrees.
    pub fn ext_adi_gyro_get(gyro: ext_adi_gyro_t) -> f64;
}
extern "C" {
    /// Initializes a gyroscope on the given port. If the given port has not
    /// previously been configured as a gyro, then this function starts a 1300
    /// ms
    /// calibration period.
    ///
    /// It is highly recommended that this function be called from initialize()
    /// when
    /// the robot is stationary to ensure proper calibration.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as a gyro
    ///
    /// \param smart_port
    ///        The smart port number that the ADI Expander is in
    /// \param adi_port
    ///        The ADI port to initialize as a gyro (from 1-8, 'a'-'h', 'A'-'H')
    /// \param multiplier
    ///        A scalar value that will be multiplied by the gyro heading value
    ///        supplied by the ADI
    ///
    /// \return An adi_gyro_t object containing the given port, or PROS_ERR if
    /// the
    /// initialization failed.
    pub fn ext_adi_gyro_init(smart_port: u8, adi_port: u8, multiplier: f64) -> ext_adi_gyro_t;
}
extern "C" {
    /// Resets the gyroscope value to zero.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as a gyro
    ///
    /// \param gyro
    ///        The adi_gyro_t object for which the angle will be returned
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_gyro_reset(gyro: ext_adi_gyro_t) -> i32;
}
extern "C" {
    /// Disables the gyro and voids the configuration on its port.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - Either the ADI port value or the smart port value is not within
    /// its
    ///	   valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
    /// EADDRINUSE - The port is not configured as a gyro
    ///
    /// \param gyro
    ///        The adi_gyro_t object to be shut down
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn ext_adi_gyro_shutdown(gyro: ext_adi_gyro_t) -> i32;
}
pub const controller_id_e_t_E_CONTROLLER_MASTER: controller_id_e_t = 0;
pub const controller_id_e_t_E_CONTROLLER_PARTNER: controller_id_e_t = 1;
pub type controller_id_e_t = u32;
pub const controller_analog_e_t_E_CONTROLLER_ANALOG_LEFT_X: controller_analog_e_t = 0;
pub const controller_analog_e_t_E_CONTROLLER_ANALOG_LEFT_Y: controller_analog_e_t = 1;
pub const controller_analog_e_t_E_CONTROLLER_ANALOG_RIGHT_X: controller_analog_e_t = 2;
pub const controller_analog_e_t_E_CONTROLLER_ANALOG_RIGHT_Y: controller_analog_e_t = 3;
pub type controller_analog_e_t = u32;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_L1: controller_digital_e_t = 6;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_L2: controller_digital_e_t = 7;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_R1: controller_digital_e_t = 8;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_R2: controller_digital_e_t = 9;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_UP: controller_digital_e_t = 10;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_DOWN: controller_digital_e_t = 11;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_LEFT: controller_digital_e_t = 12;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_RIGHT: controller_digital_e_t = 13;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_X: controller_digital_e_t = 14;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_B: controller_digital_e_t = 15;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_Y: controller_digital_e_t = 16;
pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_A: controller_digital_e_t = 17;
pub type controller_digital_e_t = u32;
extern "C" {
    /// Gets the value of an analog channel (joystick) on a controller.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - A value other than E_CONTROLLER_MASTER or E_CONTROLLER_PARTNER
    /// is
    /// given.
    /// EACCES - Another resource is currently trying to access the controller
    /// port.
    ///
    /// \param id
    ///        The ID of the controller (e.g. the master or partner controller).
    ///        Must be one of CONTROLLER_MASTER or CONTROLLER_PARTNER
    /// \param channel
    ///        The analog channel to get.
    ///        Must be one of ANALOG_LEFT_X, ANALOG_LEFT_Y, ANALOG_RIGHT_X,
    ///        ANALOG_RIGHT_Y
    ///
    /// \return The current reading of the analog channel: [-127, 127].
    /// If the controller was not connected, then 0 is returned
    pub fn controller_get_analog(id: controller_id_e_t, channel: controller_analog_e_t) -> i32;
}
extern "C" {
    /// Checks if a digital channel (button) on the controller is currently
    /// pressed.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - A value other than E_CONTROLLER_MASTER or E_CONTROLLER_PARTNER
    /// is
    /// given.
    /// EACCES - Another resource is currently trying to access the controller
    /// port.
    ///
    /// \param id
    ///        The ID of the controller (e.g. the master or partner controller).
    ///        Must be one of CONTROLLER_MASTER or CONTROLLER_PARTNER
    /// \param button
    ///        The button to read.
    ///        Must be one of DIGITAL_{RIGHT,DOWN,LEFT,UP,A,B,Y,X,R1,R2,L1,L2}
    ///
    /// \return 1 if the button on the controller is pressed.
    /// If the controller was not connected, then 0 is returned
    pub fn controller_get_digital(id: controller_id_e_t, button: controller_digital_e_t) -> i32;
}
extern "C" {
    /// Sets the voltage for the motor from -127 to 127.
    ///
    /// This is designed to map easily to the input from the controller's analog
    /// stick for simple opcontrol use. The actual behavior of the motor is
    /// analogous
    /// to use of motor_move_voltage(), or motorSet() from the PROS 2 API.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param voltage
    ///        The new motor voltage from -127 to 127
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_move(port: u8, voltage: i32) -> i32;
}
extern "C" {
    /// Sets the target absolute position for the motor to move to.
    ///
    /// This movement is relative to the position of the motor when initialized
    /// or
    /// the position when it was most recently reset with
    /// motor_set_zero_position().
    ///
    /// \note This function simply sets the target for the motor, it does not
    /// block
    /// program execution until the movement finishes.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param position
    ///        The absolute position to move to in the motor's encoder units
    /// \param velocity
    ///        The maximum allowable velocity for the movement in RPM
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_move_absolute(port: u8, position: f64, velocity: i32) -> i32;
}
extern "C" {
    /// Sets the relative target position for the motor to move to.
    ///
    /// This movement is relative to the current position of the motor as given
    /// in
    /// motor_get_position(). Providing 10.0 as the position parameter would
    /// result
    /// in the motor moving clockwise 10 units, no matter what the current
    /// position
    /// is.
    ///
    /// \note This function simply sets the target for the motor, it does not
    /// block
    /// program execution until the movement finishes.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param position
    ///        The relative position to move to in the motor's encoder units
    /// \param velocity
    ///        The maximum allowable velocity for the movement in RPM
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_move_relative(port: u8, position: f64, velocity: i32) -> i32;
}
extern "C" {
    /// Sets the velocity for the motor.
    ///
    /// This velocity corresponds to different actual speeds depending on the
    /// gearset
    /// used for the motor. This results in a range of +-100 for
    /// E_MOTOR_GEARSET_36,
    /// +-200 for E_MOTOR_GEARSET_18, and +-600 for E_MOTOR_GEARSET_6. The
    /// velocity
    /// is held with PID to ensure consistent speed, as opposed to setting the
    /// motor's voltage.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param velocity
    ///        The new motor velocity from +-100, +-200, or +-600 depending on
    /// the
    ///        motor's gearset
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_move_velocity(port: u8, velocity: i32) -> i32;
}
extern "C" {
    /// Sets the output voltage for the motor from -12000 to 12000 in millivolts
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param voltage
    ///        The new voltage value from -12000 to 12000
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_move_voltage(port: u8, voltage: i32) -> i32;
}
extern "C" {
    /// Changes the output velocity for a profiled movement (motor_move_absolute
    /// or
    /// motor_move_relative). This will have no effect if the motor is not
    /// following
    /// a profiled movement.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param velocity
    ///        The new motor velocity from +-100, +-200, or +-600 depending on
    /// the
    ///        motor's gearset
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_modify_profiled_velocity(port: u8, velocity: i32) -> i32;
}
extern "C" {
    /// Gets the target position set for the motor by the user.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The target position in its encoder units or PROS_ERR_F if the
    /// operation failed, setting errno.
    pub fn motor_get_target_position(port: u8) -> f64;
}
extern "C" {
    /// Gets the velocity commanded to the motor by the user.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The commanded motor velocity from +-100, +-200, or +-600, or
    /// PROS_ERR
    /// if the operation failed, setting errno.
    pub fn motor_get_target_velocity(port: u8) -> i32;
}
extern "C" {
    /// Gets the actual velocity of the motor.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's actual velocity in RPM or PROS_ERR_F if the
    /// operation
    /// failed, setting errno.
    pub fn motor_get_actual_velocity(port: u8) -> f64;
}
extern "C" {
    /// Gets the current drawn by the motor in mA.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's current in mA or PROS_ERR if the operation failed,
    /// setting errno.
    pub fn motor_get_current_draw(port: u8) -> i32;
}
extern "C" {
    /// Gets the direction of movement for the motor.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return 1 for moving in the positive direction, -1 for moving in the
    /// negative direction, or PROS_ERR if the operation failed, setting errno.
    pub fn motor_get_direction(port: u8) -> i32;
}
extern "C" {
    /// Gets the efficiency of the motor in percent.
    ///
    /// An efficiency of 100% means that the motor is moving electrically while
    /// drawing no electrical power, and an efficiency of 0% means that the
    /// motor
    /// is drawing power but not moving.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's efficiency in percent or PROS_ERR_F if the operation
    /// failed, setting errno.
    pub fn motor_get_efficiency(port: u8) -> f64;
}
extern "C" {
    /// Checks if the motor is drawing over its current limit.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return 1 if the motor's current limit is being exceeded and 0 if the
    /// current
    /// limit is not exceeded, or PROS_ERR if the operation failed, setting
    /// errno.
    pub fn motor_is_over_current(port: u8) -> i32;
}
extern "C" {
    /// Checks if the motor's temperature is above its limit.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return 1 if the temperature limit is exceeded and 0 if the the
    /// temperature
    /// is below the limit, or PROS_ERR if the operation failed, setting errno.
    pub fn motor_is_over_temp(port: u8) -> i32;
}
extern "C" {
    /// Gets the absolute position of the motor in its encoder units.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's absolute position in its encoder units or PROS_ERR_F
    /// if the operation failed, setting errno.
    pub fn motor_get_position(port: u8) -> f64;
}
extern "C" {
    /// Gets the power drawn by the motor in Watts.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's power draw in Watts or PROS_ERR_F if the operation
    /// failed, setting errno.
    pub fn motor_get_power(port: u8) -> f64;
}
extern "C" {
    /// Gets the temperature of the motor in degrees Celsius.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's temperature in degrees Celsius or PROS_ERR_F if the
    /// operation failed, setting errno.
    pub fn motor_get_temperature(port: u8) -> f64;
}
extern "C" {
    /// Gets the torque generated by the motor in Newton Meters (Nm).
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's torque in Nm or PROS_ERR_F if the operation failed,
    /// setting errno.
    pub fn motor_get_torque(port: u8) -> f64;
}
extern "C" {
    /// Gets the voltage delivered to the motor in millivolts.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's voltage in mV or PROS_ERR_F if the operation failed,
    /// setting errno.
    pub fn motor_get_voltage(port: u8) -> i32;
}
pub const motor_brake_mode_e_E_MOTOR_BRAKE_COAST: motor_brake_mode_e = 0;
pub const motor_brake_mode_e_E_MOTOR_BRAKE_BRAKE: motor_brake_mode_e = 1;
pub const motor_brake_mode_e_E_MOTOR_BRAKE_HOLD: motor_brake_mode_e = 2;
pub const motor_brake_mode_e_E_MOTOR_BRAKE_INVALID: motor_brake_mode_e = 2147483647;
/// Indicates the current 'brake mode' of a motor.
pub type motor_brake_mode_e = u32;
/// Indicates the current 'brake mode' of a motor.
pub use self::motor_brake_mode_e as motor_brake_mode_e_t;
pub const motor_encoder_units_e_E_MOTOR_ENCODER_DEGREES: motor_encoder_units_e = 0;
pub const motor_encoder_units_e_E_MOTOR_ENCODER_ROTATIONS: motor_encoder_units_e = 1;
pub const motor_encoder_units_e_E_MOTOR_ENCODER_COUNTS: motor_encoder_units_e = 2;
pub const motor_encoder_units_e_E_MOTOR_ENCODER_INVALID: motor_encoder_units_e = 2147483647;
/// Indicates the units used by the motor encoders.
pub type motor_encoder_units_e = u32;
/// Indicates the units used by the motor encoders.
pub use self::motor_encoder_units_e as motor_encoder_units_e_t;
pub const motor_gearset_e_E_MOTOR_GEARSET_36: motor_gearset_e = 0;
pub const motor_gearset_e_E_MOTOR_GEARSET_18: motor_gearset_e = 1;
pub const motor_gearset_e_E_MOTOR_GEARSET_06: motor_gearset_e = 2;
pub const motor_gearset_e_E_MOTOR_GEARSET_INVALID: motor_gearset_e = 2147483647;
/// Indicates the current internal gear ratio of a motor.
pub type motor_gearset_e = u32;
/// Indicates the current internal gear ratio of a motor.
pub use self::motor_gearset_e as motor_gearset_e_t;
extern "C" {
    /// Sets the position for the motor in its encoder units.
    ///
    /// This will be the future reference point for the motor's "absolute"
    /// position.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param position
    ///        The new reference position in its encoder units
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_set_zero_position(port: u8, position: f64) -> i32;
}
extern "C" {
    /// Sets the "absolute" zero position of the motor to its current position.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_tare_position(port: u8) -> i32;
}
extern "C" {
    /// Sets one of motor_brake_mode_e_t to the motor.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param mode
    ///        The motor_brake_mode_e_t to set for the motor
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_set_brake_mode(port: u8, mode: motor_brake_mode_e_t) -> i32;
}
extern "C" {
    /// Sets the current limit for the motor in mA.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param limit
    ///        The new current limit in mA
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_set_current_limit(port: u8, limit: i32) -> i32;
}
extern "C" {
    /// Sets one of motor_encoder_units_e_t for the motor encoder.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param units
    ///        The new motor encoder units
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_set_encoder_units(port: u8, units: motor_encoder_units_e_t) -> i32;
}
extern "C" {
    /// Sets one of motor_gearset_e_t for the motor.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param gearset
    ///        The new motor gearset
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_set_gearing(port: u8, gearset: motor_gearset_e_t) -> i32;
}
extern "C" {
    /// Sets the reverse flag for the motor.
    ///
    /// This will invert its movements and the values returned for its position.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param reverse
    ///        True reverses the motor, false is default
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_set_reversed(port: u8, reverse: bool) -> i32;
}
extern "C" {
    /// Sets the voltage limit for the motor in Volts.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param limit
    ///        The new voltage limit in Volts
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn motor_set_voltage_limit(port: u8, limit: i32) -> i32;
}
extern "C" {
    /// Gets the brake mode that was set for the motor.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return One of motor_brake_mode_e_t, according to what was set for the
    /// motor,
    /// or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno.
    pub fn motor_get_brake_mode(port: u8) -> motor_brake_mode_e_t;
}
extern "C" {
    /// Gets the current limit for the motor in mA.
    ///
    /// The default value is 2500 mA.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's current limit in mA or PROS_ERR if the operation
    /// failed,
    /// setting errno.
    pub fn motor_get_current_limit(port: u8) -> i32;
}
extern "C" {
    /// Gets the encoder units that were set for the motor.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return One of motor_encoder_units_e_t according to what is set for the
    /// motor
    /// or E_MOTOR_ENCODER_INVALID if the operation failed.
    pub fn motor_get_encoder_units(port: u8) -> motor_encoder_units_e_t;
}
extern "C" {
    /// Gets the gearset that was set for the motor.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return One of motor_gearset_e_t according to what is set for the motor,
    /// or E_GEARSET_INVALID if the operation failed.
    pub fn motor_get_gearing(port: u8) -> motor_gearset_e_t;
}
extern "C" {
    /// Gets the operation direction of the motor as set by the user.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return 1 if the motor has been reversed and 0 if the motor was not
    /// reversed,
    /// or PROS_ERR if the operation failed, setting errno.
    pub fn motor_is_reversed(port: u8) -> i32;
}
extern "C" {
    /// Gets the voltage limit set by the user.
    ///
    /// Default value is 0V, which means that there is no software limitation
    /// imposed
    /// on the voltage.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as a motor
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The motor's voltage limit in V or PROS_ERR if the operation
    /// failed,
    /// setting errno.
    pub fn motor_get_voltage_limit(port: u8) -> i32;
}
pub type task_t = *mut libc::c_void;
pub type task_fn_t = ::core::option::Option<unsafe extern "C" fn(arg1: *mut libc::c_void)>;
pub const task_state_e_t_E_TASK_STATE_RUNNING: task_state_e_t = 0;
pub const task_state_e_t_E_TASK_STATE_READY: task_state_e_t = 1;
pub const task_state_e_t_E_TASK_STATE_BLOCKED: task_state_e_t = 2;
pub const task_state_e_t_E_TASK_STATE_SUSPENDED: task_state_e_t = 3;
pub const task_state_e_t_E_TASK_STATE_DELETED: task_state_e_t = 4;
pub const task_state_e_t_E_TASK_STATE_INVALID: task_state_e_t = 5;
pub type task_state_e_t = u32;
pub type mutex_t = *mut libc::c_void;
extern "C" {
    /// Gets the number of milliseconds since PROS initialized.
    ///
    /// \return The number of milliseconds since PROS initialized
    pub fn millis() -> u32;
}
extern "C" {
    /// Creates a new task and add it to the list of tasks that are ready to
    /// run.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENOMEM - The stack cannot be used as the TCB was not created.
    ///
    /// \param function
    ///        Pointer to the task entry function
    /// \param parameters
    ///        Pointer to memory that will be used as a parameter for the task
    /// being
    ///        created. This memory should not typically come from stack, but
    /// rather
    ///        from dynamically (i.e., malloc'd) or statically allocated memory.
    /// \param prio
    ///        The priority at which the task should run.
    ///        TASK_PRIO_DEFAULT plus/minus 1 or 2 is typically used.
    /// \param stack_depth
    ///        The number of words (i.e. 4 * stack_depth) available on the
    /// task's
    ///        stack. TASK_STACK_DEPTH_DEFAULT is typically sufficienct.
    /// \param name
    ///        A descriptive name for the task.  This is mainly used to
    /// facilitate
    ///        debugging. The name may be up to 32 characters long.
    ///
    /// \return A handle by which the newly created task can be referenced. If
    /// an
    /// error occurred, NULL will be returned and errno can be checked for hints
    /// as
    /// to why task_create failed.
    pub fn task_create(
        function: task_fn_t,
        parameters: *mut libc::c_void,
        prio: u32,
        stack_depth: u16,
        name: *const libc::c_char,
    ) -> task_t;
}
extern "C" {
    /// Removes a task from the RTOS real time kernel's management. The task
    /// being
    /// deleted will be removed from all ready, blocked, suspended and event
    /// lists.
    ///
    /// Memory dynamically allocated by the task is not automatically freed, and
    /// should be freed before the task is deleted.
    ///
    /// \param task
    ///        The handle of the task to be deleted.  Passing NULL will cause
    /// the
    ///        calling task to be deleted.
    pub fn task_delete(task: task_t);
}
extern "C" {
    /// Delays a task for a given number of milliseconds.
    ///
    /// This is not the best method to have a task execute code at predefined
    /// intervals, as the delay time is measured from when the delay is
    /// requested.
    /// To delay cyclically, use task_delay_until().
    ///
    /// \param milliseconds
    ///        The number of milliseconds to wait (1000 milliseconds per second)
    pub fn task_delay(milliseconds: u32);
}
extern "C" {
    /// Delays a task until a specified time.  This function can be used by
    /// periodic
    /// tasks to ensure a constant execution frequency.
    ///
    /// The task will be woken up at the time *prev_time + delta, and *prev_time
    /// will
    /// be updated to reflect the time at which the task will unblock.
    ///
    /// \param prev_time
    ///        A pointer to the location storing the setpoint time. This should
    ///        typically be initialized to the return value of millis().
    /// \param delta
    ///        The number of milliseconds to wait (1000 milliseconds per second)
    pub fn task_delay_until(prev_time: *mut u32, delta: u32);
}
extern "C" {
    /// Gets the priority of the specified task.
    ///
    /// \param task
    ///        The task to check
    ///
    /// \return The priority of the task
    pub fn task_get_priority(task: task_t) -> u32;
}
extern "C" {
    /// Gets the state of the specified task.
    ///
    /// \param task
    ///        The task to check
    ///
    /// \return The state of the task
    pub fn task_get_state(task: task_t) -> task_state_e_t;
}
extern "C" {
    /// Gets the name of the specified task.
    ///
    /// \param task
    ///        The task to check
    ///
    /// \return A pointer to the name of the task
    pub fn task_get_name(task: task_t) -> *mut libc::c_char;
}
extern "C" {
    /// Gets a task handle from the specified name
    ///
    /// The operation takes a relatively long time and should be used sparingly.
    ///
    /// \param name
    ///        The name to query
    ///
    /// \return A task handle with a matching name, or NULL if none were found.
    pub fn task_get_by_name(name: *const libc::c_char) -> task_t;
}
extern "C" {
    /// Get the currently running task handle. This could be useful if a task
    /// wants to tell another task about itself.
    ///
    /// \return The currently running task handle.
    pub fn task_get_current() -> task_t;
}
extern "C" {
    /// Sends a simple notification to task and increments the notification
    /// counter.
    ///
    /// See https://pros.cs.purdue.edu/v5/tutorials/topical/notifications.html for
    /// details.
    ///
    /// \param task
    ///        The task to notify
    ///
    /// \return Always returns true.
    pub fn task_notify(task: task_t) -> u32;
}
extern "C" {
    /// Waits for a notification to be nonzero.
    ///
    /// See https://pros.cs.purdue.edu/v5/tutorials/topical/notifications.html for
    /// details.
    ///
    /// \param clear_on_exit
    ///        If true (1), then the notification value is cleared.
    ///        If false (0), then the notification value is decremented.
    /// \param timeout
    ///        Specifies the amount of time to be spent waiting for a
    /// notification
    ///        to occur.
    ///
    /// \return The value of the task's notification value before it is
    /// decremented
    /// or cleared
    pub fn task_notify_take(clear_on_exit: bool, timeout: u32) -> u32;
}
extern "C" {
    /// Deletes a mutex
    ///
    /// \param mutex
    ///        Mutex to unlock.
    pub fn mutex_delete(mutex: mutex_t);
}
extern "C" {
    /// Reset Rotation Sensor
    ///
    /// Reset the current absolute position to be the same as the
    /// Rotation Sensor angle.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as an Rotation Sensor
    ///
    /// \param port
    ///        The V5 Rotation Sensor port number from 1-21
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn rotation_reset(port: u8) -> i32;
}
extern "C" {
    /// Get the Rotation Sensor's current position in centidegrees
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as an Rotation Sensor
    ///
    /// \param  port
    /// 				 The V5 Rotation Sensor port number from 1-21
    /// \return The position value or PROS_ERR_F if the operation failed,
    /// setting
    /// errno.
    pub fn rotation_get_position(port: u8) -> i32;
}
extern "C" {
    /// Get the Rotation Sensor's current velocity in centidegrees per second
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// ENXIO - The given value is not within the range of V5 ports (1-21).
    /// ENODEV - The port cannot be configured as an Rotation Sensor
    ///
    /// \param  port
    /// 				 The V5 Rotation Sensor port number from 1-21
    /// \return The velocity value or PROS_ERR_F if the operation failed,
    /// setting
    /// errno.
    pub fn rotation_get_velocity(port: u8) -> i32;
}
extern "C" {
    /// Enables generic serial on the given port.
    ///
    /// \note This function must be called before any of the generic serial
    /// functions will work.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn serial_enable(port: u8) -> i32;
}
extern "C" {
    /// Sets the baudrate for the serial port to operate at.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param baudrate
    ///        The baudrate to operate at
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn serial_set_baudrate(port: u8, baudrate: i32) -> i32;
}
extern "C" {
    /// Clears the internal input and output FIFO buffers.
    ///
    /// This can be useful to reset state and remove old, potentially unneeded
    /// data
    /// from the input FIFO buffer or to cancel sending any data in the output
    /// FIFO
    /// buffer.
    ///
    /// \note This function does not cause the data in the output buffer to be
    /// written, it simply clears the internal buffers. Unlike stdout, generic
    /// serial does not use buffered IO (the FIFO buffers are written as soon
    /// as possible).
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return 1 if the operation was successful or PROS_ERR if the operation
    /// failed, setting errno.
    pub fn serial_flush(port: u8) -> i32;
}
extern "C" {
    /// Returns the number of bytes available to be read in the the port's FIFO
    /// input buffer.
    ///
    /// \note This function does not actually read any bytes, is simply returns
    /// the
    /// number of bytes available to be read.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The number of bytes avaliable to be read or PROS_ERR if the
    /// operation
    /// failed, setting errno.
    pub fn serial_get_read_avail(port: u8) -> i32;
}
extern "C" {
    /// Returns the number of bytes free in the port's FIFO output buffer.
    ///
    /// \note This function does not actually write any bytes, is simply returns
    /// the
    /// number of bytes free in the port's buffer.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The number of bytes free or PROS_ERR if the operation failed,
    /// setting errno.
    pub fn serial_get_write_free(port: u8) -> i32;
}
extern "C" {
    /// Reads the next byte avaliable in the port's input buffer without
    /// removing it.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The next byte avaliable to be read, -1 if none are available, or
    /// PROS_ERR if the operation failed, setting errno.
    pub fn serial_peek_byte(port: u8) -> i32;
}
extern "C" {
    /// Reads the next byte avaliable in the port's input buffer.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    ///
    /// \return The next byte avaliable to be read, -1 if none are available, or
    /// PROS_ERR if the operation failed, setting errno.
    pub fn serial_read_byte(port: u8) -> i32;
}
extern "C" {
    /// Reads up to the next length bytes from the port's input buffer and
    /// places
    /// them in the user supplied buffer.
    ///
    /// \note This function will only return bytes that are currently avaliable
    /// to be
    /// read and will not block waiting for any to arrive.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param buffer
    ///        The location to place the data read
    /// \param length
    ///        The maximum number of bytes to read
    ///
    /// \return The number of bytes read or PROS_ERR if the operation failed,
    /// setting
    /// errno.
    pub fn serial_read(port: u8, buffer: *mut u8, length: i32) -> i32;
}
extern "C" {
    /// Write the given byte to the port's output buffer.
    ///
    /// \note Data in the port's output buffer is written to the serial port as
    /// soon
    /// as possible on a FIFO basis and can not be done manually by the user.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    /// EIO - Serious internal write error.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param buffer
    ///        The byte to write
    ///
    /// \return The number of bytes written or PROS_ERR if the operation failed,
    /// setting errno.
    pub fn serial_write_byte(port: u8, buffer: u8) -> i32;
}
extern "C" {
    /// Writes up to length bytes from the user supplied buffer to the port's
    /// output
    /// buffer.
    ///
    /// \note Data in the port's output buffer is written to the serial port as
    /// soon
    /// as possible on a FIFO basis and can not be done manually by the user.
    ///
    /// This function uses the following values of errno when an error state is
    /// reached:
    /// EINVAL - The given value is not within the range of V5 ports (1-21).
    /// EACCES - Another resource is currently trying to access the port.
    /// EIO - Serious internal write error.
    ///
    /// \param port
    ///        The V5 port number from 1-21
    /// \param buffer
    ///        The data to write
    /// \param length
    ///        The maximum number of bytes to write
    ///
    /// \return The number of bytes written or PROS_ERR if the operation failed,
    /// setting errno.
    pub fn serial_write(port: u8, buffer: *mut u8, length: i32) -> i32;
}
pub type sem_t = *mut libc::c_void;
extern "C" {
    /// Creates a recursive mutex which can be locked recursively by the owner.
    ///
    /// See
    /// https://pros.cs.purdue.edu/v5/extended/multitasking.html#recursive_mutexes
    /// for details.
    ///
    /// \return A newly created recursive mutex.
    pub fn mutex_recursive_create() -> mutex_t;
}
extern "C" {
    /// Takes a recursive mutex.
    ///
    /// See
    /// https://pros.cs.purdue.edu/v5/extended/multitasking.html#recursive_mutexes
    /// for details.
    ///
    /// \param mutex
    ///        A mutex handle created by mutex_recursive_create
    /// \param wait_time
    ///        Amount of time to wait before timing out
    ///
    /// \return 1 if the mutex was obtained, 0 otherwise
    pub fn mutex_recursive_take(mutex: mutex_t, timeout: u32) -> bool;
}
extern "C" {
    /// Gives a recursive mutex.
    ///
    /// See
    /// https://pros.cs.purdue.edu/v5/extended/multitasking.html#recursive_mutexes
    /// for details.
    ///
    /// \param mutex
    ///        A mutex handle created by mutex_recursive_create
    ///
    /// \return 1 if the mutex was obtained, 0 otherwise
    pub fn mutex_recursive_give(mutex: mutex_t) -> bool;
}
extern "C" {
    /// Creates a counting sempahore.
    ///
    /// See https://pros.cs.purdue.edu/v5/tutorials/multitasking.html#semaphores for
    ///details.
    ///
    /// \param max_count
    ///        The maximum count value that can be reached.
    /// \param init_count
    ///        The initial count value assigned to the new semaphore.
    ///
    /// \return A newly created semaphore. If an error occurred, NULL will be
    /// returned and errno can be checked for hints as to why sem_create failed.
    pub fn sem_create(max_count: u32, init_count: u32) -> sem_t;
}
extern "C" {
    /// Deletes a semaphore (or binary semaphore)
    ///
    /// See https://pros.cs.purdue.edu/v5/extended/multitasking.html#semaphores for
    /// details.
    ///
    /// \param sem
    /// 			  Semaphore to delete
    pub fn sem_delete(sem: sem_t);
}
extern "C" {
    /// Waits for the semaphore's value to be greater than 0. If the value is
    /// already
    /// greater than 0, this function immediately returns.
    ///
    /// See https://pros.cs.purdue.edu/v5/tutorials/multitasking.html#semaphores for
    /// details.
    ///
    /// \param sem
    ///        Semaphore to wait on
    /// \param timeout
    ///        Time to wait before the semaphore's becomes available. A timeout
    /// of 0
    ///        can be used to poll the sempahore. TIMEOUT_MAX can be used to
    /// block
    ///        indefinitely.
    ///
    /// \return True if the semaphore was successfully take, false otherwise. If
    /// false is returned, then errno is set with a hint about why the sempahore
    /// couldn't be taken.
    pub fn sem_wait(sem: sem_t, timeout: u32) -> bool;
}
extern "C" {
    /// Increments a semaphore's value.
    ///
    /// See https://pros.cs.purdue.edu/v5/tutorials/multitasking.html#semaphores for
    /// details.
    ///
    /// \param sem
    ///        Semaphore to post
    ///
    /// \return True if the value was incremented, false otherwise. If false is
    /// returned, then errno is set with a hint about why the semaphore couldn't
    /// be
    /// taken.
    pub fn sem_post(sem: sem_t) -> bool;
}
extern "C" {
    /// Returns the current value of the semaphore.
    ///
    /// See https://pros.cs.purdue.edu/v5/extended/multitasking.html#extra for
    /// details.
    ///
    /// \param sem
    ///        A semaphore handle
    ///
    /// \return The current value of the semaphore (e.g. the number of resources
    /// available)
    pub fn sem_get_count(sem: sem_t) -> u32;
}
pub const PROS_ERR_: i32 = 2147483647;
pub const PROS_ERR_F_: f64 = ::core::f64::INFINITY;