NUCLEO-F334R8 This program show this functionality: USART2 (Virtual Com for debug) USART1 DigitalIn Decimal to Binary conversion CRC calculation NOTE: A jumper must be present from PB_6 to PA_10 (USART1) More details are available here: http://www.emcu.it/NUCLEOevaBoards/mBed/QSG-Mbed-Library.pdf

Dependencies:   mbed

Committer:
emcu
Date:
Thu Apr 02 00:01:21 2015 +0000
Revision:
0:464e44ee4534
NUCLEO-F334R8; This program show this functionality:;         USART2 (Virtual Com for debug);         USART1;         DigitalIn;         Decimal to Binary conversion;         CRC calculation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emcu 0:464e44ee4534 1 #include "mbed.h"
emcu 0:464e44ee4534 2 /*
emcu 0:464e44ee4534 3
emcu 0:464e44ee4534 4 Last chage: 21-03-2014
emcu 0:464e44ee4534 5
emcu 0:464e44ee4534 6 Project Name: NucleoF334R8-DigIN-CRC-DECtoBIN
emcu 0:464e44ee4534 7
emcu 0:464e44ee4534 8 By: www.emcu.it - Enrico Marinoni
emcu 0:464e44ee4534 9
emcu 0:464e44ee4534 10 NOTE: see here: http://www.emcu.it/NUCLEOevaBoards/NUCLEOevaBoards.html#Tutorial
emcu 0:464e44ee4534 11
emcu 0:464e44ee4534 12
emcu 0:464e44ee4534 13 This program show this functionality:
emcu 0:464e44ee4534 14 USART2 (Virtual Com for debug)
emcu 0:464e44ee4534 15 USART1
emcu 0:464e44ee4534 16 DigitalIn
emcu 0:464e44ee4534 17 Decimal to Binary conversion
emcu 0:464e44ee4534 18 CRC calculation
emcu 0:464e44ee4534 19 NOTE:
emcu 0:464e44ee4534 20 A jumper must be present from PB_6 to PA_10 (USART1)
emcu 0:464e44ee4534 21 More details are available here:
emcu 0:464e44ee4534 22 http://www.emcu.it/NUCLEOevaBoards/mBed/QSG-Mbed-Library.pdf
emcu 0:464e44ee4534 23
emcu 0:464e44ee4534 24
emcu 0:464e44ee4534 25 * Permission is hereby granted, free of charge, to any person obtaining a copy
emcu 0:464e44ee4534 26 * of this software and associated documentation files (the "Software"), to deal
emcu 0:464e44ee4534 27 * in the Software without restriction, including without limitation the rights
emcu 0:464e44ee4534 28 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
emcu 0:464e44ee4534 29 * copies of the Software, and to permit persons to whom the Software is
emcu 0:464e44ee4534 30 * furnished to do so, subject to the following conditions:
emcu 0:464e44ee4534 31 *
emcu 0:464e44ee4534 32 * The above copyright notice and this permission notice shall be included in
emcu 0:464e44ee4534 33 * all copies or substantial portions of the Software.
emcu 0:464e44ee4534 34 *
emcu 0:464e44ee4534 35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
emcu 0:464e44ee4534 36 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
emcu 0:464e44ee4534 37 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
emcu 0:464e44ee4534 38 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
emcu 0:464e44ee4534 39 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
emcu 0:464e44ee4534 40 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
emcu 0:464e44ee4534 41 * THE SOFTWARE.
emcu 0:464e44ee4534 42
emcu 0:464e44ee4534 43
emcu 0:464e44ee4534 44 VARIABLEs
emcu 0:464e44ee4534 45
emcu 0:464e44ee4534 46 IO Status -> variable name is: IOStatus
emcu 0:464e44ee4534 47 Name Bit Directions Note
emcu 0:464e44ee4534 48 Din1 0 IN PB_8
emcu 0:464e44ee4534 49 Din2 1 IN PB_9
emcu 0:464e44ee4534 50 Din3 2 IN PA_6 - Not used in this release of FW
emcu 0:464e44ee4534 51 Din4 3 IN PA_7 " " " "
emcu 0:464e44ee4534 52 RL1 4 OUT PA_8 Optional 4 Relay shield from SEED STUDIO - Not used in this release of FW
emcu 0:464e44ee4534 53 RL2 5 OUT PB_10 " " " " " - " " " "
emcu 0:464e44ee4534 54 RL3 6 OUT PB_4 " " " " " - " " " "
emcu 0:464e44ee4534 55 RL4 7 OUT PB_5 " " " " " - " " " "
emcu 0:464e44ee4534 56
emcu 0:464e44ee4534 57 ADC Status - Not used in this release of FW
emcu 0:464e44ee4534 58 Name Variable Name Note
emcu 0:464e44ee4534 59 Ain0 ValAin0 PA_0 - Not used in this release of FW
emcu 0:464e44ee4534 60 Ain1 ValAin1 PA_1 " " " "
emcu 0:464e44ee4534 61 Ain2 ValAin2 PA_4 " " " "
emcu 0:464e44ee4534 62 Ain3 ValAin3 PB_0 " " " "
emcu 0:464e44ee4534 63 Ain4 ValAin4 PC_1 " " " "
emcu 0:464e44ee4534 64
emcu 0:464e44ee4534 65
emcu 0:464e44ee4534 66 USART2 (RX==D0 - PA_3, TX==D1 - PA2) it is used for debug (connected to the PC) using TeraTerm.
emcu 0:464e44ee4534 67 USART1 (RX==D2 - PA_10 , TX==D10 - PB_6) it is used for show the way to use another USART.
emcu 0:464e44ee4534 68 Both USART are used in RX Interrupt mode.
emcu 0:464e44ee4534 69 The USART parameters are:
emcu 0:464e44ee4534 70 Baud Rate: 1200
emcu 0:464e44ee4534 71 Data: 8
emcu 0:464e44ee4534 72 Parity: NONE
emcu 0:464e44ee4534 73 Stop: 1
emcu 0:464e44ee4534 74 Flow Control: NONE
emcu 0:464e44ee4534 75
emcu 0:464e44ee4534 76 */
emcu 0:464e44ee4534 77
emcu 0:464e44ee4534 78 Serial pc(SERIAL_TX, SERIAL_RX); // This is USART2 tx, rx
emcu 0:464e44ee4534 79 // It is used for Debug via VirtualCOM
emcu 0:464e44ee4534 80 // I suggest to use Tera TERM on PC
emcu 0:464e44ee4534 81 Serial Serial1(PB_6, PA_10); // This is USART1 tx, rx
emcu 0:464e44ee4534 82
emcu 0:464e44ee4534 83 DigitalOut myled(LED1); // This LED is on NUCLEO-F334R8
emcu 0:464e44ee4534 84
emcu 0:464e44ee4534 85 DigitalIn BlueButton(USER_BUTTON); // This is Blue-Button and is on NUCLEO-L153RE
emcu 0:464e44ee4534 86 // Digital InPut - from the field
emcu 0:464e44ee4534 87 DigitalIn Din1(PB_8);
emcu 0:464e44ee4534 88 DigitalIn Din2(PB_9);
emcu 0:464e44ee4534 89 DigitalIn Din3(PA_6);
emcu 0:464e44ee4534 90 DigitalIn Din4(PA_7);
emcu 0:464e44ee4534 91
emcu 0:464e44ee4534 92 #define Pressed 0
emcu 0:464e44ee4534 93 #define NotPressed 1
emcu 0:464e44ee4534 94 #define Enable 1
emcu 0:464e44ee4534 95 #define Disable 0
emcu 0:464e44ee4534 96 #define POLYNOMIAL 0xD8 /* Is for CRC calculation - 11011 followed by 0's */
emcu 0:464e44ee4534 97
emcu 0:464e44ee4534 98 int Car='\0';
emcu 0:464e44ee4534 99 int CarSerial1='\0';
emcu 0:464e44ee4534 100 int n=0;
emcu 0:464e44ee4534 101 int DinStatus = 0;
emcu 0:464e44ee4534 102 int ValCRC = 0;
emcu 0:464e44ee4534 103
emcu 0:464e44ee4534 104
emcu 0:464e44ee4534 105
emcu 0:464e44ee4534 106 // Functions -----------------------------------------------------------------------
emcu 0:464e44ee4534 107 void SendToPCtheDinStatusAndCRC(void);
emcu 0:464e44ee4534 108
emcu 0:464e44ee4534 109 int ReadIO(void); // Read and return the Din1...4 status
emcu 0:464e44ee4534 110
emcu 0:464e44ee4534 111 void ConvDecToBin(int); // Convert Decimal number in Binary and send the result
emcu 0:464e44ee4534 112 // to the PC
emcu 0:464e44ee4534 113
emcu 0:464e44ee4534 114 uint8_t crcNaive(uint8_t const);
emcu 0:464e44ee4534 115
emcu 0:464e44ee4534 116 void callback2() // PC - USART2 used for Debug
emcu 0:464e44ee4534 117 {
emcu 0:464e44ee4534 118 // Note: you need to actually read from the serial to clear the RX interrupt
emcu 0:464e44ee4534 119 Car = pc.getc();
emcu 0:464e44ee4534 120 }
emcu 0:464e44ee4534 121
emcu 0:464e44ee4534 122 void USART1_INT() // USART1
emcu 0:464e44ee4534 123 {
emcu 0:464e44ee4534 124 // Note: you need to actually read from the serial to clear the RX interrupt
emcu 0:464e44ee4534 125 CarSerial1 = Serial1.getc();
emcu 0:464e44ee4534 126 }
emcu 0:464e44ee4534 127
emcu 0:464e44ee4534 128 // Interrupt used for flashing the Green Led
emcu 0:464e44ee4534 129 Timeout to1;
emcu 0:464e44ee4534 130 #define ON 1
emcu 0:464e44ee4534 131 #define OFF 0
emcu 0:464e44ee4534 132 #define DLYFlash 0.5
emcu 0:464e44ee4534 133 int ONOFF_Flashing = ON;
emcu 0:464e44ee4534 134 void IntFlash(void);
emcu 0:464e44ee4534 135
emcu 0:464e44ee4534 136
emcu 0:464e44ee4534 137 // MAIN program ---------------------------------------------------------------------
emcu 0:464e44ee4534 138 int main() {
emcu 0:464e44ee4534 139
emcu 0:464e44ee4534 140 // Define the USART ports
emcu 0:464e44ee4534 141 Serial1.attach(&USART1_INT);
emcu 0:464e44ee4534 142 pc.attach(&callback2);
emcu 0:464e44ee4534 143
emcu 0:464e44ee4534 144 // SetUp the baud rate
emcu 0:464e44ee4534 145 pc.baud(1200);
emcu 0:464e44ee4534 146 Serial1.baud(1200);
emcu 0:464e44ee4534 147
emcu 0:464e44ee4534 148
emcu 0:464e44ee4534 149 // Set PullUp on Digital Input Pins (Din1...4)
emcu 0:464e44ee4534 150 Din1.mode(PullUp);
emcu 0:464e44ee4534 151 Din2.mode(PullUp);
emcu 0:464e44ee4534 152 Din3.mode(PullUp);
emcu 0:464e44ee4534 153 Din4.mode(PullUp);
emcu 0:464e44ee4534 154
emcu 0:464e44ee4534 155 // Start flashing the Green Led
emcu 0:464e44ee4534 156 ONOFF_Flashing = ON; // Enabling flashing flag
emcu 0:464e44ee4534 157 to1.attach(&IntFlash, DLYFlash); // Enabling flashing Interrupt
emcu 0:464e44ee4534 158
emcu 0:464e44ee4534 159
emcu 0:464e44ee4534 160 pc.printf("\n\r\n\r START MAIN - NucleoF334R8-DigIN-CRC-DECtoBIN\n\r");
emcu 0:464e44ee4534 161
emcu 0:464e44ee4534 162 while(1) // Main infinite loop --------------------------------------------------
emcu 0:464e44ee4534 163 {
emcu 0:464e44ee4534 164
emcu 0:464e44ee4534 165 // Test the Blue Button
emcu 0:464e44ee4534 166 if (BlueButton == Pressed)
emcu 0:464e44ee4534 167 {
emcu 0:464e44ee4534 168 while(BlueButton == Pressed)
emcu 0:464e44ee4534 169 {
emcu 0:464e44ee4534 170 if (n == 0)
emcu 0:464e44ee4534 171 pc.printf("Please release the BLUE Button\n\r");
emcu 0:464e44ee4534 172 n++;
emcu 0:464e44ee4534 173 }
emcu 0:464e44ee4534 174 n = 0;
emcu 0:464e44ee4534 175 pc.printf("The Digital Input status are:\n\r");
emcu 0:464e44ee4534 176 DinStatus = ReadIO();
emcu 0:464e44ee4534 177 pc.printf("DinStatus == %x\n\r", DinStatus);
emcu 0:464e44ee4534 178 pc.printf("Din4 Din3 Din2 Din1\n\r");
emcu 0:464e44ee4534 179 ConvDecToBin(DinStatus);
emcu 0:464e44ee4534 180
emcu 0:464e44ee4534 181 // CRC calculation
emcu 0:464e44ee4534 182 ValCRC = crcNaive(DinStatus);
emcu 0:464e44ee4534 183 pc.printf("CRC == %d\n\r", ValCRC);
emcu 0:464e44ee4534 184
emcu 0:464e44ee4534 185 ONOFF_Flashing = OFF; // Disable Interrupt of Green LED
emcu 0:464e44ee4534 186
emcu 0:464e44ee4534 187 // Start flashing the Green Led (enable Interrupt)
emcu 0:464e44ee4534 188 ONOFF_Flashing = ON; // Enabling flashing flag
emcu 0:464e44ee4534 189 to1.attach(&IntFlash, DLYFlash); // Enabling flashing Interrupt
emcu 0:464e44ee4534 190
emcu 0:464e44ee4534 191 }
emcu 0:464e44ee4534 192
emcu 0:464e44ee4534 193
emcu 0:464e44ee4534 194 // Test the char. received from PC - USART2 that is USB Virtual COM
emcu 0:464e44ee4534 195 if (Car == 'E')
emcu 0:464e44ee4534 196 {
emcu 0:464e44ee4534 197 pc.printf("\n\r - Send char. E (received from USB_VirtualCOM PC-USART2) to USART1\n\r");
emcu 0:464e44ee4534 198 pc.printf(" - If there is a jumper from PB_6 to PA_10, you will see the Din4...1 status + CRC\n\r");
emcu 0:464e44ee4534 199 Serial1.putc('E'); // Send char. E to USART1
emcu 0:464e44ee4534 200 Car = '\0';
emcu 0:464e44ee4534 201 }
emcu 0:464e44ee4534 202
emcu 0:464e44ee4534 203
emcu 0:464e44ee4534 204 if (Car == '?')
emcu 0:464e44ee4534 205 {
emcu 0:464e44ee4534 206 // Send to PC the status of Digital Inputs Din1...4
emcu 0:464e44ee4534 207 SendToPCtheDinStatusAndCRC();
emcu 0:464e44ee4534 208 Car = '\0';
emcu 0:464e44ee4534 209 }
emcu 0:464e44ee4534 210
emcu 0:464e44ee4534 211
emcu 0:464e44ee4534 212 // Test the char. received from AUREL (USART1)
emcu 0:464e44ee4534 213 if (CarSerial1 == 'E')
emcu 0:464e44ee4534 214 {
emcu 0:464e44ee4534 215 pc.printf("RX char. E from USART1\n\r");
emcu 0:464e44ee4534 216 // Send to PC the status of Digital Inputs Din1...4
emcu 0:464e44ee4534 217 SendToPCtheDinStatusAndCRC();
emcu 0:464e44ee4534 218 CarSerial1 = '\0';
emcu 0:464e44ee4534 219 }
emcu 0:464e44ee4534 220 }
emcu 0:464e44ee4534 221 // END Main infinite loop -------------------------------------------------------
emcu 0:464e44ee4534 222 }
emcu 0:464e44ee4534 223
emcu 0:464e44ee4534 224
emcu 0:464e44ee4534 225 void SendToPCtheDinStatusAndCRC(void)
emcu 0:464e44ee4534 226 {
emcu 0:464e44ee4534 227 ONOFF_Flashing = OFF; // Disable Interrupt of Green LED
emcu 0:464e44ee4534 228 pc.printf("\n\r- PC request, to know the Digital Inputs Status\n\r");
emcu 0:464e44ee4534 229 DinStatus = ReadIO();
emcu 0:464e44ee4534 230 pc.printf("DinStatus == %x\n\r", DinStatus);
emcu 0:464e44ee4534 231 pc.printf("Din4 Din3 Din2 Din1\n\r");
emcu 0:464e44ee4534 232 ConvDecToBin(DinStatus);
emcu 0:464e44ee4534 233 // CRC calculation
emcu 0:464e44ee4534 234 ValCRC = crcNaive(DinStatus);
emcu 0:464e44ee4534 235 pc.printf("CRC related to Din4...1 == %d\n\r", ValCRC);
emcu 0:464e44ee4534 236 Car = '\0';
emcu 0:464e44ee4534 237 // Start flashing the Green Led (enable Interrupt)
emcu 0:464e44ee4534 238 ONOFF_Flashing = ON; // Enabling flashing flag
emcu 0:464e44ee4534 239 to1.attach(&IntFlash, DLYFlash); // Enabling flashing Interrupt
emcu 0:464e44ee4534 240 }
emcu 0:464e44ee4534 241
emcu 0:464e44ee4534 242
emcu 0:464e44ee4534 243 int ReadIO(void)
emcu 0:464e44ee4534 244 {
emcu 0:464e44ee4534 245 DigitalIn Din1(PB_8);
emcu 0:464e44ee4534 246 int DinValue=255;
emcu 0:464e44ee4534 247
emcu 0:464e44ee4534 248 /* Read all the Digital Inputs (Din1...4) and return a DinValue
emcu 0:464e44ee4534 249
emcu 0:464e44ee4534 250 DinValue (bit) Note
emcu 0:464e44ee4534 251 0 Din1 - 1 == OPEN, 0 == CLOSE
emcu 0:464e44ee4534 252 1 Din2 - " "
emcu 0:464e44ee4534 253 2 Din3 - " "
emcu 0:464e44ee4534 254 3 Din4 - " "
emcu 0:464e44ee4534 255 */
emcu 0:464e44ee4534 256
emcu 0:464e44ee4534 257 // Test Din1 status
emcu 0:464e44ee4534 258 if (Din1 == 0)
emcu 0:464e44ee4534 259 DinValue = DinValue & 254; // 0
emcu 0:464e44ee4534 260 else
emcu 0:464e44ee4534 261 DinValue = DinValue & 255; // 1
emcu 0:464e44ee4534 262
emcu 0:464e44ee4534 263 // Test Din2 status
emcu 0:464e44ee4534 264 if (Din2 == 0)
emcu 0:464e44ee4534 265 DinValue = DinValue & 253; // 0
emcu 0:464e44ee4534 266 else
emcu 0:464e44ee4534 267 DinValue = DinValue & 255; // 1
emcu 0:464e44ee4534 268
emcu 0:464e44ee4534 269 // Test Din3 status
emcu 0:464e44ee4534 270 if (Din3 == 0)
emcu 0:464e44ee4534 271 DinValue = DinValue & 251; // 0
emcu 0:464e44ee4534 272 else
emcu 0:464e44ee4534 273 DinValue = DinValue & 255; // 1
emcu 0:464e44ee4534 274
emcu 0:464e44ee4534 275 // Test Din4 status
emcu 0:464e44ee4534 276 if (Din4 == 0)
emcu 0:464e44ee4534 277 DinValue = DinValue & 247; // 0
emcu 0:464e44ee4534 278 else
emcu 0:464e44ee4534 279 DinValue = DinValue & 255; // 1
emcu 0:464e44ee4534 280
emcu 0:464e44ee4534 281 return DinValue;
emcu 0:464e44ee4534 282 }
emcu 0:464e44ee4534 283
emcu 0:464e44ee4534 284 //
emcu 0:464e44ee4534 285 // Function that convert a Decimal number in Binary
emcu 0:464e44ee4534 286 // the original function is here:
emcu 0:464e44ee4534 287 // http://www.programmingsimplified.com/c/source-code/c-program-convert-decimal-to-binary
emcu 0:464e44ee4534 288 //
emcu 0:464e44ee4534 289 void ConvDecToBin(int n)
emcu 0:464e44ee4534 290 {
emcu 0:464e44ee4534 291 int c, k;
emcu 0:464e44ee4534 292 for (c = 3; c >= 0; c--)
emcu 0:464e44ee4534 293 {
emcu 0:464e44ee4534 294 k = n >> c;
emcu 0:464e44ee4534 295
emcu 0:464e44ee4534 296 if (k & 1)
emcu 0:464e44ee4534 297 pc.printf(" 1 ");
emcu 0:464e44ee4534 298 else
emcu 0:464e44ee4534 299 pc.printf(" 0 ");
emcu 0:464e44ee4534 300 }
emcu 0:464e44ee4534 301 pc.printf("\n\r");
emcu 0:464e44ee4534 302 }
emcu 0:464e44ee4534 303
emcu 0:464e44ee4534 304
emcu 0:464e44ee4534 305 //
emcu 0:464e44ee4534 306 // Function that flashing the Green Led
emcu 0:464e44ee4534 307 //
emcu 0:464e44ee4534 308 void IntFlash(void)
emcu 0:464e44ee4534 309 {
emcu 0:464e44ee4534 310 if (ONOFF_Flashing == ON)
emcu 0:464e44ee4534 311 myled = !myled;
emcu 0:464e44ee4534 312 else
emcu 0:464e44ee4534 313 myled = 0;
emcu 0:464e44ee4534 314 to1.detach();
emcu 0:464e44ee4534 315 to1.attach(&IntFlash, DLYFlash); // this line reload Interrupt
emcu 0:464e44ee4534 316 }
emcu 0:464e44ee4534 317
emcu 0:464e44ee4534 318
emcu 0:464e44ee4534 319 //
emcu 0:464e44ee4534 320 // CRC calculation
emcu 0:464e44ee4534 321 // Original code is gere: http://www.barrgroup.com/Embedded-Systems/How-To/CRC-Calculation-C-Code
emcu 0:464e44ee4534 322 //
emcu 0:464e44ee4534 323 uint8_t crcNaive(uint8_t const message)
emcu 0:464e44ee4534 324 {
emcu 0:464e44ee4534 325 uint8_t remainder;
emcu 0:464e44ee4534 326
emcu 0:464e44ee4534 327
emcu 0:464e44ee4534 328 /*
emcu 0:464e44ee4534 329 * Initially, the dividend is the remainder.
emcu 0:464e44ee4534 330 */
emcu 0:464e44ee4534 331 remainder = message;
emcu 0:464e44ee4534 332
emcu 0:464e44ee4534 333 /*
emcu 0:464e44ee4534 334 * For each bit position in the message....
emcu 0:464e44ee4534 335 */
emcu 0:464e44ee4534 336 for (uint8_t bit = 8; bit > 0; --bit)
emcu 0:464e44ee4534 337 {
emcu 0:464e44ee4534 338 /*
emcu 0:464e44ee4534 339 * If the uppermost bit is a 1...
emcu 0:464e44ee4534 340 */
emcu 0:464e44ee4534 341 if (remainder & 0x80)
emcu 0:464e44ee4534 342 {
emcu 0:464e44ee4534 343 /*
emcu 0:464e44ee4534 344 * XOR the previous remainder with the divisor.
emcu 0:464e44ee4534 345 */
emcu 0:464e44ee4534 346 remainder ^= POLYNOMIAL;
emcu 0:464e44ee4534 347 }
emcu 0:464e44ee4534 348
emcu 0:464e44ee4534 349 /*
emcu 0:464e44ee4534 350 * Shift the next bit of the message into the remainder.
emcu 0:464e44ee4534 351 */
emcu 0:464e44ee4534 352 remainder = (remainder << 1);
emcu 0:464e44ee4534 353 }
emcu 0:464e44ee4534 354
emcu 0:464e44ee4534 355 /*
emcu 0:464e44ee4534 356 * Return only the relevant bits of the remainder as CRC.
emcu 0:464e44ee4534 357 */
emcu 0:464e44ee4534 358 return (remainder >> 4);
emcu 0:464e44ee4534 359
emcu 0:464e44ee4534 360 }