Download USB HOST CONTROLLER FOR A MICROCONTROLLER

Transcript
}
return temp[2] * 256 + temp[3];
}
// ***********************************************************************
// VNC1L - DIR determines file length
// Maximum 64 kByte!!!
// Parameters: file_name : Address of file_name
//
file_content : Address of the intermediate stores (temporary use)
//
file_length : Address of the length of the file to be played back
// Return: 0 = OK
// ***********************************************************************
unsigned char vnc_rd_dir_UART(char *file_name, unsigned int *file_length, unsigned int
file_name_length)
{
unsigned char status
= 0;
unsigned int buff_index
= 0;
char *start;
// Address of hex strings (beginning)
int vnc_i;
sprintf (&vnc.send_buffer[0], "DIR %s", file_name);
status = vnc_wr_cmd_UART(vnc.send_buffer);
//status = vnc_prompt_check_UART();
// clean up the buffer
for(int k = 0; k < 60; k++)
{
vnc.receive_buffer[k] = 0;
}
// DIR file_name command returns two CRs, the file name followed by $xx $xx $xx $xx CR and
a prompt
for(vnc_i = 0; vnc_i < (file_name_length + 22); vnc_i++) // file name length + 18 + 4
{
// wait until a byte has been received
while((UCSR1A & (1<<RXC1)) == 0);
vnc.receive_buffer[vnc_i] = UDR1;
}
// Response string to DIR is read
// char *strchr(const char *s, int c); it locates the first occurrence of c in the string
pointed to by s.
//
it returns a pointer to the byte, or a null pointer if the byte was not found.
90