📄 uimgr.lst
字号:
1 .file "UIMgr.c"
2 .arch atmega128
3 __SREG__ = 0x3f
4 __SP_H__ = 0x3e
5 __SP_L__ = 0x3d
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
11 .text
12 .Ltext0:
72 .lcomm charCount,1
73 .lcomm charIndex,1
74 .lcomm tokenCount,1
75 .data
78 receivedCmd:
79 0000 05 .byte 5
82 AVRcamVersion:
83 0001 4156 5263 .string "AVRcam v1.4\r"
83 616D 2076
83 312E 340D
83 00
84 .global UIMgr_rxFifoHead
85 .global UIMgr_rxFifoHead
86 .section .bss
89 UIMgr_rxFifoHead:
90 0000 00 .skip 1,0
91 .global UIMgr_rxFifoTail
92 .global UIMgr_rxFifoTail
95 UIMgr_rxFifoTail:
96 0001 00 .skip 1,0
97 .global UIMgr_txFifoHead
98 .global UIMgr_txFifoHead
101 UIMgr_txFifoHead:
102 0002 00 .skip 1,0
103 .global UIMgr_txFifoTail
104 .global UIMgr_txFifoTail
107 UIMgr_txFifoTail:
108 0003 00 .skip 1,0
109 .text
111 .global UIMgr_init
113 UIMgr_init:
1:UIMgr.c **** /***********************************************************
2:UIMgr.c **** Module Name: UIMgr.c
3:UIMgr.c **** Module Date: 04/10/2004
4:UIMgr.c **** Module Auth: John Orlando
5:UIMgr.c ****
6:UIMgr.c **** Description: This module is responsible for providing
7:UIMgr.c **** the processing to manage the user interface of the
8:UIMgr.c **** system. This user interface is provided via the UART.
9:UIMgr.c **** This module handles the incoming serial commands, and
10:UIMgr.c **** performs the needed functionality. It is then
11:UIMgr.c **** responsible for generating any needed response to
12:UIMgr.c **** the external entity.
13:UIMgr.c ****
14:UIMgr.c ****
15:UIMgr.c **** ***********************************************************/
16:UIMgr.c ****
17:UIMgr.c **** /* Includes */
18:UIMgr.c **** #include <avr/io.h>
19:UIMgr.c **** #include <stdlib.h>
20:UIMgr.c **** #include <string.h>
21:UIMgr.c **** #include <avr/eeprom.h>
22:UIMgr.c **** #include "CommonDefs.h"
23:UIMgr.c **** #include "UIMgr.h"
24:UIMgr.c **** #include "UartInterface.h"
25:UIMgr.c **** #include "CamConfig.h"
26:UIMgr.c **** #include "Utility.h"
27:UIMgr.c **** #include "Executive.h"
28:UIMgr.c **** #include "CamInterface.h"
29:UIMgr.c ****
30:UIMgr.c **** /* Local Structures and Typedefs */
31:UIMgr.c ****
32:UIMgr.c **** typedef enum
33:UIMgr.c **** {
34:UIMgr.c **** getVersionCmd,
35:UIMgr.c **** pingCmd,
36:UIMgr.c **** setCameraRegsCmd,
37:UIMgr.c **** dumpFrameCmd,
38:UIMgr.c **** resetCameraCmd,
39:UIMgr.c **** noCmd,
40:UIMgr.c **** invalidCmd
41:UIMgr.c **** } UIMgr_Cmd_t;
42:UIMgr.c ****
43:UIMgr.c ****
44:UIMgr.c ****
45:UIMgr.c **** /* Local Variables */
46:UIMgr.c **** static unsigned char charCount = 0;
47:UIMgr.c **** static unsigned char charIndex = 0;
48:UIMgr.c **** static unsigned char asciiTokenBuffer[MAX_TOKEN_LENGTH+1]; /* +1 to ensure NULL at end =3*/
49:UIMgr.c **** static unsigned char tokenCount = 0;
50:UIMgr.c **** static unsigned char tokenBuffer[MAX_TOKEN_COUNT];
51:UIMgr.c **** static UIMgr_Cmd_t receivedCmd = noCmd;
52:UIMgr.c **** static unsigned char AVRcamVersion[] = "AVRcam v1.4\r";
53:UIMgr.c ****
54:UIMgr.c **** /* Local Function Declaration */
55:UIMgr.c **** static unsigned char UIMgr_readRxFifo(void);
56:UIMgr.c **** static unsigned char UIMgr_readTxFifo(void);
57:UIMgr.c **** static unsigned char UIMgr_readRxFifo(void);
58:UIMgr.c **** static void UIMgr_sendNck(void);
59:UIMgr.c **** static void UIMgr_sendAck(void);
60:UIMgr.c **** static void UIMgr_convertTokenToCmd(void);
61:UIMgr.c **** static void UIMgr_convertTokenToValue(void);
62:UIMgr.c **** static void UIMgr_executeCmd(void);
63:UIMgr.c ****
64:UIMgr.c **** /* Extern Variables */
65:UIMgr.c **** unsigned char UIMgr_rxFifo[UI_MGR_RX_FIFO_SIZE];
66:UIMgr.c **** unsigned char UIMgr_rxFifoHead=0;
67:UIMgr.c **** unsigned char UIMgr_rxFifoTail=0;
68:UIMgr.c ****
69:UIMgr.c **** unsigned char UIMgr_txFifo[UI_MGR_TX_FIFO_SIZE];
70:UIMgr.c **** unsigned char UIMgr_txFifoHead=0;
71:UIMgr.c **** unsigned char UIMgr_txFifoTail=0;
72:UIMgr.c ****
73:UIMgr.c **** /* Definitions */
74:UIMgr.c **** #define IS_DATA_IN_TX_FIFO() (!(UIMgr_txFifoHead == UIMgr_txFifoTail))
75:UIMgr.c **** #define IS_DATA_IN_RX_FIFO() (!(UIMgr_rxFifoHead == UIMgr_rxFifoTail))
76:UIMgr.c ****
77:UIMgr.c **** /* MAX_EEPROM_WRITE_ATTEMPTS limits the number of writes that can be
78:UIMgr.c **** done to a particular EEPROM cell, so that it can't possible just
79:UIMgr.c **** write to the same cell over and over */
80:UIMgr.c **** #define MAX_EEPROM_WRITE_ATTEMPTS 3
81:UIMgr.c ****
82:UIMgr.c **** /***********************************************************
83:UIMgr.c **** Function Name: UIMgr_init
84:UIMgr.c **** Function Description: This function is responsible for
85:UIMgr.c **** initializing the UIMgr module. It sets up the fifo
86:UIMgr.c **** used to hold incoming data, etc.
87:UIMgr.c **** Inputs: none
88:UIMgr.c **** Outputs: none
89:UIMgr.c **** ***********************************************************/
90:UIMgr.c **** void UIMgr_init(void)
91:UIMgr.c **** {
115 .LM1:
116 /* prologue: frame size=0 */
117 /* prologue end (size=0) */
92:UIMgr.c **** memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH+1);
119 .LM2:
120 0000 1092 0000 sts asciiTokenBuffer,__zero_reg__
121 0004 1092 0000 sts (asciiTokenBuffer)+1,__zero_reg__
122 0008 1092 0000 sts (asciiTokenBuffer)+2,__zero_reg__
123 000c 1092 0000 sts (asciiTokenBuffer)+3,__zero_reg__
93:UIMgr.c **** memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
125 .LM3:
126 0010 80E4 ldi r24,lo8(64)
127 0012 E0E0 ldi r30,lo8(tokenBuffer)
128 0014 F0E0 ldi r31,hi8(tokenBuffer)
129 0016 982F mov r25,r24
130 0018 1192 st Z+,__zero_reg__
131 001a 9A95 dec r25
132 001c E9F7 brne .-6
94:UIMgr.c **** memset(UIMgr_txFifo,0x00,UI_MGR_TX_FIFO_SIZE);
134 .LM4:
135 001e E0E0 ldi r30,lo8(UIMgr_txFifo)
136 0020 F0E0 ldi r31,hi8(UIMgr_txFifo)
137 0022 1192 st Z+,__zero_reg__
138 0024 8A95 dec r24
139 0026 E9F7 brne .-6
95:UIMgr.c **** memset(UIMgr_rxFifo,0x00,UI_MGR_RX_FIFO_SIZE);
141 .LM5:
142 0028 80E2 ldi r24,lo8(32)
143 002a E0E0 ldi r30,lo8(UIMgr_rxFifo)
144 002c F0E0 ldi r31,hi8(UIMgr_rxFifo)
145 002e 1192 st Z+,__zero_reg__
146 0030 8A95 dec r24
147 0032 E9F7 brne .-6
148 /* epilogue: frame size=0 */
149 0034 0895 ret
150 /* epilogue end (size=1) */
151 /* function UIMgr_init size 27 (26) */
153 .Lscope0:
156 .global UIMgr_dispatchEvent
158 UIMgr_dispatchEvent:
96:UIMgr.c **** }
97:UIMgr.c ****
98:UIMgr.c **** /***********************************************************
99:UIMgr.c **** Function Name: UIMgr_dispatchEvent
100:UIMgr.c **** Function Description: This function is responsible for
101:UIMgr.c **** processing events that pertain to the UIMgr.
102:UIMgr.c **** Inputs: event - the generated event
103:UIMgr.c **** Outputs: none
104:UIMgr.c **** ***********************************************************/
105:UIMgr.c **** void UIMgr_dispatchEvent(unsigned char event)
106:UIMgr.c **** {
160 .LM6:
161 /* prologue: frame size=0 */
162 /* prologue end (size=0) */
107:UIMgr.c **** switch(event)
164 .LM7:
165 0036 9927 clr r25
166 0038 8130 cpi r24,1
167 003a 9105 cpc r25,__zero_reg__
168 003c 21F0 breq .L4
170 .LM8:
171 003e 8039 cpi r24,144
172 0040 9105 cpc r25,__zero_reg__
173 0042 21F0 breq .L5
174 0044 0895 ret
175 .L4:
108:UIMgr.c **** {
109:UIMgr.c ****
110:UIMgr.c **** case EV_SERIAL_DATA_RECEIVED: //first reach here
111:UIMgr.c ****
112:UIMgr.c **** UIMgr_processReceivedData();
177 .LM9:
178 0046 0E94 0000 call UIMgr_processReceivedData
113:UIMgr.c **** break;
180 .LM10:
181 004a 0895 ret
182 .L5:
114:UIMgr.c ****
115:UIMgr.c **** case EV_SERIAL_DATA_PENDING_TX:
116:UIMgr.c **** UIMgr_flushTxBuffer();
184 .LM11:
185 004c 0E94 0000 call UIMgr_flushTxBuffer
186 0050 0895 ret
187 /* epilogue: frame size=0 */
188 0052 0895 ret
189 /* epilogue end (size=1) */
190 /* function UIMgr_dispatchEvent size 15 (14) */
192 .Lscope1:
194 .global UIMgr_transmitPendingData
196 UIMgr_transmitPendingData:
117:UIMgr.c **** break;
118:UIMgr.c **** }
119:UIMgr.c **** }
120:UIMgr.c **** /***********************************************************
121:UIMgr.c **** Function Name: UIMgr_transmitPendingData
122:UIMgr.c **** Function Description: This function is responsible for
123:UIMgr.c **** transmitting a single byte of data if data is waiting
124:UIMgr.c **** to be sent. Otherwise, if nothing is waiting, the
125:UIMgr.c **** function just returns.
126:UIMgr.c **** Inputs: none
127:UIMgr.c **** Outputs: none
128:UIMgr.c **** ***********************************************************/
129:UIMgr.c **** void UIMgr_transmitPendingData(void)
130:UIMgr.c **** {
198 .LM12:
199 /* prologue: frame size=0 */
200 /* prologue end (size=0) */
131:UIMgr.c **** if (IS_DATA_IN_TX_FIFO() == TRUE)
202 .LM13:
203 0054 9091 0000 lds r25,UIMgr_txFifoHead
204 0058 8091 0000 lds r24,UIMgr_txFifoTail
205 005c 9817 cp r25,r24
206 005e 21F0 breq .L6
132:UIMgr.c **** {
133:UIMgr.c **** /* data is waiting...send a single byte */
134:UIMgr.c **** UartInt_txByte( UIMgr_readTxFifo() );
208 .LM14:
209 0060 0E94 0000 call UIMgr_readTxFifo
210 0064 0E94 0000 call UartInt_txByte
211 .L6:
212 0068 0895 ret
213 /* epilogue: frame size=0 */
214 006a 0895 ret
215 /* epilogue end (size=1) */
216 /* function UIMgr_transmitPendingData size 12 (11) */
218 .Lscope2:
220 .global UIMgr_processReceivedData
222 UIMgr_processReceivedData:
135:UIMgr.c **** }
136:UIMgr.c **** }
137:UIMgr.c **** /***********************************************************
138:UIMgr.c **** Function Name: UIMgr_processReceivedData
139:UIMgr.c **** Function Description: This function is responsible for
140:UIMgr.c **** parsing any serial data waiting in the rx fifo
141:UIMgr.c **** Inputs: none
142:UIMgr.c **** Outputs: none
143:UIMgr.c **** ***********************************************************/
144:UIMgr.c **** void UIMgr_processReceivedData(void)
145:UIMgr.c **** {
224 .LM15:
225 /* prologue: frame size=0 */
226 006c CF93 push r28
227 /* prologue end (size=1) */
146:UIMgr.c **** unsigned char tmpData = 0;
147:UIMgr.c ****
148:UIMgr.c **** /* still need to add a mechanism to handle token counts
149:UIMgr.c **** that are excessive!!! FIX ME!!! */
150:UIMgr.c ****
151:UIMgr.c **** while(IS_DATA_IN_RX_FIFO() == TRUE)
152:UIMgr.c **** {
153:UIMgr.c **** tmpData = UIMgr_readRxFifo();
154:UIMgr.c **** if (tmpData == '\r')
155:UIMgr.c **** {
156:UIMgr.c **** /* we have reached a token separator */
157:UIMgr.c **** if (tokenCount == 0)
158:UIMgr.c **** {
159:UIMgr.c **** /* convert the command */
160:UIMgr.c **** UIMgr_convertTokenToCmd();
161:UIMgr.c **** }
162:UIMgr.c **** else
163:UIMgr.c **** {
164:UIMgr.c **** /* convert a value */
165:UIMgr.c **** UIMgr_convertTokenToValue();
166:UIMgr.c **** tokenCount++;
167:UIMgr.c **** }
168:UIMgr.c **** /* either way, it is time to try to process the received
169:UIMgr.c **** token list since we have reached the end of the cmd. */
170:UIMgr.c **** Utility_delay(100);
171:UIMgr.c **** if (receivedCmd == invalidCmd ||
172:UIMgr.c **** receivedCmd == noCmd )
173:UIMgr.c **** {
174:UIMgr.c **** UIMgr_sendNck();
175:UIMgr.c **** PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);//Exec_writeEventFifo(event)
176:UIMgr.c **** }
177:UIMgr.c **** else
178:UIMgr.c **** {
179:UIMgr.c **** UIMgr_sendAck();
180:UIMgr.c **** /* publish the serial data pending event, so it
181:UIMgr.c **** will push the ACK out before we execute the cmd */
182:UIMgr.c **** PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);
183:UIMgr.c **** UIMgr_executeCmd();
184:UIMgr.c **** }
185:UIMgr.c ****
186:UIMgr.c **** /* reset any necessary data */
187:UIMgr.c **** tokenCount = 0;
188:UIMgr.c **** memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
189:UIMgr.c **** }
190:UIMgr.c **** else if (tmpData == ' ') /* space char */
191:UIMgr.c **** {
192:UIMgr.c **** /* the end of a token has been reached */
193:UIMgr.c **** if (tokenCount == 0)
194:UIMgr.c **** {
195:UIMgr.c **** UIMgr_convertTokenToCmd();
196:UIMgr.c **** tokenCount++; /* check this...why is this being incremented here??? This
197:UIMgr.c **** means we have received a token, with tokenCount == 0, which means it is a
198:UIMgr.c **** command...why is this contributing to tokenCount?
199:UIMgr.c **** This might cause the set color map command to include too much data, since
200:UIMgr.c **** it sets the color map based on tokenCount...CHECK*/
201:UIMgr.c **** }
202:UIMgr.c **** else
203:UIMgr.c **** {
204:UIMgr.c **** /* check to see if this token is going to push
205:UIMgr.c **** us over the limit...if so, abort the transaction */
206:UIMgr.c **** if (tokenCount+1 >= MAX_TOKEN_COUNT)//=64
207:UIMgr.c **** {
208:UIMgr.c **** /* we received too many tokens, and
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -