You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

110 lines
3.6 KiB

#include "port.h"
// 用到的io 串口:两个 led:4+1 RGB:3 风扇:1
/**
* @brief 未使用的io设置为输出模式,固定电平并浮空
*
*/
void unused_gpio_init(void) {
GPIO_InitSettingType x;
x.Signal = GPIO_Pin_Signal_Digital;
x.Dir = GPIO_Direction_Output; //输出模式
// x.Dir = GPIO_Direction_Input;
x.Func = GPIO_Reuse_Func0;
x.ODE = GPIO_ODE_Output_Disable;
x.DS = GPIO_DS_Output_Normal;
x.PUE = GPIO_PUE_Input_Disable;
x.PDE = GPIO_PDE_Input_Enable;
GPIO_Init(GPIO_Pin_A10, &x);
GPIO_Init(GPIO_Pin_A23, &x);
GPIO_Init(GPIO_Pin_A27, &x); // 自己原理图上是26
GPIO_Init(GPIO_Pin_A28, &x); // 自己原理图上是27
GPIO_Init(GPIO_Pin_B0, &x);
//三个adc
GPIO_Init(GPIO_Pin_B8, &x);
GPIO_Init(GPIO_Pin_B9, &x);
GPIO_Init(GPIO_Pin_A2, &x);
GPIO_WriteBit(GPIO_Pin_A10, 0);
GPIO_WriteBit(GPIO_Pin_A23, 0);
GPIO_WriteBit(GPIO_Pin_A27, 0);
GPIO_WriteBit(GPIO_Pin_A28, 0);
GPIO_WriteBit(GPIO_Pin_B0, 0);
GPIO_WriteBit(GPIO_Pin_B8, 0);
GPIO_WriteBit(GPIO_Pin_B9, 0);
GPIO_WriteBit(GPIO_Pin_A2, 0);
}
static void led_gpio_init(void) {
GPIO_InitSettingType x;
x.Signal = GPIO_Pin_Signal_Digital;
x.Dir = GPIO_Direction_Output;
x.Func = GPIO_Reuse_Func0;
x.ODE = GPIO_ODE_Output_Disable;
x.DS = GPIO_DS_Output_Normal;
x.PUE = GPIO_PUE_Input_Disable;
x.PDE = GPIO_PDE_Input_Enable;
GPIO_Init(GPIO_Pin_A3, &x);
GPIO_Init(GPIO_Pin_B13, &x);
GPIO_Init(GPIO_Pin_A5, &x);
GPIO_Init(GPIO_Pin_A6, &x);
GPIO_Init(GPIO_Pin_A7, &x);
GPIO_Init(GPIO_Pin_A8, &x);
GPIO_Init(GPIO_Pin_A9, &x);
GPIO_Init(GPIO_Pin_B1, &x); //风扇
GPIO_Init(GPIO_Pin_A22, &x);
// led rgb debug
GPIO_WriteBit(GPIO_Pin_A3, 0);
GPIO_WriteBit(GPIO_Pin_A5, 0);
GPIO_WriteBit(GPIO_Pin_A6, 0);
GPIO_WriteBit(GPIO_Pin_A7, 0);
GPIO_WriteBit(GPIO_Pin_A8, 0);
GPIO_WriteBit(GPIO_Pin_A9, 0);
GPIO_WriteBit(GPIO_Pin_B13, 0);
GPIO_WriteBit(GPIO_Pin_A22, 0);
GPIO_WriteBit(GPIO_Pin_B1, 0);
}
static void key_gpio_init(void) {
/**
* @brief PA11~PA13
*
*/
GPIO_InitSettingType x;
x.Signal = GPIO_Pin_Signal_Digital;
x.Dir = GPIO_Direction_Input;
x.Func = GPIO_Reuse_Func0;
x.PUE = GPIO_PUE_Input_Disable;
x.PDE = GPIO_PDE_Input_Disable;
GPIO_Init(GPIO_Pin_A11, &x); //
GPIO_Init(GPIO_Pin_A16, &x); //
GPIO_Init(GPIO_Pin_A13, &x);
GPIO_Init(GPIO_Pin_A12, &x);
}
void gpio_init(void) {
led_gpio_init();
key_gpio_init();
}
void port_debug_set(bool state) { GPIO_SET(A, 22, !, state); }
void port_fan_set(bool state) { GPIO_SET(B, 1, !!, state); }
void port_led0_set(bool state) { GPIO_SET(A, 3, !, state); }
void port_led1_set(bool state) { GPIO_SET(B, 13, !, state); }
void port_led2_set(bool state) { GPIO_SET(A, 5, !, state); }
void port_led3_set(bool state) { GPIO_SET(A, 6, !, state); }
void port_led_r_set(bool state) { GPIO_SET(A, 7, !, state); }
void port_led_g_set(bool state) { GPIO_SET(A, 8, !, state); }
void port_led_b_set(bool state) { GPIO_SET(A, 9, !, state); }
bool port_gpio_get_timer_key_state(void) { return GPIO_GET(A, 11, !!); }
bool port_gpio_get_gears_key_state(void) { return GPIO_GET(A, 16, !!); }
bool port_gpio_get_switch_key_state(void) { return GPIO_GET(A, 12, !!); }
bool port_gpio_get_interval_key_state(void) { return GPIO_GET(A, 13, !!); }
bool port_led0_get_state(void) { return GPIO_GET(A, 3, !); }
bool port_led1_get_state(void) { return GPIO_GET(B, 13, !); }
bool port_led2_get_state(void) { return GPIO_GET(A, 5, !); }
bool port_led3_get_state(void) { return GPIO_GET(A, 6, !); }