English
Language : 

SH7262 Datasheet, PDF (34/45 Pages) Renesas Technology Corp – High-speed Read/Write Serial Flash Memory
SH7262/SH7264 Group
High-speed Read/Write Serial Flash Memory
Using the Renesas Serial Peripheral Interface
3.16 Sample Program Listing "serial_flash.c" (13/19)
515
while(data_sz--){
516
while( RSPI0.SPSR.BIT.SPTEF == 0 ){
517
/* wait */
518
}
519
RSPI0.SPDR.BYTE = *data++;
520
if( RSPI0.SPSR.BIT.SPRF == 1 ){
521
tmp = RSPI0.SPDR.BYTE; /* Dummy read to avoid an overflow of data */
522
}
523
}
524
io_wait_tx_end();
/* Waits for transfer end */
525
526
/* ---- SPI transfer end (SSL negation) ---- */
527
RSPI0.SPCR.BIT.SPE = 0;
528 }
529 /*""FUNC COMMENT""**************************************************************
530
* ID
:
531
* Outline
: Execute command (With read data, byte transfer).
532
*------------------------------------------------------------------------------
533
* Include
:
534
*------------------------------------------------------------------------------
535
* Declaration : static void io_cmd_exe_rdmode(unsigned char *ope, int ope_sz,
536
*
:
unsigned char *rd, int rd_sz)
537
*------------------------------------------------------------------------------
538
* Description : Executes the specified command.
539
*
: Transmits the argument ope, and then receives data in the argument rd.
540
*
: Transfer data in unit of bytes.
541
*
: Set one of the values between 0 and 8 in the ope_sz.
542
*
: More than 0 can be set in the rd_sz.
543
*------------------------------------------------------------------------------
544
* Argument
: unsigned char *ope ; I : Start address of the opcode block and
545
*
address block to transmit
546
*
: int ope_sz
; I : Number of bytes in the opcode block and
547
*
address block
548
*
: unsigned char *rd ; I : Buffer address to store the received data
549
*
: int rd_sz
; I : Number of bytes in the data block
550
*------------------------------------------------------------------------------
551
* Return Value : void
552
*------------------------------------------------------------------------------
553
* Note
: None
554
*""FUNC COMMENT END""**********************************************************/
555 static void io_cmd_exe_rdmode(unsigned char *ope, int ope_sz, unsigned char *rd, int rd_sz)
556 {
557
/* ==== Resets buffer ==== */
558
RSPI0.SPBFCR.BYTE = 0xC0u;
559
RSPI0.SPBFCR.BYTE = 0x00u;
560
REJ06B0889-0100/Rev.1.00
June 2009
Page 34 of 45