1
0
mirror of https://github.com/mist-devel/mist-board.git synced 2026-02-26 08:14:07 +00:00

Fixed sd_card wrapper bit synchronization

This commit is contained in:
harbaum
2015-03-03 19:42:07 +00:00
parent 8ee5da2f34
commit 711234a7ea
3 changed files with 24 additions and 3 deletions

View File

@@ -309,18 +309,25 @@ end
// spi receiver
reg illegal_write_state /* synthesis noprune */;
reg synced;
always @(posedge sd_sck or posedge sd_cs) begin
// cs is active low
if(sd_cs == 1) begin
bit_cnt <= 3'd0;
synced <= 1'b0;
end else begin
illegal_write_state <= 1'b0;
new_cmd_rcvd <= 1'b0;
buffer_write_strobe <= 1'b0;
req_io_wr <= 1'b0;
bit_cnt <= bit_cnt + 3'd1;
// wait for first 0 bit until start counting bits
if(synced || !sd_sdi) begin
synced <= 1'b1;
bit_cnt <= bit_cnt + 3'd1;
end
// assemble byte
if(bit_cnt != 7)
sbuf[6:0] <= { sbuf[5:0], sd_sdi };

View File

@@ -156,6 +156,19 @@ u08 spiTransferFF() {
return spiTransferByte(0xff);
}
void spiTx1(int i) {
while(i--) {
top->sd_sdi = 1;
dump();
top->sd_sck = 1;
dump();
top->sd_sck = 0;
dump();
}
dump();
}
#define DIR_INIT_MEMSIZE 16*1024
u08 mem[DIR_INIT_MEMSIZE];
char ROM_DIR[]="/atari800/rom";

View File

@@ -60,6 +60,7 @@ u08 spiTransferByte(u08 data);
// operates on a whole word (16-bits of data).
u08 spiTransferFF();
void spiTransferTwoFF();
void spiTx1(int i);
void spiDisplay(int i);