@ -50,6 +50,7 @@ TIM_HandleTypeDef htim6;
UART_HandleTypeDef huart1 ;
UART_HandleTypeDef huart1 ;
UART_HandleTypeDef huart2 ;
UART_HandleTypeDef huart2 ;
DMA_HandleTypeDef hdma_usart1_rx ;
/* USER CODE BEGIN PV */
/* USER CODE BEGIN PV */
volatile uint8_t huart2_rxc ;
volatile uint8_t huart2_rxc ;
@ -64,8 +65,9 @@ void SystemClock_Config(void);
static void MX_GPIO_Init ( void ) ;
static void MX_GPIO_Init ( void ) ;
static void MX_TIM2_Init ( void ) ;
static void MX_TIM2_Init ( void ) ;
static void MX_USART2_UART_Init ( void ) ;
static void MX_USART2_UART_Init ( void ) ;
static void MX_ TIM6 _Init( void ) ;
static void MX_ DMA _Init( void ) ;
static void MX_USART1_UART_Init ( void ) ;
static void MX_USART1_UART_Init ( void ) ;
static void MX_TIM6_Init ( void ) ;
/* USER CODE BEGIN PFP */
/* USER CODE BEGIN PFP */
static void UART2_RxCpltCallback ( UART_HandleTypeDef * huart ) ;
static void UART2_RxCpltCallback ( UART_HandleTypeDef * huart ) ;
@ -106,8 +108,9 @@ int main(void)
MX_GPIO_Init ( ) ;
MX_GPIO_Init ( ) ;
MX_TIM2_Init ( ) ;
MX_TIM2_Init ( ) ;
MX_USART2_UART_Init ( ) ;
MX_USART2_UART_Init ( ) ;
MX_ TIM6 _Init( ) ;
MX_ DMA _Init( ) ;
MX_USART1_UART_Init ( ) ;
MX_USART1_UART_Init ( ) ;
MX_TIM6_Init ( ) ;
/* USER CODE BEGIN 2 */
/* USER CODE BEGIN 2 */
huart2 . RxCpltCallback = UART2_RxCpltCallback ;
huart2 . RxCpltCallback = UART2_RxCpltCallback ;
@ -116,15 +119,15 @@ int main(void)
// HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2);
// HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2);
// HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);
// HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);
setPWM ( & htim2 , TIM_CHANNEL_2 , 50 ) ;
// setPWM(&htim2, TIM_CHANNEL_2, 50);
setPWM ( & htim2 , TIM_CHANNEL_4 , 25 ) ;
// setPWM(&htim2, TIM_CHANNEL_4, 25);
HAL_GPIO_WritePin ( m1_dir_GPIO_Port , m1_dir_Pin , 1 ) ;
HAL_GPIO_WritePin ( m1_dir_GPIO_Port , m1_dir_Pin , 1 ) ;
HAL_GPIO_WritePin ( m2_dir_GPIO_Port , m2_dir_Pin , 1 ) ;
HAL_GPIO_WritePin ( m2_dir_GPIO_Port , m2_dir_Pin , 1 ) ;
mc_init ( & htim2 ) ;
// mc_init(&htim2);
HAL_UART_Receive_IT ( & huart2 , & huart2_rxc , 1 ) ;
HAL_UART_Receive_IT ( & huart2 , & huart2_rxc , 1 ) ;
HAL_TIM_Base_Start_IT ( & htim6 ) ;
// HAL_TIM_Base_Start_IT(&htim6);
p_serial_mgr_start ( ) ;
p_serial_mgr_start ( ) ;
@ -133,22 +136,9 @@ int main(void)
/* Infinite loop */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
/* USER CODE BEGIN WHILE */
uint8_t rxb [ 256 ] = { 0 } ;
while ( 1 )
while ( 1 )
{
{
if ( p_serial_mgr_service ( ) )
p_serial_mgr_service ( ) ;
{
volatile HAL_StatusTypeDef ret ;
ret = HAL_UART_Receive ( & huart1 , rxb , 256 , 5 ) ;
for ( int ind = 0 ; ind < 20 ; ind + + )
{
p_uart_async_write_byte ( rxb [ ind ] ) ;
}
PDEBUG ( " \n \n \n \n " ) ;
memset ( rxb , 0 , 256 ) ;
p_serial_mgr_start ( ) ;
}
// if (b_timer_struck)
// if (b_timer_struck)
// {
// {
// // PDEBUG("%d\n", sys_time);
// // PDEBUG("%d\n", sys_time);
@ -398,6 +388,21 @@ static void MX_USART2_UART_Init(void)
/* USER CODE END USART2_Init 2 */
/* USER CODE END USART2_Init 2 */
}
}
/**
* Enable DMA controller clock
*/
static void MX_DMA_Init ( void )
{
/* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE ( ) ;
/* DMA interrupt init */
/* DMA1_Channel5_IRQn interrupt configuration */
HAL_NVIC_SetPriority ( DMA1_Channel5_IRQn , 0 , 0 ) ;
HAL_NVIC_EnableIRQ ( DMA1_Channel5_IRQn ) ;
}
/**
/**
* @ brief GPIO Initialization Function
* @ brief GPIO Initialization Function
* @ param None
* @ param None