Compare commits

...

2 Commits

@ -67,3 +67,37 @@ r
q
q
q
q
q
b 392
r
s
s
c
p huart1_rxc
s
s
s
c
q
q
q
b 392
r
c
c
del
b main()
b 124
r
n
q
b 392
r
p huart1_rxc
c
p huart1_rxc
p huart1_rxc
c
p huart1_rxc
q

@ -67,6 +67,8 @@ void setPWM(TIM_HandleTypeDef *timer, uint32_t channel, uint8_t dc_percent);
#define m1_dir_GPIO_Port GPIOA
#define m2_dir_Pin GPIO_PIN_5
#define m2_dir_GPIO_Port GPIOA
#define USART1_DE_Pin GPIO_PIN_12
#define USART1_DE_GPIO_Port GPIOA
#define SWDIO_Pin GPIO_PIN_13
#define SWDIO_GPIO_Port GPIOA
#define SWCLK_Pin GPIO_PIN_14

@ -55,6 +55,7 @@ void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void USART1_IRQHandler(void);
void USART2_IRQHandler(void);
void TIM6_DAC_IRQHandler(void);
/* USER CODE BEGIN EFP */

@ -44,7 +44,7 @@
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim6;
UART_HandleTypeDef huart1;
@ -52,11 +52,10 @@ UART_HandleTypeDef huart2;
/* USER CODE BEGIN PV */
volatile uint8_t huart2_rxc;
volatile uint8_t huart1_rxc;
static volatile uint32_t sys_time = 0;
static volatile bool b_timer_struck = false;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@ -76,38 +75,38 @@ static void MX_USART1_UART_Init(void);
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_TIM2_Init();
MX_USART2_UART_Init();
MX_TIM6_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_TIM2_Init();
MX_USART2_UART_Init();
MX_TIM6_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
p_uart_init(&huart2);
// HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2);
@ -121,11 +120,13 @@ int main(void)
mc_init(&htim2);
HAL_UART_Receive_IT(&huart2, &huart2_rxc, 1);
HAL_TIM_Base_Start_IT(&htim6);
HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
uint16_t motor_degrees = 0;
/* USER CODE END 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
if (b_timer_struck)
@ -135,272 +136,277 @@ int main(void)
motor_degrees = (motor_degrees + 1) % 360;
mc_service(motor_degrees, 50);
}
/* USER CODE END WHILE */
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
/* USER CODE END 3 */
}
/**
* @brief System Clock Configuration
* @retval None
*/
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
{
Error_Handler();
}
/** Configure LSE Drive Capability
*/
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = 0;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 16;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
/** Enable MSI Auto calibration
*/
HAL_RCCEx_EnableMSIPLLMode();
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
{
Error_Handler();
}
/** Configure LSE Drive Capability
*/
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = 0;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 16;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
/** Enable MSI Auto calibration
*/
HAL_RCCEx_EnableMSIPLLMode();
}
/**
* @brief TIM2 Initialization Function
* @param None
* @retval None
*/
* @brief TIM2 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM2_Init(void)
{
/* USER CODE BEGIN TIM2_Init 0 */
/* USER CODE END TIM2_Init 0 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};
/* USER CODE BEGIN TIM2_Init 1 */
/* USER CODE END TIM2_Init 1 */
htim2.Instance = TIM2;
htim2.Init.Prescaler = 127;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 499;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_PWM_Init(&htim2) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 250;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
sConfigOC.Pulse = 125;
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM2_Init 2 */
/* USER CODE END TIM2_Init 2 */
HAL_TIM_MspPostInit(&htim2);
/* USER CODE BEGIN TIM2_Init 0 */
/* USER CODE END TIM2_Init 0 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};
/* USER CODE BEGIN TIM2_Init 1 */
/* USER CODE END TIM2_Init 1 */
htim2.Instance = TIM2;
htim2.Init.Prescaler = 127;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 499;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_PWM_Init(&htim2) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 250;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
sConfigOC.Pulse = 125;
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM2_Init 2 */
/* USER CODE END TIM2_Init 2 */
HAL_TIM_MspPostInit(&htim2);
}
/**
* @brief TIM6 Initialization Function
* @param None
* @retval None
*/
* @brief TIM6 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM6_Init(void)
{
/* USER CODE BEGIN TIM6_Init 0 */
/* USER CODE END TIM6_Init 0 */
/* USER CODE BEGIN TIM6_Init 0 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE END TIM6_Init 0 */
/* USER CODE BEGIN TIM6_Init 1 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE END TIM6_Init 1 */
htim6.Instance = TIM6;
htim6.Init.Prescaler = 127;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 249;
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM6_Init 2 */
/* USER CODE BEGIN TIM6_Init 1 */
/* USER CODE END TIM6_Init 2 */
/* USER CODE END TIM6_Init 1 */
htim6.Instance = TIM6;
htim6.Init.Prescaler = 127;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 249;
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM6_Init 2 */
/* USER CODE END TIM6_Init 2 */
}
/**
* @brief USART1 Initialization Function
* @param None
* @retval None
*/
* @brief USART1 Initialization Function
* @param None
* @retval None
*/
static void MX_USART1_UART_Init(void)
{
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_RS485Ex_Init(&huart1, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_RS485Ex_Init(&huart1, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
}
/**
* @brief USART2 Initialization Function
* @param None
* @retval None
*/
* @brief USART2 Initialization Function
* @param None
* @retval None
*/
static void MX_USART2_UART_Init(void)
{
/* USER CODE BEGIN USART2_Init 0 */
/* USER CODE END USART2_Init 0 */
/* USER CODE BEGIN USART2_Init 0 */
/* USER CODE BEGIN USART2_Init 1 */
/* USER CODE END USART2_Init 0 */
/* USER CODE END USART2_Init 1 */
huart2.Instance = USART2;
huart2.Init.BaudRate = 115200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART2_Init 2 */
/* USER CODE BEGIN USART2_Init 1 */
/* USER CODE END USART2_Init 2 */
/* USER CODE END USART2_Init 1 */
huart2.Instance = USART2;
huart2.Init.BaudRate = 115200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART2_Init 2 */
/* USER CODE END USART2_Init 2 */
}
/**
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct = {0};
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, m1_dir_Pin|m2_dir_Pin, GPIO_PIN_RESET);
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/*Configure GPIO pins : m1_dir_Pin m2_dir_Pin */
GPIO_InitStruct.Pin = m1_dir_Pin|m2_dir_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, m1_dir_Pin | m2_dir_Pin, GPIO_PIN_RESET);
/*Configure GPIO pins : m1_dir_Pin m2_dir_Pin */
GPIO_InitStruct.Pin = m1_dir_Pin | m2_dir_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
/* USER CODE BEGIN 4 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Transmit(&huart2, &huart2_rxc, 1, 100);
HAL_UART_Receive_IT(&huart2, &huart2_rxc, 1);
if (huart == &huart1)
{
HAL_GPIO_WritePin(USART1_DE_GPIO_Port, USART1_DE_Pin, 1);
huart2_rxc = huart1_rxc;
HAL_UART_Transmit(&huart2, &huart2_rxc, 1, 500);
HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
HAL_GPIO_WritePin(USART1_DE_GPIO_Port, USART1_DE_Pin, 0);
}
else if (huart == &huart2)
{
HAL_UART_Transmit(&huart1, &huart2_rxc, 1, 100);
HAL_UART_Receive_IT(&huart2, &huart2_rxc, 1);
}
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
sys_time += 1;
if(++sys_time % 250 == 0)
if (++sys_time % 250 == 0)
{
b_timer_struck = true;
}
@ -424,33 +430,33 @@ void setPWM(TIM_HandleTypeDef *timer, uint32_t channel, uint8_t dc_percent)
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
__disable_irq();
while (1)
{
}
/* USER CODE END Error_Handler_Debug */
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

@ -227,19 +227,22 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
/* Peripheral clock enable */
__HAL_RCC_USART1_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**USART1 GPIO Configuration
PB3 (JTDO-TRACESWO) ------> USART1_DE
PB6 ------> USART1_TX
PB7 ------> USART1_RX
PA9 ------> USART1_TX
PA10 ------> USART1_RX
PA12 ------> USART1_DE
*/
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10|USART1_DE_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USART1 interrupt Init */
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspInit 1 */
/* USER CODE END USART1_MspInit 1 */
@ -308,12 +311,14 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
__HAL_RCC_USART1_CLK_DISABLE();
/**USART1 GPIO Configuration
PB3 (JTDO-TRACESWO) ------> USART1_DE
PB6 ------> USART1_TX
PB7 ------> USART1_RX
PA9 ------> USART1_TX
PA10 ------> USART1_RX
PA12 ------> USART1_DE
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10|USART1_DE_Pin);
/* USART1 interrupt DeInit */
HAL_NVIC_DisableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspDeInit 1 */
/* USER CODE END USART1_MspDeInit 1 */

@ -56,6 +56,7 @@
/* External variables --------------------------------------------------------*/
extern TIM_HandleTypeDef htim6;
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
/* USER CODE BEGIN EV */
@ -199,6 +200,20 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32l4xx.s). */
/******************************************************************************/
/**
* @brief This function handles USART1 global interrupt.
*/
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
/* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART1_IRQn 1 */
/* USER CODE END USART1_IRQn 1 */
}
/**
* @brief This function handles USART2 global interrupt.
*/

