mirror of
https://github.com/DashyFox/StackSport.git
synced 2025-05-04 15:20:16 +00:00
todo
This commit is contained in:
parent
7d2bbc63e8
commit
962333bfec
@ -148,10 +148,10 @@ int main(void)
|
|||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_I2C1_Init();
|
MX_I2C1_Init();
|
||||||
MX_USB_DEVICE_Init();
|
MX_USB_DEVICE_Init();
|
||||||
|
MX_USART3_UART_Init();
|
||||||
MX_TIM1_Init();
|
MX_TIM1_Init();
|
||||||
MX_TIM2_Init();
|
MX_TIM2_Init();
|
||||||
MX_TIM3_Init();
|
MX_TIM3_Init();
|
||||||
MX_USART3_UART_Init();
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); //PA8
|
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); //PA8
|
||||||
|
@ -451,6 +451,10 @@ void SysTick_Handler(void)
|
|||||||
TIM2->CCR3 = Vupr2;
|
TIM2->CCR3 = Vupr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TIM2->CCR4 = 0xffff;
|
||||||
|
// TIM2->CCR3 = 0xffff;
|
||||||
|
// TIM2->CCR1 = 0xffff;
|
||||||
|
// TIM2->CCR2 = 0xffff;
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><>
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><>
|
||||||
if (vi < 600)
|
if (vi < 600)
|
||||||
@ -494,22 +498,22 @@ void SysTick_Handler(void)
|
|||||||
void EXTI0_IRQHandler(void)
|
void EXTI0_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN EXTI0_IRQn 0 */
|
/* USER CODE BEGIN EXTI0_IRQn 0 */
|
||||||
if (avto == 1)
|
// if (avto == 1)
|
||||||
{
|
// {
|
||||||
if (rejim_number < rejim[0])
|
// if (rejim_number < rejim[0])
|
||||||
rejim_number++;
|
// rejim_number++;
|
||||||
else
|
// else
|
||||||
rejim_number = 1;
|
// rejim_number = 1;
|
||||||
|
//
|
||||||
SetServo(0, rejim[1 + (rejim_number - 1) * 6]);
|
// SetServo(0, rejim[1 + (rejim_number - 1) * 6]);
|
||||||
SetServo(1, rejim[2 + (rejim_number - 1) * 6]);
|
// SetServo(1, rejim[2 + (rejim_number - 1) * 6]);
|
||||||
SetServo(2, rejim[3 + (rejim_number - 1) * 6]);
|
// SetServo(2, rejim[3 + (rejim_number - 1) * 6]);
|
||||||
Vz1 = rejim[4 + (rejim_number - 1) * 6];
|
// Vz1 = rejim[4 + (rejim_number - 1) * 6];
|
||||||
Vz2 = rejim[5 + (rejim_number - 1) * 6];
|
// Vz2 = rejim[5 + (rejim_number - 1) * 6];
|
||||||
TIM1->CCR1 = 0;
|
// TIM1->CCR1 = 0;
|
||||||
TIM1->CCR2 = (uint16_t)(40 * rejim[6 + (rejim_number - 1) * 6]);
|
// TIM1->CCR2 = (uint16_t)(40 * rejim[6 + (rejim_number - 1) * 6]);
|
||||||
vi = 0; // zapis grafika start
|
// vi = 0; // zapis grafika start
|
||||||
}
|
// }
|
||||||
/* USER CODE END EXTI0_IRQn 0 */
|
/* USER CODE END EXTI0_IRQn 0 */
|
||||||
HAL_GPIO_EXTI_IRQHandler(BALL_EXT_Pin);
|
HAL_GPIO_EXTI_IRQHandler(BALL_EXT_Pin);
|
||||||
/* USER CODE BEGIN EXTI0_IRQn 1 */
|
/* USER CODE BEGIN EXTI0_IRQn 1 */
|
||||||
|
81
StackSport Release.launch
Normal file
81
StackSport Release.launch
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.cubeprog_external_loaders" value="[]"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_certif_path" value=""/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_check_enable" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_key_path" value=""/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_permission" value=""/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_live_expr" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_swv" value="false"/>
|
||||||
|
<intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.formatVersion" value="2"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.ip_address_local" value="localhost"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.enabled" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.value" value=""/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.loadList" value="{"fItems":[{"fIsFromMainTab":true,"fPath":"Debug/StackSport.elf","fProjectName":"StackSport","fPerformBuild":true,"fDownload":true,"fLoadSymbols":true}]}"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.override_start_address_mode" value="default"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.remoteCommand" value="target remote"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startServer" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.divby0" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="48000000"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_signal_halt" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_logging" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_max_halt_delay" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="0"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="C:\AnyProject\StackSport\StackSport\Release\st-link_gdbserver_log.txt"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="cortex_m0"/>
|
||||||
|
<intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||||
|
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||||
|
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/StackSport.elf"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="StackSport"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.952459078"/>
|
||||||
|
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
|
<listEntry value="/StackSport"/>
|
||||||
|
</listAttribute>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
|
<listEntry value="4"/>
|
||||||
|
</listAttribute>
|
||||||
|
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
||||||
|
</launchConfiguration>
|
90
TODO.md
90
TODO.md
@ -39,4 +39,94 @@ IR:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t GetTimerClockFrequency(TIM_TypeDef *TIMx) {
|
||||||
|
uint32_t clock_frequency = 0;
|
||||||
|
uint32_t sysclk_frequency = 0;
|
||||||
|
uint32_t hclk_frequency = 0;
|
||||||
|
uint32_t apb1_frequency = 0;
|
||||||
|
uint32_t apb2_frequency = 0;
|
||||||
|
|
||||||
|
// Определяем источник системного тактирования (SYSCLK)
|
||||||
|
switch (RCC->CFGR & RCC_CFGR_SWS) {
|
||||||
|
case RCC_CFGR_SWS_HSI: // HSI используется как системный клок
|
||||||
|
sysclk_frequency = 8000000; // HSI - 8 MHz
|
||||||
|
break;
|
||||||
|
case RCC_CFGR_SWS_HSE: // HSE используется как системный клок
|
||||||
|
sysclk_frequency = HSE_VALUE; // Предположим, что значение HSE_VALUE определено
|
||||||
|
break;
|
||||||
|
case RCC_CFGR_SWS_PLL: // PLL используется как системный клок
|
||||||
|
// Получаем значение входного тактового сигнала PLL
|
||||||
|
if ((RCC->CFGR & RCC_CFGR_PLLSRC) == RCC_CFGR_PLLSRC_HSI_DIV2) {
|
||||||
|
sysclk_frequency = 4000000; // HSI/2 - 4 MHz
|
||||||
|
} else {
|
||||||
|
sysclk_frequency = HSE_VALUE; // HSE_VALUE определено как 8 или 16 MHz
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получаем множитель PLL
|
||||||
|
uint32_t pll_mul = ((RCC->CFGR & RCC_CFGR_PLLMULL) >> 18) + 2;
|
||||||
|
sysclk_frequency *= pll_mul;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sysclk_frequency = 8000000; // По умолчанию HSI
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Определяем частоту шины AHB (HCLK)
|
||||||
|
uint32_t ahb_prescaler = (RCC->CFGR & RCC_CFGR_HPRE) >> 4;
|
||||||
|
if (ahb_prescaler < 8) {
|
||||||
|
hclk_frequency = sysclk_frequency;
|
||||||
|
} else {
|
||||||
|
hclk_frequency = sysclk_frequency >> ((ahb_prescaler - 7));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Определяем частоту шины APB1
|
||||||
|
uint32_t apb1_prescaler = (RCC->CFGR & RCC_CFGR_PPRE1) >> 8;
|
||||||
|
if (apb1_prescaler < 4) {
|
||||||
|
apb1_frequency = hclk_frequency;
|
||||||
|
} else {
|
||||||
|
apb1_frequency = hclk_frequency >> ((apb1_prescaler - 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Определяем частоту шины APB2
|
||||||
|
uint32_t apb2_prescaler = (RCC->CFGR & RCC_CFGR_PPRE2) >> 11;
|
||||||
|
if (apb2_prescaler < 4) {
|
||||||
|
apb2_frequency = hclk_frequency;
|
||||||
|
} else {
|
||||||
|
apb2_frequency = hclk_frequency >> ((apb2_prescaler - 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Определяем частоту для конкретного таймера
|
||||||
|
if (TIMx == TIM1 || TIMx == TIM8) { // Таймеры на шине APB2
|
||||||
|
clock_frequency = (apb2_prescaler == 0 ? apb2_frequency : apb2_frequency * 2);
|
||||||
|
} else { // Таймеры на шине APB1
|
||||||
|
clock_frequency = (apb1_prescaler == 0 ? apb1_frequency : apb1_frequency * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return clock_frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Функция для вычисления целевого значения
|
||||||
|
uint32_t CalculateTargetCount(TIM_TypeDef *TIMx, uint32_t freq) {
|
||||||
|
// Проверяем, что частота не равна нулю
|
||||||
|
if (freq == 0) return 0xFFFFFFFF; // Защита от деления на ноль
|
||||||
|
|
||||||
|
// Получаем частоту тактового генератора для данного таймера
|
||||||
|
uint32_t clock_frequency = GetTimerClockFrequency(TIMx);
|
||||||
|
|
||||||
|
// Получаем значение предделителя (PSC) и ARR таймера
|
||||||
|
uint32_t psc = TIMx->PSC;
|
||||||
|
uint32_t arr = TIMx->ARR;
|
||||||
|
|
||||||
|
// Вычисляем частоту работы таймера
|
||||||
|
uint32_t timer_frequency = clock_frequency / ((psc + 1) * (arr + 1));
|
||||||
|
|
||||||
|
// Вычисляем целевое значение счетчика для заданной частоты
|
||||||
|
uint32_t target_count = timer_frequency / freq;
|
||||||
|
|
||||||
|
return target_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user