Add version command

This commit is contained in:
henryk@ploetzli.ch 2009-08-28 00:37:28 +00:00
commit ba8a80b30c
6 changed files with 66 additions and 0 deletions

View file

@ -236,6 +236,14 @@ void ReadMem(int addr)
DbpIntegers(0, data[i], data[i+1]);
}
void SendVersion(void)
{
char temp[48]; /* Limited data payload in USB packets */
DbpString("Prox/RFID mark3 RFID instrument");
FpgaGatherVersion(temp, sizeof(temp));
DbpString(temp);
}
// samy's sniff and repeat routine
void SamyRun()
{
@ -616,6 +624,9 @@ void UsbPacketReceived(BYTE *packet, int len)
case CMD_SET_LF_DIVISOR:
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, c->ext1);
break;
case CMD_VERSION:
SendVersion();
break;
#ifdef WITH_LCD
case CMD_LCD_RESET:
LCDReset();

View file

@ -30,6 +30,7 @@ extern DWORD BigBuf[];
void FpgaSendCommand(WORD cmd, WORD v);
void FpgaWriteConfWord(BYTE v);
void FpgaDownloadAndGo(void);
void FpgaGatherVersion(char *dst, int len);
void FpgaSetupSsc(void);
void SetupSpi(int mode);
void FpgaSetupSscDma(BYTE *buf, int len);
@ -104,6 +105,7 @@ int strlen(char *str);
void *memcpy(void *dest, const void *src, int len);
void *memset(void *dest, int c, int len);
int memcmp(const void *av, const void *bv, int len);
char *strncat(char *dest, const char *src, unsigned int n);
void SpinDelay(int ms);
void SpinDelayUs(int us);
void LED(int led, int ms);

View file

@ -285,6 +285,37 @@ void FpgaDownloadAndGo(void)
DownloadFPGA((DWORD *)0x2000, 10524, 1);
}
void FpgaGatherVersion(char *dst, int len)
{
char *fpga_info;
unsigned int fpga_info_len;
dst[0] = 0;
if(!bitparse_find_section('e', (void**)&fpga_info, &fpga_info_len)) {
strncat(dst, "FPGA image: legacy image without version information", len-1);
} else {
strncat(dst, "FPGA image built", len-1);
/* USB packets only have 48 bytes data payload, so be terse */
#if 0
if(bitparse_find_section('a', (void**)&fpga_info, &fpga_info_len) && fpga_info[fpga_info_len-1] == 0 ) {
strncat(dst, " from ", len-1);
strncat(dst, fpga_info, len-1);
}
if(bitparse_find_section('b', (void**)&fpga_info, &fpga_info_len) && fpga_info[fpga_info_len-1] == 0 ) {
strncat(dst, " for ", len-1);
strncat(dst, fpga_info, len-1);
}
#endif
if(bitparse_find_section('c', (void**)&fpga_info, &fpga_info_len) && fpga_info[fpga_info_len-1] == 0 ) {
strncat(dst, " on ", len-1);
strncat(dst, fpga_info, len-1);
}
if(bitparse_find_section('d', (void**)&fpga_info, &fpga_info_len) && fpga_info[fpga_info_len-1] == 0 ) {
strncat(dst, " at ", len-1);
strncat(dst, fpga_info, len-1);
}
}
}
//-----------------------------------------------------------------------------
// Send a 16 bit command/data pair to the FPGA.
// The bit format is: C3 C2 C1 C0 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0

View file

@ -52,6 +52,19 @@ int strlen(char *str)
return l;
}
char* strncat(char *dest, const char *src, unsigned int n)
{
unsigned int dest_len = strlen(dest);
unsigned int i;
for (i = 0 ; i < n && src[i] != '\0' ; i++)
dest[dest_len + i] = src[i];
dest[dest_len + i] = '\0';
return dest;
}
void LEDsoff()
{
LED_A_OFF();