Browse Source

update(使用if endif条件编译)

master
zwsd 3 years ago
parent
commit
7b8f043c56
  1. 59
      main/main.c

59
main/main.c

@ -16,13 +16,40 @@
#include "port.h" #include "port.h"
#define MAIN_LOG_TAG "MAIN" #define MAIN_LOG_TAG "MAIN"
#define SUPPORT_KEY_INT 0
#define SUPPORT_ELECTRIC_RELAY 0
#define SUPPORT_DEBUG_LIGHT 1
#define ble_uart_tx_size 128 #define ble_uart_tx_size 128
#define ble_uart_rx_size 128 #define ble_uart_rx_size 128
#if SUPPORT_DEBUG_LIGHT
#define DEBUG_LIGHT 12
#define GPIO_DEBUG_LIGHT_OUTPUT_PIN_SEL ((1ULL << DEBUG_LIGHT))
#endif
#if SUPPORT_KEY_INT
#define KEY_INT1 27 #define KEY_INT1 27
#define KEY_INT2 14 #define KEY_INT2 14
#define DEBUG_LIGHT 12
#define GPIO_KEY_INPUT_PIN_SEL ((1ULL << KEY_INT1) | (1ULL << KEY_INT2)) #define GPIO_KEY_INPUT_PIN_SEL ((1ULL << KEY_INT1) | (1ULL << KEY_INT2))
#define GPIO_DEBUG_LIGHT_OUTPUT_PIN_SEL ((1ULL << DEBUG_LIGHT))
#endif
#if 0 //
#define TEMPER_LINE 18 //单总线温度传感器
#define FAN 19 //风扇控制
#endif
#if SUPPORT_ELECTRIC_RELAY
#define ELECTRIC_RELAY1 25
#define ELECTRIC_RELAY2 26
#define GPIO_ELECTRIC_RELAY_OUTPUT_PIN_SEL ((1ULL << ELECTRIC_RELAY1) | (1ULL << ELECTRIC_RELAY2))
#endif
static uint8_t bluetooth_tx_buffer[ble_uart_tx_size] = {0}; static uint8_t bluetooth_tx_buffer[ble_uart_tx_size] = {0};
static uint8_t bluetooth_rx_buffer[ble_uart_rx_size] = {0}; static uint8_t bluetooth_rx_buffer[ble_uart_rx_size] = {0};
@ -99,6 +126,7 @@ void motor_on_event(motor_event_t event) {
} }
} }
#if SUPPORT_KEY_INT
void gpio_input_key_init() { void gpio_input_key_init() {
gpio_config_t gpio_grb_led_structer; gpio_config_t gpio_grb_led_structer;
@ -111,6 +139,24 @@ void gpio_input_key_init() {
gpio_config(&gpio_grb_led_structer); gpio_config(&gpio_grb_led_structer);
} }
#endif
#if SUPPORT_ELECTRIC_RELAY
void gpio_electric_relay_init() {
gpio_config_t gpio_grb_led_structer;
gpio_grb_led_structer.intr_type = GPIO_INTR_DISABLE;
gpio_grb_led_structer.mode = GPIO_MODE_OUTPUT;
gpio_grb_led_structer.pin_bit_mask = GPIO_ELECTRIC_RELAY_OUTPUT_PIN_SEL;
gpio_grb_led_structer.pull_down_en = 0;
gpio_grb_led_structer.pull_up_en = 0;
gpio_config(&gpio_grb_led_structer);
}
#endif
#if SUPPORT_DEBUG_LIGHT
void gpio_output_debug_light_init() { void gpio_output_debug_light_init() {
gpio_config_t gpio_grb_led_structer; gpio_config_t gpio_grb_led_structer;
@ -131,6 +177,8 @@ void port_do_debug_light_state() {
} }
} }
#endif
void app_main(void) { void app_main(void) {
bleuart_init(&ble_uart_init_struct); bleuart_init(&ble_uart_init_struct);
bleuart_reg_cb(blerxcb); bleuart_reg_cb(blerxcb);
@ -138,9 +186,16 @@ void app_main(void) {
motor_init(&ble_uart_motor_structer); motor_init(&ble_uart_motor_structer);
motor_reg_event_cb(motor_on_event); motor_reg_event_cb(motor_on_event);
#if SUPPORT_DEBUG_LIGHT
gpio_output_debug_light_init(); gpio_output_debug_light_init();
#endif
while (true) { while (true) {
#if SUPPORT_DEBUG_LIGHT
port_do_debug_light_state(); port_do_debug_light_state();
#endif
bleuart_schedule(); bleuart_schedule();
motor_module_schedule(); motor_module_schedule();
} }

Loading…
Cancel
Save