update modbus
This commit is contained in:
@@ -236,7 +236,7 @@ static void bsp_DS1302Init(void)
|
||||
if ((pDS1302->Time.Year > 99) || (pDS1302->Time.Month > 12) || (pDS1302->Time.Day > 31) ||
|
||||
(pDS1302->Time.Hour > 23) || (pDS1302->Time.Minute > 59) || (pDS1302->Time.Second > 59))
|
||||
{
|
||||
pDS1302->Time.Year = 25;
|
||||
pDS1302->Time.Year = 26;
|
||||
pDS1302->Time.Month = 1;
|
||||
pDS1302->Time.Day = 1;
|
||||
pDS1302->Time.Hour = 0;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "bsp_Led.h"
|
||||
#include "app_timer.h"
|
||||
|
||||
//#define LED1_ON HAL_GPIO_WritePin (LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET)
|
||||
//#define LED1_OFF HAL_GPIO_WritePin (LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET)
|
||||
//#define LED1_TOGGLE HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin)
|
||||
#define LED_ON HAL_GPIO_WritePin (LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET)
|
||||
#define LED_OFF HAL_GPIO_WritePin (LED_GPIO_Port, LED_Pin, GPIO_PIN_SET)
|
||||
#define LED_TOGGLE HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin)
|
||||
|
||||
//#define LED2_ON HAL_GPIO_WritePin (LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET)
|
||||
//#define LED2_OFF HAL_GPIO_WritePin (LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET)
|
||||
@@ -28,11 +28,11 @@ static void bsp_led_init(void)
|
||||
for(u8 i = 0;i < 20;i++)
|
||||
{
|
||||
delay_ms(50);
|
||||
// HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
|
||||
}
|
||||
}
|
||||
|
||||
static void bsp_led_task(void)
|
||||
{
|
||||
// HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ static void Write_SOCK_Data_Buffer(bsp_W5500_Class_t *pW5500_Class, u8 *dat_ptr,
|
||||
bsp_W5500_t W5500 =
|
||||
{
|
||||
.Gateway_IP = {192,168,1,1},
|
||||
.Sub_Mask = {255,255,255,0},
|
||||
.Sub_Mask = {255,255,255,0},/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
.Phy_Addr = {0x0c,0x29,0xab,0x7c,0x00,0x01},
|
||||
|
||||
//.IP_Addr = {169,254,107,101},
|
||||
.IP_Addr = {192,168,1,101},
|
||||
.IP_Addr = {192,168,100,101},
|
||||
|
||||
.Interrupt_Process = bsp_W5500_Interrupt_Process,
|
||||
|
||||
@@ -61,7 +61,7 @@ bsp_W5500_t W5500 =
|
||||
.ConfigData.Sub_Mask = {255,255,255,0},
|
||||
.ConfigData.Phy_Addr = {0x0c,0x29,0xab,0x7c,0x00,0x01},
|
||||
|
||||
.ConfigData.IP_Addr = {192,168,1,101},
|
||||
.ConfigData.IP_Addr = {192,168,100,101},
|
||||
.ConfigData.Port = {0x13,0x88},
|
||||
|
||||
// .ConfigData.DIP = {192,168,1,32},
|
||||
@@ -776,7 +776,7 @@ static void bsp_W5500_Init()
|
||||
{
|
||||
bsp_W5500_Socket_Init(&pW5500->W5500_Class[i]);
|
||||
pW5500->W5500_Class[i].Run_State = 0; /*<2A><>λ״̬*/
|
||||
//bsp_W5500_Socket_Set(&pW5500->W5500_Class[i]); /*W5500<30>˿ڳ<CBBF>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
// bsp_W5500_Socket_Set(&pW5500->W5500_Class[i]); /*W5500<30>˿ڳ<CBBF>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,14 +205,14 @@
|
||||
#define S_TX_SIZE 2048 /*<2A><><EFBFBD><EFBFBD>Socket<65><74><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD>W5500_TMSR<53><52><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
|
||||
/***************----- W5500 GPIO<49><4F><EFBFBD><EFBFBD> -----***************/
|
||||
#define W5500_SCS GPIO_PIN_0 // <20><><EFBFBD><EFBFBD>W5500<30><30>CS<43><53><EFBFBD><EFBFBD>
|
||||
#define W5500_SCS_PORT GPIOB
|
||||
#define W5500_SCS W5500_SPI1_CS_Pin // <20><><EFBFBD><EFBFBD>W5500<30><30>CS<43><53><EFBFBD><EFBFBD>
|
||||
#define W5500_SCS_PORT W5500_SPI1_CS_GPIO_Port
|
||||
|
||||
#define W5500_RST GPIO_PIN_4 // <20><><EFBFBD><EFBFBD>W5500<30><30>RST<53><54><EFBFBD><EFBFBD>
|
||||
#define W5500_RST_PORT GPIOA
|
||||
#define W5500_RST W5500_RST_Pin // <20><><EFBFBD><EFBFBD>W5500<30><30>RST<53><54><EFBFBD><EFBFBD>
|
||||
#define W5500_RST_PORT W5500_RST_GPIO_Port
|
||||
|
||||
#define W5500_INT GPIO_PIN_1 // <20><><EFBFBD><EFBFBD>W5500<30><30>INT<4E><54><EFBFBD><EFBFBD>
|
||||
#define W5500_INT_PORT GPIOA
|
||||
#define W5500_INT W5500_INT_Pin // <20><><EFBFBD><EFBFBD>W5500<30><30>INT<4E><54><EFBFBD><EFBFBD>
|
||||
#define W5500_INT_PORT W5500_INT_GPIO_Port
|
||||
|
||||
///***************----- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -----***************/
|
||||
//extern u8 Gateway_IP[4]; // <20><><EFBFBD><EFBFBD>IP<49><50>ַ
|
||||
|
||||
@@ -2,8 +2,14 @@
|
||||
#include "string.h"
|
||||
|
||||
/* RS485<38><35><EFBFBD>ƺ궨<C6BA><EAB6A8> */
|
||||
#define RS485_RX HAL_GPIO_WritePin(RS485_EN_GPIO_Port, RS485_EN_Pin, GPIO_PIN_SET)
|
||||
#define RS485_TX HAL_GPIO_WritePin(RS485_EN_GPIO_Port, RS485_EN_Pin, GPIO_PIN_SET)
|
||||
#define RS485_1_RX HAL_GPIO_WritePin(RS485_1_EN_GPIO_Port, RS485_1_EN_Pin, GPIO_PIN_RESET)
|
||||
#define RS485_1_TX HAL_GPIO_WritePin(RS485_1_EN_GPIO_Port, RS485_1_EN_Pin, GPIO_PIN_SET)
|
||||
#define RS485_2_RX HAL_GPIO_WritePin(RS485_2_EN_GPIO_Port, RS485_2_EN_Pin, GPIO_PIN_RESET)
|
||||
#define RS485_2_TX HAL_GPIO_WritePin(RS485_2_EN_GPIO_Port, RS485_2_EN_Pin, GPIO_PIN_SET)
|
||||
#define RS485_3_RX HAL_GPIO_WritePin(RS485_3_EN_GPIO_Port, RS485_3_EN_Pin, GPIO_PIN_RESET)
|
||||
#define RS485_3_TX HAL_GPIO_WritePin(RS485_3_EN_GPIO_Port, RS485_3_EN_Pin, GPIO_PIN_SET)
|
||||
#define RS485_4_RX HAL_GPIO_WritePin(RS485_4_EN_GPIO_Port, RS485_4_EN_Pin, GPIO_PIN_RESET)
|
||||
#define RS485_4_TX HAL_GPIO_WritePin(RS485_4_EN_GPIO_Port, RS485_4_EN_Pin, GPIO_PIN_SET)
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD>С */
|
||||
#define RX_TEMP_BUFF_NUM (3000U)
|
||||
@@ -181,6 +187,14 @@ static void bsp_uart_dma_send(bsp_uart_t *p_uart, u8 *p_data, u16 len)
|
||||
{
|
||||
u32 tick_start, tick;
|
||||
|
||||
if(p_uart == &com_uart4)
|
||||
{
|
||||
RS485_1_TX;
|
||||
}else if(p_uart == &com_uart2)
|
||||
{
|
||||
RS485_2_TX;
|
||||
}
|
||||
|
||||
p_uart->tx_dma_complete_flag = 0;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵ij<CDB5><C4B3>ȴ<EFBFBD><C8B4>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD>ض<EFBFBD> */
|
||||
@@ -221,7 +235,12 @@ static void bsp_uart_send(bsp_uart_t *p_uart, u8 *p_data, u16 len)
|
||||
|
||||
/* RS485<38>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ */
|
||||
if(p_uart == &com_uart4)
|
||||
RS485_TX;
|
||||
{
|
||||
RS485_1_TX;
|
||||
}else if(p_uart == &com_uart2)
|
||||
{
|
||||
RS485_2_TX;
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>͵Ĵ<CDB5><C4B4><EFBFBD> */
|
||||
send_num = len / p_uart->tx_dma_len;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "main.h"
|
||||
|
||||
/* spi flash Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD> - pb12 */
|
||||
#define W25Q32_CS_LOW() HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET)
|
||||
#define W25Q32_CS_HIGH() HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET)
|
||||
#define W25Q32_CS_LOW() HAL_GPIO_WritePin(SPI2_CS_GPIO_Port, SPI2_CS_Pin, GPIO_PIN_RESET)
|
||||
#define W25Q32_CS_HIGH() HAL_GPIO_WritePin(SPI2_CS_GPIO_Port, SPI2_CS_Pin, GPIO_PIN_SET)
|
||||
|
||||
/* spi <20><><EFBFBD>亯<EFBFBD><E4BAAF> */
|
||||
static void w25q32_spi_transmit(uint8_t *data, uint16_t size) {
|
||||
@@ -30,7 +30,6 @@ static void w25q32_write_enable(void);
|
||||
static void w25q32_write_disable(void);
|
||||
static uint8_t w25q32_read_status_reg(void);
|
||||
static void w25q32_wait_for_write_end(void);
|
||||
static void w25q32_sector_erase(uint32_t sector_addr);
|
||||
static void w25q32_block_erase(uint32_t block_addr);
|
||||
static void w25q32_page_write(uint32_t addr, uint8_t *data, uint16_t len);
|
||||
static uint8_t w25q32_read_id(void);
|
||||
@@ -43,6 +42,7 @@ w25q32_t w25q32 = {
|
||||
.read = w25q32_read,
|
||||
.write = w25q32_write,
|
||||
.chip_erase = w25q32_chip_erase,
|
||||
.sector_erase = w25q32_sector_erase,
|
||||
};
|
||||
|
||||
|
||||
@@ -106,7 +106,8 @@ static void w25q32_wait_for_write_end(void) {
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (4kb) */
|
||||
static void w25q32_sector_erase(uint32_t sector_addr) {
|
||||
void w25q32_sector_erase(uint32_t sector_addr)
|
||||
{
|
||||
uint8_t cmd[4];
|
||||
|
||||
/* ȷ<><C8B7><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>4k<34><6B><EFBFBD><EFBFBD> */
|
||||
|
||||
@@ -31,6 +31,8 @@ extern "C" {
|
||||
#define W25Q32_MANUFACTURER_ID 0x90
|
||||
#define W25Q32_JEDEC_ID 0x9F
|
||||
|
||||
void w25q32_sector_erase(uint32_t sector_addr);
|
||||
|
||||
/* ״̬<D7B4>Ĵ<EFBFBD><C4B4><EFBFBD>λ */
|
||||
#define W25Q32_STATUS_BUSY (1 << 0)
|
||||
#define W25Q32_STATUS_WRITE_EN (1 << 1)
|
||||
@@ -39,12 +41,25 @@ extern "C" {
|
||||
#define W25Q32_USER_DATA_ADDR 0x000000 /* <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݴ洢<DDB4><E6B4A2>ʼ<EFBFBD><CABC>ַ */
|
||||
#define W25Q32_USER_DATA_SIZE 0x100000 /* <20><>Լ1mb<6D>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> */
|
||||
|
||||
#define W25Q32_DEVICE_INFO_ADDR (0x001000) /* <20>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD>洢<EFBFBD><E6B4A2>ַ - <20><><EFBFBD><EFBFBD>1<EFBFBD><31>4K<34><4B><EFBFBD><EFBFBD> */
|
||||
#define DEVICE_INFO_STORAGE_SIZE (APP_LEAKAGE_SUB_DEVICE_NUM * sizeof(app_leakage_sub_device_flash_data_t)) /*<2A>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD>洢<EFBFBD><E6B4A2>С*/
|
||||
|
||||
/* <20><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><E6B4A2>ַ<EFBFBD>ʹ<EFBFBD>С */
|
||||
#define W25Q32_HISTORY_ALARM_METADATA_ADDR 0x002000 /* <20><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ݴ洢<DDB4><E6B4A2>ַ - <20><><EFBFBD><EFBFBD>2 */
|
||||
#define W25Q32_HISTORY_ALARM_DATA_ADDR 0x003000 /* <20><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ洢<DDB4><E6B4A2>ַ - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><33>ʼ */
|
||||
|
||||
#define HISTORY_ALARM_RECORD_SIZE (sizeof(app_leakage_history_alarm_t)) /* ÿ<><C3BF><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>С */
|
||||
#define HISTORY_ALARM_RECORDS_PER_SECTOR (W25Q32_SECTOR_SIZE / HISTORY_ALARM_RECORD_SIZE) /* ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC> */
|
||||
#define MAX_HISTORY_ALARM_RECORDS (1000) /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC> */
|
||||
#define HISTORY_ALARM_SECTORS_NEEDED ((MAX_HISTORY_ALARM_RECORDS * HISTORY_ALARM_RECORD_SIZE + W25Q32_SECTOR_SIZE - 1) / W25Q32_SECTOR_SIZE)
|
||||
|
||||
/* w25q32 <20><><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9> */
|
||||
typedef struct {
|
||||
void (*init)(void);
|
||||
void (*read)(uint32_t addr, uint8_t *data, uint32_t len);
|
||||
void (*write)(uint32_t addr, uint8_t *data, uint32_t len);
|
||||
void (*chip_erase)(void);
|
||||
void (*sector_erase)(uint32_t sector_addr);
|
||||
} w25q32_t;
|
||||
|
||||
/* ȫ<>ֶ<EFBFBD><D6B6><EFBFBD> */
|
||||
|
||||
Reference in New Issue
Block a user