Esempio n. 1
0
File: encode.c Progetto: elyl/lzw
void encode(t_enc *ctx)
{
  char			str[BUFFER_SIZE];
  int			size;
  int			i;
  t_elem		*tmp;
  
  init_enc(ctx);
  while ((size = read(ctx->fin, &str[0], BUFFER_SIZE)))
    {
      i = 0;
      while (i < size)
	{
	  tmp = search_str(str[i], ctx->code, ctx);
	  if (tmp == NULL)
	    {
	      write_bits(ctx, ctx->code, ctx->nbits);
	      add_str(str[i], ctx->code, ctx);
	      ctx->code = str[i];	     
	    }
	  else
	    ctx->code = tmp->code;
	  if (ctx->code_max == (1 << ctx->nbits))
	    ctx->code_max++;
	  i++;
	}
    }
}
Esempio n. 2
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_spi();
    init_enc();

    ENC_MISO = &D[1];
    ENC_MOSI = &D[0];
    ENC_SCK = &D[2];
    ENC_NCS = &D[3];

    pin_digitalOut(ENC_NCS);
    pin_set(ENC_NCS);

    spi_open(&spi1, ENC_MISO, ENC_MOSI, ENC_SCK, 2e6, 1);

    InitUSB();                              // initialize the USB registers and serial interface engine
    while (USB_USWSTAT!=CONFIG_STATE) {     // while the peripheral is not configured...
        ServiceUSB();                       // ...service USB requests
    }
    while (1) {
        ServiceUSB();                       // service any pending USB requests
    }
}
Esempio n. 3
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_timer();
    init_oc();
    init_spi();
    init_enc();
    init_md();
    init_motor();

    // (&motor1)->vel_set = 360.0;

    InitUSB();
    while (USB_USWSTAT!=CONFIG_STATE) {
        ServiceUSB();
    }
    while (1) {
        ServiceUSB();
    }
}