LPCOpen Platform
v1.03
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Modules
Data Structures
Files
Related Pages
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
crc.c
Go to the documentation of this file.
1
/*
2
* @brief Cyclic Redundancy Check (CRC) generator example.
3
*
4
* @note
5
* Copyright(C) NXP Semiconductors, 2012
6
* All rights reserved.
7
*
8
* @par
9
* Software that is described herein is for illustrative purposes only
10
* which provides customers with programming information regarding the
11
* LPC products. This software is supplied "AS IS" without any warranties of
12
* any kind, and NXP Semiconductors and its licensor disclaim any and
13
* all warranties, express or implied, including all implied warranties of
14
* merchantability, fitness for a particular purpose and non-infringement of
15
* intellectual property rights. NXP Semiconductors assumes no responsibility
16
* or liability for the use of the software, conveys no license or rights under any
17
* patent, copyright, mask work right, or any other intellectual property rights in
18
* or to any products. NXP Semiconductors reserves the right to make changes
19
* in the software without notification. NXP Semiconductors also makes no
20
* representation or warranty that such application will be suitable for the
21
* specified use without further testing or modification.
22
*
23
* @par
24
* Permission to use, copy, modify, and distribute this software and its
25
* documentation is hereby granted, under NXP Semiconductors' and its
26
* licensor's relevant copyrights in the software, without fee, provided that it
27
* is used in conjunction with NXP Semiconductors microcontrollers. This
28
* copyright, permission, and disclaimer notice must appear in all copies of
29
* this code.
30
*/
31
32
#include "board.h"
33
60
/*****************************************************************************
61
* Private types/enumerations/variables
62
****************************************************************************/
63
64
/* Expected CRC values for test */
65
#define EXPECTED_CCIT_SUM (0xFD2F)
66
#define EXPECTED_CRC16_SUM (0x2799)
67
#define EXPECTED_CRC32_SUM (0x100ECE8C)
68
69
/* Test block size in bytes */
70
#define BLOCK_SIZE 0x40
71
72
/*****************************************************************************
73
* Public types/enumerations/variables
74
****************************************************************************/
75
76
/*****************************************************************************
77
* Private functions
78
****************************************************************************/
79
80
/* Populate block Data for tests */
81
static
void
initBlockData
(uint8_t *p8)
82
{
83
uint32_t
i;
84
85
for
(i = 0; i <
BLOCK_SIZE
; i++) {
86
p8[i] = i;
87
}
88
}
89
90
/*****************************************************************************
91
* Public functions
92
****************************************************************************/
93
98
int
main
(
void
) {
99
uint32_t
result
;
100
uint32_t
BlockData[
BLOCK_SIZE
/ 4];
101
volatile
int
noExit = 1;
/* For build warning only */
102
103
/* Board Initialization */
104
Board_Init
();
105
106
/* Chip Initialization */
107
Chip_CRC_Init
();
108
109
Board_LED_Set
(0,
false
);
110
initBlockData
((uint8_t *) BlockData);
111
DEBUGSTR
(
"CRC engine test\r\n"
);
112
113
/* 8-bit CCIT */
114
result =
Chip_CRC_CRC8
((
const
uint8_t *) BlockData,
BLOCK_SIZE
);
115
DEBUGOUT
(
"CCIT test results, expected 0x%x, got 0x%x\r\n"
,
116
EXPECTED_CCIT_SUM
, result);
117
if
(result !=
EXPECTED_CCIT_SUM
) {
118
Board_LED_Set
(0,
true
);
119
}
120
121
/* 16-bit CRC16 */
122
result =
Chip_CRC_CRC16
((
const
uint16_t *) BlockData,
BLOCK_SIZE
/ 2);
123
DEBUGOUT
(
"CRC16 test results, expected 0x%x, got 0x%x\r\n"
,
124
EXPECTED_CRC16_SUM
, result);
125
if
(result !=
EXPECTED_CRC16_SUM
) {
126
Board_LED_Set
(0,
true
);
127
}
128
129
/* 32-bit CRC16 */
130
result =
Chip_CRC_CRC32
((
const
uint32_t
*) BlockData,
BLOCK_SIZE
/ 4);
131
DEBUGOUT
(
"CRC32 test results, expected 0x%x, got 0x%x\r\n"
,
132
EXPECTED_CRC32_SUM
, result);
133
if
(result !=
EXPECTED_CRC32_SUM
) {
134
Board_LED_Set
(0,
true
);
135
}
136
137
while
(noExit) {}
138
139
return
0;
140
}
141
applications
lpc17xx_40xx
examples
periph
periph_crc
crc.c
Generated on Fri May 10 2013 10:41:59 for LPCOpen Platform by
1.8.2