Echelon Neuron C Instrukcja Użytkownika Strona 96

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 267
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 95
76 Functions
Syntax
#include <byte.h>
void clr_bit (void *
array
, unsigned
bitnum
);
Example
#include <byte.h>
unsigned short a[4];
void f(void)
{
memset(a, 0xFF, 4); // Sets all bits
clr_bit(a, 4); // Clears a[0] to 0xF7 (5th bit)
}
crc8( ) Function
The crc8( ) function iteratively calculates an 8-bit cyclic redundancy check (CRC)
over an array of data using the following polynomial:
1
458
xxx
This function is useful in conjunction with the support for the Touch I/O model,
but can also be used whenever a CRC is needed.
Syntax
#include <stdlib.h>
unsigned crc8 (unsigned
crc
, unsigned
new-data
);
Example
#include <stdlib.h>
unsigned data[SIZE];
void f(void)
{
unsigned i; // Or 'unsigned long' depending on SIZE
unsigned crc;
crc = 0;
for (i = 0; i < SIZE; ++i) {
// Combine partial CRC with next data byte
crc = crc8(crc, data[i]);
}
}
crc16( ) Function
The crc16( ) function iteratively calculates a 16-bit cyclic redundancy check (CRC)
over an array of data bytes using the following polynomial:
Przeglądanie stron 95
1 2 ... 91 92 93 94 95 96 97 98 99 100 101 ... 266 267

Komentarze do niniejszej Instrukcji

Brak uwag