Пример #1
0
static size_t lha_pm2_decoder_read(void *data, uint8_t *buf)
{
	LHAPM2Decoder *decoder = data;
	size_t result;
	int code;

	// On first pass through, build initial lookup trees.

	if (decoder->tree_state == PM2_REBUILD_UNBUILT) {

		// First bit in stream is discarded?

		read_bit(&decoder->bit_stream_reader);
		rebuild_tree(decoder);
	}

	result = 0;

	code = read_from_tree(&decoder->bit_stream_reader, decoder->code_tree);

	if (code < 0) {
		return 0;
	}

	if (code < 8) {
		read_single_byte(decoder, (unsigned int) code, buf, &result);
	} else {
		copy_from_history(decoder, (unsigned int) code - 8,
		                  buf, &result);
	}

	return result;
}
Пример #2
0
 char* Extsram::verify_sram_with_rand(char* str, uint8_t num_of_runs){
	//leds_control l;
	char status_ok[] PROGMEM = "sram verification succesfull";
	char status_nok[] PROGMEM = "rand sram verification failed at address:";
	char tmp_string[6];
	address_result result;
	uint16_t a;
	result.result = ok;
	result.addr = 0;
	uint8_t rand_d;
	for(uint16_t r=0; r <= num_of_runs; r++){
		//l.L1 = l.sw;
		for(a=0; a<EXTSRAM_SIZ; a++){
			rand_d = rand();
			write_single_byte(a, rand_d);
			if(read_single_byte(a) != rand_d){
				result.addr = a;
				result.result = nok;
				break;
			}
		}
	}
	if(not result.result){
		strcpy(str, status_nok);
		utoa(result.addr, tmp_string, 10);
		strcat(str, tmp_string);
	}
	else{
		strcpy(str, status_ok);
	}
	return str;
}