
\		REQUIRES: lib_registers.txt
\		REQUIRES: lib_dump.txt
\		REQUIRES: drv_spi2.txt
\		REQUIRES: drv_flash.txt



\ init module
flashInit

\ some tests
$200 buffer: flashbuffer
: .b flashbuffer $200 b-dump ;
: .r flashId. cr flashStatus> . cr ;
: .l $4000 0 do i flash> . loop ;
: .t flashStatus> . cr ;


: initFlashbuffer
	$200 0 do i flashbuffer over + c! loop ;

initFlashbuffer


: flashRead ( -- )
	cr cr
	$100 0 do i flash> . loop 
	cr cr
	$1200 $E00 do i flash> . loop 
 ;

: flashWrite ( -- )
 	$AA $80 >flash
	$55 $96 >flash
	$33 $88 >flash
 	flashbuffer $40 0 >>flash
 	flashbuffer $100 $F00 >>flash
 	flashbuffer $100 $1000 >>flash
;

\ flash dump -> include lib-dump.txt
: .flBVAL 2 SPACES $10 0 DO DUP flash> 2# SPACE 1+ LOOP DROP ;	\ printing byte values in hex
: .flAVAL 4 SPACES $10 0 DO DUP flash> .PRINTCHAR 1+ LOOP ;		\ printing only printable ascii values

: flash. ( c-addr cnt -- )
	BASE @ >R HEX					\ save base
	.ADDRHEAD .BHEAD .AHEAD			\ print header
	$10 / 0 DO
		.ADDRESS .flBVAL .flAVAL	\ print byte values
	LOOP 
	R> BASE ! DROP ;				\ restore base


