added and fixed reading of RFE-Pin

This commit is contained in:
2024-12-26 23:24:53 +01:00
parent 8bc6520d6f
commit 76dffdba5c
5 changed files with 119 additions and 307 deletions

View File

@@ -18,6 +18,7 @@ void app_main(void)
bool Hall_A_On = false;
bool Hall_B_On = false;
bool Hall_C_On = false;
bool RFE_Pulled = false;
int direction = 0;
float Speed_indx = 0.0;
float Speed_AB = 0.0;
@@ -32,6 +33,7 @@ void app_main(void)
conf_mcpwm_timers();
int i =0;
set_enc_in_counter(menu_counter);
//gpio_set_level(CONFIG_HIN_V_GPIO, 1);
while (1) {
@@ -51,7 +53,11 @@ void app_main(void)
//Speed_indx = get_speed_index();
//Speed_AB = get_speed_AB();
//direction = get_direction();
RFE_Pulled = !(gpio_get_level(CONFIG_RFE_GPIO));
menu_counter = get_enc_in_counter();
if (menu_counter >= 4){
@@ -63,7 +69,7 @@ void app_main(void)
in_menu ^= 1;
}
//Current_bridge = get_current_bridge(adc1_handle, CONFIG_I_SENSE_ADC);
gpio_set_level(CONFIG_LIN_U_GPIO,1);
//gpio_set_level(CONFIG_LIN_U_GPIO,1);
snprintf(display_message, sizeof(display_message), "PWM-Param.");
@@ -78,11 +84,11 @@ void app_main(void)
snprintf(display_message, sizeof(display_message), "DeadTime: %i ", enc_counter);
ssd1306_display_text(dev_pt, 5, display_message, 14, !(menu_counter-2));
if (in_menu){
snprintf(display_message, sizeof(display_message), "Active:press ");
if (RFE_Pulled){
snprintf(display_message, sizeof(display_message), "RFE pulled");
}
else{
snprintf(display_message, sizeof(display_message), "Active:not press");
snprintf(display_message, sizeof(display_message), "RFE not pulled");
}
ssd1306_display_text(dev_pt, 7, display_message, 14, !(menu_counter-3));

View File

@@ -13,7 +13,7 @@ portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
uint64_t last_AB_time = 0; // Definition der Variablen
adc_cali_handle_t cali_handle= NULL;
adc_cali_handle_t cali_handle = NULL;
/*############################################*/
/*############### GPIO-Setup #################*/
@@ -44,6 +44,13 @@ void configure_GPIO_dir(const char *TAG)
gpio_reset_pin(CONFIG_EXT_ENC_RIGHT_GPIO);
gpio_reset_pin(CONFIG_RFE_GPIO);
gpio_config_t io_conf_RFE = {};
io_conf_RFE.intr_type = GPIO_INTR_DISABLE; // Keine Interrupts
io_conf_RFE.mode = GPIO_MODE_INPUT; // Als Eingang setzen
io_conf_RFE.pin_bit_mask = (1ULL << CONFIG_RFE_GPIO); // Pin festlegen
io_conf_RFE.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf_RFE.pull_up_en = GPIO_PULLUP_ENABLE; // Pull-up-Widerstand aktivieren
gpio_config(&io_conf_RFE);
/* Set the GPIO as a push/pull output
gpio_set_direction(CONFIG_HIN_U_GPIO, GPIO_MODE_OUTPUT);
gpio_set_direction(CONFIG_HIN_V_GPIO, GPIO_MODE_OUTPUT);
@@ -381,9 +388,8 @@ void conf_mcpwm_timers(){
ESP_ERROR_CHECK(mcpwm_generator_set_dead_time(generator_U_HIN, generator_U_LIN, &deadtime_config));
//ESP_ERROR_CHECK(mcpwm_generator_set_dead_time(generator_V_HIN, generator_V_LIN, &deadtime_config));
//ESP_ERROR_CHECK(mcpwm_generator_set_dead_time(generator_W_HIN, generator_W_LIN, &deadtime_config));
}
/*############################################*/
/*############ Blockkommutierung #############*/
/*############################################*/