| 1234567891011121314151617181920212223242526272829303132333435363738 |
- #include "detection.h"
- #include "gd32e230x_conf.h"
- void detection_Init()
- {
- rcu_periph_clock_enable(RCU_GPIOB);
- rcu_periph_clock_enable(RCU_GPIOA);
- gpio_mode_set(GPIOB, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP,GPIO_PIN_3);
- gpio_mode_set(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP,GPIO_PIN_11);
-
- }
- uint8_t get_detection()
- {
- uint8_t value = 0;
- if(gpio_input_bit_get(GPIOA,GPIO_PIN_11)==0)
- value |= 1;
- if(gpio_input_bit_get(GPIOB,GPIO_PIN_3)==0)
- value |= 2;
- return value;
- }
|