update
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#include "bsp_w25q.h"
|
||||
|
||||
#include "spi.h"
|
||||
#include "main.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "app_leakage.h"
|
||||
|
||||
/* spi flash Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD> - pb12 */
|
||||
#define W25Q32_CS_LOW() HAL_GPIO_WritePin(SPI2_CS_GPIO_Port, SPI2_CS_Pin, GPIO_PIN_RESET)
|
||||
@@ -46,10 +50,57 @@ w25q32_t w25q32 = {
|
||||
};
|
||||
|
||||
|
||||
/* <20><>W25Q32<33><32>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2>app_leakage */
|
||||
static void gui_tjc_hmi_read_device_info_from_w25q(void)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
app_leakage_sub_device_flash_data_t temp_buffer[APP_LEAKAGE_SUB_DEVICE_NUM];
|
||||
|
||||
/* һ<><D2BB><EFBFBD>Զ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>Ϣ */
|
||||
w25q32.read(W25Q32_DEVICE_INFO_ADDR,
|
||||
(uint8_t*)temp_buffer,
|
||||
DEVICE_INFO_STORAGE_SIZE);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7> */
|
||||
uint8_t data_valid = 1;
|
||||
for(int i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶζ<D6B6><CEB6><EFBFBD>0xFF<46><46>˵<EFBFBD><CBB5><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if(temp_buffer[i].state == 0xFF &&
|
||||
temp_buffer[i].com == 0xFF &&
|
||||
temp_buffer[i].modbus_id == 0xFF)
|
||||
{
|
||||
data_valid = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(data_valid)
|
||||
{
|
||||
/* <20><><EFBFBD>Ƶ<EFBFBD>app_leakage<67>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD> */
|
||||
for(int i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
leakage.sub_device_data[i].flash_data = temp_buffer[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FlashΪ<68>գ<EFBFBD><D5A3><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>豸<EFBFBD><E8B1B8>ϢΪĬ<CEAA><C4AC>ֵ */
|
||||
for(int i = 0; i < APP_LEAKAGE_SUB_DEVICE_NUM; i++)
|
||||
{
|
||||
memset(&leakage.sub_device_data[i].flash_data, 0,
|
||||
sizeof(app_leakage_sub_device_flash_data_t));
|
||||
leakage.sub_device_data[i].flash_data.state = DISABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
static void w25q32_init(void) {
|
||||
W25Q32_CS_HIGH(); /* <20><>ʼʱƬѡ<C6AC><D1A1><EFBFBD><EFBFBD> */
|
||||
w25q32_wake_up(); /* <20><><EFBFBD><EFBFBD>оƬ */
|
||||
gui_tjc_hmi_read_device_info_from_w25q();
|
||||
}
|
||||
|
||||
/* <20><>ȡоƬid */
|
||||
|
||||
Reference in New Issue
Block a user