原创 GPIO程序

2022-8-3 18:40 1103 8 8 分类: FPGA/CPLD 文集: 2022
  1. #include "DSP28_Device.h"
  2. #include "DSP28_Globalprototypes.h"
  3. // Prototype statements for functions found within this file.
  4. // interrupt void ISRTimer2(void);
  5. void delay_loop(void);
  6. void Gpio_select(void);
  7. unsigned int var1 = 0;
  8. unsigned int var2 = 0;
  9. unsigned int var3 = 0;
  10. unsigned int var4 = 0;
  11. unsigned int var5 = 0;
  12. void main(void)
  13. {
  14. int ii=0;
  15. int i;
  16. InitSysCtrl();
  17. // Disable and clear all CPU interrupts:
  18. DINT;
  19. IER = 0x0000;
  20. IFR = 0x0000;
  21. // Initialize Pie Control Registers To Default State:
  22. InitPieCtrl();
  23. InitPieVectTable();
  24. InitGpio();
  25. // Run GPIO test
  26. var1 = 0x0000; // sets GPIO Muxs as I/Os
  27. var2 = 0xFFFF; // sets GPIO DIR as outputs
  28. var3 = 0x0000; // sets the Input qualifier values
  29. // Gpio_select();
  30. // Toggle I/Os using DATA register for ever
  31. while(1)
  32. {
  33. /*
  34. GpioDataRegs.GPADAT.all = 0x000A;
  35. for(ii = 0; ii < 100; ii++)
  36. {
  37. delay_loop();
  38. }
  39. GpioDataRegs.GPADAT.all = 0x0005;
  40. delay_loop();
  41. for(ii = 0; ii < 100; ii++)
  42. {
  43. delay_loop();
  44. }
  45. */
  46. for(i = 0; i < 4; i++)
  47. {
  48. GpioDataRegs.GPADAT.all = 0x08 >> i;
  49. for(ii = 0; ii < 50; ii++)
  50. {
  51. delay_loop();
  52. }
  53. GpioDataRegs.GPACLEAR.all = 0x08 >> i;
  54. for(ii = 0; ii < 10; ii++)
  55. {
  56. //delay_loop();
  57. }
  58. }
  59. }
  60. }
  61. void delay_loop()
  62. {
  63. short i;
  64. for (i = 0; i < 5000; i++) {}
  65. }
  66. void Gpio_select(void)
  67. {
  68. EALLOW;
  69. GpioMuxRegs.GPAMUX.all=var1;
  70. // GpioMuxRegs.GPBMUX.all=var1;
  71. GpioMuxRegs.GPADIR.all=var2; // GPIO PORTs as output
  72. // GpioMuxRegs.GPBDIR.all=var2; // GPIO DIR select GPIOs as output
  73. GpioMuxRegs.GPAQUAL.all=var3; // Set GPIO input qualifier values
  74. // GpioMuxRegs.GPBQUAL.all=var3;
  75. EDIS;
  76. }
PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
8
关闭 站长推荐上一条 /1 下一条