本文整理汇总了C++中gpio::gpio_read方法的典型用法代码示例。如果您正苦于以下问题:C++ gpio::gpio_read方法的具体用法?C++ gpio::gpio_read怎么用?C++ gpio::gpio_read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpio
的用法示例。
在下文中一共展示了gpio::gpio_read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: button_testing
/*----------------------------------------------------------------------------*/
void button_testing(void)
{
start_waiting_esc_character();
HA_NOTIFY("\n*** BUTTON & MBOARD TEST ***\n"
"(press ESC to quit).\n");
while(1)
{
if(is_press_button(MB1_up.gpio_read()))
{
testing_delay_us(10000);
while(is_press_button(MB1_up.gpio_read()));
HA_NOTIFY("Press button UP.\n");
}
if(is_press_button(MB1_down.gpio_read()))
{
testing_delay_us(10000);
while(is_press_button(MB1_down.gpio_read()));
HA_NOTIFY("Press button DOWN.\n");
}
if(is_press_button(MB1_left.gpio_read()))
{
testing_delay_us(10000);
while(is_press_button(MB1_left.gpio_read()));
HA_NOTIFY("Press button LEFT.\n");
}
if(is_press_button(MB1_right.gpio_read()))
{
testing_delay_us(10000);
while(is_press_button(MB1_right.gpio_read()));
HA_NOTIFY("Press button RIGHT.\n");
}
if(is_press_button(MB1_select.gpio_read()))
{
testing_delay_us(10000);
while(is_press_button(MB1_select.gpio_read()));
HA_NOTIFY("Press button SELECT.\n");
}
/* poll the esc_pressed */
if (esc_pressed == true) {
break;
}
}//End while().
stop_waiting_esc_character();
HA_NOTIFY("Test stopped.\n");
}
示例2:
/*----------------------------------------------------------------------------*/
static void sim900_testing_init(void)
{
HA_NOTIFY("\nInitializing hardware for sim900 tests\n"
"USART: %u, Baudrate: %lu\n"
"RI pin: port: %u (port A = 0,...), pin: %u\n",
uart_num, baudrate,
RI_params.port, RI_params.pin);
/* Initialize UART */
MB1_usart.Restart(baudrate);
MB1_usart.it_enable(0,1);
MB1_usart.it_config(USART_IT_RXNE, ENABLE);
MB1_int.subISR_assign(MB1_int_type, usart3_irq);
/* Init RI pin */
RI_pin.gpio_init(&RI_params);
HA_NOTIFY("\nRI: %d (should be 1)\n", RI_pin.gpio_read());
/* Create ring buffer */
rb_init(&rx_buffer, 128);
}
示例3: while
static void sim900_gsm_test(void)
{
uint8_t state = 0, data, ri = 0;
start_waiting_esc_character();
HA_NOTIFY("\nTEST #2: GSM TEST\n"
"This test calls *101# to check money account\n"
"(Press ESC to continue)\n");
while (esc_pressed == false);
stop_waiting_esc_character();
/* Clear buffer brfore testing */
rb_clear(&rx_buffer);
HA_NOTIFY("\nCalling *101# ... \n");
/* Call *101# */
MB1_usart.Print("ATD*101#;\r");
start_waiting_esc_character();
while(1)
{
/* Receiving message */
if (rb_get_data(&rx_buffer,&data,1) > 0)
{
switch (state)
{
/* Print content between two " " */
case 0:
if (data == '"')
{
state = 1;
HA_NOTIFY("\nReceived Message: \n");
/*check RI pin*/
if (RI_pin.gpio_read() == 0) ri = 1;
}
break;
case 1:
if (data == '"')
{
state = 2;
HA_NOTIFY("\n");
}
else
{
HA_NOTIFY("%c", (char)data);
}
break;
/* End of message */
case 2:
if (data == '\r')
{
state = 3;
HA_NOTIFY("\nSuccessful !\n");
}
break;
}
}
if (esc_pressed == true)
{
break;
}
}
stop_waiting_esc_character();
/* Fail to receive message */
if (state != 3)
{
HA_NOTIFY("\nFail\n");
}
else
{
if (ri == 1)
{
HA_NOTIFY("\nRI pin works\n");
}
else
{
HA_NOTIFY("\nRI pin does not work\n");
}
}
}