@ -1,5 +1,5 @@
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Wed Apr 06 17:40:48 CDT 2022]
# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Fri Apr 08 15:05:50 CDT 2022]
##########################################################################################################################
# ------------------------------------------------

@ -25,14 +25,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_it.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_it.lst",
"-MFbuild/stm32l4xx_hal_dma.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma.lst",
"-o",
"build/stm32l4xx_it.o",
"Core/Src/stm32l4xx_it.c"
"build/stm32l4xx_hal_dma.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Core/Src/stm32l4xx_it.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
},
{
"arguments": [
@ -66,7 +66,7 @@
"build/stm32l4xx_hal_gpio.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
},
{
@ -95,14 +95,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_dma_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma_ex.lst",
"-MFbuild/stm32l4xx_hal.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal.lst",
"-o",
"build/stm32l4xx_hal_dma_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
"build/stm32l4xx_hal.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
},
{
"arguments": [
@ -130,14 +130,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/motor_controller.d",
"-Wa,-a,-ad,-alms=build/motor_controller.lst",
"-MFbuild/stm32l4xx_it.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_it.lst",
"-o",
"build/motor_controller.o",
"shared/devices/motor_controller.c"
"build/stm32l4xx_it.o",
"Core/Src/stm32l4xx_it.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "shared/devices/motor_controller.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/stm32l4xx_it.c"
},
{
"arguments": [
@ -165,14 +165,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_msp.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_msp.lst",
"-MFbuild/stm32l4xx_hal_rcc.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_rcc.lst",
"-o",
"build/stm32l4xx_hal_msp.o",
"Core/Src/stm32l4xx_hal_msp.c"
"build/stm32l4xx_hal_rcc.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Core/Src/stm32l4xx_hal_msp.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c"
},
{
"arguments": [
@ -200,14 +200,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_i2c.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c.lst",
"-MFbuild/stm32l4xx_hal_tim.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim.lst",
"-o",
"build/stm32l4xx_hal_i2c.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
"build/stm32l4xx_hal_tim.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
},
{
"arguments": [
@ -235,14 +235,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal.lst",
"-MFbuild/putil.d",
"-Wa,-a,-ad,-alms=build/putil.lst",
"-o",
"build/stm32l4xx_hal.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
"build/putil.o",
"shared/util/putil.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "shared/util/putil.c"
},
{
"arguments": [
@ -270,14 +270,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_tim_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim_ex.lst",
"-MFbuild/system_stm32l4xx.d",
"-Wa,-a,-ad,-alms=build/system_stm32l4xx.lst",
"-o",
"build/stm32l4xx_hal_tim_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
"build/system_stm32l4xx.o",
"Core/Src/system_stm32l4xx.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/system_stm32l4xx.c"
},
{
"arguments": [
@ -305,21 +305,19 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_pwr.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr.lst",
"-MFbuild/motor_controller.d",
"-Wa,-a,-ad,-alms=build/motor_controller.lst",
"-o",
"build/stm32l4xx_hal_pwr.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
"build/motor_controller.o",
"shared/devices/motor_controller.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "shared/devices/motor_controller.c"
},
{
"arguments": [
"arm-none-eabi-gcc",
"-c",
"-x",
"assembler-with-cpp",
"-mcpu=cortex-m4",
"-mthumb",
"-mfpu=fpv4-sp-d16",
@ -342,13 +340,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/startup_stm32l432xx.d",
"-MFbuild/stm32l4xx_hal_uart_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart_ex.lst",
"-o",
"build/startup_stm32l432xx.o",
"startup_stm32l432xx.s"
"build/stm32l4xx_hal_uart_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "startup_stm32l432xx.s"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
},
{
"arguments": [
@ -376,14 +375,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_uart.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart.lst",
"-MFbuild/stm32l4xx_hal_pwr_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr_ex.lst",
"-o",
"build/stm32l4xx_hal_uart.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
"build/stm32l4xx_hal_pwr_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
},
{
"arguments": [
@ -411,14 +410,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_flash_ramfunc.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ramfunc.lst",
"-MFbuild/stm32l4xx_hal_i2c_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c_ex.lst",
"-o",
"build/stm32l4xx_hal_flash_ramfunc.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
"build/stm32l4xx_hal_i2c_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
},
{
"arguments": [
@ -446,14 +445,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_rcc.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_rcc.lst",
"-MFbuild/stm32l4xx_hal_flash.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash.lst",
"-o",
"build/stm32l4xx_hal_rcc.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c"
"build/stm32l4xx_hal_flash.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
},
{
"arguments": [
@ -481,14 +480,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_flash_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ex.lst",
"-MFbuild/stm32l4xx_hal_flash_ramfunc.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ramfunc.lst",
"-o",
"build/stm32l4xx_hal_flash_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
"build/stm32l4xx_hal_flash_ramfunc.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
},
{
"arguments": [
@ -516,14 +515,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_cortex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_cortex.lst",
"-MFbuild/stm32l4xx_hal_dma_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma_ex.lst",
"-o",
"build/stm32l4xx_hal_cortex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
"build/stm32l4xx_hal_dma_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
},
{
"arguments": [
@ -551,14 +550,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_pwr_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr_ex.lst",
"-MFbuild/main.d",
"-Wa,-a,-ad,-alms=build/main.lst",
"-o",
"build/stm32l4xx_hal_pwr_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
"build/main.o",
"Core/Src/main.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/main.c"
},
{
"arguments": [
@ -586,14 +585,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_dma.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma.lst",
"-MFbuild/stm32l4xx_hal_cortex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_cortex.lst",
"-o",
"build/stm32l4xx_hal_dma.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
"build/stm32l4xx_hal_cortex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
},
{
"arguments": [
@ -621,14 +620,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_uart_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart_ex.lst",
"-MFbuild/stm32l4xx_hal_flash_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ex.lst",
"-o",
"build/stm32l4xx_hal_uart_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
"build/stm32l4xx_hal_flash_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
},
{
"arguments": [
@ -656,14 +655,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_exti.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_exti.lst",
"-MFbuild/stm32l4xx_hal_rcc_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_rcc_ex.lst",
"-o",
"build/stm32l4xx_hal_exti.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c"
"build/stm32l4xx_hal_rcc_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
},
{
"arguments": [
@ -691,14 +690,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/putil.d",
"-Wa,-a,-ad,-alms=build/putil.lst",
"-MFbuild/stm32l4xx_hal_exti.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_exti.lst",
"-o",
"build/putil.o",
"shared/util/putil.c"
"build/stm32l4xx_hal_exti.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "shared/util/putil.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c"
},
{
"arguments": [
@ -726,14 +725,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_tim.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim.lst",
"-MFbuild/stm32l4xx_hal_i2c.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c.lst",
"-o",
"build/stm32l4xx_hal_tim.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
"build/stm32l4xx_hal_i2c.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
},
{
"arguments": [
@ -761,14 +760,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_i2c_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c_ex.lst",
"-MFbuild/stm32l4xx_hal_msp.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_msp.lst",
"-o",
"build/stm32l4xx_hal_i2c_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
"build/stm32l4xx_hal_msp.o",
"Core/Src/stm32l4xx_hal_msp.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/stm32l4xx_hal_msp.c"
},
{
"arguments": [
@ -796,19 +795,21 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_rcc_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_rcc_ex.lst",
"-MFbuild/stm32l4xx_hal_pwr.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr.lst",
"-o",
"build/stm32l4xx_hal_rcc_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
"build/stm32l4xx_hal_pwr.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
},
{
"arguments": [
"arm-none-eabi-gcc",
"-c",
"-x",
"assembler-with-cpp",
"-mcpu=cortex-m4",
"-mthumb",
"-mfpu=fpv4-sp-d16",
@ -831,14 +832,13 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/main.d",
"-Wa,-a,-ad,-alms=build/main.lst",
"-MFbuild/startup_stm32l432xx.d",
"-o",
"build/main.o",
"Core/Src/main.c"
"build/startup_stm32l432xx.o",
"startup_stm32l432xx.s"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Core/Src/main.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "startup_stm32l432xx.s"
},
{
"arguments": [
@ -866,14 +866,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/system_stm32l4xx.d",
"-Wa,-a,-ad,-alms=build/system_stm32l4xx.lst",
"-MFbuild/stm32l4xx_hal_uart.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart.lst",
"-o",
"build/system_stm32l4xx.o",
"Core/Src/system_stm32l4xx.c"
"build/stm32l4xx_hal_uart.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Core/Src/system_stm32l4xx.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
},
{
"arguments": [
@ -901,13 +901,13 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_flash.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash.lst",
"-MFbuild/stm32l4xx_hal_tim_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim_ex.lst",
"-o",
"build/stm32l4xx_hal_flash.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
"build/stm32l4xx_hal_tim_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
}
]

3024
gdb.txt

File diff suppressed because it is too large Load Diff

@ -15,10 +15,10 @@ Mcu.Name=STM32L432K(B-C)Ux
Mcu.Package=UFQFPN32
Mcu.Pin0=PC14-OSC32_IN (PC14)
Mcu.Pin1=PC15-OSC32_OUT (PC15)
Mcu.Pin10=PA15 (JTDI)
Mcu.Pin11=PB3 (JTDO-TRACESWO)
Mcu.Pin12=PB6
Mcu.Pin13=PB7
Mcu.Pin10=PA12
Mcu.Pin11=PA13 (JTMS-SWDIO)
Mcu.Pin12=PA14 (JTCK-SWCLK)
Mcu.Pin13=PA15 (JTDI)
Mcu.Pin14=VP_SYS_VS_Systick
Mcu.Pin15=VP_TIM6_VS_ClockSourceINT
Mcu.Pin2=PA0
@ -27,8 +27,8 @@ Mcu.Pin4=PA2
Mcu.Pin5=PA3
Mcu.Pin6=PA4
Mcu.Pin7=PA5
Mcu.Pin8=PA13 (JTMS-SWDIO)
Mcu.Pin9=PA14 (JTCK-SWCLK)
Mcu.Pin8=PA9
Mcu.Pin9=PA10
Mcu.PinsNb=16
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
@ -46,6 +46,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true
NVIC.TIM6_DAC_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
PA0.GPIOParameters=GPIO_Label
@ -54,6 +55,14 @@ PA0.Locked=true
PA0.Mode=HSE-External-Clock-Source-for-LittleOrca
PA0.Signal=RCC_CK_IN
PA1.Signal=S_TIM2_CH2
PA10.Locked=true
PA10.Mode=Asynchronous
PA10.Signal=USART1_RX
PA12.GPIOParameters=GPIO_Label
PA12.GPIO_Label=USART1_DE
PA12.Locked=true
PA12.Mode=Hardware Flow Control (RS485)
PA12.Signal=USART1_DE
PA13\ (JTMS-SWDIO).GPIOParameters=GPIO_Label
PA13\ (JTMS-SWDIO).GPIO_Label=SWDIO
PA13\ (JTMS-SWDIO).Locked=true
@ -83,14 +92,9 @@ PA5.GPIOParameters=GPIO_Label
PA5.GPIO_Label=m2_dir
PA5.Locked=true
PA5.Signal=GPIO_Output
PB3\ (JTDO-TRACESWO).Locked=true
PB3\ (JTDO-TRACESWO).Mode=Hardware Flow Control (RS485)
PB3\ (JTDO-TRACESWO).Signal=USART1_DE
PB6.Mode=Asynchronous
PB6.Signal=USART1_TX
PB7.Locked=true
PB7.Mode=Asynchronous
PB7.Signal=USART1_RX
PA9.Locked=true
PA9.Mode=Asynchronous
PA9.Signal=USART1_TX
PC14-OSC32_IN\ (PC14).Locked=true
PC14-OSC32_IN\ (PC14).Mode=LSE-External-Oscillator
PC14-OSC32_IN\ (PC14).Signal=RCC_OSC32_IN

@ -1,10 +1,10 @@
#include "motor_controller.h"
#include <math.h>
#include "putil.h"
#include "stm32l4xx_hal_tim.h"
#include <math.h>
static TIM_HandleTypeDef* _motor_timer = NULL;
void mc_init(TIM_HandleTypeDef* tim)
static TIM_HandleTypeDef *_motor_timer = NULL;
void mc_init(TIM_HandleTypeDef *tim)
{
_motor_timer = tim;
}
@ -13,14 +13,14 @@ void mc_init(TIM_HandleTypeDef* tim)
// speed is anything from 0-99
void mc_service(uint16_t degrees, uint8_t speed)
{
float right_pwm = cos(((float)degrees*(3.1415 / 180.0f)));
float left_pwm = right_pwm;
PDEBUG("| DEGREES | COS | SIN | \n");
PDEBUG("| %7d | %-5.3f | %-5.3f | \n",
(int)degrees,
right_pwm,
right_pwm);
float right_pwm = cos(((float)degrees * (3.1415 / 180.0f)));
float left_pwm = right_pwm;
// PDEBUG("| DEGREES | COS | SIN | \n");
// PDEBUG("| %7d | %-5.3f | %-5.3f | \n",
// (int)degrees,
// right_pwm,
// right_pwm);
HAL_GPIO_WritePin(m1_dir_GPIO_Port, m1_dir_Pin, right_pwm >= 0 ? 0 : 1);
HAL_GPIO_WritePin(m2_dir_GPIO_Port, m2_dir_Pin, left_pwm >= 0 ? 0 : 1);
setPWM(_motor_timer, TIM_CHANNEL_2, abs((int)(right_pwm * 100.0)));

Loading…
Cancel
Save