25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

getBanks.c 2.0 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * getBanks.c:
  3. * Call digitalReadBank to get values of all GPIOs.
  4. *
  5. ***********************************************************************
  6. * This file is part of wiringPi:
  7. * https://github.com/nuncio-bitis/WiringPi
  8. *
  9. * wiringPi is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as published
  11. *by the Free Software Foundation, either version 3 of the License, or (at your
  12. *option) any later version.
  13. *
  14. * wiringPi is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
  21. ***********************************************************************
  22. */
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <signal.h>
  26. #include <wiringPi.h>
  27. //**********************************************************************************************************************
  28. int main (void)
  29. {
  30. printf ("Raspberry Pi Bank Read Test\n");
  31. wiringPiSetupGpio();
  32. uint32_t bank0 = digitalReadBank(0);
  33. uint32_t bank1 = digitalReadBank(1);
  34. printf("Bank 0: 0x%08X\n", bank0);
  35. printf("Bank 1: 0x%08X\n", bank1);
  36. printf(" ");
  37. for (int i = 31; i >= 0; --i)
  38. {
  39. printf("%2d ", i);
  40. }
  41. printf("\n");
  42. printf(" ");
  43. for (int i = 31; i >= 0; --i)
  44. {
  45. printf("-- ");
  46. }
  47. printf("\n");
  48. printf("B0 :");
  49. for (int i = 31; i >= 0; --i)
  50. {
  51. printf("%2d ", (bank0 & (1 << i)) ? 1 : 0);
  52. }
  53. printf("\n");
  54. printf("B1 :");
  55. for (int i = 31; i >= 0; --i)
  56. {
  57. printf("%2d ", (bank1 & (1 << i)) ? 1 : 0);
  58. }
  59. printf("\n");
  60. return EXIT_SUCCESS;
  61. }
  62. //**********************************************************************************************************************