#include "key.h" uint8_t Get_key_value(uint8_t key_num) { uint8_t key_value = 0; switch (key_num) { case KEY_1: key_value = Dt_KEY_1; break; case KEY_2: key_value = Dt_KEY_2; break; case KEY_3: key_value = Dt_KEY_3; break; case KEY_4: key_value = Dt_KEY_4; break; case KEY_5: key_value = Dt_KEY_5; break; case KEY_6: key_value = Dt_KEY_6; break; case KEY_7: key_value = Dt_KEY_7; break; case KEY_8: key_value = Dt_KEY_8; break; default: break; } return key_value; } void KEY_Init(void) { /* enable the relay GPIO clock */ rcu_periph_clock_enable(RCU_GPIOA); /* enable the LED GPIO clock */ rcu_periph_clock_enable(RCU_GPIOC); /* enable the User key clock */ rcu_periph_clock_enable(RCU_GPIOB); gpio_init(GPIOA, GPIO_MODE_IPU, GPIO_OSPEED_50MHZ, GPIO_PIN_5 | GPIO_PIN_15); gpio_init(GPIOB, GPIO_MODE_IPU, GPIO_OSPEED_50MHZ, GPIO_PIN_10 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15); gpio_init(GPIOC, GPIO_MODE_IPU, GPIO_OSPEED_50MHZ, GPIO_PIN_10); /* configure relay GPIO port */ // add by zzw 20230308 relay /*GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_PIN = GPIO_PIN_5 | GPIO_PIN_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU,; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_PIN = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_PIN = GPIO_PIN_4 | GPIO_PIN_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOC, &GPIO_InitStructure);*/ }