mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-27 12:53:53 +01:00
add crc16 function and remove oda, to be reimplemented
This commit is contained in:
14
src/lib.c
14
src/lib.c
@@ -1,6 +1,7 @@
|
||||
#include "common.h"
|
||||
#include "rds.h"
|
||||
#include <time.h>
|
||||
#include "lib.h"
|
||||
|
||||
extern int nanosleep(const struct timespec *req, struct timespec *rem);
|
||||
void msleep(unsigned long ms) {
|
||||
@@ -16,6 +17,19 @@ int _strnlen(const char *s, int maxlen) {
|
||||
return len;
|
||||
}
|
||||
|
||||
// For RDS2 RFT, and UECP
|
||||
uint16_t crc16_ccitt(char* data, uint16_t len) {
|
||||
uint16_t i, crc=0xFFFF;
|
||||
for (i=0; i < len; i++ ) {
|
||||
crc = (unsigned char)(crc >> 8) | (crc << 8);
|
||||
crc ^= data[i];
|
||||
crc ^= (unsigned char)(crc & 0xff) >> 4;
|
||||
crc ^= (crc << 8) << 4;
|
||||
crc ^= ((crc & 0xff) << 4) << 1;
|
||||
}
|
||||
return ((crc ^= 0xFFFF) & 0xFFFF);
|
||||
}
|
||||
|
||||
static uint16_t offset_words[] = {
|
||||
0x0FC, /* A */
|
||||
0x198, /* B */
|
||||
|
||||
Reference in New Issue
Block a user