[应用方案] NV32 GPIO位带操作

[复制链接]
 楼主| 萧洛毫 发表于 2018-2-27 09:24 | 显示全部楼层 |阅读模式
GPIO, pi, IO, gp, AC
GPIO位带操作.zip (385.58 KB, 下载次数: 14)
 楼主| 萧洛毫 发表于 2018-2-27 09:25 | 显示全部楼层
  1. #include "common.h"
  2. #include "systick.h"
  3. #include "bme.h"
  4. #include "gpio.h"
  5. #include "sysinit.h"
  6. #include "start.h"

  7. /***********************************************
  8. #define LD0_Off    GPIOB_OutPut1(7)  
  9. #define LD0_On     GPIOB_OutPut0(7)    //PE7
  10. #define LD1_Off    GPIOB_OutPut1(25)  
  11. #define LD1_On     GPIOB_OutPut0(25)   //PH1
  12. #define LD2_Off    GPIOB_OutPut1(26)  
  13. #define LD2_On     GPIOB_OutPut0(26)   //PH2
  14. ***************************************************/

  15. #define LD0_Off    PE_OutPut1(7)
  16. #define LD0_On     PE_OutPut0(7)
  17. #define LD1_Off    PH_OutPut1(1)
  18. #define LD1_On     PH_OutPut0(1)  
  19. #define LD2_Off    PH_OutPut1(2)  
  20. #define LD2_On     PH_OutPut0(2)

  21. int main (void);

  22. int main (void)
  23. {
  24.    sysinit();
  25.        
  26.    BME_BIT_SET(&GPIOB->PDDR,7); //set PE7 output
  27.          
  28.          BME_BIT_SET(&GPIOB->PDDR,25); //set PH1 output
  29.          
  30.          BME_BIT_SET(&GPIOB->PDDR,26); //set PH2 output
  31.        

  32.     while(1)
  33.     {
  34.                         delay_ms(1000);
  35.                         LD0_Off;
  36.                         delay_ms(1000);
  37.                         LD1_Off;
  38.                         delay_ms(1000);
  39.                   LD2_Off;
  40.                         delay_ms(1000);
  41.                         LD2_On;
  42.                         delay_ms(1000);
  43.                         LD1_On;
  44.                         delay_ms(1000);
  45.                         LD0_On;
  46.                         delay_ms(1000);
  47.                         LD0_Off;
  48.                         LD1_Off;
  49.                         LD2_Off;
  50.                         delay_ms(1000);
  51.                         LD0_On;
  52.                         LD1_On;
  53.                         LD2_On;
  54.     }
  55. }

  56. /********************************************************************/
 楼主| 萧洛毫 发表于 2018-2-27 09:25 | 显示全部楼层
  1. /******************************************************************************
  2. *
  3. * [url=home.php?mod=space&uid=247401]@brief[/url] define interrupt service routines referenced by the vector table.
  4. *
  5. * Note: Only "vectors.c" should include this header file.
  6. *
  7. *******************************************************************************
  8. ******************************************************************************/

  9. #ifndef __ISR_H
  10. #define __ISR_H


  11. /* Example */
  12. /*
  13. #undef  VECTOR_036
  14. #define VECTOR_036 RTC_Isr

  15. // ISR(s) are defined in your project directory.
  16. extern void RTC_Isr(void);
  17. */

  18. /*!
  19. * @brief define interrupt service routine for different vectors.
  20. *
  21. */
  22. #undef  VECTOR_036
  23. #define VECTOR_036      RTC_Isr          /*!< Vector 36 points to RTC interrupt service routine */

  24. #undef  VECTOR_015
  25. #define VECTOR_015      SysTick_Isr          /*!< Vector 15 points to SysTick interrupt service routine */

  26. #undef  VECTOR_040
  27. #define VECTOR_040 KBI0_Isr

  28. extern void KBI0_Isr(void);
  29. extern void SysTick_Isr(void);
  30. extern void RTC_Isr(void);

  31. #endif  //__ISR_H

  32. /* End of "isr.h" */
余三水 发表于 2018-2-27 20:09 | 显示全部楼层
位带的操作是哪个呢?没有看懂,是PE_OutPut1(7)这些吗?
tomyoct 发表于 2018-2-28 15:46 | 显示全部楼层
余三水 发表于 2018-2-27 20:09
位带的操作是哪个呢?没有看懂,是PE_OutPut1(7)这些吗?

是的,应该就是这个的,做了个地址映射应该是。
smilingangel 发表于 2018-3-18 16:00 | 显示全部楼层
这个看下具体的操作的
余三水 发表于 2018-5-29 08:56 | 显示全部楼层
tomyoct 发表于 2018-2-28 15:46
是的,应该就是这个的,做了个地址映射应该是。

感觉这个操作很是奇怪的。
tomyoct 发表于 2018-5-29 17:06 | 显示全部楼层
余三水 发表于 2018-2-27 20:09
位带的操作是哪个呢?没有看懂,是PE_OutPut1(7)这些吗?

BME_BIT_SET(&GPIOB->PDDR,7); //set PE7 output
这个才是位带操作的。
tomyoct 发表于 2018-5-29 17:11 | 显示全部楼层
余三水 发表于 2018-5-29 08:56
感觉这个操作很是奇怪的。

不奇怪,库函数就是这么写的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

53

主题

254

帖子

0

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