我看了按键例程,它是用中断的方式来运行的,那么如果我想要使用按键查询的方式来获取按键值,我应该如何修改例程呢?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
这个参考的Button_open有些错误,它应该只有两个参数,不应包含callback函数
/*!
* @brief Function to open a given Button
*
* Function to open a button instance corresponding to a #Button_Config in the
* Button_config array. The GPIO configurations must exist prior to calling
* this function. The #Button_Params may be used to specify runtime parameters.
*
* @pre Button_init() has to be called first
*
* @param[in] buttonIndex Logical button number indexed into
* the Button_config table
*
* @param[in] *params A pointer to #Button_Params structure. If NULL,
* it will use default values.
*
* @return A #Button_Handle on success, or a NULL on failure.
*
* @sa Button_init()
* @sa Button_Params_init()
* @sa Button_close()
*/
extern Button_Handle Button_open(uint_least8_t buttonIndex, Button_Params *params);
GPIO_init();
/* Configure the LED and button pins */
GPIO_setConfig(13, GPIO_CFG_IN_PU); //可不写,因为已在GPIO_init()中配置了。
GPIO_setConfig(22, GPIO_CFG_IN_PU); //可不写,因为已在GPIO_init()中配置了。
/* Turn on user LED */
GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
uint8_t tmp8;
while(1){
tmp8= GPIO_read(13);
if(tmp8)
{
//GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
GPIOPinWrite(GPIOA1_BASE, GPIO_PIN_1, GPIO_PIN_1);
}
else{
//GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_OFF);
GPIOPinWrite(GPIOA1_BASE, GPIO_PIN_1, 0);
}
}
我对open,read,write也不习惯。