|
write_buffer1_current_page: ;пишу в буфер
push temporary1
rcall set_actual_CS_zerowrite_buffer1_current_page_:
sbis pind,FLASH_operation_ready ;читаю ногу "бизи"
rjmp write_buffer1_current_page_ldi temporary1,buffer_1_write_command
rcall out_byte_to_SPIldi temporary1,0
rcall out_byte_to_SPIlds temporary1,flash_execution_addr_h
andi temporary1,0b00000011
rcall out_byte_to_SPIlds temporary1,flash_execution_addr_l
rcall out_byte_to_SPIpop temporary1 ;тут данные для записи
rcall out_byte_to_SPIrjmp exit_flash_cs_to_one :вываливаюсь, и ЦС=1
move_buffer1_to_current_page: ;шлём буффер в страницу
rcall set_actual_CS_zeromove_buffer1_to_current_page_:
sbis pind,FLASH_operation_ready ; ждём готовности - читаем бизи
rjmp move_buffer1_to_current_page_ldi temporary1,buffer_1_stor_eras_command
rcall out_byte_to_SPIlds temporary1,flash_execution_page_h ; там лежит №страницы
lds temporary2,flash_execution_page_lmove_to_current_page:
rol temporary2
rol temporary1
rol temporary2
rol temporary1
andi temporary2,0b11111100
rcall out_byte_to_SPI
mov temporary1,temporary2
rcall out_byte_to_SPI
ldi temporary1,0
rcall out_byte_to_SPI
rjmp exit_flash_cs_to_one ;сваливаем отсюдаmove_current_page_to_buffer1: ; читаем текущую стр. в буфер
rcall set_actual_CS_zeromove_current_page_to_buffer1_:
sbis pind,FLASH_operation_ready
rjmp move_current_page_to_buffer1_ldi temporary1,mem_to_buffer_1_load_command
rcall out_byte_to_SPIlds temporary1,flash_execution_page_h ;тут №стр.
lds temporary2,flash_execution_page_landi temporary1,0b00011111
rol temporary2
rol temporary1
rol temporary2
rol temporary1
andi temporary2,0b11111100rcall out_byte_to_SPI
mov temporary1,temporary2
rcall out_byte_to_SPI
ldi temporary1,0
rcall out_byte_to_SPIexit_flash_cs_to_one:
in temporary2,portb ;так мы сваливаем отсюда,
ori temporary2,0b00011100
out portb,temporary2ret ;данные в буфере будут через некоторое время, см. внизу
send_channel_to_host:
ldi temporary2,128
sub checksumm_reg,checksumm_regrcall set_actual_CS_zero
send_channel_to_host_:
sbis pind,FLASH_operation_ready
rjmp send_channel_to_host_ldi temporary1,buffer_1_read_command ;данные в буфере!!
rcall out_byte_to_SPIldi temporary1,0
rcall out_byte_to_SPIlds temporary1,externl_addr_in_buff1_h
andi temporary1,0b00000011
rcall out_byte_to_SPIldi temporary1,0
rcall out_byte_to_SPIldi temporary1,0
rcall out_byte_to_SPIsend_next_data_to_host:
ldi temporary1,0
rcall out_byte_to_SPIin temporary1,spdr
mov source_dat_L,temporary1 ; тут начинается моя песня, к сабжу нет отн.ldi temporary1,0
rcall out_byte_to_SPIin temporary1,spdr
mov source_dat_H,temporary1push temporary2
rcall expand_hex_to_decrcall send_expanded_data_to_host
pop temporary2dec temporary2
brne send_next_data_to_hostmov temporary1,checksumm_reg
neg temporary1
rcall send_byte_as_charsrjmp exit_flash_cs_to_one
E-mail: info@telesys.ru