Skip to content

Commit

Permalink
串口简化
Browse files Browse the repository at this point in the history
  • Loading branch information
losehu committed Jun 28, 2024
1 parent 7ba53a5 commit c0f3b7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
9 changes: 2 additions & 7 deletions app/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ static void CMD_051B(const uint8_t *pBuffer) {
const CMD_051B_t *pCmd = (const CMD_051B_t *) pBuffer;
REPLY_051B_t Reply;
#ifdef ENABLE_BLOCK

bool bLocked = false;
#endif
if (pCmd->Timestamp != Timestamp)
Expand Down Expand Up @@ -630,9 +629,11 @@ static void CMD_0801(const uint8_t *pBuffer)

void UART_HandleCommand(void) {
switch (UART_Command.Header.ID) {
case 0x051B:
case 0x052B://read
CMD_051B(UART_Command.Buffer);
break;
case 0x051D:
case 0x0538://write
CMD_0538(UART_Command.Buffer);
break;
Expand All @@ -647,13 +648,7 @@ void UART_HandleCommand(void) {
CMD_0514(UART_Command.Buffer);
break;

case 0x051B:
CMD_051B(UART_Command.Buffer);
break;

case 0x051D:
CMD_051D(UART_Command.Buffer);
break;


case 0x0527:
Expand Down
19 changes: 4 additions & 15 deletions driver/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ void EEPROM_ReadBuffer(uint32_t Address, void *pBuffer, uint8_t Size) {

void EEPROM_WriteBuffer(uint32_t Address, const void *pBuffer, uint8_t WRITE_SIZE) {

if (pBuffer == NULL)
return;
// if (pBuffer == NULL)
// return;
uint8_t buffer[128];
EEPROM_ReadBuffer(Address, buffer, WRITE_SIZE);
if (memcmp(pBuffer, buffer, WRITE_SIZE) != 0) {
uint8_t IIC_ADD = 0xA0 | ((Address / 0x10000) << 1);
uint8_t IIC_ADD = 0xA0 | Address >> 15 &14;

I2C_Start();

I2C_Write(IIC_ADD);
Expand All @@ -140,15 +141,3 @@ void EEPROM_WriteBuffer(uint32_t Address, const void *pBuffer, uint8_t WRITE_SIZ
}


void EEPROM_Buffer_MORE(uint32_t Address, void *pBuffer, uint16_t WRITE_SIZE, uint8_t TYPE) {
uint16_t SUM_WRITE = 0;
while (WRITE_SIZE) {
uint16_t NOW_WRITE_SIZE = (WRITE_SIZE < 128 ? WRITE_SIZE : 128) - (Address & 0x7f);
WRITE_SIZE -= NOW_WRITE_SIZE;
if (TYPE) EEPROM_WriteBuffer(Address, pBuffer + SUM_WRITE, NOW_WRITE_SIZE);
else EEPROM_ReadBuffer(Address, pBuffer + SUM_WRITE, NOW_WRITE_SIZE);

SUM_WRITE += NOW_WRITE_SIZE;
Address += NOW_WRITE_SIZE;
}
}

0 comments on commit c0f3b7e

Please sign in to comment.