📄 owicrc.lst
字号:
##############################################################################
# #
# IAR Atmel AVR C/EC++ Compiler V3.20A/W32 19/Aug/2004 15:43:30 #
# Copyright 1996-2004 IAR Systems. All rights reserved. #
# #
# Source file = Z:\qvcs\AVR318 Dallas 1-wire Communication #
# Interface\Source Code\IAR\common_files\OWIcrc.c #
# Command line = --cpu=m32 -ms -o "Z:\qvcs\AVR318 Dallas 1-wire #
# Communication Interface\Source #
# Code\IAR\polled\Debug\Obj\" -lC "Z:\qvcs\AVR318 Dallas #
# 1-wire Communication Interface\Source #
# Code\IAR\polled\Debug\List\" -lA "Z:\qvcs\AVR318 #
# Dallas 1-wire Communication Interface\Source #
# Code\IAR\polled\Debug\List\" --initializers_in_flash #
# --root_variables -z2 --no_cse --no_inline #
# --no_code_motion --no_cross_call --no_clustering #
# --debug -DENABLE_BIT_DEFINITIONS -e -I "C:\Program #
# Files\IAR Systems\Embedded Workbench 3.2\avr\INC\" -I #
# "C:\Program Files\IAR Systems\Embedded Workbench #
# 3.2\avr\INC\CLIB\" --eeprom_size 1024 "Z:\qvcs\AVR318 #
# Dallas 1-wire Communication Interface\Source #
# Code\IAR\common_files\OWIcrc.c" #
# List file = Z:\qvcs\AVR318 Dallas 1-wire Communication #
# Interface\Source Code\IAR\polled\Debug\List\OWIcrc.lst #
# Object file = Z:\qvcs\AVR318 Dallas 1-wire Communication #
# Interface\Source Code\IAR\polled\Debug\Obj\OWIcrc.r90 #
# #
# #
##############################################################################
Z:\qvcs\AVR318 Dallas 1-wire Communication Interface\Source Code\IAR\common_files\OWIcrc.c
1 // This file has been prepared for Doxygen automatic documentation generation.
2 /*! \file ********************************************************************
3 *
4 * Atmel Corporation
5 *
6 * \li File: OWIcrc.c
7 * \li Compiler: IAR EWAAVR 3.20a
8 * \li Support mail: avr@atmel.com
9 *
10 * \li Supported devices: All AVRs.
11 *
12 * \li Application Note: AVR318 - Dallas 1-Wire(R) master.
13 *
14 *
15 * \li Description: CRC algorithms typically used in a 1-Wire(R)
16 * environment.
17 *
18 * $Revision: 1.6 $
19 * $Date: Thursday, August 19, 2004 09:02:00 UTC $
20 ****************************************************************************/
21
22 #include "OWIcrc.h"
23 #include "OWIdefs.h"
24
25
26 /*! \brief Compute the CRC8 value of a data set.
27 *
28 * This function will compute the CRC8 or DOW-CRC of inData using seed
29 * as inital value for the CRC.
30 *
31 * \param inData One byte of data to compute CRC from.
32 *
33 * \param seed The starting value of the CRC.
34 *
35 * \return The CRC8 of inData with seed as initial value.
36 *
37 * \note Setting seed to 0 computes the crc8 of the inData.
38 *
39 * \note Constantly passing the return value of this function
40 * As the seed argument computes the CRC8 value of a
41 * longer string of data.
42 */
\ In segment CODE, align 2, keep-with-next
43 unsigned char OWI_ComputeCRC8(unsigned char inData, unsigned char seed)
\ OWI_ComputeCRC8:
44 {
\ 00000000 2F30 MOV R19,R16
\ 00000002 2F01 MOV R16,R17
45 unsigned char bitsLeft;
46 unsigned char temp;
47
48 for (bitsLeft = 8; bitsLeft > 0; bitsLeft--)
\ 00000004 E018 LDI R17,8
\ ??OWI_ComputeCRC8_0:
\ 00000006 3011 CPI R17,1
\ 00000008 F090 BRCS ??OWI_ComputeCRC8_1
49 {
50 temp = ((seed ^ inData) & 0x01);
\ 0000000A 2F50 MOV R21,R16
\ 0000000C 7051 ANDI R21,0x01
\ 0000000E 2F23 MOV R18,R19
\ 00000010 7021 ANDI R18,0x01
\ 00000012 2725 EOR R18,R21
\ 00000014 7021 ANDI R18,0x01
\ 00000016 2F42 MOV R20,R18
51 if (temp == 0)
\ 00000018 2344 TST R20
\ 0000001A F411 BRNE ??OWI_ComputeCRC8_2
52 {
53 seed >>= 1;
\ 0000001C 9506 LSR R16
\ 0000001E C004 RJMP ??OWI_ComputeCRC8_3
54 }
55 else
56 {
57 seed ^= 0x18;
\ ??OWI_ComputeCRC8_2:
\ 00000020 E128 LDI R18,24
\ 00000022 2702 EOR R16,R18
58 seed >>= 1;
\ 00000024 9506 LSR R16
59 seed |= 0x80;
\ 00000026 6800 ORI R16,0x80
60 }
61 inData >>= 1;
\ ??OWI_ComputeCRC8_3:
\ 00000028 9536 LSR R19
62 }
\ 0000002A 951A DEC R17
\ 0000002C CFEC RJMP ??OWI_ComputeCRC8_0
63 return seed;
\ ??OWI_ComputeCRC8_1:
\ 0000002E 9508 RET
64 }
65
66
67 /*! \brief Compute the CRC16 value of a data set.
68 *
69 * This function will compute the CRC16 of inData using seed
70 * as inital value for the CRC.
71 *
72 * \param inData One byte of data to compute CRC from.
73 *
74 * \param seed The starting value of the CRC.
75 *
76 * \return The CRC16 of inData with seed as initial value.
77 *
78 * \note Setting seed to 0 computes the crc16 of the inData.
79 *
80 * \note Constantly passing the return value of this function
81 * As the seed argument computes the CRC16 value of a
82 * longer string of data.
83 */
\ In segment CODE, align 2, keep-with-next
84 unsigned int OWI_ComputeCRC16(unsigned char inData, unsigned int seed)
\ OWI_ComputeCRC16:
85 {
\ 00000000 2F50 MOV R21,R16
86 unsigned char bitsLeft;
87 unsigned char temp;
88
89 for (bitsLeft = 8; bitsLeft > 0; bitsLeft--)
\ 00000002 E048 LDI R20,8
\ ??OWI_ComputeCRC16_0:
\ 00000004 3041 CPI R20,1
\ 00000006 F0B0 BRCS ??OWI_ComputeCRC16_1
90 {
91 temp = ((seed ^ inData) & 0x01);
\ 00000008 2F12 MOV R17,R18
\ 0000000A 7011 ANDI R17,0x01
\ 0000000C 2F05 MOV R16,R21
\ 0000000E 7001 ANDI R16,0x01
\ 00000010 2701 EOR R16,R17
\ 00000012 7001 ANDI R16,0x01
\ 00000014 2F60 MOV R22,R16
92 if (temp == 0)
\ 00000016 2366 TST R22
\ 00000018 F419 BRNE ??OWI_ComputeCRC16_2
93 {
94 seed >>= 1;
\ 0000001A 9536 LSR R19
\ 0000001C 9527 ROR R18
\ 0000001E C007 RJMP ??OWI_ComputeCRC16_3
95 }
96 else
97 {
98 seed ^= 0x4002;
\ ??OWI_ComputeCRC16_2:
\ 00000020 E002 LDI R16,2
\ 00000022 E410 LDI R17,64
\ 00000024 2720 EOR R18,R16
\ 00000026 2731 EOR R19,R17
99 seed >>= 1;
\ 00000028 9536 LSR R19
\ 0000002A 9527 ROR R18
100 seed |= 0x8000;
\ 0000002C 6830 ORI R19,0x80
101 }
102 inData >>= 1;
\ ??OWI_ComputeCRC16_3:
\ 0000002E 9556 LSR R21
103 }
\ 00000030 954A DEC R20
\ 00000032 CFE8 RJMP ??OWI_ComputeCRC16_0
104 return seed;
\ ??OWI_ComputeCRC16_1:
\ 00000034 0189 MOVW R17 : R16,R19 : R18
\ 00000036 9508 RET
105 }
106
107
108 /*! \brief Calculate and check the CRC of a 64 bit ROM identifier.
109 *
110 * This function computes the CRC8 value of the first 56 bits of a
111 * 64 bit identifier. It then checks the calculated value against the
112 * CRC value stored in ROM.
113 *
114 * \param romvalue A pointer to an array holding a 64 bit identifier.
115 *
116 * \retval OWI_CRC_OK The CRC's matched.
117 * \retval OWI_CRC_ERROR There was a discrepancy between the calculated and the stored CRC.
118 */
\ In segment CODE, align 2, keep-with-next
119 unsigned char OWI_CheckRomCRC(unsigned char * romValue)
\ OWI_CheckRomCRC:
120 {
\ 00000000 ........ CALL ?PROLOGUE4_L09
\ 00000004 01D8 MOVW R27 : R26,R17 : R16
121 unsigned char i;
122 unsigned char crc8 = 0;
\ 00000006 E090 LDI R25,0
123
124 for (i = 0; i < 7; i++)
\ 00000008 E080 LDI R24,0
\ ??OWI_CheckRomCRC_0:
\ 0000000A 3087 CPI R24,7
\ 0000000C F440 BRCC ??OWI_CheckRomCRC_1
125 {
126 crc8 = OWI_ComputeCRC8(*romValue, crc8);
\ 0000000E 2F19 MOV R17,R25
\ 00000010 01FD MOVW R31 : R30,R27 : R26
\ 00000012 8100 LD R16,Z
\ 00000014 .... RCALL OWI_ComputeCRC8
\ 00000016 2F90 MOV R25,R16
127 romValue++;
\ 00000018 9611 ADIW R27 : R26,1
128 }
\ 0000001A 9583 INC R24
\ 0000001C CFF6 RJMP ??OWI_CheckRomCRC_0
129 if (crc8 == (*romValue))
\ ??OWI_CheckRomCRC_1:
\ 0000001E 910C LD R16,X
\ 00000020 1790 CP R25,R16
\ 00000022 F411 BRNE ??OWI_CheckRomCRC_2
130 {
131 return OWI_CRC_OK;
\ 00000024 E000 LDI R16,0
\ 00000026 C001 RJMP ??OWI_CheckRomCRC_3
132 }
133 return OWI_CRC_ERROR;
\ ??OWI_CheckRomCRC_2:
\ 00000028 E001 LDI R16,1
\ ??OWI_CheckRomCRC_3:
\ 0000002A E0E4 LDI R30,4
\ 0000002C ........ JMP ?EPILOGUE_B4_L09
134 }
\ In segment ABSOLUTE, at 0x3e, root
\ union <unnamed> volatile __io _A_EEAR
\ _A_EEAR:
\ 00000000 DS 2
\ In segment ABSOLUTE, at 0x40, root
\ union <unnamed> volatile __io _A_UBRRH
\ _A_UBRRH:
\ 00000000 DS 1
\ In segment ABSOLUTE, at 0x41, root
\ union <unnamed> volatile __io _A_WDTCR
\ _A_WDTCR:
\ 00000000 DS 1
\ In segment ABSOLUTE, at 0x42, root
\ union <unnamed> volatile __io _A_ASSR
\ _A_ASSR:
\ 00000000 DS 1
\ In segment ABSOLUTE, at 0x43, root
\ union <unnamed> volatile __io _A_OCR2
\ _A_OCR2:
\ 00000000 DS 1
\ In segment ABSOLUTE, at 0x44, root
\ union <unnamed> volatile __io _A_TCNT2
\ _A_TCNT2:
\ 00000000 DS 1
\ In segment ABSOLUTE, at 0x45, root
\ union <unnamed> volatile __io _A_TCCR2
\ _A_TCCR2:
\ 00000000 DS 1
\ In segment ABSOLUTE, at 0x46, root
\ union <unnamed> volatile __io _A_ICR1
\ _A_ICR1:
\ 00000000 DS 2
\ In segment ABSOLUTE, at 0x48, root
\ union <unnamed> volatile __io _A_OCR1B
\ _A_OCR1B:
\ 00000000 DS 2
\ In segment ABSOLUTE, at 0x4a, root
\ union <unnamed> volatile __io _A_OCR1A
\ _A_OCR1A:
\ 00000000 DS 2
\ In segment ABSOLUTE, at 0x4c, root
\ union <unnamed> volatile __io _A_TCNT1
\ _A_TCNT1:
\ 00000000 DS 2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -