#author("2022-11-16T17:09:51+08:00","default:Admin","Admin")
#author("2022-11-16T17:18:24+08:00","default:Admin","Admin")
[[+Zigbee30+EmberZnet]]

&color(red){※This article is based on EmberZnet SDK 6.7.5.0 and EFR32MG Series};

#contents

* API [#pedaa204]

** GPIO_PinModeSet [#sac84aa8]

Set the mode for a GPIO pin.

#codeprettify{{
void GPIO_PinModeSet(GPIO_Port_TypeDef 	port, 
			unsigned int 	pin, 
			GPIO_Mode_TypeDef 	mode, 
			unsigned int 	out 
			)

Parameters
- port	The GPIO port to access.
- pin	The pin number in the port.
- mode	The desired pin mode.
- out	A value to set for the pin in the DOUT register. The DOUT setting is important for some input mode configurations to determine the pull-up/down direction.
}}


收发引脚的配置,根据手册中的描述和例子,需要将对应的TX配置为推挽输出模式,RX配置为输入模式。
#codeprettify{{
//  配置引脚
GPIO_PinModeSet(PORTIO_USART0_TX_PORT,PORTIO_USART0_TX_PIN,gpioModePushPull,true);
GPIO_PinModeSet(PORTIO_USART0_RX_PORT,PORTIO_USART0_RX_PIN,gpioModeInput,true);
}}

重要!!!由于硬件设计非常灵活,所以USART0的收发两个引脚必须路由到指定的GPIO引脚上去,而且要注意,光是路由过去还不行,还必须要使能相应的引脚功能。
#codeprettify{{
//  引脚路由
GPIO->USARTROUTE_SET[USART_NUM(USART0)].RXROUTE =
   (PORTIO_USART0_RX_PORT<<_GPIO_USART_RXROUTE_PORT_SHIFT) |
   (PORTIO_USART0_RX_PIN <<_GPIO_USART_RXROUTE_PIN_SHIFT);

GPIO->USARTROUTE_SET[USART_NUM(USART0)].TXROUTE =
   (PORTIO_USART0_TX_PORT<<_GPIO_USART_TXROUTE_PORT_SHIFT) |
   (PORTIO_USART0_TX_PIN <<_GPIO_USART_TXROUTE_PIN_SHIFT);
//  引脚使能
GPIO->USARTROUTE_SET[USART_NUM(USART0)].ROUTEEN =(GPIO_USART_ROUTEEN_RXPEN | GPIO_USART_ROUTEEN_TXPEN);
}}
** GPIO_IntConfig [#m46bd188]

Configure GPIO interrupt.

If reconfiguring a GPIO interrupt that is already enabled, it is generally recommended to disable it first, see GPIO_Disable().

The actual GPIO interrupt handler must be in place before enabling the interrupt.

Notice that any pending interrupt for the selected pin is cleared by this function.

#codeprettify{{
__STATIC_INLINE void GPIO_IntConfig(GPIO_Port_TypeDef 	port, 
					unsigned int 	pin, 
					bool 	risingEdge, 
					bool 	fallingEdge, 
					bool 	enable 
					)		
Deprecated:
Deprecated function. New code should use GPIO_ExtIntConfig().

Note
A certain pin number can only be associated with one port; i.e., if GPIO interrupt 1 is assigned to port A/pin 1, then it is not possible to use pin 1 from any other ports for interrupts. Refer to the reference manual. On devices which implement GPIO_EXTIPINSEL registers a more flexible approach is possible, refer to GPIO_ExtIntConfig().
Parameters
- port	The port to associate with pin.
- pin	The pin number on the port ( == GPIO EXTI interrupt number).
- risingEdge	Set to true if interrupts will be enabled on rising edge, otherwise false.
- fallingEdge	Set to true if interrupts will be enabled on falling edge, otherwise false.
- enable	Set to true if interrupt will be enabled after configuration completed, false to leave disabled. See GPIO_IntDisable() and GPIO_IntEnable().
}}

** GPIO_PinOutSet [#m1038908]

Set a single pin in GPIO data out register to 1.

#codeprettify{{
__STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef 	port, unsigned int 	pin )

Note
In order for the setting to take effect on the output pad, the pin must have been configured properly. If not, it will take effect whenever the pin has been properly configured.
Parameters
- port	The GPIO port to access.
- pin	The pin to set.
}}

 GPIO_PinOutSet(gpioPortA, 5); //高电平,耗时约20ns
 halResetWatchdog();//耗时约680ns

** GPIO_PinOutClear [#c0b5a8e8]

Set a single pin in GPIO data out port register to 0.

#codeprettify{{
__STATIC_INLINE void GPIO_PinOutClear(GPIO_Port_TypeDef 	port, unsigned int 	pin )

Note
In order for the setting to take effect on the output pad, the pin must have been configured properly. If not, it will take effect whenever the pin has been properly configured.
Parameters
- port	The GPIO port to access.
- pin	The pin to set.
}}

 GPIO_PinOutClear(gpioPortA, 5); //低电平,耗时约20ns+60ns

&ref(ZigBee.png);

#hr();
Comment:
#comment_kcaptcha

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS