44 printf(
"asm isr\n\r");
45 ASM->CONTROL0bits.CLEAR_IRQ = 1;
55 uart_init(INC, MOD, SAMP);
63 printf(
"ASM Control 0: %08x\n\r", (
unsigned int)ASM->CONTROL0);
64 printf(
"ASM Control 1: %08x\n\r", (
unsigned int)ASM->CONTROL1);
65 printf(
"ASM Status: %08x\n\r", (
unsigned int)ASM->STATUS);
66 printf(
"ASM Test pass: %d\n\r", ASM->STATUSbits.TEST_PASS);
69 printf(
"\n\r*** ASM self-test ***\n\r");
71 ASM->CONTROL1bits.ON = 1;
72 ASM->CONTROL1bits.SELF_TEST = 1;
73 ASM->CONTROL0bits.START = 1;
78 for(i = 0; i < 3330; i++) {
continue; }
80 printf(
"ASM Test pass: %d\n\r", ASM->STATUSbits.TEST_PASS);
83 ASM->CONTROL1bits.SELF_TEST = 0;
89 ASM->CONTROL1bits.NORMAL_MODE = 1;
93 ASM->CONTROL1bits.BYPASS = 0;
95 printf(
"\n\r*** set ASM key ***\n\r");
96 ASM->KEY0 = 0xccddeeff;
97 ASM->KEY1 = 0x8899aabb;
98 ASM->KEY2 = 0x44556677;
99 ASM->KEY3 = 0x00112233;
103 printf(
"ASM Key [3,2,1,0] : 0x%08x%08x%08x%08x\n",
104 (
unsigned int) ASM->KEY3,
105 (
unsigned int) ASM->KEY2,
106 (
unsigned int) ASM->KEY1,
107 (
unsigned int) ASM->KEY0);
109 printf(
"\n\r*** CTR test ***\n\r");
110 printf(
"Encrypt\n\r");
111 ASM->CONTROL1bits.CTR = 1;
113 ASM->DATA0 = 0xdeaddead;
114 ASM->DATA1 = 0xbeefbeef;
115 ASM->DATA2 = 0xfaceface;
116 ASM->DATA3 = 0x01234567;
118 printf(
"ASM Data [3,2,1,0] : 0x%08x%08x%08x%08x\n",
119 (
unsigned int) ASM->DATA3,
120 (
unsigned int) ASM->DATA2,
121 (
unsigned int) ASM->DATA1,
122 (
unsigned int) ASM->DATA0);
124 ASM->CTR0 = 0x33333333;
125 ASM->CTR1 = 0x22222222;
126 ASM->CTR2 = 0x11111111;
127 ASM->CTR3 = 0x00000000;
129 printf(
"ASM CTR [3,2,1,0] : 0x%08x%08x%08x%08x\n",
130 (
unsigned int) ASM->CTR3,
131 (
unsigned int) ASM->CTR2,
132 (
unsigned int) ASM->CTR1,
133 (
unsigned int) ASM->CTR0);
135 ASM->CONTROL0bits.START = 1;
136 while(ASM->STATUSbits.DONE == 0) {
continue; }
138 printf(
"ASM CTR RESULT [3,2,1,0]: 0x%08x%08x%08x%08x\n",
139 (
unsigned int) ASM->CTR3_RESULT,
140 (
unsigned int) ASM->CTR2_RESULT,
141 (
unsigned int) ASM->CTR1_RESULT,
142 (
unsigned int) ASM->CTR0_RESULT);
144 printf(
"Decrypt\n\r");
146 ASM->DATA0 = ASM->CTR0_RESULT;
147 ASM->DATA1 = ASM->CTR1_RESULT;
148 ASM->DATA2 = ASM->CTR2_RESULT;
149 ASM->DATA3 = ASM->CTR3_RESULT;
151 ASM->CONTROL0bits.START = 1;
152 while(ASM->STATUSbits.DONE == 0) {
continue; }
154 printf(
"ASM CTR RESULT [3,2,1,0]: 0x%08x%08x%08x%08x\n",
155 (
unsigned int) ASM->CTR3_RESULT,
156 (
unsigned int) ASM->CTR2_RESULT,
157 (
unsigned int) ASM->CTR1_RESULT,
158 (
unsigned int) ASM->CTR0_RESULT);
160 printf(
"\n\r*** CBC MAC generation ***\n\r");
162 ASM->CONTROL1bits.CTR = 0;
163 ASM->CONTROL1bits.CBC = 1;
170 ASM->DATA0 = 0xdeaddead;
171 ASM->DATA1 = 0xbeefbeef;
172 ASM->DATA2 = 0xfaceface;
173 ASM->DATA3 = 0x01234567;
175 ASM->CONTROL0bits.CLEAR = 1;
177 ASM->CONTROL0bits.START = 1;
178 while(ASM->STATUSbits.DONE == 0) {
continue; }
180 printf(
"ASM CBC RESULT [3,2,1,0]: 0x%08x%08x%08x%08x\n",
181 (
unsigned int) ASM->CBC3_RESULT,
182 (
unsigned int) ASM->CBC2_RESULT,
183 (
unsigned int) ASM->CBC1_RESULT,
184 (
unsigned int) ASM->CBC0_RESULT);
186 printf(
"\n\r*** CCM (CTR+CBC) ***\n\r");
188 ASM->CONTROL1bits.CTR = 1;
189 ASM->CONTROL1bits.CBC = 1;
190 ASM->CONTROL0bits.CLEAR = 1;
192 ASM->CONTROL0bits.START = 1;
193 while(ASM->STATUSbits.DONE == 0) {
continue; }
195 printf(
"ASM CTR RESULT [3,2,1,0]: 0x%08x%08x%08x%08x\n",
196 (
unsigned int) ASM->CTR3_RESULT,
197 (
unsigned int) ASM->CTR2_RESULT,
198 (
unsigned int) ASM->CTR1_RESULT,
199 (
unsigned int) ASM->CTR0_RESULT);
201 printf(
"ASM CBC RESULT [3,2,1,0]: 0x%08x%08x%08x%08x\n",
202 (
unsigned int) ASM->CBC3_RESULT,
203 (
unsigned int) ASM->CBC2_RESULT,
204 (
unsigned int) ASM->CBC1_RESULT,
205 (
unsigned int) ASM->CBC0_RESULT);