📄 i993_lcd_avr168.asm
字号:
.include "m168def.inc"
;-------------------------------------------------
;----------------------
.equ TW_START =0x08
.equ TW_REP_START =0x10
;// Master Transmitter
.equ MT_SLA_ACK =0x18
.equ MT_SLA_NACK =0x20
.equ MT_DATA_ACK =0x28
.equ MT_DATA_NACK =0x30
.equ MT_ARB_LOST =0x38
;// Master Receiver
.equ MR_ARB_LOST =0x38
.equ MR_SLA_ACK =0x40
.equ MR_SLA_NACK =0x48
.equ MR_DATA_ACK =0x50
.equ MR_DATA_NACK =0x58
// Slave Transmitter
.equ ST_SLA_ACK =0xA8
.equ ST_ARB_LOST_SLA_ACK =0xB0
.equ ST_DATA_ACK =0xB8
.equ ST_DATA_NACK =0xC0
.equ ST_LAST_DATA =0xC8
;// Slave Receiver
.equ SR_SLA_ACK =0x60
.equ SR_ARB_LOST_SLA_ACK =0x68
.equ SR_GCALL_ACK =0x70
.equ SR_ARB_LOST_GCALL_ACK =0x78
.equ SR_DATA_ACK =0x80
.equ SR_DATA_NACK =0x88
.equ SR_GCALL_DATA_ACK =0x90
.equ SR_GCALL_DATA_NACK =0x98
.equ SR_STOP =0xA0
;// Misc
.equ TW_NO_INFO =0xF8
.equ TW_BUS_ERROR =0x00
// defines and constants
.equ CR_CMD_MASK =0x0F
.equ SR_STATUS_MASK =0xF8
;// return values
.equ I2C_OK =0x00
.equ I2C_ERROR_NODEV =0x01
.equ SLA_W =0b11000000
.equ SLA_R =0b11000001
;------------------------------------------------
;--------------------------------------------------------变量定义
.EQU TEMP =0X0100
.EQU TEMP1 =0X0101
.equ uncode_high =0x0102 ;uncode
.equ uncode_low =0x0103
.equ volregister =0x0104
.equ bcddata1000 =0x0105
.equ bcddata100 =0x0106
.equ bcddata10 =0x0107
.equ bcddata1 =0x0108
.equ playcontrol_status =0x0109
.equ playnumber_high =0x010a
.equ playnumber_low =0x010b
.equ playindex_high =0x010c
.equ playindex_low =0x010d
.equ delaycount =0x010e
.equ delaycount1 =0x010f
.equ delaycount2 =0x0110
;-----------------------------------------------
.equ play_status =0x0111 ;=0 play =1 pause =2 FF =3 REW
.equ dis_wenzi_cunt =0x0112
.equ yidong_register_high =0x0113
.equ yidong_register_low =0x1114
.equ page_count =0x1115
.equ column_count =0x0116
;-------------------------------------------------------------;=0 normal ; 1 =display ;=2 radio
.equ model_status =0x0117
;========================================================= 除法
.equ dividend_3 =0x0118
.equ dividend_2 =0x0119
.equ dividend_1 =0x011a
.equ dividend_0 =0x011b
.equ divisor_3 =0x011c
.equ divisor_2 =0x011d
.equ divisor_1 =0x011e
.equ divisor_0 =0x011f
.equ quotient_3 =0x0120
.equ quotient_2 =0x0121
.equ quotient_1 =0x0122
.equ quotient_0 =0x0123
.equ dianci_level =0x0124
;----------------------------------------------------main_level
.equ main_level =0x0125
;------------------------------------------------------
.equ first_status =0x0126
.equ repeat_status =0x0127
.equ shuffle_status =0x0128
.equ categorytype =0x0129;lei xing ji cheng qi
.equ status_sub =0x012a
.equ categorytypetemp =0x012b
.EQU YUSHU_LO =0X012c
;-------------------------------------------------------
.equ numberrecord_hi_bubian =0x012d
.equ numberrecord_lo_bubian =0x012e
;------------------------------------------------------
.equ dis_leixing =0x012f
.equ display_byte_count =0x0130
.equ shuffle_rigister =0x0131
.equ dissendipodcount_lo =0x0132
.equ dissendipodcount_hi =0x0133
.equ hold_register =0x0134
.equ qiehan3s_status =0x0135
.equ autointo_status =0x0136
.equ autointo_count =0x0137
.equ play_status_temp =0x0138
.equ delay1s_count =0x0139
.equ sendipodcount_hi =0x013a
.equ sendipodcount_lo =0x013b
.equ distype =0x013c
.equ numberrecord_lo =0x013d
.equ numberrecord_hi =0x013e
;===============================================
.equ eepromaddr_hi =0x0140
.equ eepromdata_hi =0x0141
.equ eepromdata_lo =0x0142
.equ qs_register =0x0143
.equ frequency_hi =0x0144
.equ frequency_lo =0x0145
.equ twpll_hi =0x0146
.equ twpll_lo =0x0147
.equ key_time =0x0148
.equ readtime =0x0149
.equ page_register =0x014a
.EQU OFFSET =0X014B
.EQU BYTE_COUNT =0X014C
.equ info_count =0x014d
.equ pause_time =0x014e
.equ ipod_number_no =0x014f
.equ radio_model_sleep =0x0150
;----------------------------------------------------
.equ readdata =0x0160
.equ senddata =0x0167
;=====================================================段寄陈器
.equ readipod_start =0x0200
.equ utf_8data =0x0206
.equ stop_start =0x020e
.equ playnumber_start =0x0206
.equ playindex_start =0x0206
.equ utf8_data_start =0x020a
.equ geming_start =0x0206
.equ back_utf8_data_start =0x030a
.equ back_geming_start =0x0306
.equ read_status_start =0x03a0
;========================================================
;.equ dis_chanr_start =0x0400 ;0x0400-0x0318
;=============================================================
.equ interrupt =0x044f
;-------------------------------------lcd i\o c
.equ LCD_RST = 0 ;portc,1
.equ LCD_CS = 1 ;portc,0
.equ LCD_A0 = 4 ;portc,2 ,SDA RADIO
.equ LCD_SCLK = 5 ;portc,3 ,SCL RADIO
.equ LCD_SID = 3 ;portc,4
.equ sda =4
.equ scl =5
;=================================== i\o B
.equ play_key =3
.equ vol_add_key =2
.equ vol_mius_key =1
.equ next_track_key =4
.equ pre_track_key =0
;---------------------------------------model_ley
.equ mp3_key =2 ;pind,2
.equ dis_key =3 ;pind,3
;============================================== 临时设定
.equ lm48_clk =6 ;portd,0
.equ lm48_updn =7 ;portd,1
.equ mute =5 ;portd
;----------------------------------
.equ led =5 ;portb,led
;*****************************************************
;======================================================
;r8 r9 x register zhobg zhuan
;----------------------------------------------数据 标记
;r11,0=0数据没有转换完,;r11,0=1数据已转换完
;r11,1=0 正常显示,r11,1=1 反白显示,
;r11,2=0 显示 菜单 ,;r11,2=1 显示 设置
;r11,4=0 bu yi dong ;r11,4=1 xu yiao yi dong
;r11,6=0 first dis char,;r11,6=1 before first dis char
;r11,7=0 显示内容不是空; ;r11,7=1 显示内容 是空;
;------------------------------------------ 系统 标记
;r10,0=0 3s延时 时间到 ,r10,0=1 3s延时 时间没有到
;r10,1 临时 用
;r10,2=0 no ying lian + - ;r10,2=1 is ying lian + -
;r10,3=1
;------------------------------------------------------------d04 de
;r10,4=0 没有进入播放状态, r10,4=1 进入播放状态
;r10,5=0 selectdbrecord,r10,5=1 selectdbrecord0
;
;r10,6=0 ,不是最后一级,r10,6=1 ,是最后一级(
;***************************************************************RADIO r10
.EQU save_status =7
.EQU search_status =6
.EQU up_down_model =5
;================================================================
.ORG $0000
rjmp RESET
.ORG $0020
RESET:
; ldi r16,6
; cpi r16,0x07
; brcs jfhjfh
; nop
;jfhjfh:
;-------------------------------
ldi r16,0x00
ldi xl,$00
ldi xh,$01
Init_SRAM1:
ST X+,R16
CPI XL,$5f
BRNE Init_SRAM1
CPI XH, 4
BRNE Init_SRAM1
;-----------------------------------------------------------
LDI R16,low(interrupt)
OUT SPL,R16 ;SP <- $045f
ldi r16,high(interrupt)
out sph,r16
call register_clear
call INITIALIZE
;==========================================================debug]
; ldi r16,5
; sts TCCR1B,r16
; ldi r16,0x00
; sts TCNT1L,r16
; ldi r16,0xff
; sts TCNT1h,r16
;bgfsdfh:
; in r16,TIFR1
; in r16,pind
; rjmp bgfsdfh
;=======================================================debug_end
ldi r16,12
sts eepromaddr_hi,r16
call eeprom_read
lds r16,eepromdata_hi
cpi r16,0x55
brne bandanfirst
rjmp banduansvaeexit
bandanfirst:
ldi r17,10
ldi r19,0
ldi zl,low(yuchuntaitab)
ldi zh,high(yuchuntaitab)
CLC
ROL ZL
ROL ZH
bandanfirstloop:
sts eepromaddr_hi,r19
inc r19
;sts eepromaddr_lo,r19
inc r19
ORI ZL,0B00000001
LPM R16,Z
sts eepromdata_hi,r16
ANDI ZL,0B11111110
lpm r16,z
sts eepromdata_lo,r16
call eeprom_write
adiw zl,2
dec r17
brne bandanfirstloop
banduansvaeexit:
;===============================================
call idendify
call delay_20ms
call play_pause
call delay_100ms
call play_pause
call delay_100ms
call delay_100ms
call delay_100ms
call delay_100ms
call delay_100ms
call delay_100ms
call delay_100ms
readipodnumber:
ldi r16,0
sts ipod_number_no,r16
call getipod_munber
call readipod
lds r16,readipod_start+4
cpi r16,0x0e
brne readipodnumber
lds r16,readipod_start+5
cpi r16,0x00
brne readipodnumber
lds r16,readipod_start+6
cpi r16,0x13
brne readipodnumber_0
rjmp readipodnumber_1
readipodnumber_0:
cpi r16,0x14
brne readipodnumber_exit
readipodnumber_1:
ldi r16,1
sts ipod_number_no,r16
readipodnumber_exit:
call initLCDM
;;=================================================== debug end
;---------------------------------------------------初始 音量
ldi r16,18
sts eepromaddr_hi,r16
rcall eeprom_read
lds r16,eepromdata_hi
sts volregister,r16
;==========================================
ldi r16,0x50
volint:
rcall vol_mius
dec r16
brne volint
lds r16,volregister
cpi r16,0
breq volint_exit
volint_1:
rcall vol_add
dec r16
brne volint_1
volint_exit:
;--------------------------------------------------
sbis pind,dis_key
rjmp RESET_1
;-------------------------------------------------mp3 model
call into_mp3_model
ldi r16,0
sts delay1s_count,r16 ; 清 延时一秒计数寄存器
rjmp main
RESET_1:
call into_lcd_model
ldi r16,0
sts delay1s_count,r16 ; 清 延时一秒计数寄存器
;--------------------------------------------------
main:
;---------------------------------------------- mp3 model
lds r16,model_status
cpi r16,0
brne lcd_dis_model
mp3_model:
call radio_delay
sbic pind,dis_key
rjmp to_key
call delay_1ms
sbic pind,dis_key
rjmp to_key
call into_lcd_model
rjmp main
;=========================================
lcd_dis_model:
sbrs r11,4
rjmp lcd_dis_model_1
call delay1skey
rjmp lcd_dis_model_2
lcd_dis_model_1:
lds r16,dis_leixing
cpi r16,0
brne lcd_dis_model_1_1
call delay_key_500ms
rjmp lcd_dis_model_2
lcd_dis_model_1_1:
call delay3skey
lcd_dis_model_2:
;==============================================lcd display model
main_lcd_display_model:
sbic pind,mp3_key
rjmp main_lcd_display_model_1
call delay_1ms
sbic pind,mp3_key
rjmp main_lcd_display_model_1
call into_mp3_model
rjmp main
main_lcd_display_model_1:
sbis pind,dis_key
rjmp main_lcd_display_model_2
;============================================hold model
main_hold_model:
lds r16,hold_register
cpi r16,1
breq main_lcd_display_model_3
call dis_hold
ldi r16,1
sts hold_register,r16
rjmp main_lcd_display_model_3
main_lcd_display_model_2:
lds r16,hold_register
cpi r16,0
breq main_lcd_display_model_3
call dis_hold_blank
ldi r16,0
sts hold_register,r16
main_lcd_display_model_3:
lds r16,main_level
cpi r16,1
breq to_key ; set model
sbrs r11,2
rjmp main_lcd_display_model_5
call clrarscrren
call dis_first_info
clt
bld r11,2
main_lcd_display_model_5:
sbrs r11,4
rjmp main_2_0
call wenziyidong ; 播放 状态 移动
rjmp to_key
;=======================================================
main_2_0:
call getplaystatus ; 歌曲停止 进入 主画面
call readipod_no_save
lds r16,read_status_start+14
cpi r16,0
brne main_2_no_stop
call reset_program
rjmp main
main_2_no_stop:
sbrs r10,2
call display_content_comom ; 播放状态 显示播放信息
;=====================================按键程序
to_key:
in r16,pind
andi r16,0b00001100
cpi r16,0x0c
brne to_key_1
rjmp main
to_key_1:
call dly
in r16,pinb
andi r16,0x1f
cpi r16,0x1f
brne to_key_2
rjmp main
;========================================防抖
to_key_2:
call delay_1ms
in r16,pinb
andi r16,0x1f
cpi r16,0x1f
brne to_key_3
rjmp main
to_key_3:
ldi r16,0
sts delay1s_count,r16 ; 清 延时一秒计数寄存器
cbi portb,led
to_key_4:
lds r17,model_status
cpi r17,0
brne to_key_5
rjmp radio_model ;to simple mp3 model
to_key_5:
sbic pinb,play_key
rjmp to_key_6
rjmp center_key_program
to_key_6:
sbic pinb,pre_track_key
rjmp to_key_7
rjmp left_key_program
to_key_7:
sbic pinb,vol_mius_key
rjmp to_key_8
rjmp down_key_progrm
to_key_8:
sbic pinb,next_track_key
rjmp up_key_program
rjmp right_key_program
;=========================================== 判断有没有松键
radio_model:
;=====================================按键程序
;==================================================vol_mius
sbic pinb,vol_mius_key
rjmp to_key_9
rjmp downkeyprogram
;================================================vol_add
to_key_9:
sbic pinb,vol_add_key
rjmp to_key_10
rjmp upkeyprogram
;===============================================
to_key_10:
sbis pinb,next_track_key
rjmp remotefrequencyup
sbis pinb,pre_track_key
rjmp remotefrequencydown
sbis pinb,play_key
rjmp qs_tai
rjmp main
;******************************************* key main program
into_lcd_model:
cbi portd,mute
call exit_radio_model
call idendify
call delay_20ms
call play_pause
call delay_100ms
call play_pause
call delay1s
;-------------------------------
ldi r16,1
sts model_status,r16 ;dis_song_name
call register_clear
call in_exmodel
call delay_100ms
ldi r16,5
sts categorytype,r16
ldi r16,0
sts sendipodcount_hi,r16
ldi r16,1
sts sendipodcount_lo,r16
call selectdbrecord
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -