<commit_before>/*
  wpulse.cpp - pulseIn() function for 86Duino
  Copyright (c) 2013 Android Lin <<EMAIL>>. All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <stdio.h>
#include "Arduino.h"
#include "io.h"


unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) {
	uint8_t _state;
	unsigned long long int _timeout, now_time, width = 0L;
	
	if(pin >= PINS) return 0x00;
	
	_timeout = ((unsigned long long int)timeout)*333L + timer_GetClocks64(); // CPUCLK = 300MHz
	while(digitalRead(pin) == state)
		if(timer_GetClocks64() >= _timeout)
			return 0;
	while(digitalRead(pin) != state)
		if(timer_GetClocks64() >= _timeout)
			return 0;
	now_time = timer_GetClocks64();
	while(digitalRead(pin) == state)
		if(timer_GetClocks64() >= _timeout)
			return 0;
	width = timer_GetClocks64() - now_time;
	width = (unsigned long long int)(width * 0.00333); // CPUCLK = 300MHz
  
	return ((unsigned long)width); // unit is micro second 
}<commit_msg>pulseIn() will get CPU freq to work<commit_after>/*
  wpulse.cpp - pulseIn() function for 86Duino
  Copyright (c) 2013 Android Lin <<EMAIL>>. All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <stdio.h>
#include "Arduino.h"
#include "io.h"


unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) {
	uint8_t _state;
	unsigned long long int _timeout, now_time, width = 0L;
	
	if(pin >= PINS) return 0x00;
	
	_timeout = ((unsigned long long int)timeout)*vx86_CpuCLK() + timer_GetClocks64();
	while(digitalRead(pin) == state)
		if(timer_GetClocks64() >= _timeout)
			return 0;
	while(digitalRead(pin) != state)
		if(timer_GetClocks64() >= _timeout)
			return 0;
	now_time = timer_GetClocks64();
	while(digitalRead(pin) == state)
		if(timer_GetClocks64() >= _timeout)
			return 0;
	width = timer_GetClocks64() - now_time;
	width = (unsigned long long int)(width * (1.0/vx86_CpuCLK()));
  
	return ((unsigned long)width); // unit is micro second 
}
{'fraction_non_alphanumeric': 0.08926961226330027, 'fraction_numerical': 0.03095882176134656, 'mean_word_length': 4.2, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6473862', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1006, 'n_words': 414}