update modbus
This commit is contained in:
@@ -61,16 +61,32 @@ void Error_Handler(void);
|
||||
#define W5500_RST_GPIO_Port GPIOC
|
||||
#define W5500_INT_Pin GPIO_PIN_5
|
||||
#define W5500_INT_GPIO_Port GPIOC
|
||||
#define RS485_1_EN_Pin GPIO_PIN_0
|
||||
#define RS485_1_EN_GPIO_Port GPIOB
|
||||
#define RS485_2_EN_Pin GPIO_PIN_1
|
||||
#define RS485_2_EN_GPIO_Port GPIOB
|
||||
#define RS485_3_EN_Pin GPIO_PIN_2
|
||||
#define RS485_3_EN_GPIO_Port GPIOB
|
||||
#define RS485_4_EN_Pin GPIO_PIN_7
|
||||
#define RS485_4_EN_GPIO_Port GPIOE
|
||||
#define JK2_Pin GPIO_PIN_9
|
||||
#define JK2_GPIO_Port GPIOE
|
||||
#define JK3_Pin GPIO_PIN_10
|
||||
#define JK3_GPIO_Port GPIOE
|
||||
#define W5500_SPI1_CS_Pin GPIO_PIN_11
|
||||
#define W5500_SPI1_CS_GPIO_Port GPIOE
|
||||
#define SPI2_CS_Pin GPIO_PIN_12
|
||||
#define SPI2_CS_GPIO_Port GPIOB
|
||||
#define LED_Pin GPIO_PIN_12
|
||||
#define LED_GPIO_Port GPIOA
|
||||
#define DS1302_CLK_Pin GPIO_PIN_3
|
||||
#define DS1302_CLK_GPIO_Port GPIOD
|
||||
#define DS1302_DIO_Pin GPIO_PIN_4
|
||||
#define DS1302_DIO_GPIO_Port GPIOD
|
||||
#define DS1302_RST_Pin GPIO_PIN_5
|
||||
#define DS1302_RST_GPIO_Port GPIOD
|
||||
#define JK4_Pin GPIO_PIN_5
|
||||
#define JK4_GPIO_Port GPIOB
|
||||
#define RS485_EN_Pin GPIO_PIN_8
|
||||
#define RS485_EN_GPIO_Port GPIOB
|
||||
|
||||
|
||||
@@ -48,18 +48,22 @@ void MX_GPIO_Init(void)
|
||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOC, W5500_RST_Pin|W5500_INT_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(W5500_SPI1_CS_GPIO_Port, W5500_SPI1_CS_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOB, RS485_1_EN_Pin|RS485_2_EN_Pin|RS485_3_EN_Pin|SPI2_CS_Pin
|
||||
|JK4_Pin|RS485_EN_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, SPI2_CS_Pin|RS485_EN_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOE, RS485_4_EN_Pin|JK2_Pin|JK3_Pin|W5500_SPI1_CS_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOD, DS1302_CLK_Pin|DS1302_DIO_Pin|DS1302_RST_Pin, GPIO_PIN_RESET);
|
||||
@@ -71,20 +75,36 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = W5500_SPI1_CS_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(W5500_SPI1_CS_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PBPin PBPin */
|
||||
GPIO_InitStruct.Pin = SPI2_CS_Pin|RS485_EN_Pin;
|
||||
/*Configure GPIO pins : PBPin PBPin PBPin PBPin
|
||||
PBPin */
|
||||
GPIO_InitStruct.Pin = RS485_1_EN_Pin|RS485_2_EN_Pin|RS485_3_EN_Pin|SPI2_CS_Pin
|
||||
|RS485_EN_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PEPin PEPin */
|
||||
GPIO_InitStruct.Pin = RS485_4_EN_Pin|W5500_SPI1_CS_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PEPin PEPin */
|
||||
GPIO_InitStruct.Pin = JK2_Pin|JK3_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = LED_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PDPin PDPin PDPin */
|
||||
GPIO_InitStruct.Pin = DS1302_CLK_Pin|DS1302_DIO_Pin|DS1302_RST_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
@@ -92,6 +112,13 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = JK4_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(JK4_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
@@ -98,6 +98,7 @@ int main(void)
|
||||
MX_USART6_UART_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
app_init();
|
||||
//HAL_GPIO_WritePin(JK1_GPIO_Port,JK1_Pin,GPIO_PIN_SET);
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
|
||||
Reference in New Issue
Block a user