симулируется упп на stm32f103

This commit is contained in:
2025-05-10 01:20:08 +03:00
parent c6269ca448
commit 08719ffc05
397 changed files with 516 additions and 30524 deletions

View File

@@ -779,33 +779,33 @@ HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef* hadc)
return tmp_hal_status;
}
/**
* @brief Initializes the ADC MSP.
* @param hadc: ADC handle
* @retval None
*/
__weak void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hadc);
/* NOTE : This function should not be modified. When the callback is needed,
function HAL_ADC_MspInit must be implemented in the user file.
*/
}
///**
// * @brief Initializes the ADC MSP.
// * @param hadc: ADC handle
// * @retval None
// */
//__weak void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
//{
// /* Prevent unused argument(s) compilation warning */
// UNUSED(hadc);
// /* NOTE : This function should not be modified. When the callback is needed,
// function HAL_ADC_MspInit must be implemented in the user file.
// */
//}
/**
* @brief DeInitializes the ADC MSP.
* @param hadc: ADC handle
* @retval None
*/
__weak void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hadc);
/* NOTE : This function should not be modified. When the callback is needed,
function HAL_ADC_MspDeInit must be implemented in the user file.
*/
}
///**
// * @brief DeInitializes the ADC MSP.
// * @param hadc: ADC handle
// * @retval None
// */
//__weak void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
//{
// /* Prevent unused argument(s) compilation warning */
// UNUSED(hadc);
// /* NOTE : This function should not be modified. When the callback is needed,
// function HAL_ADC_MspDeInit must be implemented in the user file.
// */
//}
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
/**

View File

@@ -1,36 +1,36 @@
#include "stm32f1xx_matlab_gpio.h"
void __GPIO_BSRR_Sim(GPIO_TypeDef* port);
void GPIO_to_SFUNC(real_T *disc)
void Simulate_GPIO_BSRR(void)
{
for (int i = 0; i < PORT_WIDTH; i++)
{
if (GPIOA->ODR & (1 << i))
{
disc[i] = 1;
}
if (GPIOB->ODR & (1 << i))
{
disc[PORT_WIDTH + i] = 1;
}
}
#ifdef GPIOA
__GPIO_BSRR_Sim(GPIOA);
#endif
#ifdef GPIOB
__GPIO_BSRR_Sim(GPIOB);
#endif
#ifdef GPIOC
__GPIO_BSRR_Sim(GPIOC);
#endif
#ifdef GPIOD
__GPIO_BSRR_Sim(GPIOD);
#endif
}
void SFUNC_to_GPIO(real_T* in)
void __GPIO_BSRR_Sim(GPIO_TypeDef* port)
{
for (int i = 0; i < PORT_WIDTH; i++)
{
if (in[i] > 0.5)
{
GPIOA->IDR |= (1 << i);
}
else
{
GPIOA->IDR &= ~(1 << i);
}
}
// Сохраняем значение регистра BSRR
uint32_t bsrr = port->BSRR;
// Нижние 16 бит — установка соответствующих битов ODR
port->ODR |= (uint16_t)(bsrr & 0xFFFF);
// Верхние 16 бит — сброс соответствующих битов ODR
port->ODR &= ~(uint16_t)((bsrr >> 16) & 0xFFFF);
// Обнуляем BSRR после обработки (в реальных STM32 он не сохраняет значение)
port->BSRR = 0;
}

View File

@@ -16,7 +16,8 @@
void SFUNC_to_GPIO(real_T* disc);
void GPIO_to_SFUNC(real_T* in);
void Simulate_GPIO_BSRR(void);
void WriteFromSFunc(real_T* disc);
void ReadToSFunc(real_T* in);
#endif // _MATLAB_GPIO_H_

View File

@@ -582,8 +582,8 @@ void TIM_SIM_DEINIT(void)
/* Вызов прерывания */
void call_IRQHandller(TIM_TypeDef* TIMx)
{ // calling HANDLER
if (TIMx == TIM1)
TIM1_UP_IRQHandler();
//if (TIMx == TIM1)
// TIM1_UP_IRQHandler();
//if ((TIMx == TIM1) || (TIMx == TIM10))
// TIM1_UP_TIM10_IRQHandler();
//else if (TIMx == TIM2)