mirror of
https://gitea.ecohim.ru:3000/RS485_BSV/RS485_BSV_fw.git
synced 2025-08-03 15:07:06 +03:00
WIP
This commit is contained in:
@@ -57,6 +57,8 @@ void Error_Handler(void);
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define LED_ACT_Pin GPIO_PIN_1
|
||||
#define LED_ACT_GPIO_Port GPIOC
|
||||
#define U_CTRL_Pin GPIO_PIN_4
|
||||
#define U_CTRL_GPIO_Port GPIOA
|
||||
#define I_CTRL_Pin GPIO_PIN_5
|
||||
|
@@ -44,6 +44,7 @@ ADC_HandleTypeDef hadc1;
|
||||
|
||||
DAC_HandleTypeDef hdac;
|
||||
|
||||
UART_HandleTypeDef huart4;
|
||||
UART_HandleTypeDef huart1;
|
||||
DMA_HandleTypeDef hdma_usart1_rx;
|
||||
DMA_HandleTypeDef hdma_usart1_tx;
|
||||
@@ -59,6 +60,7 @@ static void MX_DMA_Init(void);
|
||||
static void MX_USART1_UART_Init(void);
|
||||
static void MX_DAC_Init(void);
|
||||
static void MX_ADC1_Init(void);
|
||||
static void MX_UART4_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
@@ -101,6 +103,7 @@ int main(void)
|
||||
MX_USART1_UART_Init();
|
||||
MX_DAC_Init();
|
||||
MX_ADC1_Init();
|
||||
MX_UART4_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
@@ -260,6 +263,39 @@ static void MX_DAC_Init(void)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART4 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_UART4_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN UART4_Init 0 */
|
||||
|
||||
/* USER CODE END UART4_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN UART4_Init 1 */
|
||||
|
||||
/* USER CODE END UART4_Init 1 */
|
||||
huart4.Instance = UART4;
|
||||
huart4.Init.BaudRate = 115200;
|
||||
huart4.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart4.Init.StopBits = UART_STOPBITS_1;
|
||||
huart4.Init.Parity = UART_PARITY_NONE;
|
||||
huart4.Init.Mode = UART_MODE_TX_RX;
|
||||
huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
huart4.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
if (HAL_UART_Init(&huart4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN UART4_Init 2 */
|
||||
|
||||
/* USER CODE END UART4_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USART1 Initialization Function
|
||||
* @param None
|
||||
@@ -325,22 +361,22 @@ static void MX_GPIO_Init(void)
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(HVS_ENABLE_GPIO_Port, HVS_ENABLE_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOC, LED_ACT_Pin|HVS_ENABLE_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(TXEN_GPIO_Port, TXEN_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin : HVS_ENABLE_Pin */
|
||||
GPIO_InitStruct.Pin = HVS_ENABLE_Pin;
|
||||
/*Configure GPIO pins : LED_ACT_Pin HVS_ENABLE_Pin */
|
||||
GPIO_InitStruct.Pin = LED_ACT_Pin|HVS_ENABLE_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(HVS_ENABLE_GPIO_Port, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : HVS_OVERLOAD_Pin HVS_OVERHEAT_Pin */
|
||||
GPIO_InitStruct.Pin = HVS_OVERLOAD_Pin|HVS_OVERHEAT_Pin;
|
||||
|
@@ -228,7 +228,34 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac)
|
||||
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(huart->Instance==USART1)
|
||||
if(huart->Instance==UART4)
|
||||
{
|
||||
/* USER CODE BEGIN UART4_MspInit 0 */
|
||||
|
||||
/* USER CODE END UART4_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_UART4_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
/**UART4 GPIO Configuration
|
||||
PC10 ------> UART4_TX
|
||||
PC11 ------> UART4_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_10;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN UART4_MspInit 1 */
|
||||
|
||||
/* USER CODE END UART4_MspInit 1 */
|
||||
}
|
||||
else if(huart->Instance==USART1)
|
||||
{
|
||||
/* USER CODE BEGIN USART1_MspInit 0 */
|
||||
|
||||
@@ -304,7 +331,25 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||||
*/
|
||||
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
{
|
||||
if(huart->Instance==USART1)
|
||||
if(huart->Instance==UART4)
|
||||
{
|
||||
/* USER CODE BEGIN UART4_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END UART4_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_UART4_CLK_DISABLE();
|
||||
|
||||
/**UART4 GPIO Configuration
|
||||
PC10 ------> UART4_TX
|
||||
PC11 ------> UART4_RX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11);
|
||||
|
||||
/* USER CODE BEGIN UART4_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END UART4_MspDeInit 1 */
|
||||
}
|
||||
else if(huart->Instance==USART1)
|
||||
{
|
||||
/* USER CODE BEGIN USART1_MspDeInit 0 */
|
||||
|
||||
|
@@ -39,33 +39,37 @@ Mcu.IP2=DMA
|
||||
Mcu.IP3=NVIC
|
||||
Mcu.IP4=RCC
|
||||
Mcu.IP5=SYS
|
||||
Mcu.IP6=USART1
|
||||
Mcu.IPNb=7
|
||||
Mcu.IP6=UART4
|
||||
Mcu.IP7=USART1
|
||||
Mcu.IPNb=8
|
||||
Mcu.Name=STM32F103R(C-D-E)Tx
|
||||
Mcu.Package=LQFP64
|
||||
Mcu.Pin0=PD0-OSC_IN
|
||||
Mcu.Pin1=PD1-OSC_OUT
|
||||
Mcu.Pin10=PC9
|
||||
Mcu.Pin11=PA8
|
||||
Mcu.Pin12=PA9
|
||||
Mcu.Pin13=PA10
|
||||
Mcu.Pin14=PA11
|
||||
Mcu.Pin15=PA13
|
||||
Mcu.Pin16=PA14
|
||||
Mcu.Pin17=PB3
|
||||
Mcu.Pin18=PB5
|
||||
Mcu.Pin19=PB6
|
||||
Mcu.Pin2=PA4
|
||||
Mcu.Pin20=PB7
|
||||
Mcu.Pin21=VP_SYS_VS_Systick
|
||||
Mcu.Pin3=PA5
|
||||
Mcu.Pin4=PA6
|
||||
Mcu.Pin5=PA7
|
||||
Mcu.Pin6=PC4
|
||||
Mcu.Pin7=PC5
|
||||
Mcu.Pin8=PC7
|
||||
Mcu.Pin9=PC8
|
||||
Mcu.PinsNb=22
|
||||
Mcu.Pin10=PC8
|
||||
Mcu.Pin11=PC9
|
||||
Mcu.Pin12=PA8
|
||||
Mcu.Pin13=PA9
|
||||
Mcu.Pin14=PA10
|
||||
Mcu.Pin15=PA11
|
||||
Mcu.Pin16=PA13
|
||||
Mcu.Pin17=PA14
|
||||
Mcu.Pin18=PC10
|
||||
Mcu.Pin19=PC11
|
||||
Mcu.Pin2=PC1
|
||||
Mcu.Pin20=PB3
|
||||
Mcu.Pin21=PB5
|
||||
Mcu.Pin22=PB6
|
||||
Mcu.Pin23=PB7
|
||||
Mcu.Pin24=VP_SYS_VS_Systick
|
||||
Mcu.Pin3=PA4
|
||||
Mcu.Pin4=PA5
|
||||
Mcu.Pin5=PA6
|
||||
Mcu.Pin6=PA7
|
||||
Mcu.Pin7=PC4
|
||||
Mcu.Pin8=PC5
|
||||
Mcu.Pin9=PC7
|
||||
Mcu.PinsNb=25
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F103RCTx
|
||||
@@ -129,6 +133,14 @@ PB6.Signal=USART1_TX
|
||||
PB7.Locked=true
|
||||
PB7.Mode=Asynchronous
|
||||
PB7.Signal=USART1_RX
|
||||
PC1.GPIOParameters=GPIO_Label
|
||||
PC1.GPIO_Label=LED_ACT
|
||||
PC1.Locked=true
|
||||
PC1.Signal=GPIO_Output
|
||||
PC10.Mode=Asynchronous
|
||||
PC10.Signal=UART4_TX
|
||||
PC11.Mode=Asynchronous
|
||||
PC11.Signal=UART4_RX
|
||||
PC4.GPIOParameters=GPIO_Label
|
||||
PC4.GPIO_Label=HVS_24V
|
||||
PC4.Signal=ADCx_IN14
|
||||
@@ -224,6 +236,8 @@ SH.COMP_DAC2_group.0=DAC_OUT2,DAC_OUT2
|
||||
SH.COMP_DAC2_group.ConfNb=1
|
||||
SH.GPXTI11.0=GPIO_EXTI11
|
||||
SH.GPXTI11.ConfNb=1
|
||||
UART4.IPParameters=VirtualMode
|
||||
UART4.VirtualMode=Asynchronous
|
||||
USART1.BaudRate=9600
|
||||
USART1.IPParameters=VirtualMode,BaudRate
|
||||
USART1.VirtualMode=VM_ASYNC
|
||||
|
Reference in New Issue
Block a user