cancel
Showing results for 
Search instead for 
Did you mean: 

unknown type name

JCuna.1
Senior
 
7 REPLIES 7
JCuna.1
Senior
#ifndef __APP_H
#define __APP_H
 
#include "engine.h"
#include "schedule.h"
 
extern uint8_t bootloader_mode;
 
#define APP_OPERACION_MAX_SCHEDULES	(uint8_t)2
 
typedef struct{
	uint32_t elapsed_time;
}App_operacion_timer;
 
typedef struct{
	uint32_t init_date;
	Schedule schedules[APP_OPERACION_MAX_SCHEDULES];
}App_operacion_schedule;
 
typedef struct{
	App_operacion_timer timer;
	App_operacion_schedule extended_schedule;
	App_operacion_schedule main_schedule;
}App_operacion;
 
typedef struct{
	uint32_t execution_id;
	uint32_t timestamp;
	ADC_rules_raw _adc_rules_raw;
	App_operacion operacion;
}App_order;
 
extern App_order app_order;
 
void 	app_init(void);
 
void 	app_mode_stop(void);
uint8_t app_mode_operacion(App_order my_app_order);
 
void	process_app(void);
 
 
uint8_t app_is_running(void);
uint8_t app_get_mode(void);
 
 
#endif

app.h

/*
 * 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.

What is wrong with my definitions

Show the source file that's getting the error

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
JCuna.1
Senior

in source file, the only part that use this struct is:

uint8_t app_mode_operacion(App_order my_app_order){
	my_time_set_timestamp(my_app_order._timestamp);
 
	my_time_print_local_time();
 
	memset(engine_samples_buffer, 0, sizeof(engine_samples_buffer));
	engine_samples_index = 0;
 
	memset(&engine_status, 0, sizeof(engine_status));
 
	engine_config_rules(my_app_order._adc_rules_raw);
 
	_app_machine_state = APP_MACHINE_STATE_RESET_ERROR;
	_app_next_machine_state = APP_MACHINE_STATE_OPERACION_1;
 
	_app_mode_timer_machine_state = APP_MODE_TIMER_MACHINE_STATE_INIT;
 
	return 1;
}

JCuna.1
Senior

in engine.h

void engine_config_rules(ADC_rules_raw my_adc_rules_raw){
//	engine_adc_rules.min_vbatt = (uint16_t)((float)(min_vbatt * 4095.0 * 100.0 / (3.3 * 780.0 * 10.0)));
	engine_adc_rules.min_v_bat = (uint16_t)(my_adc_rules_raw.min_v_bat_x_10 * 15.90909);
 
//	engine_adc_rules.max_i_servo = (uint16_t)(max_i_servo * 4095.0 * 0.01 * 50.0 / (3.3 * 10.0));
	engine_adc_rules.max_i_servo = (uint16_t)(my_adc_rules_raw.max_i_servo_x_10 * 62.04545);
 
//	engine_adc_rules.max_i_m1 = (uint16_t)(max_i_m1 * 4095.0 * 0.01 * 50.0 / (3.3 * 10.0));
	engine_adc_rules.max_i_m1 = (uint16_t)(my_adc_rules_raw.max_i_m1_x_10 * 62.04545);
 
//	engine_adc_rules.max_i_start = (uint16_t)(max_i_start * 4095.0 * 0.001 * 50 / 3.3);
	engine_adc_rules.max_i_start = (uint16_t)(my_adc_rules_raw.max_i_start * 62.04545);
 
	engine_adc_rules.pulse_wifth_off = my_adc_rules_raw.pulse_width_off;
	engine_adc_rules.pulse_width_on = my_adc_rules_raw.pulse_width_on;
	engine_adc_rules.low_voltage_threshold = (uint16_t)((my_adc_rules_raw.voltage_threshold_control & 0x0F) * 4095 * 100 / (3.3 * 780 * _ENGINE_ALT_DIV_THRESOLD_STEP));
	engine_adc_rules.high_voltage_threshold = (uint16_t)(((my_adc_rules_raw.voltage_threshold_control & 0xF0) >> 4) * 4095 * 100 / (3.3 * 780 * _ENGINE_ALT_DIV_THRESOLD_STEP));
	engine_adc_rules.max_run_alt_hz = (uint16_t)(my_adc_rules_raw.max_run_alt_hz_div_10 * 10);
	engine_adc_rules.max_temperature_x_2 = my_adc_rules_raw.max_temperature_x_2;
	engine_adc_rules.sampling_time_ms = (uint32_t)(my_adc_rules_raw.sampling_time_m * 60000);
 
	_engine_print_rules(my_adc_rules_raw);
}

and also

static void _engine_print_rules(ADC_rules_raw my_adc_rules_raw){
	printf("RULES\n");
	printf("min_v_bat = %.1f\n", my_adc_rules_raw.min_v_bat_x_10 / 10.0);
	printf("max_i_servo = %.1f\n", my_adc_rules_raw.max_i_servo_x_10 / 10.0);
	printf("max_i_m1 = %.1f\n", my_adc_rules_raw.max_i_m1_x_10 / 10.0);
	printf("max_i_start = %d\n", my_adc_rules_raw.max_i_start);
	printf("pulse_width_off = %d\n", my_adc_rules_raw.pulse_width_off);
	printf("pulse_width_on = %d\n", my_adc_rules_raw.pulse_width_on);
	printf("low_voltage_threshold = %.1f\n", (my_adc_rules_raw.voltage_threshold_control & 0x0F) / _ENGINE_ALT_DIV_THRESOLD_STEP);
	printf("high_voltage_threshold = %.1f\n", ((my_adc_rules_raw.voltage_threshold_control & 0xF0) >> 4) / _ENGINE_ALT_DIV_THRESOLD_STEP);
	printf("max_run_rps = %u\n", my_adc_rules_raw.max_run_alt_hz_div_10 * 10);
	printf("max_temp = %.1f\n\n", my_adc_rules_raw.max_temperature_x_2 / 2.0);
}

Passing as the structure, not as a pointer to it?

It's hard to see any of the context of the error the way you present it.

Show the actual error in the IDE.

If the error is reported in a .C file, then the issue is with how the preprocessor is pulling in the include file.

Switch the IDE such that it generates a pre-processor output file, and walk that.

Pretty sure the compiler is telling you what it believes to be true, you'll have to unwind why, but it will follow the rules doggedly..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
JCuna.1
Senior
In file included from ../Core/Inc/main.h:55,
                 from ../Core/Inc/gpio.h:29,
                 from ../Core/Inc/engine.h:13,
                 from ../Core/Src/engine.c:2:
../Core/Inc/app.h:29:2: error: unknown type name 'ADC_rules_raw'
   29 |  ADC_rules_raw _adc_rules_raw;
      |  ^~~~~~~~~~~~~
arm-none-eabi-gcc "../Core/Src/my_crc.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=48000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G0B1xx -c -I../Core/Inc -I../Drivers/STM32G0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32G0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/my_crc.d" -MT"Core/Src/my_crc.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/my_crc.o"
make: *** [Core/Src/subdir.mk:100: Core/Src/engine.o] Error 1
make: *** Waiting for unfinished jobs....
"make -j16 all" terminated with exit code 2. Build might be incomplete.

JCuna.1
Senior
-mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=48000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G0B1xx -c -I../Core/Inc -I../Drivers/STM32G0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32G0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity --specs=nano.specs -mfloat-abi=soft -mthumb

compile lines generated for stm32cube ide