2krom写满了,都不知道怎么优化了

This commit is contained in:
2021-10-24 17:27:41 +08:00
parent b8bf07f4cf
commit 564e56fad6
27 changed files with 7967 additions and 6711 deletions
Vendored
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -22,7 +22,7 @@
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.509070238" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.509070238" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.2118512488" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.2118512488" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.662707504" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.5 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F030F4Px || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/STM32F0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F0xx/Include || || || USE_HAL_DRIVER | STM32F030x6 || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F030F4PX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || " valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.662707504" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.5 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F030F4Px || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/STM32F0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F0xx/Include || || || USE_HAL_DRIVER | STM32F030x6 || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F030F4PX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.1319346613" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex" value="true" valueType="boolean"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.1319346613" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1501135504" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1501135504" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/Motor_Controller2}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1249847428" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/> <builder buildPath="${workspace_loc:/Motor_Controller2}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1249847428" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.130361303" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.130361303" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
+4
View File
@@ -79,8 +79,12 @@ void Error_Handler(void);
#define HC595_SLK_GPIO_Port GPIOA #define HC595_SLK_GPIO_Port GPIOA
#define HC595_RLK_Pin GPIO_PIN_7 #define HC595_RLK_Pin GPIO_PIN_7
#define HC595_RLK_GPIO_Port GPIOA #define HC595_RLK_GPIO_Port GPIOA
#define iic_sda_Pin GPIO_PIN_1
#define iic_sda_GPIO_Port GPIOB
#define HC595_SLK2_Pin GPIO_PIN_9 #define HC595_SLK2_Pin GPIO_PIN_9
#define HC595_SLK2_GPIO_Port GPIOA #define HC595_SLK2_GPIO_Port GPIOA
#define iic_scl_Pin GPIO_PIN_10
#define iic_scl_GPIO_Port GPIOA
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */ /* USER CODE END Private defines */
+19 -1
View File
@@ -249,10 +249,14 @@ static void MX_GPIO_Init(void)
/* GPIO Ports Clock Enable */ /* GPIO Ports Clock Enable */
__HAL_RCC_GPIOF_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, U_T_Pin|HC595_DLK_Pin|HC595_SLK_Pin|HC595_RLK_Pin HAL_GPIO_WritePin(GPIOA, U_T_Pin|HC595_DLK_Pin|HC595_SLK_Pin|HC595_RLK_Pin
|HC595_SLK2_Pin, GPIO_PIN_RESET); |HC595_SLK2_Pin|iic_scl_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(iic_sda_GPIO_Port, iic_sda_Pin, GPIO_PIN_RESET);
/*Configure GPIO pins : MOT_IN1_Pin MOT_IN2_Pin */ /*Configure GPIO pins : MOT_IN1_Pin MOT_IN2_Pin */
GPIO_InitStruct.Pin = MOT_IN1_Pin|MOT_IN2_Pin; GPIO_InitStruct.Pin = MOT_IN1_Pin|MOT_IN2_Pin;
@@ -281,6 +285,20 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(I_R_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(I_R_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : iic_sda_Pin */
GPIO_InitStruct.Pin = iic_sda_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(iic_sda_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : iic_scl_Pin */
GPIO_InitStruct.Pin = iic_scl_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(iic_scl_GPIO_Port, &GPIO_InitStruct);
/* EXTI interrupt init*/ /* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI2_3_IRQn, 0, 0); HAL_NVIC_SetPriority(EXTI2_3_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI2_3_IRQn); HAL_NVIC_EnableIRQ(EXTI2_3_IRQn);
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -3,4 +3,4 @@ main.c:115:6:SystemClock_Config 80 static
main.c:155:13:MX_ADC_Init 24 static main.c:155:13:MX_ADC_Init 24 static
main.c:214:13:MX_TIM14_Init 8 static main.c:214:13:MX_TIM14_Init 8 static
main.c:245:13:MX_GPIO_Init 48 static main.c:245:13:MX_GPIO_Init 48 static
main.c:298:6:Error_Handler 8 static,ignoring_inline_asm main.c:316:6:Error_Handler 8 static,ignoring_inline_asm
Binary file not shown.
+6975 -6159
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
my_software/flash.o: ../my_software/flash.c ../my_software/flash.h \ my_software/eeprom.o: ../my_software/eeprom.c ../my_software/eeprom.h \
../Core/Inc/main.h ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal.h \ ../Core/Inc/main.h ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal.h \
../Core/Inc/stm32f0xx_hal_conf.h \ ../Core/Inc/stm32f0xx_hal_conf.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_rcc.h \ ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_rcc.h \
@@ -27,9 +27,10 @@ my_software/flash.o: ../my_software/flash.c ../my_software/flash.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr.h \ ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr_ex.h \ ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr_ex.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h \ ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h \
../my_software/iic.h
../my_software/flash.h: ../my_software/eeprom.h:
../Core/Inc/main.h: ../Core/Inc/main.h:
@@ -90,3 +91,5 @@ my_software/flash.o: ../my_software/flash.c ../my_software/flash.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h: ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h:
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h: ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h:
../my_software/iic.h:
+4
View File
@@ -0,0 +1,4 @@
eeprom.c:16:6:EPPROM_SLOWWRITE_INIT 8 static
eeprom.c:26:6:EEPROM_SLOWWRITE_SERVER 16 static
eeprom.c:53:6:EEPROM_READ_BATY 16 static
eeprom.c:58:6:EEPROM_WRITE_BATY 32 static
+4 -1
View File
@@ -27,7 +27,8 @@ my_software/iic.o: ../my_software/iic.c ../my_software/iic.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr.h \ ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr_ex.h \ ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr_ex.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h \ ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h \
../my_software/gpio.h
../my_software/iic.h: ../my_software/iic.h:
@@ -90,3 +91,5 @@ my_software/iic.o: ../my_software/iic.c ../my_software/iic.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h: ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h:
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h: ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h:
../my_software/gpio.h:
+7
View File
@@ -0,0 +1,7 @@
iic.c:15:6:iic_start 8 static
iic.c:23:6:iic_stop 8 static
iic.c:30:6:iic_ack 8 static
iic.c:36:6:IIC_Write_Byte 24 static
iic.c:53:15:IIC_Read_Byte 16 static
iic.c:72:6:IIC_SAND_DATE 32 static
iic.c:88:6:IIC_READ_DATE 32 static
+3 -3
View File
@@ -29,7 +29,7 @@ my_software/my_code.o: ../my_software/my_code.c ../my_software/my_code.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h \ ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim.h \
../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h \ ../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_tim_ex.h \
../my_software/gpio.h ../my_software/button.h ../my_software/ht1621.h \ ../my_software/gpio.h ../my_software/button.h ../my_software/ht1621.h \
../my_software/flash.h ../my_software/r480r.h ../my_software/r480r.h ../my_software/eeprom.h
../my_software/my_code.h: ../my_software/my_code.h:
@@ -99,6 +99,6 @@ my_software/my_code.o: ../my_software/my_code.c ../my_software/my_code.h \
../my_software/ht1621.h: ../my_software/ht1621.h:
../my_software/flash.h:
../my_software/r480r.h: ../my_software/r480r.h:
../my_software/eeprom.h:
+1 -1
View File
@@ -3,4 +3,4 @@ my_code.c:56:6:Sand_Byte_to_595_2 24 static
my_code.c:77:6:hc2_sever 16 static my_code.c:77:6:hc2_sever 16 static
my_code.c:104:6:moto_server 8 static my_code.c:104:6:moto_server 8 static
my_code.c:210:6:HT1621_Display_GetButton 24 static my_code.c:210:6:HT1621_Display_GetButton 24 static
my_code.c:254:6:my_code 32 static my_code.c:254:6:my_code 40 static
+3 -3
View File
@@ -6,7 +6,7 @@
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \ C_SRCS += \
../my_software/button.c \ ../my_software/button.c \
../my_software/flash.c \ ../my_software/eeprom.c \
../my_software/gpio.c \ ../my_software/gpio.c \
../my_software/ht1621.c \ ../my_software/ht1621.c \
../my_software/iic.c \ ../my_software/iic.c \
@@ -15,7 +15,7 @@ C_SRCS += \
OBJS += \ OBJS += \
./my_software/button.o \ ./my_software/button.o \
./my_software/flash.o \ ./my_software/eeprom.o \
./my_software/gpio.o \ ./my_software/gpio.o \
./my_software/ht1621.o \ ./my_software/ht1621.o \
./my_software/iic.o \ ./my_software/iic.o \
@@ -24,7 +24,7 @@ OBJS += \
C_DEPS += \ C_DEPS += \
./my_software/button.d \ ./my_software/button.d \
./my_software/flash.d \ ./my_software/eeprom.d \
./my_software/gpio.d \ ./my_software/gpio.d \
./my_software/ht1621.d \ ./my_software/ht1621.d \
./my_software/iic.d \ ./my_software/iic.d \
+1 -1
View File
@@ -23,7 +23,7 @@
"./Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.o" "./Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.o"
"./Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.o" "./Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.o"
"./my_software/button.o" "./my_software/button.o"
"./my_software/flash.o" "./my_software/eeprom.o"
"./my_software/gpio.o" "./my_software/gpio.o"
"./my_software/ht1621.o" "./my_software/ht1621.o"
"./my_software/iic.o" "./my_software/iic.o"
+16 -6
View File
@@ -13,11 +13,13 @@ Mcu.Name=STM32F030F4Px
Mcu.Package=TSSOP20 Mcu.Package=TSSOP20
Mcu.Pin0=PF0-OSC_IN Mcu.Pin0=PF0-OSC_IN
Mcu.Pin1=PF1-OSC_OUT Mcu.Pin1=PF1-OSC_OUT
Mcu.Pin10=PA9 Mcu.Pin10=PB1
Mcu.Pin11=PA13 Mcu.Pin11=PA9
Mcu.Pin12=PA14 Mcu.Pin12=PA10
Mcu.Pin13=VP_SYS_VS_Systick Mcu.Pin13=PA13
Mcu.Pin14=VP_TIM14_VS_ClockSourceINT Mcu.Pin14=PA14
Mcu.Pin15=VP_SYS_VS_Systick
Mcu.Pin16=VP_TIM14_VS_ClockSourceINT
Mcu.Pin2=PA0 Mcu.Pin2=PA0
Mcu.Pin3=PA1 Mcu.Pin3=PA1
Mcu.Pin4=PA2 Mcu.Pin4=PA2
@@ -26,7 +28,7 @@ Mcu.Pin6=PA4
Mcu.Pin7=PA5 Mcu.Pin7=PA5
Mcu.Pin8=PA6 Mcu.Pin8=PA6
Mcu.Pin9=PA7 Mcu.Pin9=PA7
Mcu.PinsNb=15 Mcu.PinsNb=17
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F030F4Px Mcu.UserName=STM32F030F4Px
@@ -48,6 +50,10 @@ PA1.GPIOParameters=GPIO_Label
PA1.GPIO_Label=ADC_CH1 PA1.GPIO_Label=ADC_CH1
PA1.Locked=true PA1.Locked=true
PA1.Signal=SharedAnalog_PA1 PA1.Signal=SharedAnalog_PA1
PA10.GPIOParameters=GPIO_Label
PA10.GPIO_Label=iic_scl
PA10.Locked=true
PA10.Signal=GPIO_Output
PA13.Mode=Serial_Wire PA13.Mode=Serial_Wire
PA13.Signal=SYS_SWDIO PA13.Signal=SYS_SWDIO
PA14.Mode=Serial_Wire PA14.Mode=Serial_Wire
@@ -93,6 +99,10 @@ PA9.GPIO_PuPd=GPIO_PULLDOWN
PA9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH PA9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA9.Locked=true PA9.Locked=true
PA9.Signal=GPIO_Output PA9.Signal=GPIO_Output
PB1.GPIOParameters=GPIO_Label
PB1.GPIO_Label=iic_sda
PB1.Locked=true
PB1.Signal=GPIO_Output
PF0-OSC_IN.GPIOParameters=GPIO_PuPd,GPIO_Label PF0-OSC_IN.GPIOParameters=GPIO_PuPd,GPIO_Label
PF0-OSC_IN.GPIO_Label=MOT_IN1 PF0-OSC_IN.GPIO_Label=MOT_IN1
PF0-OSC_IN.GPIO_PuPd=GPIO_PULLDOWN PF0-OSC_IN.GPIO_PuPd=GPIO_PULLDOWN
+88
View File
@@ -0,0 +1,88 @@
/*
* eeprom.c
*
* Created on: Oct 24, 2021
* Author: wuwenfeng
*/
#include "eeprom.h"
#include "iic.h"
eeprom_write_buff_info eeprom_write_buffer;
void EPPROM_SLOWWRITE_INIT()
{
eeprom_write_buffer.buff=NULL;
eeprom_write_buffer.end=NULL;
eeprom_write_buffer.head=NULL;
eeprom_write_buffer.save_timeout=5;
eeprom_write_buffer.save_busy=0;
}
void EEPROM_SLOWWRITE_SERVER()
{
eeprom_write_buff *buff;
char data;
if(eeprom_write_buffer.save_busy)
{
if(HAL_GetTick()>eeprom_write_buffer.save_time)
{
eeprom_write_buffer.save_busy=0;
}
}else
{
if(eeprom_write_buffer.head!=NULL)
{
eeprom_write_buffer.save_busy=1;
eeprom_write_buffer.save_time=HAL_GetTick()+eeprom_write_buffer.save_timeout;
buff=eeprom_write_buffer.head->next;
data=eeprom_write_buffer.head->date;
IIC_SAND_DATE(EEPROM_ADDRESS,eeprom_write_buffer.head->add,&data,1);
free(eeprom_write_buffer.head);
eeprom_write_buffer.head=buff;
}
}
}
void EEPROM_READ_BATY(uint16_t IN_DEVICE_ADD,char *DATAS,uint16_t LONG)
{
IIC_READ_DATE(EEPROM_ADDRESS,IN_DEVICE_ADD,DATAS,LONG);
}
void EEPROM_WRITE_BATY(uint16_t IN_DEVICE_ADD,char *DATAS,uint16_t LONG)
{
//IIC_SAND_DATE(EEPROM_ADDRESS,IN_DEVICE_ADD,DATAS,LONG);
uint16_t addoffset=0;
eeprom_write_buff *buff;
eeprom_write_buff *buff2;
while(LONG--)
{
buff =(eeprom_write_buff*)malloc(sizeof(eeprom_write_buff));
if(buff!=NULL)
{
buff->add=IN_DEVICE_ADD+addoffset;
buff->date=DATAS[addoffset];
buff->next=NULL;
}else{return ;}
if(eeprom_write_buffer.head==NULL)
{
eeprom_write_buffer.head=buff;
eeprom_write_buffer.end=buff;
}else
{
buff2=eeprom_write_buffer.end;
buff2->next=buff;
eeprom_write_buffer.end=buff;
}
addoffset++;
}
}
+38
View File
@@ -0,0 +1,38 @@
/*
* eeprom.h
*
* Created on: Oct 24, 2021
* Author: wuwenfeng
*/
#ifndef EEPROM_H_
#define EEPROM_H_
#include "main.h"
#define EEPROM_ADDRESS 0xa0
typedef struct eeprom_write_buff
{
struct eeprom_write_buff *next;
uint16_t add;
char date;
}eeprom_write_buff;
typedef struct eeprom_write_buff_info
{
eeprom_write_buff *buff;
eeprom_write_buff *head;
eeprom_write_buff *end;
uint32_t save_time;
uint8_t save_timeout;
uint8_t save_busy:1;
}eeprom_write_buff_info;
void EPPROM_SLOWWRITE_INIT();
void EEPROM_SLOWWRITE_SERVER();
void EEPROM_READ_BATY(uint16_t IN_DEVICE_ADD,char *DATAS,uint16_t LONG);
void EEPROM_WRITE_BATY(uint16_t IN_DEVICE_ADD,char *DATAS,uint16_t LONG);
#endif /* EEPROM_H_ */
-14
View File
@@ -1,14 +0,0 @@
/*
* flash.c
*
* Created on: 2021年10月15日
* Author: wuwenfeng
*/
#include "flash.h"
-14
View File
@@ -1,14 +0,0 @@
/*
* flash.h
*
* Created on: 2021年10月15日
* Author: wuwenfeng
*/
#ifndef FLASH_H_
#define FLASH_H_
#include "main.h"
#endif /* FLASH_H_ */
+97
View File
@@ -6,3 +6,100 @@
*/ */
#include "iic.h" #include "iic.h"
#include "gpio.h"
#define iic_sda(x) HAL_GPIO_WritePin(iic_sda_GPIO_Port, iic_sda_Pin, x)
#define iic_scl(x) HAL_GPIO_WritePin(iic_scl_GPIO_Port, iic_scl_Pin, x)
#define read_iic_sda HAL_GPIO_ReadPin(iic_sda_GPIO_Port, iic_sda_Pin)
void iic_start()
{
iic_sda(1);
iic_scl(1);
iic_sda(0);
iic_scl(0);
}
void iic_stop()
{
iic_sda(0);
iic_scl(1);
iic_sda(1);
}
void iic_ack()
{
iic_scl(1);
iic_scl(0);
}
void IIC_Write_Byte(unsigned char IIC_Byte){
iic_scl(0);
change_io_function(iic_sda_GPIO_Port, iic_sda_Pin,0);
for(unsigned char i=0;i<8;i++)
{
if(IIC_Byte & 0x80)
{
iic_sda(1);
}else{
iic_sda(0);
}
IIC_Byte<<=1;
iic_scl(1);
iic_scl(0);
}
}
unsigned char IIC_Read_Byte()
{
unsigned char k=0;
iic_scl(0);
change_io_function(iic_sda_GPIO_Port, iic_sda_Pin,1);
for(unsigned char i=0; i<8; i++)
{
iic_scl(1);
if(read_iic_sda==1)
{
k|=0x01;
}
k<<=1;
iic_scl(0);
}
return(k);
}
void IIC_SAND_DATE(unsigned char DEVICE_ADD,unsigned char IN_DEVICE_ADD,char *DATAS,uint16_t LONG)
{
iic_start();
IIC_Write_Byte(DEVICE_ADD);
iic_ack();
IIC_Write_Byte(IN_DEVICE_ADD);
iic_ack();
for(int a=0;a<LONG;a++)
{
IIC_Write_Byte(*DATAS);
DATAS++;
}
iic_ack();
iic_stop();
}
void IIC_READ_DATE(unsigned char DEVICE_ADD,unsigned char IN_DEVICE_ADD,char *DATAS,uint16_t LONG)
{
iic_start();
IIC_Write_Byte(DEVICE_ADD);
iic_ack();
IIC_Write_Byte(IN_DEVICE_ADD);
iic_ack();
iic_start();
IIC_Write_Byte(IN_DEVICE_ADD+1);
iic_ack();
for(int a=0;a<LONG;a++)
{
*DATAS=IIC_Read_Byte();
DATAS++;
}
iic_ack();
iic_stop();
}
+2 -1
View File
@@ -9,6 +9,7 @@
#define IIC_H_ #define IIC_H_
#include "main.h" #include "main.h"
void IIC_SAND_DATE(unsigned char DEVICE_ADD,unsigned char IN_DEVICE_ADD,char *DATAS,uint16_t LONG);
void IIC_READ_DATE(unsigned char DEVICE_ADD,unsigned char IN_DEVICE_ADD,char *DATAS,uint16_t LONG);
#endif /* IIC_H_ */ #endif /* IIC_H_ */
+16 -4
View File
@@ -8,13 +8,13 @@
#include "gpio.h" #include "gpio.h"
#include "button.h" #include "button.h"
#include "ht1621.h" #include "ht1621.h"
#include "flash.h"
#include "r480r.h" #include "r480r.h"
#include "eeprom.h"
extern ADC_HandleTypeDef hadc; extern ADC_HandleTypeDef hadc;
struct button key1,key2,key3,key4,overload; struct button key1,key2,key3,key4,overload;
config_setting config;
#define set_filtering_times 50 #define set_filtering_times 50
struct struct
@@ -264,6 +264,13 @@ void my_code()
HT1621_Init(); HT1621_Init();
r480_init(); r480_init();
EPPROM_SLOWWRITE_INIT();
EEPROM_READ_BATY(16,(char *)&config,sizeof(config_setting));
if(config.begin!=0xab)
{
mode=6;
}
while(1) while(1)
{ {
@@ -529,7 +536,12 @@ void my_code()
} }
break; break;
case 6:
//stady mode
config.begin=0xab;
//EEPROM_WRITE_BATY(16,(char *)&config,sizeof(config_setting));
//mode=0;
break;
} }
if(ADCC.adc_value[0]>600||ADCC.adc_value[1]>600) if(ADCC.adc_value[0]>600||ADCC.adc_value[1]>600)
@@ -570,7 +582,7 @@ void my_code()
dis_buff.button_flag[2]=0; dis_buff.button_flag[2]=0;
dis_buff.button_flag[3]=0; dis_buff.button_flag[3]=0;
EEPROM_SLOWWRITE_SERVER();
HT1621_Display_GetButton(); HT1621_Display_GetButton();
hc2_sever(); hc2_sever();
moto_server(); moto_server();
+11 -4
View File
@@ -13,12 +13,19 @@ void my_code();
#define HC595_DCK(x) HAL_GPIO_WritePin(HC595_DLK_GPIO_Port, HC595_DLK_Pin, x); #define HC595_DCK(x) HAL_GPIO_WritePin(HC595_DLK_GPIO_Port, HC595_DLK_Pin, x)
#define HC595_RCK(x) HAL_GPIO_WritePin(HC595_RLK_GPIO_Port, HC595_RLK_Pin, x); #define HC595_RCK(x) HAL_GPIO_WritePin(HC595_RLK_GPIO_Port, HC595_RLK_Pin, x)
#define HC595_SCK(x) HAL_GPIO_WritePin(HC595_SLK_GPIO_Port, HC595_SLK_Pin, x); #define HC595_SCK(x) HAL_GPIO_WritePin(HC595_SLK_GPIO_Port, HC595_SLK_Pin, x)
#define HC595_SCK2(x) HAL_GPIO_WritePin(HC595_SLK2_GPIO_Port, HC595_SLK2_Pin, x); #define HC595_SCK2(x) HAL_GPIO_WritePin(HC595_SLK2_GPIO_Port, HC595_SLK2_Pin, x)
#define READ_HC595_DCK HAL_GPIO_ReadPin(HC595_DLK_GPIO_Port,HC595_DLK_Pin) #define READ_HC595_DCK HAL_GPIO_ReadPin(HC595_DLK_GPIO_Port,HC595_DLK_Pin)
typedef struct
{
char begin;
char key_code[2];
int time;
char end;
}config_setting;
struct display_penal struct display_penal
{ {