Код: Выделить всё
void read_button(void) {
static uint8_t count_read_button_ok=0;
count_read_button_ok++;
//--------------------------- OK -----------------------------
static char button, button_old=1;
button_old=button;
button=GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13);
if (((button_old!=button)&&(button==0))) {
delay_ms(5);
button=GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13);
if (((button_old!=button)&&(button==0))) {
delay_ms(5);
button=GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13);
if (((button_old!=button)&&(button==0))) {
delay_ms(5);
button=GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13);
if (((button_old!=button)&&(button==0))) {
delay_ms(5);
button=GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13);
if (((button_old!=button)&&(button==0))) {
second_systick_ms=0;
button_second=0;
while (((GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13)==0)&&(button_second<2))); // зачем это???
if (button_second<2) {
button_ok_press(); // управляющая функция.
}
else {
RTC_Counter = RTC_GetCounter();
RTC_GetDateTime(RTC_Counter, &RTC_DateTime);
RTC_DateTime.RTC_Seconds=0;
RTC_SetCounter(RTC_GetRTC_Counter(&RTC_DateTime));
}
}
}
}
}
}
Код: Выделить всё
//PinB 13 - Ok, PinB 14 - Down, PinB 15 - Up
static void button_init(void){
GPIO_InitTypeDef button_ok =
{.GPIO_Pin = GPIO_Pin_13, .GPIO_Speed = GPIO_Speed_2MHz, .GPIO_Mode = GPIO_Mode_IPU};
GPIO_InitTypeDef button_down =
{.GPIO_Pin = GPIO_Pin_14, .GPIO_Speed = GPIO_Speed_2MHz, .GPIO_Mode = GPIO_Mode_IPU};
GPIO_InitTypeDef button_up =
{.GPIO_Pin = GPIO_Pin_15, .GPIO_Speed = GPIO_Speed_2MHz, .GPIO_Mode = GPIO_Mode_IPU};
GPIO_Init(GPIOB, &button_up);
GPIO_Init(GPIOB, &button_down);
GPIO_Init(GPIOB, &button_ok);
}