I use the following code to write 32-byte to L01-module. (The wireless-communication works successfully ).
The following (420us+200us), accompany only 32-byte wireless-transmission, which means the real-rate is only 412 Kbps. How to make speed fast?
//-----------------//-----------------//-----------------
for( cnt=0; cnt<=Total; cnt+= 32 ) {
read_image_info ( (org_addr+ cnt), &buf32B[0] ); //about 420us // Master SPI, config 1/4 * 16M
LE1_SPI_Write_Buf (WR_TX_PLOAD, &buf32B[0], 32 ); // about 200us
}
//-----------------//-----------------//-----------------
void LE1_SPI_Write_Buf (unsigned char addr, unsigned char *Buf, unsigned char num)
{
RFCSN = 0;
SPI_RW(addr);
while(num--) { SPI_RW(*Buf++); }
RFCSN = 1;
}
unsigned char SPI_RW (unsigned char value)
{
SPIRDAT = value;
while(!(SPIRSTAT & 0x02));
return SPIRDAT;
}
//-----------------//-----------------//-----------------
SPIMCON0 = 0x13; //Master SPI [6:4],001,1/4 ckMCU; [3],0,MSBit first; [2:1],01-mode; [0],1,SPI master-EN
void read_image_info (uint32_t addr17bit, uint8_t *ptr)
{
uint8_t i, addr17pos;
addr17pos = (addr17bit>>16) & 0x01 ;
SPI_CSn = 0;
IO_SPI_RW( 0x80 | addr17pos); //100_wr1rd0_000(imgPosition)_addr17pos
IO_SPI_RW( addr17bit>>8 );
IO_SPI_RW( addr17bit);
for( i=0; i<31; i++) *(ptr+i) = IO_SPI_RW(0x55);
SPI_CSn = 1;
}
uint8_t IO_SPI_RW (uint8_t value)
{
SPIMDAT = value;
while ( ! (SPIMSTAT & 0x02) );
return SPIMDAT; // Return data register
}