软件iic怎么一直调不出来呢
This commit is contained in:
+12
-6
@@ -253,10 +253,13 @@ static void MX_GPIO_Init(void)
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOA, U_T_Pin|HC595_DLK_Pin|HC595_SLK_Pin|HC595_RLK_Pin
|
||||
|HC595_SLK2_Pin|iic_scl_Pin, GPIO_PIN_RESET);
|
||||
|HC595_SLK2_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(iic_sda_GPIO_Port, iic_sda_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(iic_sda_GPIO_Port, iic_sda_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(iic_scl_GPIO_Port, iic_scl_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pins : MOT_IN1_Pin MOT_IN2_Pin */
|
||||
GPIO_InitStruct.Pin = MOT_IN1_Pin|MOT_IN2_Pin;
|
||||
@@ -288,17 +291,20 @@ static void MX_GPIO_Init(void)
|
||||
/*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;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
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;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(iic_scl_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/**/
|
||||
HAL_I2CEx_EnableFastModePlus(SYSCFG_CFGR1_I2C_FMP_PA10);
|
||||
|
||||
/* EXTI interrupt init*/
|
||||
HAL_NVIC_SetPriority(EXTI2_3_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI2_3_IRQn);
|
||||
|
||||
@@ -3,4 +3,4 @@ main.c:115:6:SystemClock_Config 80 static
|
||||
main.c:155:13:MX_ADC_Init 24 static
|
||||
main.c:214:13:MX_TIM14_Init 8 static
|
||||
main.c:245:13:MX_GPIO_Init 48 static
|
||||
main.c:316:6:Error_Handler 8 static,ignoring_inline_asm
|
||||
main.c:322:6:Error_Handler 8 static,ignoring_inline_asm
|
||||
|
||||
Binary file not shown.
+6956
-6878
File diff suppressed because it is too large
Load Diff
+424
-559
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,2 @@
|
||||
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
|
||||
eeprom.c:16:6:EEPROM_READ_BATY 16 static
|
||||
eeprom.c:21:6:EEPROM_WRITE_BATY 16 static
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
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
|
||||
iic.c:37:6:iic_wait_ack 16 static
|
||||
iic.c:57:6:IIC_Write_Byte 24 static
|
||||
iic.c:75:15:IIC_Read_Byte 16 static
|
||||
iic.c:97:6:IIC_SAND_DATE 32 static
|
||||
iic.c:114:6:IIC_READ_DATE 32 static
|
||||
|
||||
@@ -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:104:6:moto_server 8 static
|
||||
my_code.c:210:6:HT1621_Display_GetButton 24 static
|
||||
my_code.c:254:6:my_code 40 static
|
||||
my_code.c:254:6:my_code 32 static
|
||||
|
||||
+10
-2
@@ -50,9 +50,14 @@ PA1.GPIOParameters=GPIO_Label
|
||||
PA1.GPIO_Label=ADC_CH1
|
||||
PA1.Locked=true
|
||||
PA1.Signal=SharedAnalog_PA1
|
||||
PA10.GPIOParameters=GPIO_Label
|
||||
PA10.GPIOParameters=GPIO_Speed,GPIO_FMA10,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
|
||||
PA10.GPIO_FMA10=SYSCFG_CFGR1_I2C_FMP_PA10
|
||||
PA10.GPIO_Label=iic_scl
|
||||
PA10.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
|
||||
PA10.GPIO_PuPd=GPIO_PULLUP
|
||||
PA10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PA10.Locked=true
|
||||
PA10.PinState=GPIO_PIN_SET
|
||||
PA10.Signal=GPIO_Output
|
||||
PA13.Mode=Serial_Wire
|
||||
PA13.Signal=SYS_SWDIO
|
||||
@@ -99,9 +104,12 @@ PA9.GPIO_PuPd=GPIO_PULLDOWN
|
||||
PA9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PA9.Locked=true
|
||||
PA9.Signal=GPIO_Output
|
||||
PB1.GPIOParameters=GPIO_Label
|
||||
PB1.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label
|
||||
PB1.GPIO_Label=iic_sda
|
||||
PB1.GPIO_PuPd=GPIO_PULLUP
|
||||
PB1.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PB1.Locked=true
|
||||
PB1.PinState=GPIO_PIN_SET
|
||||
PB1.Signal=GPIO_Output
|
||||
PF0-OSC_IN.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PF0-OSC_IN.GPIO_Label=MOT_IN1
|
||||
|
||||
+1
-65
@@ -12,43 +12,6 @@
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -57,32 +20,5 @@ 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)
|
||||
{
|
||||
//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++;
|
||||
}
|
||||
|
||||
IIC_SAND_DATE(EEPROM_ADDRESS,IN_DEVICE_ADD,DATAS,LONG);
|
||||
}
|
||||
|
||||
@@ -11,26 +11,6 @@
|
||||
|
||||
#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);
|
||||
|
||||
+39
-13
@@ -29,19 +29,41 @@ void iic_stop()
|
||||
|
||||
void iic_ack()
|
||||
{
|
||||
iic_scl(0);
|
||||
iic_sda(0);
|
||||
iic_scl(1);
|
||||
iic_scl(0);
|
||||
}
|
||||
|
||||
void IIC_Write_Byte(unsigned char IIC_Byte){
|
||||
iic_scl(0);
|
||||
char iic_wait_ack()
|
||||
{
|
||||
int a=3000;
|
||||
iic_scl(1);
|
||||
iic_sda(1);
|
||||
change_io_function(iic_sda_GPIO_Port, iic_sda_Pin,1);
|
||||
// while(read_iic_sda)
|
||||
// {
|
||||
// a--;
|
||||
// if(a==0)
|
||||
// {
|
||||
// iic_stop();
|
||||
// return 1;
|
||||
// }
|
||||
// }
|
||||
HAL_Delay(1);
|
||||
change_io_function(iic_sda_GPIO_Port, iic_sda_Pin,0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void IIC_Write_Byte(unsigned char IIC_Byte)
|
||||
{
|
||||
iic_scl(0);
|
||||
for(unsigned char i=0;i<8;i++)
|
||||
{
|
||||
if(IIC_Byte & 0x80)
|
||||
{
|
||||
iic_sda(1);
|
||||
}else{
|
||||
}else
|
||||
{
|
||||
iic_sda(0);
|
||||
}
|
||||
IIC_Byte<<=1;
|
||||
@@ -54,17 +76,20 @@ unsigned char IIC_Read_Byte()
|
||||
{
|
||||
unsigned char k=0;
|
||||
iic_scl(0);
|
||||
iic_sda(1);
|
||||
change_io_function(iic_sda_GPIO_Port, iic_sda_Pin,1);
|
||||
for(unsigned char i=0; i<8; i++)
|
||||
{
|
||||
iic_scl(1);
|
||||
k<<=1;
|
||||
if(read_iic_sda==1)
|
||||
{
|
||||
k|=0x01;
|
||||
}
|
||||
k<<=1;
|
||||
|
||||
iic_scl(0);
|
||||
}
|
||||
change_io_function(iic_sda_GPIO_Port, iic_sda_Pin,0);
|
||||
return(k);
|
||||
}
|
||||
|
||||
@@ -73,15 +98,16 @@ void IIC_SAND_DATE(unsigned char DEVICE_ADD,unsigned char IN_DEVICE_ADD,char *DA
|
||||
{
|
||||
iic_start();
|
||||
IIC_Write_Byte(DEVICE_ADD);
|
||||
iic_ack();
|
||||
if(iic_wait_ack()){return;}
|
||||
IIC_Write_Byte(IN_DEVICE_ADD);
|
||||
iic_ack();
|
||||
if(iic_wait_ack()){return;}
|
||||
for(int a=0;a<LONG;a++)
|
||||
{
|
||||
IIC_Write_Byte(*DATAS);
|
||||
DATAS++;
|
||||
|
||||
}
|
||||
iic_ack();
|
||||
if(iic_wait_ack()){return;}
|
||||
iic_stop();
|
||||
}
|
||||
|
||||
@@ -89,17 +115,17 @@ void IIC_READ_DATE(unsigned char DEVICE_ADD,unsigned char IN_DEVICE_ADD,char *DA
|
||||
{
|
||||
iic_start();
|
||||
IIC_Write_Byte(DEVICE_ADD);
|
||||
iic_ack();
|
||||
if(iic_wait_ack()){return;}
|
||||
IIC_Write_Byte(IN_DEVICE_ADD);
|
||||
iic_ack();
|
||||
if(iic_wait_ack()){return;}
|
||||
iic_start();
|
||||
IIC_Write_Byte(IN_DEVICE_ADD+1);
|
||||
iic_ack();
|
||||
IIC_Write_Byte(DEVICE_ADD+1);
|
||||
if(iic_wait_ack()){return;}
|
||||
for(int a=0;a<LONG;a++)
|
||||
{
|
||||
*DATAS=IIC_Read_Byte();
|
||||
DATAS++;
|
||||
}
|
||||
iic_ack();
|
||||
if(iic_wait_ack()){return;}
|
||||
iic_stop();
|
||||
}
|
||||
|
||||
+28
-10
@@ -254,26 +254,25 @@ void HT1621_Display_GetButton(void)
|
||||
void my_code()
|
||||
{
|
||||
uint32_t runtime=0,move=0;
|
||||
uint8_t mode=0,overload_mode=0;
|
||||
uint8_t mode=6,overload_mode=0;
|
||||
|
||||
uint16_t overload_times=0;
|
||||
long countdown=1000;
|
||||
long countdown_set=15000;
|
||||
|
||||
|
||||
|
||||
HT1621_Init();
|
||||
r480_init();
|
||||
EPPROM_SLOWWRITE_INIT();
|
||||
|
||||
EEPROM_READ_BATY(16,(char *)&config,sizeof(config_setting));
|
||||
if(config.begin!=0xab)
|
||||
{
|
||||
mode=6;
|
||||
}
|
||||
config.begin=18;
|
||||
EEPROM_WRITE_BATY(8,(char *)&config,sizeof(config_setting));
|
||||
config.begin=1;
|
||||
EEPROM_READ_BATY(8,(char *)&config,sizeof(config_setting));
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
//get ADC
|
||||
for(char a=0;a<2;a++)
|
||||
{
|
||||
@@ -538,9 +537,28 @@ void my_code()
|
||||
break;
|
||||
case 6:
|
||||
//stady mode
|
||||
config.begin=0xab;
|
||||
//config.begin=0xab;
|
||||
//EEPROM_WRITE_BATY(16,(char *)&config,sizeof(config_setting));
|
||||
//mode=0;
|
||||
if(HAL_GetTick()>runtime)
|
||||
{
|
||||
runtime+=1000;
|
||||
|
||||
if(dis_buff.led_run==1)
|
||||
{
|
||||
dis_buff.led_run=0;
|
||||
dis_buff.dot4=1;
|
||||
}else
|
||||
{
|
||||
dis_buff.led_run=1;
|
||||
dis_buff.dot4=0;
|
||||
}
|
||||
}
|
||||
dis_buff.d_num[3]=(config.begin)%10;
|
||||
dis_buff.d_num[2]=(config.begin/10)%10;
|
||||
dis_buff.d_num[1]=(config.begin/100)%10;
|
||||
dis_buff.d_num[0]=(config.begin/1000)%10;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -582,7 +600,7 @@ void my_code()
|
||||
dis_buff.button_flag[2]=0;
|
||||
dis_buff.button_flag[3]=0;
|
||||
|
||||
EEPROM_SLOWWRITE_SERVER();
|
||||
|
||||
HT1621_Display_GetButton();
|
||||
hc2_sever();
|
||||
moto_server();
|
||||
|
||||
@@ -24,7 +24,6 @@ typedef struct
|
||||
char begin;
|
||||
char key_code[2];
|
||||
int time;
|
||||
char end;
|
||||
}config_setting;
|
||||
|
||||
struct display_penal
|
||||
|
||||
Reference in New Issue
Block a user