Specifications
* Set data line.
*/
if(data & mask)
sbi(VS_SI_PORT, VS_SI_BIT);
else
cbi(VS_SI_PORT, VS_SI_BIT);
/*
* Toggle clock and shift mask.
*/
sbi(VS_SCK_PORT, VS_SCK_BIT);
mask >>= 1;
cbi(VS_SCK_PORT, VS_SCK_BIT);
}
}
/*
* Write a word to the VS1001 command interface.
*/
static void VsWriteReg(u_char reg, u_short data)
{
/*
* Disable interrupts and select chip.
*/
cli();
//asm volatile("cli");
cbi(VS_XCS_PORT, VS_XCS_BIT);
cbi(SPCR, SPE);
//outp(BV(MSTR) | BV(SPE), SPCR);
VsSciPutByte(VS_OPCODE_WRITE);
VsSciPutByte(reg);
VsSciPutByte((u_char)(data >> 8));
VsSciPutByte((u_char)data);
/*
* Added on Jesper's recommendation.
*/
if(writeDelay)
NutDelay(writeDelay);
/*
* Re-enable SPI. Changed due to a hint by Jesper.
*/
outp(BV(MSTR) | BV(SPE), SPCR);
outp(inp(SPSR), SPSR);
/*
* Deselect chip and enable interrupts.
*/
sbi(VS_XCS_PORT, VS_XCS_BIT);
// asm volatile("sei");
sei();
}
/*
* Write a byte to the VS1001 data interface.
*/
static inline void VsSend(u_char b)
97










