phyphox BLE
Plot your Arduino's data in the phyphox app and control the board from the phone
Loading...
Searching...
No Matches
Crc32.h
Go to the documentation of this file.
1// CRC-32 (IEEE 802.3, polynomial 0xEDB88320, reflected) — the checksum the phyphox transfer
2// header carries and the apps verify. Table-free, bit-serial: ~40 bytes of code, no 1 KB table
3// in RAM, and a 5 KB document takes well under a millisecond on any supported board.
4#ifndef PHYPHOX_BLE_CORE_CRC32_H
5#define PHYPHOX_BLE_CORE_CRC32_H
6
7#include <stdint.h>
8#include <stddef.h>
9
10namespace phyphox {
11
12class Crc32 {
13public:
14 Crc32() : state_(0xFFFFFFFFu) {}
15 void reset() { state_ = 0xFFFFFFFFu; }
16 void update(const uint8_t* data, size_t len);
17 void update(uint8_t byte);
19 uint32_t value() const { return state_ ^ 0xFFFFFFFFu; }
21 static uint32_t of(const uint8_t* data, size_t len) { Crc32 c; c.update(data, len); return c.value(); }
22private:
23 uint32_t state_;
24};
25
26} // namespace phyphox
27
28#endif
Definition Crc32.h:12
void update(const uint8_t *data, size_t len)
Crc32()
Definition Crc32.h:14
static uint32_t of(const uint8_t *data, size_t len)
One-shot helper.
Definition Crc32.h:21
void reset()
Definition Crc32.h:15
void update(uint8_t byte)
uint32_t value() const
The finished value (does not alter the running state).
Definition Crc32.h:19
Definition ChannelStore.h:11