Initial commit of Fertirrega v6

This commit is contained in:
2026-07-16 12:04:22 +01:00
commit 08709213d9
247 changed files with 126849 additions and 0 deletions
+206
View File
@@ -0,0 +1,206 @@
/**
* @file ad5934_driver.h
* @brief Header file for AD5934 I2C impedance converter driver.
*
* This driver provides functions to configure and read from the AD5934
* 16-bit, 200kHz I2C impedance converter. The device supports frequency sweep
* measurements and provides magnitude and phase data.
*
* @note Based on AD5934 datasheet Rev. E October 2017
*/
#ifndef INC_AD5934_DRIVER_H_
#define INC_AD5934_DRIVER_H_
#include "stm32f1xx_hal.h"
#include <math.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
/******************* ADP5589 Registers Definitions ***************************/
/*****************************************************************************/
// AD5934 I2C Address
#define AD5934_I2C_ADDRESS (0x0D << 1)
// Registers Address
#define AD5934_CONTROL_REG_HB 0x80
#define AD5934_CONTROL_REG_LB 0x81
#define AD5934_START_FREQ_REG_HB 0x82
#define AD5934_START_FREQ_REG_MB 0x83
#define AD5934_START_FREQ_REG_LB 0x84
#define AD5934_FREQ_INCR_REG_HB 0x85
#define AD5934_FREQ_INCR_REG_MB 0x86
#define AD5934_FREQ_INCR_REG_LB 0x87
#define AD5934_NR_INCR_REG_HB 0x88
#define AD5934_NR_INCR_REG_LB 0x89
#define AD5934_NR_SETTLE_REG_HB 0x8A
#define AD5934_NR_SETTLE_REG_LB 0x8B
#define AD5934_STATUS_REG 0x8F
#define AD5934_TEMP_REG_HB 0x92
#define AD5934_TEMP_REG_LB 0x93
#define AD5934_REAL_REG_HB 0x94
#define AD5934_REAL_REG_LB 0x95
#define AD5934_IMG_REG_HB 0x96
#define AD5934_IMG_REG_LB 0x97
/*****************************************************************************/
/******************* ADP5589 Registers Bits **********************************/
/*****************************************************************************/
// Control Register High Bits 0x80
#define AD5934_CONTROL_FUNCTION(x) ((x) << 4)
// AD5934_CONTROL_FUNCTION(x) options
#define AD5934_INIT_START_FREQ 0x01
#define AD5934_START_FREQ_SWEEP 0x02
#define AD5934_INCR_FREQ 0x03
#define AD5934_REPEAT_FREQ 0x04
#define AD5934_POWER_DOWN 0x0A
#define AD5934_STANDBY 0x0B
#define AD5934_RESERVED 0x08
#define AD5934_CONTROL_RANGE(x) ((x) << 1)
// AD5934_CONTROL_RANGE(x) options
#define AD5934_2Vpp_RANGE 0x00
#define AD5934_200mVpp_RANGE 0x01
#define AD5934_400mVpp_RANGE 0x02
#define AD5934_1Vpp_RANGE 0x03
#define AD5934_PGA_GAIN(x) ((x) << 0)
// AD5934_PGA_GAIN(x) options
#define AD5934_PGA_GAIN_X5 0x00
#define AD5934_PGA_GAIN_X1 0x01
// Control Register Low Bits 0x81
#define AD5934_RESET (1 << 4)
#define AD5934_FUNCTION_NOP 0x0
// Status Register 0x8F
#define AD5934_STATUS_TEMP_VALID 1
#define AD5934_STATUS_DATA_VALID (1 << 1)
#define AD5934_STATUS_SWEEP_DONE (1 << 2)
// Values for frequency counts = (freq*2^27)/(1MHz/16)
#define AD5934_FREQ_1K590HZ 0x003419E3 // 1.59kHz
#define AD5934_FREQ_0HZ 0x00000000 // 0Hz
#define AD5934_STEP_FREQ_0 0x0000 // 0 passos
#define AD5934_SETTLING_TIME_0S01 0x000C // 0,01s
/*****************************************************************************/
/**************************** Command Codes **********************************/
/*****************************************************************************/
#define AD5934_BLOCK_WRITE 0xA0
#define AD5934_BLOCK_READ 0xA1
#define AD5934_ADDR_POINTER 0xB0
/*! ADG715 Registers */
#define ADG715_I2C_ADDRESS (0x48 << 1)
#define ADG715_SW1 0x01 //Rf = 150R
#define ADG715_SW2 0x02 //Rf = 1.5k
#define ADG715_SW3 0x04 //Rf = 6.2k
#define ADG715_SW4 0x08 //Rcal = 100R
#define ADG715_SW5 0x10 //Rcal = 1k
#define ADG715_SW6 0x20 //Rcal = 10k
#define ADG715_SW7 0x40 //RTD Input
#define ADG715_SW8 0x80 //CE Input
#define AD5934_CH_REF_100R 0x10
#define AD5934_CH_REF_1K 0x11
#define AD5934_CH_REF_10K 0x12
#define AD5934_CH_PT100 0x00
#define AD5934_CH_PT1000 0x01
#define AD5934_CH_EC_10MS 0x21
#define AD5934_CH_EC_5MS 0x22
#define AD5934_CH_DELTA 0x10
#define AD5934_GAIN_FACTOR_100R 100.0f
#define AD5934_GAIN_FACTOR_1K 1000.0f
#define AD5934_GAIN_FACTOR_10K 10000.0f
#define AD5934_RTD_A 3.9083e-3f
#define AD5934_RTD_B (-5.775e-7f)
#define AD5934_TEMP_AVERAGES 8
#define AD5934_EC_AVERAGES 8
union Bytes2Int
{
uint8_t bytes[2];
uint16_t number;
};
union Bytes2Long
{
uint8_t bytes[4];
uint32_t number;
};
union Short2Long
{
uint16_t ints[2];
uint32_t number;
};
extern int16_t temperature_dut_samples[AD5934_TEMP_AVERAGES][2];
extern int16_t temperature_ref_samples[AD5934_TEMP_AVERAGES][2];
extern float temperature_display[AD5934_TEMP_AVERAGES];
extern int16_t ec_dut_samples[AD5934_EC_AVERAGES][2];
extern int16_t ec_ref1_samples[AD5934_EC_AVERAGES][2];
extern int16_t ec_ref2_samples[AD5934_EC_AVERAGES][2];
extern float ec_display[AD5934_EC_AVERAGES];
extern float ec_temp_dut[AD5934_EC_AVERAGES];
extern float ec_temp_ref1[AD5934_EC_AVERAGES];
extern float ec_temp_ref2[AD5934_EC_AVERAGES];
extern I2C_HandleTypeDef hi2c2;
/*****************************************************************************/
/************************ Functions Declarations *****************************/
/*****************************************************************************/
void AD5934_SetRegisterValue(uint8_t registerAddress, uint32_t registerValue, uint8_t numberOfBytes);
uint32_t AD5934_GetRegisterValue(uint8_t registerAddress, uint8_t numberOfBytes);
uint32_t AD5934_ReadRegister(uint8_t regAddr, uint8_t numberOfBytes);
void AD5934_Init(void);
uint32_t AD5934_Sweep(void);
void AD5934_RestartSweep(void);
float AD5934_GetTemperature(void);
float AD5934_GetImpedance(void);
void AD5934_Wait_For_Data_Valid(void);
float AD5934_Round_Float_Precision(float value, uint8_t number_of_decimals);
float AD5934_Linear_Correction(float raw_value);
void ADG715_SetRegisterValue(char value);
void ADG715_SetChannels(uint8_t ch1, uint8_t ch2);
void ADG715_ResetChannels(void);
void ADG715_Update(uint8_t channel);
#ifdef __cplusplus
}
#endif
#endif /* INC_AD5934_DRIVER_H_ */
+55
View File
@@ -0,0 +1,55 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file adc.h
* @brief This file contains all the function prototypes for
* the adc.c file
******************************************************************************
* @attention
*
* Copyright (c) 2026 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 __ADC_H__
#define __ADC_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
extern ADC_HandleTypeDef hadc1;
extern ADC_HandleTypeDef hadc2;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_ADC1_Init(void);
void MX_ADC2_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /* __ADC_H__ */
+163
View File
@@ -0,0 +1,163 @@
/**
* @file ads1015_driver.h
* @brief Header file for ADS1015 I2C ADC driver.
*
* This driver provides functions to configure and read from the ADS1015
* 12-bit, 3300 SPS I2C ADC. The device supports up to four single-ended
* inputs or two differential inputs.
*
* @note Based on Texas Instruments datasheet SBAS473F MAY 2009 REVISED JANUARY 2025
*/
#ifndef INC_ADS1015_DRIVER_H_
#define INC_ADS1015_DRIVER_H_
#include <stdint.h>
#include "stm32f1xx_hal.h"
#ifdef __cplusplus
extern "C" {
#endif
/*=========================================================================
I2C ADDRESS/BITS - Connect the following pin to ADDR
-----------------------------------------------------------------------*/
#define ADS_ADDR_GND (0x48) ///< 1001 000 (ADDR -> GND)
#define ADS_ADDR_VDD (0x49) ///< 1001 001 (ADDR -> VDD)
#define ADS_ADDR_SDA (0x4A) ///< 1001 010 (ADDR -> SDA)
#define ADS_ADDR_SCL (0x4B) ///< 1001 011 (ADDR -> SCL)
/*=========================================================================*/
/*=========================================================================
CONVERSION DELAY (in mS)
-----------------------------------------------------------------------*/
#define ADS1015_CONVERSIONDELAY (4) ///< Conversion delay
#define ADS1115_CONVERSIONDELAY (8) ///< Conversion delay
/*=========================================================================*/
/*=========================================================================
POINTER REGISTER
-----------------------------------------------------------------------*/
#define ADS1015_REG_POINTER_MASK (0x03) ///< Point mask
#define ADS1015_REG_POINTER_CONVERT (0x00) ///< Conversion
#define ADS1015_REG_POINTER_CONFIG (0x01) ///< Configuration
#define ADS1015_REG_POINTER_LOWTHRESH (0x02) ///< Low threshold
#define ADS1015_REG_POINTER_HITHRESH (0x03) ///< High threshold
/*=========================================================================*/
/*=========================================================================
CONFIG REGISTER
-----------------------------------------------------------------------*/
#define ADS1015_REG_CONFIG_OS_MASK (0x8000) ///< OS Mask
#define ADS1015_REG_CONFIG_OS_SINGLE \
(0x8000) ///< Write: Set to start a single-conversion
#define ADS1015_REG_CONFIG_OS_BUSY \
(0x0000) ///< Read: Bit = 0 when conversion is in progress
#define ADS1015_REG_CONFIG_OS_NOTBUSY \
(0x8000) ///< Read: Bit = 1 when device is not performing a conversion
#define ADS1015_REG_CONFIG_MUX_MASK (0x7000) ///< Mux Mask
#define ADS1015_REG_CONFIG_MUX_DIFF_0_1 \
(0x0000) ///< Differential P = AIN0, N = AIN1 (default)
#define ADS1015_REG_CONFIG_MUX_DIFF_0_3 \
(0x1000) ///< Differential P = AIN0, N = AIN3
#define ADS1015_REG_CONFIG_MUX_DIFF_1_3 \
(0x2000) ///< Differential P = AIN1, N = AIN3
#define ADS1015_REG_CONFIG_MUX_DIFF_2_3 \
(0x3000) ///< Differential P = AIN2, N = AIN3
#define ADS1015_REG_CONFIG_MUX_SINGLE_0 (0x4000) ///< Single-ended AIN0
#define ADS1015_REG_CONFIG_MUX_SINGLE_1 (0x5000) ///< Single-ended AIN1
#define ADS1015_REG_CONFIG_MUX_SINGLE_2 (0x6000) ///< Single-ended AIN2
#define ADS1015_REG_CONFIG_MUX_SINGLE_3 (0x7000) ///< Single-ended AIN3
#define ADS1015_REG_CONFIG_PGA_MASK (0x0E00) ///< PGA Mask
#define ADS1015_REG_CONFIG_PGA_6_144V (0x0000) ///< +/-6.144V range = Gain 2/3
#define ADS1015_REG_CONFIG_PGA_4_096V (0x0200) ///< +/-4.096V range = Gain 1
#define ADS1015_REG_CONFIG_PGA_2_048V \
(0x0400) ///< +/-2.048V range = Gain 2 (default)
#define ADS1015_REG_CONFIG_PGA_1_024V (0x0600) ///< +/-1.024V range = Gain 4
#define ADS1015_REG_CONFIG_PGA_0_512V (0x0800) ///< +/-0.512V range = Gain 8
#define ADS1015_REG_CONFIG_PGA_0_256V (0x0A00) ///< +/-0.256V range = Gain 16
#define ADS1015_REG_CONFIG_MODE_MASK (0x0100) ///< Mode Mask
#define ADS1015_REG_CONFIG_MODE_CONTIN (0x0000) ///< Continuous conversion mode
#define ADS1015_REG_CONFIG_MODE_SINGLE \
(0x0100) ///< Power-down single-shot mode (default)
#define ADS1015_REG_CONFIG_DR_MASK (0x00E0) ///< Data Rate Mask
#define ADS1015_REG_CONFIG_DR_128SPS (0x0000) ///< 128 samples per second
#define ADS1015_REG_CONFIG_DR_250SPS (0x0020) ///< 250 samples per second
#define ADS1015_REG_CONFIG_DR_490SPS (0x0040) ///< 490 samples per second
#define ADS1015_REG_CONFIG_DR_920SPS (0x0060) ///< 920 samples per second
#define ADS1015_REG_CONFIG_DR_1600SPS \
(0x0080) ///< 1600 samples per second (default)
#define ADS1015_REG_CONFIG_DR_2400SPS (0x00A0) ///< 2400 samples per second
#define ADS1015_REG_CONFIG_DR_3300SPS (0x00C0) ///< 3300 samples per second
#define ADS1015_REG_CONFIG_CMODE_MASK (0x0010) ///< CMode Mask
#define ADS1015_REG_CONFIG_CMODE_TRAD \
(0x0000) ///< Traditional comparator with hysteresis (default)
#define ADS1015_REG_CONFIG_CMODE_WINDOW (0x0010) ///< Window comparator
#define ADS1015_REG_CONFIG_CPOL_MASK (0x0008) ///< CPol Mask
#define ADS1015_REG_CONFIG_CPOL_ACTVLOW \
(0x0000) ///< ALERT/RDY pin is low when active (default)
#define ADS1015_REG_CONFIG_CPOL_ACTVHI \
(0x0008) ///< ALERT/RDY pin is high when active
#define ADS1015_REG_CONFIG_CLAT_MASK \
(0x0004) ///< Determines if ALERT/RDY pin latches once asserted
#define ADS1015_REG_CONFIG_CLAT_NONLAT \
(0x0000) ///< Non-latching comparator (default)
#define ADS1015_REG_CONFIG_CLAT_LATCH (0x0004) ///< Latching comparator
#define ADS1015_REG_CONFIG_CQUE_MASK (0x0003) ///< CQue Mask
#define ADS1015_REG_CONFIG_CQUE_1CONV \
(0x0000) ///< Assert ALERT/RDY after one conversions
#define ADS1015_REG_CONFIG_CQUE_2CONV \
(0x0001) ///< Assert ALERT/RDY after two conversions
#define ADS1015_REG_CONFIG_CQUE_4CONV \
(0x0002) ///< Assert ALERT/RDY after four conversions
#define ADS1015_REG_CONFIG_CQUE_NONE \
(0x0003) ///< Disable the comparator and put ALERT/RDY in high state (default)
#define ADS1015_KELVIN_OFFSET 273.15f // Constante de conversão Kelvin
#define ADS1015_ADC_MAX 4095.0f
#define ADS1015_ADC_VREF 3.3f
/*=========================================================================*/
/** Gain settings */
typedef enum {
GAIN_TWOTHIRDS = ADS1015_REG_CONFIG_PGA_6_144V,
GAIN_ONE = ADS1015_REG_CONFIG_PGA_4_096V,
GAIN_TWO = ADS1015_REG_CONFIG_PGA_2_048V,
GAIN_FOUR = ADS1015_REG_CONFIG_PGA_1_024V,
GAIN_EIGHT = ADS1015_REG_CONFIG_PGA_0_512V,
GAIN_SIXTEEN = ADS1015_REG_CONFIG_PGA_0_256V
} adsGain_t;
typedef struct {
uint16_t m_i2cAddress; ///< the I2C address
uint32_t m_conversionDelay; ///< conversion delay
uint8_t m_bitShift; ///< bit shift amount
adsGain_t m_gain; ///< ADC gain
I2C_HandleTypeDef* hi2c; // Handle for I2C
}ADS1015_I2C;
extern float temp_calib, ph_compensated, v_ph4, v_ph7;
void ADS1015(ADS1015_I2C* i2c, I2C_HandleTypeDef* hi2c, uint8_t i2cAddress);
uint16_t ADSreadADC_SingleEnded(ADS1015_I2C* i2c, uint8_t channel);
int16_t ADSreadADC_Differential_0_1(ADS1015_I2C* i2c);
int16_t ADSreadADC_Differential_2_3(ADS1015_I2C* i2c);
void ADSstartComparator_SingleEnded(ADS1015_I2C* i2c, uint8_t channel, int16_t threshold);
int16_t ADSgetLastConversionResults();
void ADSsetGain(ADS1015_I2C* i2c, adsGain_t gain);
adsGain_t ADSgetGain(ADS1015_I2C* i2c);
float ADSCalculate_ph_Volts(int16_t adc_raw);
float ADSCalculate_ph_Compensated(int16_t adc_raw, float temp_dut);
#endif /* INC_ADS1015_DRIVER_H_ */
@@ -0,0 +1,43 @@
/**
* @file analog_loop_driver.h
* @brief Driver for current loop analog signal processing with dual ADC support.
*
* This driver interfaces with a 4-20mA current loop signal, using:
* - HCNR201 optocoupler with LED current sensing through 100Ω resistor
* - MMBT3906 transistor controlled by NCV20071 opamp
* - 24.9Ω shunt resistor for current-to-voltage conversion
* - Isolation using HCNR201 (input side) and NCV20071 (output side)
* - ADC input to STM32F103 via 100Ω resistor with dual ADC capability
*/
#ifndef INC_ANALOG_LOOP_DRIVER_H_
#define INC_ANALOG_LOOP_DRIVER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "stm32f1xx_hal.h"
#include <stdint.h>
// --- Configuration Parameters ---
#define ANALOG_LOOP_ADC_CHANNEL ADC_CHANNEL_0 // Assuming PA0 is used for ADC input
#define ANALOG_LOOP_ADC_RANK ADC_RANK_CHANNELNUMBER // ADC Bus
#define ANALOG_LOOP_VREF_MV 3300U // Reference voltage in millivolts (3.3V)
#define ANALOG_LOOP_CURRENT_MIN_UA 4000U // Minimum current in uA (4mA)
#define ANALOG_LOOP_CURRENT_MAX_UA 20000U // Maximum current in uA (20mA)
#define ANALOG_LOOP_R1_OHMS 100U // Resistance of R1 in ohms
#define ANALOG_LOOP_R2_OHMS 249U // Resistance of R2 in ohms
#define ANALOG_LOOP_R3_OHMS 100U // Resistance of R3 in ohms (ADC input resistor)
// --- Function Prototypes ---
HAL_StatusTypeDef AnalogLoop_Init(ADC_HandleTypeDef *hadc);
uint32_t AnalogLoop_GetRawValue(void);
int16_t AnalogLoop_GetCurrent_uA(void);
int16_t AnalogLoop_GetVoltage_mV(void);
#ifdef __cplusplus
}
#endif
#endif /* INC_ANALOG_LOOP_DRIVER_H_ */
@@ -0,0 +1,73 @@
/**
* @file digital_outputs_driver.h
* @brief Simplified Driver for controlling 8 independent open-drain digital outputs on STM32F103C8T6
* @author Embedded Systems Software Engineer
* @date 2023
*/
#ifndef DIGITAL_OUTPUTS_DRIVER_H
#define DIGITAL_OUTPUTS_DRIVER_H
#include "main.h"
#include <stdint.h>
#include <stddef.h> // For NULL definition
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Digital output pin identifiers (Index-based)
*/
typedef enum {
OUTPUT_PIN_0 = 0,
OUTPUT_PIN_1,
OUTPUT_PIN_2,
OUTPUT_PIN_3,
OUTPUT_PIN_4,
OUTPUT_PIN_5,
OUTPUT_PIN_6,
OUTPUT_PIN_7,
OUTPUT_PINS_COUNT
} digital_output_pin_t;
/**
* @brief Initializes the GPIO hardware and sets initial states.
* @retval None
*/
void digital_outputs_init(void);
/**
* @brief Sets the state of a specific output pin (open-drain)
* @param pin Pin identifier (0 to OUTPUT_PINS_COUNT - 1)
* @param state Desired state (0 = LOW, 1 = HIGH)
* @retval None
*/
void digital_outputs_set_state(digital_output_pin_t pin, uint8_t state);
/**
* @brief Gets the current state of a specific output pin
* @param pin Pin identifier
* @param p_state Pointer to a variable where the state will be stored
* @retval None
*/
void digital_outputs_get_state(digital_output_pin_t pin, uint8_t* p_state);
/**
* @brief Toggles the state of a specific output pin
* @param pin Pin identifier
* @retval None
*/
void digital_outputs_toggle(digital_output_pin_t pin);
/**
* @brief Resets all outputs to LOW (0)
* @retval None
*/
void digital_outputs_reset_all(void);
#ifdef __cplusplus
}
#endif
#endif /* DIGITAL_OUTPUTS_DRIVER_H */
+44
View File
@@ -0,0 +1,44 @@
/**
* @file flash_manager.h
* @brief Interface para gerenciamento de memória não volátil (Flash)
*/
#ifndef INC_FLASH_MANAGER_H_
#define INC_FLASH_MANAGER_H_
/**
* @file flash_storage.h
*/
#ifndef FLASH_STORAGE_H
#define FLASH_STORAGE_H
#include "stm32f1xx_hal.h"
#include <stdint.h>
#include <string.h>
/* Endereço da página (Ex: última página do F103C8) */
#define FLASH_PAGE_ADDR ((uint32_t)0x0800FC00)
#define FLASH_PAGE_SIZE 1024
/**
* @brief Estrutura de 1KB alinhada e preenchida.
* O uso de padding manual garante que não haja surpresas com o compilador.
*/
typedef struct __attribute__((packed, aligned(4))) {
uint32_t magic_number; // 4 bytes (Validação)
float calibration_offset; // 4 bytes
uint16_t sensor_threshold; // 2 bytes
uint8_t status_flag; // 1 byte
uint8_t reserved[1013]; // Preenchimento para completar 1024 bytes (1KB)
} FlashPage_t;
/* Protótipos */
HAL_StatusTypeDef Flash_Save_Page(FlashPage_t *pPage);
HAL_StatusTypeDef Flash_Load_Page(FlashPage_t *pDest);
#endif
#endif /* INC_FLASH_MANAGER_H_ */
+53
View File
@@ -0,0 +1,53 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file gpio.h
* @brief This file contains all the function prototypes for
* the gpio.c file
******************************************************************************
* @attention
*
* Copyright (c) 2026 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 __GPIO_H__
#define __GPIO_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* USER CODE BEGIN Private defines */
#define RISING_EDGE 1
#define NO_EDGE 0
#define FALLING_EDGE (-1)
extern volatile int8_t edge_state;
/* USER CODE END Private defines */
void MX_GPIO_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /*__ GPIO_H__ */
+55
View File
@@ -0,0 +1,55 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file i2c.h
* @brief This file contains all the function prototypes for
* the i2c.c file
******************************************************************************
* @attention
*
* Copyright (c) 2026 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 __I2C_H__
#define __I2C_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
extern I2C_HandleTypeDef hi2c1;
extern I2C_HandleTypeDef hi2c2;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_I2C1_Init(void);
void MX_I2C2_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /* __I2C_H__ */
+138
View File
@@ -0,0 +1,138 @@
/* 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) 2026 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 "stm32f1xx_hal.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* 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 -----------------------------------------------------------*/
#define DIGI_OUT5_Pin GPIO_PIN_13
#define DIGI_OUT5_GPIO_Port GPIOC
#define DIGI_OUT6_Pin GPIO_PIN_14
#define DIGI_OUT6_GPIO_Port GPIOC
#define DIGI_OUT7_Pin GPIO_PIN_15
#define DIGI_OUT7_GPIO_Port GPIOC
#define AIN1_Pin GPIO_PIN_0
#define AIN1_GPIO_Port GPIOA
#define AIN2_Pin GPIO_PIN_1
#define AIN2_GPIO_Port GPIOA
#define RS485_Addr0_Pin GPIO_PIN_2
#define RS485_Addr0_GPIO_Port GPIOA
#define RS485_Addr1_Pin GPIO_PIN_3
#define RS485_Addr1_GPIO_Port GPIOA
#define RS485_Addr2_Pin GPIO_PIN_4
#define RS485_Addr2_GPIO_Port GPIOA
#define RS485_Addr3_Pin GPIO_PIN_5
#define RS485_Addr3_GPIO_Port GPIOA
#define SYS_CFG0_Pin GPIO_PIN_6
#define SYS_CFG0_GPIO_Port GPIOA
#define SYS_CFG1_Pin GPIO_PIN_7
#define SYS_CFG1_GPIO_Port GPIOA
#define DIGI_OUT0_Pin GPIO_PIN_0
#define DIGI_OUT0_GPIO_Port GPIOB
#define DIGI_OUT1_Pin GPIO_PIN_1
#define DIGI_OUT1_GPIO_Port GPIOB
#define DIGI_OUT2_Pin GPIO_PIN_2
#define DIGI_OUT2_GPIO_Port GPIOB
#define I2C2_SCL_CE_Pin GPIO_PIN_10
#define I2C2_SCL_CE_GPIO_Port GPIOB
#define I2C2_SDA_CE_Pin GPIO_PIN_11
#define I2C2_SDA_CE_GPIO_Port GPIOB
#define RS485_Addr4_Pin GPIO_PIN_12
#define RS485_Addr4_GPIO_Port GPIOB
#define RS485_Addr5_Pin GPIO_PIN_13
#define RS485_Addr5_GPIO_Port GPIOB
#define RS485_Addr6_Pin GPIO_PIN_14
#define RS485_Addr6_GPIO_Port GPIOB
#define RS485_Addr7_Pin GPIO_PIN_15
#define RS485_Addr7_GPIO_Port GPIOB
#define PG_RS485_Pin GPIO_PIN_8
#define PG_RS485_GPIO_Port GPIOA
#define TX_RS485_Pin GPIO_PIN_9
#define TX_RS485_GPIO_Port GPIOA
#define RX_RS485_Pin GPIO_PIN_10
#define RX_RS485_GPIO_Port GPIOA
#define PG_CE_Pin GPIO_PIN_11
#define PG_CE_GPIO_Port GPIOA
#define TX_EN_RS485_Pin GPIO_PIN_12
#define TX_EN_RS485_GPIO_Port GPIOA
#define PG_PH_Pin GPIO_PIN_15
#define PG_PH_GPIO_Port GPIOA
#define Calib_PH_Pin GPIO_PIN_3
#define Calib_PH_GPIO_Port GPIOB
#define Calib_PH_EXTI_IRQn EXTI3_IRQn
#define LED_Red_Pin GPIO_PIN_4
#define LED_Red_GPIO_Port GPIOB
#define LED_Green_Pin GPIO_PIN_5
#define LED_Green_GPIO_Port GPIOB
#define I2C1_SCL_PH_Pin GPIO_PIN_6
#define I2C1_SCL_PH_GPIO_Port GPIOB
#define I2C1_SDA_PH_Pin GPIO_PIN_7
#define I2C1_SDA_PH_GPIO_Port GPIOB
#define DIGI_OUT3_Pin GPIO_PIN_8
#define DIGI_OUT3_GPIO_Port GPIOB
#define DIGI_OUT4_Pin GPIO_PIN_9
#define DIGI_OUT4_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */
+100
View File
@@ -0,0 +1,100 @@
/**
* @file rs485_driver.h
* @brief Header file for RS-485 communication driver.
*
* This driver provides functions to configure and control RS-485 communication
* using USART with RTS pin as TX enable. Each device has an 8-bit address
* defined by 4 bits on PB12-PB15 (upper nibble) and 4 bits on PA2-PA5 (lower nibble),
* all with pull-up resistors enabled.
*
* @note Based on STM32F103C8T6 microcontroller and USART configuration
*/
#ifndef INC_RS485_DRIVER_H_
#define INC_RS485_DRIVER_H_
#include <stdint.h>
#include "stm32f1xx_hal.h"
#include "stm32f1xx_ll_gpio.h"
#ifdef __cplusplus
extern "C" {
#endif
/* --- TX Enable Pin Configuration --- */
#define RS485_TX_EN_PORT GPIOA
#define RS485_TX_EN_PIN GPIO_PIN_12 /*!< RTS pin for TX enable */
#define RS485_ADDR_MASK_LOW 0x0000003C // GPIOA bits 2,3,4,5
#define RS485_ADDR_MASK_HIGH 0x0000F000 // GPIOB bits 12,13,14,15
#define RS485_ADDR_BIT_SET_LOW 2
#define RS485_ADDR_BIT_SET_HIGH 8
/**
* @brief RS-485 device address structure.
*/
typedef struct {
uint8_t nibble_high; /*!< High nibble of the address (PB12-PB15) */
uint8_t nibble_low; /*!< Low nibble of the address (PA2-PA5) */
uint8_t full_address; /*!< Full 8-bit address */
} rs485_address_t;
/* --- Function Prototypes --- */
/**
* @brief Initializes the RS-485 driver.
* @note This function configures GPIOs for address detection and USART1 for communication.
*/
void rs485_init(void);
/**
* @brief Gets the current device address from GPIOs.
* @return The 8-bit device address.
*/
uint8_t rs485_get_address(void);
/**
* @brief Sends data to a specific RS-485 address.
* @param address Target device address.
* @param data Pointer to the data buffer.
* @param length Number of bytes to send.
* @retval HAL_OK on success, otherwise error code.
*/
HAL_StatusTypeDef rs485_send_to_address(uint8_t address, uint8_t* data, uint16_t length);
/**
* @brief Sends data to all devices (broadcast).
* @param data Pointer to the data buffer.
* @param length Number of bytes to send.
* @retval HAL_OK on success, otherwise error code.
*/
HAL_StatusTypeDef rs485_send_broadcast(uint8_t* data, uint16_t length);
/**
* @brief Receives data from RS-485 bus.
* @param data Pointer to the receive buffer.
* @param length Maximum number of bytes to receive.
* @retval Number of bytes received, or 0 on error.
*/
uint16_t rs485_receive(uint8_t* data, uint16_t length);
/**
* @brief Enables transmission mode on RS-485 transceiver.
*/
void rs485_enable_tx(void);
/**
* @brief Disables transmission mode on RS-485 transceiver.
*/
void rs485_disable_tx(void);
#ifdef __cplusplus
}
#endif
#endif /* INC_RS485_DRIVER_H_ */
+391
View File
@@ -0,0 +1,391 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_hal_conf.h
* @brief HAL configuration file.
******************************************************************************
* @attention
*
* Copyright (c) 2017 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 __STM32F1xx_HAL_CONF_H
#define __STM32F1xx_HAL_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* ########################## Module Selection ############################## */
/**
* @brief This is the list of modules to be used in the HAL driver
*/
#define HAL_MODULE_ENABLED
#define HAL_ADC_MODULE_ENABLED
/*#define HAL_CRYP_MODULE_ENABLED */
/*#define HAL_CAN_MODULE_ENABLED */
/*#define HAL_CAN_LEGACY_MODULE_ENABLED */
/*#define HAL_CEC_MODULE_ENABLED */
/*#define HAL_CORTEX_MODULE_ENABLED */
/*#define HAL_CRC_MODULE_ENABLED */
/*#define HAL_DAC_MODULE_ENABLED */
/*#define HAL_DMA_MODULE_ENABLED */
/*#define HAL_ETH_MODULE_ENABLED */
/*#define HAL_FLASH_MODULE_ENABLED */
#define HAL_GPIO_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
/*#define HAL_I2S_MODULE_ENABLED */
/*#define HAL_IRDA_MODULE_ENABLED */
/*#define HAL_IWDG_MODULE_ENABLED */
/*#define HAL_NOR_MODULE_ENABLED */
/*#define HAL_NAND_MODULE_ENABLED */
/*#define HAL_PCCARD_MODULE_ENABLED */
/*#define HAL_PCD_MODULE_ENABLED */
/*#define HAL_HCD_MODULE_ENABLED */
/*#define HAL_PWR_MODULE_ENABLED */
/*#define HAL_RCC_MODULE_ENABLED */
/*#define HAL_RTC_MODULE_ENABLED */
/*#define HAL_SD_MODULE_ENABLED */
/*#define HAL_MMC_MODULE_ENABLED */
/*#define HAL_SDRAM_MODULE_ENABLED */
/*#define HAL_SMARTCARD_MODULE_ENABLED */
/*#define HAL_SPI_MODULE_ENABLED */
/*#define HAL_SRAM_MODULE_ENABLED */
/*#define HAL_TIM_MODULE_ENABLED */
#define HAL_UART_MODULE_ENABLED
/*#define HAL_USART_MODULE_ENABLED */
/*#define HAL_WWDG_MODULE_ENABLED */
#define HAL_CORTEX_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
/* ########################## Oscillator Values adaptation ####################*/
/**
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE 12000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
/**
* @brief Internal High Speed oscillator (HSI) value.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
#define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
/**
* @brief Internal Low Speed oscillator (LSI) value.
*/
#if !defined (LSI_VALUE)
#define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations
in voltage and temperature. */
/**
* @brief External Low Speed oscillator (LSE) value.
* This value is used by the UART, RTC HAL module to compute the system frequency
*/
#if !defined (LSE_VALUE)
#define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
/* Tip: To avoid modifying this file each time you need to use different HSE,
=== you can define the HSE value in your toolchain compiler preprocessor. */
/* ########################### System Configuration ######################### */
/**
* @brief This is the HAL system configuration section
*/
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority (lowest by default) */
#define USE_RTOS 0U
#define PREFETCH_ENABLE 1U
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
/* ########################## Assert Selection ############################## */
/**
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* HAL drivers code
*/
/* #define USE_FULL_ASSERT 1U */
/* ################## Ethernet peripheral configuration ##################### */
/* Section 1 : Ethernet peripheral configuration */
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
#define MAC_ADDR0 2U
#define MAC_ADDR1 0U
#define MAC_ADDR2 0U
#define MAC_ADDR3 0U
#define MAC_ADDR4 0U
#define MAC_ADDR5 0U
/* Definition of the Ethernet driver buffers size and count */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
#define ETH_RXBUFNB 8U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
/* Section 2: PHY configuration section */
/* DP83848_PHY_ADDRESS Address*/
#define DP83848_PHY_ADDRESS 0x01U
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
#define PHY_RESET_DELAY 0x000000FFU
/* PHY Configuration delay */
#define PHY_CONFIG_DELAY 0x00000FFFU
#define PHY_READ_TO 0x0000FFFFU
#define PHY_WRITE_TO 0x0000FFFFU
/* Section 3: Common PHY Registers */
#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
/* Section 4: Extended PHY Registers */
#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
/* ################## SPI peripheral configuration ########################## */
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
* Activated: CRC code is present inside driver
* Deactivated: CRC code cleaned from driver
*/
#define USE_SPI_CRC 0U
/* Includes ------------------------------------------------------------------*/
/**
* @brief Include module's header file
*/
#ifdef HAL_RCC_MODULE_ENABLED
#include "stm32f1xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */
#ifdef HAL_GPIO_MODULE_ENABLED
#include "stm32f1xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f1xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_DMA_MODULE_ENABLED
#include "stm32f1xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */
#ifdef HAL_ETH_MODULE_ENABLED
#include "stm32f1xx_hal_eth.h"
#endif /* HAL_ETH_MODULE_ENABLED */
#ifdef HAL_CAN_MODULE_ENABLED
#include "stm32f1xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
#include "Legacy/stm32f1xx_hal_can_legacy.h"
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
#ifdef HAL_CEC_MODULE_ENABLED
#include "stm32f1xx_hal_cec.h"
#endif /* HAL_CEC_MODULE_ENABLED */
#ifdef HAL_CORTEX_MODULE_ENABLED
#include "stm32f1xx_hal_cortex.h"
#endif /* HAL_CORTEX_MODULE_ENABLED */
#ifdef HAL_ADC_MODULE_ENABLED
#include "stm32f1xx_hal_adc.h"
#endif /* HAL_ADC_MODULE_ENABLED */
#ifdef HAL_CRC_MODULE_ENABLED
#include "stm32f1xx_hal_crc.h"
#endif /* HAL_CRC_MODULE_ENABLED */
#ifdef HAL_DAC_MODULE_ENABLED
#include "stm32f1xx_hal_dac.h"
#endif /* HAL_DAC_MODULE_ENABLED */
#ifdef HAL_FLASH_MODULE_ENABLED
#include "stm32f1xx_hal_flash.h"
#endif /* HAL_FLASH_MODULE_ENABLED */
#ifdef HAL_SRAM_MODULE_ENABLED
#include "stm32f1xx_hal_sram.h"
#endif /* HAL_SRAM_MODULE_ENABLED */
#ifdef HAL_NOR_MODULE_ENABLED
#include "stm32f1xx_hal_nor.h"
#endif /* HAL_NOR_MODULE_ENABLED */
#ifdef HAL_I2C_MODULE_ENABLED
#include "stm32f1xx_hal_i2c.h"
#endif /* HAL_I2C_MODULE_ENABLED */
#ifdef HAL_I2S_MODULE_ENABLED
#include "stm32f1xx_hal_i2s.h"
#endif /* HAL_I2S_MODULE_ENABLED */
#ifdef HAL_IWDG_MODULE_ENABLED
#include "stm32f1xx_hal_iwdg.h"
#endif /* HAL_IWDG_MODULE_ENABLED */
#ifdef HAL_PWR_MODULE_ENABLED
#include "stm32f1xx_hal_pwr.h"
#endif /* HAL_PWR_MODULE_ENABLED */
#ifdef HAL_RTC_MODULE_ENABLED
#include "stm32f1xx_hal_rtc.h"
#endif /* HAL_RTC_MODULE_ENABLED */
#ifdef HAL_PCCARD_MODULE_ENABLED
#include "stm32f1xx_hal_pccard.h"
#endif /* HAL_PCCARD_MODULE_ENABLED */
#ifdef HAL_SD_MODULE_ENABLED
#include "stm32f1xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */
#ifdef HAL_NAND_MODULE_ENABLED
#include "stm32f1xx_hal_nand.h"
#endif /* HAL_NAND_MODULE_ENABLED */
#ifdef HAL_SPI_MODULE_ENABLED
#include "stm32f1xx_hal_spi.h"
#endif /* HAL_SPI_MODULE_ENABLED */
#ifdef HAL_TIM_MODULE_ENABLED
#include "stm32f1xx_hal_tim.h"
#endif /* HAL_TIM_MODULE_ENABLED */
#ifdef HAL_UART_MODULE_ENABLED
#include "stm32f1xx_hal_uart.h"
#endif /* HAL_UART_MODULE_ENABLED */
#ifdef HAL_USART_MODULE_ENABLED
#include "stm32f1xx_hal_usart.h"
#endif /* HAL_USART_MODULE_ENABLED */
#ifdef HAL_IRDA_MODULE_ENABLED
#include "stm32f1xx_hal_irda.h"
#endif /* HAL_IRDA_MODULE_ENABLED */
#ifdef HAL_SMARTCARD_MODULE_ENABLED
#include "stm32f1xx_hal_smartcard.h"
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
#ifdef HAL_WWDG_MODULE_ENABLED
#include "stm32f1xx_hal_wwdg.h"
#endif /* HAL_WWDG_MODULE_ENABLED */
#ifdef HAL_PCD_MODULE_ENABLED
#include "stm32f1xx_hal_pcd.h"
#endif /* HAL_PCD_MODULE_ENABLED */
#ifdef HAL_HCD_MODULE_ENABLED
#include "stm32f1xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f1xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F1xx_HAL_CONF_H */
+68
View File
@@ -0,0 +1,68 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_it.h
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* Copyright (c) 2026 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 __STM32F1xx_IT_H
#define __STM32F1xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* 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 NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void EXTI3_IRQHandler(void);
void USART1_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F1xx_IT_H */
+52
View File
@@ -0,0 +1,52 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file usart.h
* @brief This file contains all the function prototypes for
* the usart.c file
******************************************************************************
* @attention
*
* Copyright (c) 2026 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 __USART_H__
#define __USART_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
extern UART_HandleTypeDef huart1;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_USART1_UART_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /* __USART_H__ */