📄 newfanremote.lst
字号:
0216 23 c_key_on_off = 0x02
0218 24 c_key_speed = 0x04
021C 25 c_key_timer = 0x08
+ 26
027C 27 c_nRF24L01_not_use = 0x68
0284 28 c_fecth_IRQ_source == 0x70
0216 29 c_fecth_flag_rx = 0x02
021C 30 c_flag_key_int = 0x08
+ 31
+ 32
+ 33
+ 34
0222 35 c_try_tx_max = 14
+ 36
0223 37 c_max_channel == 15
0222 38 c_fecth_pipe_no == 0x0e
02F4 39 c_fetch_command == 0xe0
0214 40 c_com_normal_key == 0x00
0234 41 c_com_ask == 0x20
0254 42 c_com_answer == 0x40
0274 43 c_com_factory_set == 0x60
02D4 44 c_com_return == 0xc0
+ 45 ;-----------Variables------------------
+ 46 .area main_data(data,abs)
+ 47 .org 0x02 ;0x00,0x01两个byte为ICE保留
+ 48 ;ICE_Reserved: .ds 2
+B 00 01
0002 49 tmp_a: .ds 1
0003 50 tmp_cpusts: .ds 1
0004 51 tmp_tpl:: .ds 1
0005 52 access_code:: .ds 3
0008 53 key_code: .ds 1
+ 54
0009 55 channel_count:: .ds 1
000A 56 try_ctrl: .ds 1
000B 57 command:: .ds 1
+ 58
000C 59 IRQ_source:: .ds 1
000D 60 flag:: .ds 1
+ 61
+ 62
+ 63
+ 64 ;-----------Codes------------------------
+ 65 .area Start_Up(code,abs)
+ 66 .org 0x00
+B 00 02
0000 02 00 20 67 br Reset
+ 68 .org 0x06 ;Timer0
0006 25 69 reti
+ 70 .org 0x09 ;External pin
0009 02 00 DE 71 br Ex_Int_Judge
+ 72 .org 0x0f ;Timer1
000F 25 73 reti
+ 74 ;--------------------------------------
+ 75 .area Main_Code(code,abs)
+ 76
+ 77 .org 0x20 ;0x00~0x14是IC保留的程序区
+B 00 03
0020 78 Reset:
0020 F3 2F 79 lda #2fh ;将堆栈指针指向RAM最后一个字节
0022 FC 18 80 sta sp
+ 81
0024 20 01 8D 82 call Clear_RAM
0027 20 01 A0 83 call Initialization
002A 20 05 8C 84 call eep_init_check
+ 85
+ 86 ;lda #0
+ 87 ;sta access_code
+ 88 ;sta access_code+1
+ 89 ;lda #0x22
+ 90 ;sta access_code+2
+ 91 ;call eep_save_data
+ 92
002D 20 02 82 93 call nRF24L01_Configuration ;将发送,接收控制参数写入nRF24L01
+ 94 ;---------06-07-22------------------------------------
+ 95 ;move the "Compare Access Code" and "Return Access Code" here
+ 96 ;if you want to perform these actions,you should push the combo buttons
+ 97 ;and then power-on(betteries).
0030 20 01 BD 98 call Scankey
0033 F1 08 99 lda key_code
0035 A7 0A 100 cmpe #c_key_on_off|c_key_timer
0037 06 00 9B 101 brz Press_Compare_Access_Code
003A A7 06 102 cmpe #c_key_on_off|c_key_speed
003C 06 00 C4 103 brz Press_Return_Access_Code
+ 104 ;---------------------------------------------
003F 20 03 04 105 call Power_Down ;nRF24L01 power down
0042 106 Sleep_Mode:
0042 F3 FF 107 lda #c_port_input_ctrl ;将porta改为输入是为了防止在睡眠状态中漏电
0044 FC 58 108 sta pdira
+ 109
0046 F3 1E 110 lda #c_ext_int_enable ;睡眠之前,允许PC0,PB[3:1]中断,以便唤醒
0048 FC 84 111 sta prtie
+ 112
004A F0 14 113 lda modcon
004C DB 80 114 ora #c_sleep_ctrl
004E FC 14 115 sta modcon
0050 00 116 nop
0051 00 117 nop
0052 00 118 nop
+ 119
0053 F1 0D 120 lda flag ;判断是否是按键中断
0055 CB 08 121 anda #c_flag_key_int ;IRQ中断是在中断服务程序中处理的
0057 06 00 42 122 brz Sleep_Mode
+ 123
005A F0 84 124 lda prtie ;关PB[3:1]中断,避免中断对扫键的影响
005C CB F1 125 anda #~c_all_key_high
005E FC 84 126 sta prtie
+ 127
0060 128 clearbit(flag,f_key_int)
0066 20 01 BD 129 call Scankey
0069 F1 08 130 lda key_code
006B A7 02 131 cmpe #c_key_on_off
006D 06 00 7D 132 brz Press_One_Key_Handle
0070 A7 04 133 cmpe #c_key_speed
0072 06 00 7D 134 brz Press_One_Key_Handle
0075 A7 08 135 cmpe #c_key_timer
0077 06 00 7D 136 brz Press_One_Key_Handle
+ 137 ;cmpe #c_key_speed|c_key_timer|c_key_on_off
+ 138 ;brz Press_Compare_Access_Code
+ 139 ;cmpe #c_key_on_off|c_key_speed
+ 140 ;brz Press_Return_Access_Code
007A 02 00 42 141 br Sleep_Mode
+ 142
+ 143 ;----------------------------------------------
007D 144 Press_One_Key_Handle: ;如果是单个键按下,将单个按键键值发给控制板
007D F3 81 145 lda #c_porta_dir_ctrl
007F FC 58 146 sta pdira
+ 147
0081 20 02 E6 148 call Power_UP_Tx
0084 20 05 01 149 call Flush_Tx_FIFO
+ 150 ;call Delay_10ms
+ 151 ;call Delay_2ms
+ 152
0087 F3 00 153 lda #0
0089 FD 0A 154 sta try_ctrl
+ 155
008B F1 08 156 lda key_code
008D 8B 00 157 adda #0
008F 7F 158 rorc
0090 FD 0B 159 sta command
+ 160 ; call Write_TX_Payload
0092 20 03 43 161 call Write_Command
+ 162
+ 163 ;call Delay_5us
+ 164
0095 20 04 EE 165 call CE_Pulse
0098 02 00 42 166 br Sleep_Mode
+ 167 ;-------------------------------------------
009B 168 Press_Compare_Access_Code: ;请求对码的组合键按下,发请求对码命令给writer
009B F3 81 169 lda #c_porta_dir_ctrl
009D FC 58 170 sta pdira
+ 171
009F 20 02 E6 172 call Power_UP_Tx
00A2 20 05 01 173 call Flush_Tx_FIFO
+ 174 ;将发送地址和接收地址改为与writer通信地址
00A5 20 03 5E 175 call Write_tx_addr_writer
00A8 F3 20 176 lda #c_com_ask
00AA FD 0B 177 sta command
00AC 20 03 13 178 call Write_TX_Payload
00AF 20 04 EE 179 call CE_Pulse
00B2 20 02 63 180 call Delay_100ms ;等待中断处理完毕
00B5 181 clearbit(plata,CE)
00BB 20 03 DF 182 call Write_tx_addr_Fan ;将发送地址和接收地址改回与Fan通信地址
00BE 20 03 04 183 call Power_Down
00C1 02 00 42 184 br Sleep_Mode
+ 185 ;-------------------------------------------
00C4 186 Press_Return_Access_Code: ;返回对码值的组合键按下,将接入码发给writer
00C4 F3 81 187 lda #c_porta_dir_ctrl
00C6 FC 58 188 sta pdira
+ 189
00C8 20 02 E6 190 call Power_UP_Tx
00CB 20 05 01 191 call Flush_Tx_FIFO
00CE 20 03 5E 192 call Write_tx_addr_writer
00D1 F3 C0 193 lda #c_com_return
00D3 FD 0B 194 sta command
00D5 20 03 13 195 call Write_TX_Payload
00D8 20 04 EE 196 call CE_Pulse
00DB 02 00 42 197 br Sleep_Mode
+ 198 ;====================================================
+ 199
+ 200
+ 201
+ 202 ;********************************************
+ 203 ; Function: External pin interrupt ISR
+ 204 ; Description:
+ 205 ; Judge it is a IRQ interrupt or a portb key pressed
+ 206 ; Interrupt
+ 207 ; If it is a IRQ interrupt, record the stautus register
+ 208 ; of nRF24L01 in'IRQ_source'and clear IRQ flags
+ 209 ; If it is a portb key pressed interrupt,quit directly
+ 210 ;*******************************************
00DE 211 Ex_Int_Judge:
00DE FD 02 212 sta tmp_a
00E0 F0 12 213 lda cpusts
00E2 FD 03 214 sta tmp_cpusts
00E4 F0 88 215 lda prtif
00E6 CB 10 216 anda #c_irq_int ;判断是否是IRQ中断
00E8 07 00 FA 217 brnz IRQ_ISR
00EB 218 Key_Pressed:
00EB F0 88 219 lda prtif
00ED CB F1 220 anda #~c_all_key_high
00EF FC 88 221 sta prtif
00F1 222 setbit(flag,f_key_int)
00F7 02 01 86 223 br Quit_Ex_Int
+ 224
00FA 225 IRQ_ISR:
00FA F3 81 226 lda #c_porta_dir_ctrl
00FC FC 58 227 sta pdira
00FE 00 228 nop
00FF 00 229 nop
+ 230
0100 F0 88 231 lda prtif
0102 CB EF 232 anda #~c_irq_int
0104 FC 88 233 sta prtif
+ 234
0106 235 clearbit(plata,CSN) ;读出nRF24L01的status register将其内容放在IRQ_source并清掉中断标志
010C F3 27 236 lda #WRITE_REG+#STATUS
010E FD 10 237 sta byte
0110 20 04 A5 238 call SPI_RW
0113 F1 10 239 lda byte
0115 FD 0C 240 sta IRQ_source
0117 F3 70 241 lda #0x70 ;为了将IRQ引脚置高,必须将Status寄存器中的中断标志位清掉,
0119 FD 10 242 sta byte ;以允许产生下一次IRQ中断(IRQ引脚平时为高,中断产生时置低)
011B 20 04 A5 243 call SPI_RW ;详细说明见G:\资料\美的项目\2006-05-04 MD fan information\2006-05-04 MD fan information\
011E 244 setbit(plata,CSN) ;RF\Nordic RF24L01 information Page14
+ 245
+ 246
+ 247 ;lda #STATUS
+ 248 ;sta reg_name
+ 249 ;call SPI_Read_Reg
+ 250 ;lda reg_value
+ 251 ;sta IRQ_source
+ 252
0124 253 IRQ_INT_Handle:
0124 F1 0C 254 lda IRQ_source
0126 CB 70 255 anda #c_fecth_IRQ_source
0128 A7 20 256 cmpe #TX_DS ;发送到?
012A 06 01 3A 257 brz IRQ_Tx_DS
012D A7 10 258 cmpe #MAX_RT ;未发到?
012F 06 01 57 259 brz IRQ_MAX_RT
0132 A7 40 260 cmpe #RX_DR ;接收到?
0134 06 01 73 261 brz IRQ_RX_DR
0137 02 01 86 262 br Quit_Ex_Int
+ 263 ;-------------------------------------------
013A 264 IRQ_TX_DS:
+ 265
+ 266
+ 267 ;lda #WRITE_REG+#STATUS
+ 268 ;sta reg_name
+ 269 ;lda #TX_DS
+ 270 ;sta reg_value
+ 271 ;call SPI_RW_Reg
+ 272
013A F1 0B 273 lda command
013C CB E0 274 anda #c_fetch_command
+ 275 ;cmpe #c_com_normal_key
013E 06 01 83 276 brz RF_Power_Down ;单个按键的命令发送到,直接将RF模块关掉
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -