打印
[应用方案]

NV32 GPIO位带操作

[复制链接]
765|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
萧洛毫|  楼主 | 2018-2-27 09:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
萧洛毫|  楼主 | 2018-2-27 09:25 | 只看该作者
#include "common.h"
#include "systick.h"
#include "bme.h"
#include "gpio.h"
#include "sysinit.h"
#include "start.h"

/***********************************************
#define LD0_Off    GPIOB_OutPut1(7)  
#define LD0_On     GPIOB_OutPut0(7)    //PE7
#define LD1_Off    GPIOB_OutPut1(25)  
#define LD1_On     GPIOB_OutPut0(25)   //PH1
#define LD2_Off    GPIOB_OutPut1(26)  
#define LD2_On     GPIOB_OutPut0(26)   //PH2
***************************************************/

#define LD0_Off    PE_OutPut1(7)
#define LD0_On     PE_OutPut0(7)
#define LD1_Off    PH_OutPut1(1)
#define LD1_On     PH_OutPut0(1)  
#define LD2_Off    PH_OutPut1(2)  
#define LD2_On     PH_OutPut0(2)

int main (void);

int main (void)
{
   sysinit();
       
   BME_BIT_SET(&GPIOB->PDDR,7); //set PE7 output
         
         BME_BIT_SET(&GPIOB->PDDR,25); //set PH1 output
         
         BME_BIT_SET(&GPIOB->PDDR,26); //set PH2 output
       

    while(1)
    {
                        delay_ms(1000);
                        LD0_Off;
                        delay_ms(1000);
                        LD1_Off;
                        delay_ms(1000);
                  LD2_Off;
                        delay_ms(1000);
                        LD2_On;
                        delay_ms(1000);
                        LD1_On;
                        delay_ms(1000);
                        LD0_On;
                        delay_ms(1000);
                        LD0_Off;
                        LD1_Off;
                        LD2_Off;
                        delay_ms(1000);
                        LD0_On;
                        LD1_On;
                        LD2_On;
    }
}

/********************************************************************/

使用特权

评论回复
板凳
萧洛毫|  楼主 | 2018-2-27 09:25 | 只看该作者
/******************************************************************************
*
* [url=home.php?mod=space&uid=247401]@brief[/url] define interrupt service routines referenced by the vector table.
*
* Note: Only "vectors.c" should include this header file.
*
*******************************************************************************
******************************************************************************/

#ifndef __ISR_H
#define __ISR_H


/* Example */
/*
#undef  VECTOR_036
#define VECTOR_036 RTC_Isr

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

/*!
* @brief define interrupt service routine for different vectors.
*
*/
#undef  VECTOR_036
#define VECTOR_036      RTC_Isr          /*!< Vector 36 points to RTC interrupt service routine */

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

#undef  VECTOR_040
#define VECTOR_040 KBI0_Isr

extern void KBI0_Isr(void);
extern void SysTick_Isr(void);
extern void RTC_Isr(void);

#endif  //__ISR_H

/* End of "isr.h" */

使用特权

评论回复
地板
余三水| | 2018-2-27 20:09 | 只看该作者
位带的操作是哪个呢?没有看懂,是PE_OutPut1(7)这些吗?

使用特权

评论回复
5
tomyoct| | 2018-2-28 15:46 | 只看该作者
余三水 发表于 2018-2-27 20:09
位带的操作是哪个呢?没有看懂,是PE_OutPut1(7)这些吗?

是的,应该就是这个的,做了个地址映射应该是。

使用特权

评论回复
6
smilingangel| | 2018-3-18 16:00 | 只看该作者
这个看下具体的操作的

使用特权

评论回复
7
余三水| | 2018-5-29 08:56 | 只看该作者
tomyoct 发表于 2018-2-28 15:46
是的,应该就是这个的,做了个地址映射应该是。

感觉这个操作很是奇怪的。

使用特权

评论回复
8
tomyoct| | 2018-5-29 17:06 | 只看该作者
余三水 发表于 2018-2-27 20:09
位带的操作是哪个呢?没有看懂,是PE_OutPut1(7)这些吗?

BME_BIT_SET(&GPIOB->PDDR,7); //set PE7 output
这个才是位带操作的。

使用特权

评论回复
9
tomyoct| | 2018-5-29 17:11 | 只看该作者
余三水 发表于 2018-5-29 08:56
感觉这个操作很是奇怪的。

不奇怪,库函数就是这么写的。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

53

主题

254

帖子

0

粉丝