示例#1
0
文件: crc.c 项目: vaishnavh/CRC
//A function to right shift the divisor by 1 bit
struct Message right_shift_message(struct Message message){
	int i;
	unsigned int last_bit = 0;
	for(i = 4; i >=0; i--){
		unsigned int new_quarter = (message.quarter[i] >> 1) | (last_bit << 31);
		last_bit = GET_LAST_BIT(message.quarter[i]);
		message.quarter[i] = new_quarter;
	}
	return message;
}
示例#2
0
static void print_pins(const uint8_t* buffer)
{
  unsigned int j;

#if 0 /* inline printing */

#define GET_LAST_BIT(N) (((N) & (1 << 7)) >> 7)

  unsigned int i;

  for (i = 0; i < M600_PIN_COUNT / 8; ++i, ++buffer)
    {
      uint8_t n = *buffer;

      for (j = 0; j < 8; ++j, n <<= 1)
	printf("%c", '0' + GET_LAST_BIT(n));

      printf(" ");
    }
#else /* port like printing */

#define GET_FIRST_BIT(N) ((N) & 1)

  int i;
  int k;

  for (k = 1; k >= 0; --k)
    {
      for (i = M600_PIN_COUNT / 8 - 1; i >= 0; --i)
	{
	  uint8_t n = buffer[i] >> k;

	  for (j = 0; j < 4; ++j, n >>= 2)
	    printf("%c", '0' + GET_FIRST_BIT(n));
	  printf(" ");
	}

      printf("\n");
    }
  
#endif

  printf("\n");
}