Skip to content

Commit

Permalink
Pass the correct type to sizeof
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Foukarakis committed Sep 18, 2013
1 parent 52fb90c commit 965cba6
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions lfsr.c
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
/*
* @file lfsr.c
* @author Michael Foukarakis
* @version 1.1
* @file lfsr.c
* @author Michael Foukarakis
* @version 1.1
* @date
* Created: Wed Feb 02, 2011 18:47 EET
* Last Update: Tue Mar 26, 2013 12:40 GTB Standard Time
* Created: Wed Feb 02, 2011 18:47 EET
* Last Update: Wed Sep 18, 2013 13:54 BST
*------------------------------------------------------------------------
* Description: Galois LFSR software implementation
* WARNING:
* Polynomial representation: x^4 + x^3 + 1 = 11001 = 0x19
* Description: Galois LFSR software implementation
* WARNING:
* Polynomial representation: x^4 + x^3 + 1 = 11001 = 0x19
*
* Well-known polynomials:
* CRC-12 : x^12 + x^11 + x^3 + x^2 + x + 1
* CRC-16-IBM : x^16 + x^15 + x^2 + 1
* CRC-16-DECT : x^16 + x^10 + x^8 + x^7 + x^3 + 1
* CCITT : x^16 + x^12 + x^5 + 1
* CRC-32-IEEE : x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
* CRC-12 : x^12 + x^11 + x^3 + x^2 + x + 1
* CRC-16-IBM : x^16 + x^15 + x^2 + 1
* CRC-16-DECT : x^16 + x^10 + x^8 + x^7 + x^3 + 1
* CCITT : x^16 + x^12 + x^5 + 1
* CRC-32-IEEE : x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
*
* Spread-spectrum sequences:
* 7-bit : x^7 + x + 1
* 13-bit : x^13 + x^4 + x^3 + 1
* 19-bit : x^19 + x^5 + x^2 + x + 1
* 7-bit : x^7 + x + 1
* 13-bit : x^13 + x^4 + x^3 + 1
* 19-bit : x^19 + x^5 + x^2 + x + 1
*
* Used in A5:
* x^19 + x^5 + x^2 + x + 1
Expand All @@ -36,25 +36,25 @@
* http://homepage.mac.com/afj/taplist.html
* http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf
*------------------------------------------------------------------------
* History: None yet
* TODO: Nothing yet
* History: None yet
* TODO: Nothing yet
*------------------------------------------------------------------------
*/
#include "lfsr.h"

void GLFSR_init(lfsr_t *glfsr, lfsr_data_t polynom, lfsr_data_t seed_value)
{
lfsr_data_t seed_mask;
unsigned int shift = 8 * sizeof(lfsr_data) - 1;
unsigned int shift = 8 * sizeof lfsr_data_t - 1;

glfsr->polynomial = polynom | 1;
glfsr->data = seed_value;

seed_mask = 1;
seed_mask <<= shift;

while(shift--) {
if(polynom & seed_mask) {
while (shift--) {
if (polynom & seed_mask) {
glfsr->mask = seed_mask;
break;
}
Expand All @@ -69,7 +69,7 @@ unsigned char GLFSR_next(lfsr_t *glfsr)

glfsr->data <<= 1;

if(glfsr->data & glfsr->mask) {
if (glfsr->data & glfsr->mask) {
retval = 1;
glfsr->data ^= glfsr->polynomial;
}
Expand Down

0 comments on commit 965cba6

Please sign in to comment.