Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Apr 25, 2023
1 parent faebb14 commit 3acba5a
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 114 deletions.
3 changes: 1 addition & 2 deletions FlashCommand.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ int FlashCommand_SendCommand_OneOutOneIn(unsigned char* vOut, int out_len, unsig
}

int FlashCommand_SendCommand_SetupPacketForBulkWrite(struct CAddressRange* AddrRange, unsigned char modeWrite, unsigned char WriteCom, unsigned int PageSize, unsigned int AddressMode, int Index)
{printf("\nevy FlashCommand_SendCommand_SetupPacketForBulkWrite");
printf("\nevy modeWrite=%x,WriteCom=%x,PageSize=%x",modeWrite,WriteCom,PageSize);
{
unsigned char vInstruction[15];
CNTRPIPE_RQ rq;
// length in terms of 256/128 bytes
Expand Down
41 changes: 31 additions & 10 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ bool ReadSF700AndSF600PG2SN(unsigned char* Data, int Index)
vBuffer[4]=0;
vBuffer[5]=0;

//must read twice
//must read twice
if (OutCtrlRequest(&rq, vBuffer, 6, Index) == SerialFlash_FALSE)
return false;

//first
unsigned char vBufferSN[512];
BulkPipeRead(vBufferSN, USB_TIMEOUT, Index);

if (OutCtrlRequest(&rq, vBuffer, 6, Index) == SerialFlash_FALSE)
return false;

//second
BulkPipeRead(vBufferSN, USB_TIMEOUT, Index);

memcpy(Data, vBufferSN, 16);
return true;
}
bool ReadOnBoardFlash(unsigned char* Data, bool ReadUID, int Index)
bool ReadOnBoardFlash(unsigned char* Data, bool ReadUID, int Index)
{
CNTRPIPE_RQ rq;
unsigned char vBuffer[16];
Expand Down Expand Up @@ -344,6 +344,27 @@ bool SetSPIClockValue(unsigned short v, int Index)
return true;
}

bool SetIOMOdeValue(int Index)
{
if (!Is_usbworking(Index))
return false;

// send request
CNTRPIPE_RQ rq;
unsigned char vBuffer;
rq.Function = URB_FUNCTION_VENDOR_ENDPOINT;
rq.Direction = VENDOR_DIRECTION_OUT;
rq.Request = SET_IOMODE;
rq.Value = 0;//single IO
rq.Index = RFU;
rq.Length = 0;

if (OutCtrlRequest(&rq, &vBuffer, 0, Index) == SerialFlash_FALSE)
return false;
Sleep(200);
return true;
}

unsigned int ReadUID(int Index)
{
if (!Is_usbworking(Index)) {
Expand All @@ -352,7 +373,7 @@ unsigned int ReadUID(int Index)
unsigned int dwUID = 0;
unsigned char vUID[16];

if ((g_bIsSF700 == true) || (g_bIsSF600PG2 == true)) {
if (is_SF700_Or_SF600PG2(Index)) {
if (ReadSF700AndSF600PG2SN(vUID, Index) == false)
return false;
//Sleep(200);
Expand Down Expand Up @@ -465,7 +486,7 @@ unsigned char ReadManufacturerID(int Index)
if (!Is_usbworking(Index))
return false;

if ((g_bIsSF600 == true) || (g_bIsSF700 == true)|| (g_bIsSF600PG2 == true)) {
if ((g_bIsSF600 == true) || is_SF700_Or_SF600PG2(Index) == true) {
unsigned char vUID[16];
if (ReadOnBoardFlash(vUID, false, Index) == false)
return false;
Expand Down Expand Up @@ -625,7 +646,7 @@ bool WriteUID(unsigned int dwUID, int Index)
if (!Is_usbworking(Index))
return false;

if ((g_bIsSF600 == true) || (g_bIsSF700 == true)|| (g_bIsSF600PG2 == true))
if ((g_bIsSF600 == true) || is_SF700_Or_SF600PG2(Index) == true)
return true;

CNTRPIPE_RQ rq;
Expand Down Expand Up @@ -665,7 +686,7 @@ bool WriteManufacturerID(unsigned char ManuID, int Index)
if (!Is_usbworking(Index))
return false;

if ((g_bIsSF600 == true) || (g_bIsSF700 == true)|| (g_bIsSF600PG2 == true))
if ((g_bIsSF600 == true) || is_SF700_Or_SF600PG2(Index) == true)
return true;

CNTRPIPE_RQ rq;
Expand Down Expand Up @@ -776,7 +797,7 @@ bool GetFirmwareVer(int Index)
unsigned char vBuffer[32];
unsigned int BufferSize =32;

if((g_bIsSF600== false) && (g_bIsSF700 == false) && (g_bIsSF600PG2 == false))
if((g_bIsSF600== false) && (is_SF700_Or_SF600PG2(Index) == false))
BufferSize = 16;

// first control packet
Expand Down Expand Up @@ -988,7 +1009,7 @@ bool UpdateFirmware(const char* sFolder, int Index)
unsigned int UID = 0;
unsigned char ManID = 0;
// read status
if ((g_bIsSF600 == true) || (g_bIsSF700 == true)|| (g_bIsSF600PG2 == true))
if ((g_bIsSF600 == true) || (is_SF700_Or_SF600PG2(Index) == true))
return UpdateSF600Firmware(sFolder, Index);

dediprog_set_spi_voltage(g_Vcc, Index);
Expand Down
1 change: 1 addition & 0 deletions board.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ bool SetCS(size_t value, int Index);
bool SetIOModeToSF600(size_t value, int Index);
bool BlinkProgBoard(bool boIsV5, int Index);
bool LeaveSF600Standalone(bool Enable, int Index);
bool SetIOMOdeValue(int Index);
bool SetSPIClockValue(unsigned short v, int Index);
unsigned int ReadUID(int Index);
bool SetSPIClockDefault(int Index);
Expand Down
Loading

0 comments on commit 3acba5a

Please sign in to comment.