IR_CMD_Handler

This commit is contained in:
2024-08-25 20:27:17 +03:00
parent 55e8424f78
commit 148d748c20
17 changed files with 853 additions and 469 deletions

View File

@ -3,7 +3,7 @@
#include "usbd_cdc_if.h"
void SaveShot(unsigned char number, struct StructShot* shot)
void SaveShot(unsigned char number, struct Shot* shot)
{
uint16_t blockAddr16 = (uint16_t)(START_ADR_SHOT + (uint16_t)(number*FLASH_BLOCKSIZE));
@ -26,31 +26,30 @@ void SaveShot(unsigned char number, struct StructShot* shot)
FLASH_WriteBlock(blockAddr, Buf);
}
struct StructShot GetShot( unsigned char number )
struct Shot GetShot( unsigned char number )
{
struct StructShot shot;
uint16_t blockAddr16 = (uint16_t)(START_ADR_SHOT + (uint16_t)(number*FLASH_BLOCKSIZE));
uint8_t blockAddr[2] = {HIBYTE(blockAddr16), LOBYTE(blockAddr16)};
struct Shot shot;
uint16_t blockAddr16 = (uint16_t)(START_ADR_SHOT + (uint16_t)(number*FLASH_BLOCKSIZE));
uint8_t blockAddr[2] = {HIBYTE(blockAddr16), LOBYTE(blockAddr16)};
unsigned char Buf[FLASH_BLOCKSIZE];
HAL_I2C_Master_Transmit(&hi2c1, (AT24C_ADRESS << 1), blockAddr, 2, 10);
HAL_Delay(1);
HAL_I2C_Master_Receive(&hi2c1, (AT24C_ADRESS << 1), Buf, FLASH_BLOCKSIZE, 10);
HAL_Delay(1);
shot.countRepeatShot = Buf[1];
shot.speedRollerTop = Buf[2];
shot.speedRollerBottom = Buf[3];
shot.speedScrew = Buf[4];
shot.rotationAxial = Buf[5];
shot.rotationHorizontal = Buf[6];
shot.rotationVertical = Buf[7];
unsigned char Buf[FLASH_BLOCKSIZE];
HAL_I2C_Master_Transmit(&hi2c1, (AT24C_ADRESS << 1), blockAddr, 2, 10);
HAL_Delay(1);
HAL_I2C_Master_Receive(&hi2c1, (AT24C_ADRESS << 1), Buf, FLASH_BLOCKSIZE, 10);
HAL_Delay(1);
shot.countRepeatShot = Buf[1];
shot.speedRollerTop = Buf[2];
shot.speedRollerBottom = Buf[3];
shot.speedScrew = Buf[4];
shot.rotationAxial = Buf[5];
shot.rotationHorizontal = Buf[6];
shot.rotationVertical = Buf[7];
return shot;
return shot;
}