
Appendix 2
7(15)
write_data_init(0x00, 0x04, 0x00, 0x00); // Writes raw data
start_token(); // Address sector 512, offset 40000
Counter8_WritePeriod(0x02); // Sets period to 2 clocks
Counter8_WriteCompareValue(0x01); // Generates a 50% duty cycle
UART_CPutString("S"); // Sends 'S' to show ready for raw data
while(UART_cGetChar() == 0x00); // Waits for raw data to start coming
write_data_raw(UART_bReadRxData());
for(i=0;i<511;i++) // Writes first sector of raw data
{ // Previous line read the 512th byte
while((UART_bReadRxStatus() & 0x08) != 0x08);
write_data_raw(UART_cGetChar());
}
write_CRC();
for(j=0;j<(sectors-
1);j++)
{
start_token();
for(i=0;i<512;i++
)
{
// Writes additional sectors
while((UART_bReadRxStatus() & 0x08) != 0x08);
write_data_raw(UART_cGetChar());
}
write_CRC();
}
start_token();
// Writes remaining raw bytes after all complete sectors
for(i=0;i<(file_size_partial - 1);i++)
{
while((UART_bReadRxStatus() & 0x08) != 0x08);
write_data_raw(UART_cGetChar());
}
// Fill remaining empty space in sector after partial write
write_data_fill(file_size_partial - 1);
write_CRC();
stop_token();
Counter8_WritePeriod(0x30); // Sets period to 10 clocks
Counter8_WriteCompareValue(0x15); // Generates a 50% duty cycle
k = 0;
Loading_LED_Switch(0); // Turns off LED
Write_enable_Switch(0); // Disables write
WiFly_pwr_Switch(0); // Turns off WiFly
MCU_fin_sig_Switch(1); // Signals finish to Control MCU
}
}
}
Comentarios a estos manuales