在线时间514 小时
UID2025756
注册时间2013-7-16
NXP金币0
该用户从未签到
金牌会员
 
- 积分
- 9267
- 最后登录
- 1970-1-1
|
发表于 2015-12-14 11:08:13
|
显示全部楼层
GPIO_LDD
Input signal alternation toggles output signal through external interruptThis example shows how to detect button pressing and change states light on/off of LED. There are used two components. First one is for pin configured as external interrupt and second one is for pin configured as output.
Required component setup of GPIO1:
- Interrupt service/event: Enabled
- Bit fields: 1
- Field name: Button
- Initial pin direction: Input
- Initial pin event: Falling edge or Rising edge
- OnPortEvent: Enabled
- Events: OnPortEvent
Required component setup of GPIO2:
- Interrupt service/event: Disabled
- Bit fields: 1
- Field name: Led
- Initial pin direction: Output
- Initial pin event: Disabled
- Methods: ToggleFieldBits
Content of ProcessorExpert.c:
LDD_TDeviceData *MyGPIO1Ptr, *MyGPIO2Ptr;void main(void){ ... MyGPIO1Ptr = GPIO1_Init((LDD_TUserData *)NULL); /* Initialize the button pin */ MyGPIO2Ptr = GPIO2_Init((LDD_TUserData *)NULL); /* Initialize the led pin */}Content of Event.c:
extern LDD_TDeviceData *MyGPIO2Ptr;void GPIO1_OnPortEvent(LDD_TUserData *UserDataPtr){ GPIO2_ToggleFieldBits(MyGPIO2Ptr, Led, 0x1U); /* Toggle led pin */}
|
|