[活动专区] 【杰发科技AC7802x测评】-3- 呼吸灯

[复制链接]
1839|1
 楼主| 南来之风 发表于 2023-5-29 12:12 | 显示全部楼层 |阅读模式
本帖最后由 南来之风 于 2023-5-29 13:43 编辑

本次使用AC7802x的GPIO模块来制作呼吸灯。
主要思路是通过延迟来实现PWM的效果,核心代码:
  1. void delay_us(uint16_t Nus){
  2.         
  3.         uint8_t i = 32;
  4.         
  5.         while(Nus--){
  6.                 while(i--)
  7.                         ;
  8.         }
  9. }

  10. /*!
  11. * [url=home.php?mod=space&uid=247401]@brief[/url]   main函数
  12. *
  13. * @param   none
  14. * [url=home.php?mod=space&uid=266161]@return[/url]  int
  15. */
  16. int main(void)
  17. {
  18.     InitDelay();
  19.     InitDebug();
  20.     GPIO_LedInit();
  21.     GPIO_KeyInit();
  22.     TIMER_PrdInit();

  23.     printf("Hi This is GPIO Basic Demo !\r\n");
  24.         uint32_t i = 0;
  25.         while (1)
  26.     {
  27.         //GPIO_ScanKeyInput();
  28.         //GPIO_ToggleLedPrd();
  29.                
  30.                 for(i = 0; i < 200; i++){
  31.                         LED1_OFF; LED2_OFF; delay_us(i);
  32.                         LED1_ON;LED2_ON;delay_us(200-i);                        
  33.                 }
  34.                 for(i = 0; i < 200; i++){
  35.                         LED1_ON;LED2_ON;delay_us(i);
  36.                         LED1_OFF;LED2_OFF;delay_us(200-i);                        
  37.                 }
  38.                
  39.     }
  40. }

代码目录结构:
  1. M:\AUTOCHIP\01_GPIO_BASIC
  2. │  demo.uvguix.yshu
  3. │  demo.uvoptx
  4. │  demo.uvprojx
  5. │  EventRecorderStub.scvd
  6. │  JLinkLog.txt
  7. │  JLinkSettings.ini

  8. ├─Listings
  9. │      Demo.map
  10. │      startup_ac7802x.lst

  11. ├─Objects
  12. │      ac7802x_debugout.crf
  13. │      ac7802x_debugout.d
  14. │      ac7802x_debugout.o
  15. │      ac780x_ckgen.crf
  16. │      ac780x_ckgen.d
  17. │      ac780x_ckgen.o
  18. │      ac780x_eflash.crf
  19. │      ac780x_eflash.d
  20. │      ac780x_eflash.o
  21. │      ac780x_gpio.crf
  22. │      ac780x_gpio.d
  23. │      ac780x_gpio.o
  24. │      ac780x_pwm.crf
  25. │      ac780x_pwm.d
  26. │      ac780x_pwm.o
  27. │      ac780x_spm.crf
  28. │      ac780x_spm.d
  29. │      ac780x_spm.o
  30. │      ac780x_timer.crf
  31. │      ac780x_timer.d
  32. │      ac780x_timer.o
  33. │      ac780x_uart.crf
  34. │      ac780x_uart.d
  35. │      ac780x_uart.o
  36. │      Demo.axf
  37. │      Demo.build_log.htm
  38. │      Demo.htm
  39. │      Demo.lnp
  40. │      Demo.sct
  41. │      demo_Demo.dep
  42. │      ExtDll.iex
  43. │      gpio.crf
  44. │      gpio.d
  45. │      gpio.o
  46. │      main.crf
  47. │      main.d
  48. │      main.o
  49. │      startup_ac7802x.d
  50. │      startup_ac7802x.o
  51. │      system_ac7802x.crf
  52. │      system_ac7802x.d
  53. │      system_ac7802x.o
  54. │      timer.crf
  55. │      timer.d
  56. │      timer.o

  57. ├─RTE
  58. │  ├─Board_Support
  59. │  │  └─AC78022MBQA
  60. │  │          ac7802x_debugout.c
  61. │  │
  62. │  ├─Device
  63. │  │  └─AC78022MBQA
  64. │  │          device_assert.h
  65. │  │          startup_ac7802x.s
  66. │  │          system_ac7802x.c
  67. │  │          system_ac7802x.h
  68. │  │
  69. │  └─_Demo
  70. │          RTE_Components.h

  71. └─User
  72.         gpio.c
  73.         gpio.h
  74.         main.c
  75.         timer.c
  76.         timer.h



效果展示:
ezgif.com-crop.gif






GrootBrain 发表于 2023-5-30 06:44 | 显示全部楼层
代码结构的这个图,看起来像linux的tree功能,但是工程是keil的工程。如果是windows,怎么做出的这个图片?如果是linux,怎么编译keil工程?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

69

主题

293

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部