;********************************************************************* ; Flash Power Off ; setzt Depp Power Down Mode des Flash ; Scratch-Reg: - ;********************************************************************* flash_power_off: cbi FLASH_PORT,FLASH_CS ; Flash aktiv ldi TEMP_0,0xB9 ; Deep Power Down rcall flash_read_byte ; Kommando senden sbi FLASH_PORT,FLASH_CS ; Flash inaktiv ret ;********************************************************************* ; Flash Power On ; setzt Stand By des Flash ; Scratch-Reg: - ;********************************************************************* flash_power_on: push TEMP_0 cbi FLASH_PORT,FLASH_CS ; Flash aktiv ldi TEMP_0,0xAB ; Power Resume rcall flash_read_byte ; Kommando senden sbi FLASH_PORT,FLASH_CS ; Flash inaktiv ldi TEMP_0,250 flash_power_up_loop: ; Wartezeit > 35µs dec TEMP_0 brne flash_power_up_loop ; 3 Zyklen pro Durchlauf pop TEMP_0 ret ;********************************************************************* ; Flash Read ID ; Holt Manufakturer und DeviceID ; Scratch-Reg: - ;********************************************************************* flash_read_id: cbi FLASH_PORT,FLASH_CS ; Flash aktiv ldi TEMP_0,0x9F ; Kommando rcall flash_read_byte ; Kommando senden ser TEMP_0 rcall flash_read_byte ; Manufakturer sts FLASH_MAN,TEMP_0 rcall flash_read_byte ; DeviceID sts FLASH_DEV,TEMP_0 rcall flash_read_byte ; DeviceID sts FLASH_DEV+1,TEMP_0 rcall flash_read_byte ; 0x00 sbi FLASH_PORT,FLASH_CS ; Flash inaktiv ret ;********************************************************************* ; Flash Security ; Holt Security Byte des Flash ; Scratch-Reg: - ;********************************************************************* flash_read_security: cbi FLASH_PORT,FLASH_CS ; Flash aktiv ldi TEMP_0,0x77 ; Kommando rcall flash_read_byte ; Kommando senden ser TEMP_0 rcall flash_read_byte ; 3 Dummy-Bytes rcall flash_read_byte rcall flash_read_byte ldi TEMP_1,8 flash_read_security_loop_0: push TEMP_1 ldi TEMP_1,16 ; Anzahl Bytes flash_read_security_loop_1: rcall flash_read_byte dec TEMP_1 brne flash_read_security_loop_1 pop TEMP_1 dec TEMP_1 brne flash_read_security_loop_0 sbi FLASH_PORT,FLASH_CS ; Flash inaktiv ret ;********************************************************************* ; Flash Read Status ; Holt Status Byte und wartet auf Ready des Flash ; Scratch-Reg: - ;********************************************************************* flash_read_status: cbi FLASH_PORT,FLASH_CS ; Flash aktiv ldi TEMP_0,0xD7 ; Kommando rcall flash_read_byte ; Kommando senden flash_read_status_loop: rcall flash_read_byte sbrs TEMP_0,7 ; Busy rjmp flash_read_status_loop sbi FLASH_PORT,FLASH_CS ; Flash inaktiv ret ;********************************************************************* ; Flash Read Byte ; Sendet Byte aus TEMP_0 und liest Byte nach TEMP_0 ; Scratch-Reg: - ;********************************************************************* flash_read_byte: out SPDR,TEMP_0 ; Daten raus flash_read_byte_loop: in TEMP_0,SPSR sbrs TEMP_0,SPIF ; SPI fertig? CLK/2, bei 8Bit also 16 Cyclen rjmp flash_read_byte_loop ; nein, warten in TEMP_0,SPDR ; Byte holen ret ;*********************************************************************