/*
* my_adc.h
*
* Created on: Nov 25, 2021
* Author: Jeff
*/
#ifndef __ENGINE_H
#define __ENGINE_H
#include <stdint.h>
#include "gpio.h"
#pragma pack(push)
#pragma pack (1)
typedef struct{
uint8_t min_v_bat_x_10;
uint8_t max_i_servo_x_10;
uint8_t max_i_m1_x_10;
uint8_t max_i_start;
uint8_t pulse_width_off;
uint8_t pulse_width_on;
uint8_t voltage_threshold_control;
uint8_t max_run_alt_hz_div_10;
uint8_t max_temperature_x_2;
uint8_t sampling_time_m;
}ADC_rules_raw;
#pragma pack(pop)
#pragma pack(push)
#pragma pack (1)
typedef struct{
uint16_t min_v_bat;
uint16_t max_i_servo;
uint16_t max_i_m1;
uint16_t max_i_start;
uint8_t pulse_wifth_off;
uint8_t pulse_width_on;
uint16_t low_voltage_threshold;
uint16_t high_voltage_threshold;
uint16_t max_run_alt_hz;
uint8_t max_temperature_x_2;
uint32_t sampling_time_ms;
}ADC_rules;
#pragma pack(pop)
union Engine_flag_status{
struct{
uint16_t err_idle_vbat :1; /*!< bit: 0..1 status exp board a */
uint16_t err_idle_temperature :1; /*!< bit: 0..1 status exp board a */
uint16_t err_idle_i_servo :1; /*!< bit: 2..3 status exp board b */
uint16_t err_init_i_starter :1; /*!< bit: 4..5 status exp board b */
uint16_t err_init_temperature :1; /*!< bit: 4..5 status exp board b */
uint16_t err_init_i_servo :1; /*!< bit: 2..3 status exp board b */
uint16_t err_run_alt_hz :1; /*!< bit: 4..5 status exp board b */
uint16_t err_run_temperature :1; /*!< bit: 4..5 status exp board b */
uint16_t err_run_i_servo :1; /*!< bit: 2..3 status exp board b */
uint16_t err_stop_alt_hz :1; /*!< bit: 4..5 status exp board b */
uint16_t err_stop_temperature :1; /*!< bit: 4..5 status exp board b */
uint16_t err_stop_i_servo :1; /*!< bit: 2..3 status exp board b */
uint16_t err_stop_i_m1 :1; /*!< bit: 2..3 status exp board b */
uint16_t war_alt_pin_l :1; /*!< bit: 2..3 status exp board b */
uint16_t war_motor_not_running :1; /*!< bit: 2..3 status exp board b */
}bits; /*!< Structure used for bit access */
uint16_t complete; /*!< Type used for byte access */
};
#pragma pack(push)
#pragma pack (1)
typedef struct{
union Engine_flag_status flag_status;
uint8_t temperature_x_2;
uint16_t alt_hz;
uint16_t min_v_bat_starter;
uint16_t max_i_servo_detected;
uint16_t max_i_m1_detected;
uint16_t max_i_starter_detected;
}Engine_status;
#pragma pack(pop)
extern Engine_status engine_status;
#define is_engine_status_flag_error() (engine_status.flag_status.complete & (uint16_t)0x1FFF) != 0
#define clear_engine_status_flag_error() engine_status.flag_status.complete &= (uint16_t)~(0x1FFF)
#define is_engine_status_flag_warning() (engine_status.flag_status.complete & (uint16_t)0xE000) != 0
#define ENGINE_IGNITION_SWITCH_ON() LL_GPIO_SetOutputPin(DRV_START_GPIO_Port, DRV_START_Pin)
#define ENGINE_IGNITION_SWITCH_OFF() LL_GPIO_ResetOutputPin(DRV_START_GPIO_Port, DRV_START_Pin)
#define ENGINE_ELECTROVALVE_ON() LL_GPIO_SetOutputPin(DRV_M1_GPIO_Port, DRV_M1_Pin)
#define ENGINE_ELECTROVALVE_OFF() LL_GPIO_ResetOutputPin(DRV_M1_GPIO_Port, DRV_M1_Pin)
#define ENGINE_ENABLE_ALT_IG() LL_GPIO_SetOutputPin(DRV_IG_GPIO_Port, DRV_IG_Pin)
#define ENGINE_DISABLE_ALT_IG() LL_GPIO_ResetOutputPin(DRV_IG_GPIO_Port, DRV_IG_Pin)
#define ENGINE_ALT_IG_STATE() (LL_GPIO_IsInputPinSet(IN_IG_GPIO_Port, IN_IG_Pin) != 0)
#define ENGINE_ALT_L_STATE() (LL_GPIO_IsInputPinSet(IN_L_GPIO_Port, IN_L_Pin) != 0)
#define ENGINE_SAMPLES_BUFFER_LENGTH (uint16_t)(1 * 60 * 24)
extern uint8_t engine_samples_buffer[ENGINE_SAMPLES_BUFFER_LENGTH][8];
extern uint16_t engine_samples_index;
// #define _ENGINE_ALT_HZ_TO_ENG_RPM_FACTOR 5.26472 // con ventilador
#define ENGINE_ALT_HZ_TO_ENG_RPM_FACTOR 8.00855 // con alternador
#define ENGINE_RPS_TO_RPM(rps) ((uint16_t)(ENGINE_ALT_HZ_TO_ENG_RPM_FACTOR * (rps)))
void engine_init(void);
void engine_config_rules(ADC_rules_raw my_adc_rules_raw);
void engine_turn_on(void);
void engine_turn_off(void);
uint8_t engine_reset_error(void);
uint8_t engine_can_turn_on(void);
uint8_t engine_can_turn_off(void);
uint8_t engine_is_working(void);
uint8_t engine_is_error(void);
void process_engine(void);
#endif /* __ENGINE_H */
engine.h
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32g0xx_ll_adc.h"
#include "stm32g0xx_ll_crc.h"
#include "stm32g0xx_ll_dma.h"
#include "stm32g0xx_ll_i2c.h"
#include "stm32g0xx_ll_rcc.h"
#include "stm32g0xx_ll_bus.h"
#include "stm32g0xx_ll_crs.h"
#include "stm32g0xx_ll_system.h"
#include "stm32g0xx_ll_exti.h"
#include "stm32g0xx_ll_cortex.h"
#include "stm32g0xx_ll_utils.h"
#include "stm32g0xx_ll_pwr.h"
#include "stm32g0xx_ll_rtc.h"
#include "stm32g0xx_ll_spi.h"
#include "stm32g0xx_ll_tim.h"
#include "stm32g0xx_ll_usart.h"
#include "stm32g0xx_ll_gpio.h"
#if defined(USE_FULL_ASSERT)
#include "stm32_assert.h"
#endif /* USE_FULL_ASSERT */
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "app.h"
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
...
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */
main.h
I check everything with compiler flags, and also there is not circular include library.
stm32cube ide 1.12.1 give this error 'error: unknown type name 'ADC_rules_raw'
.h files are in core/Inc folder, and .c files are in core/Src folder.