Commit 655d773a authored by Jan Kasprzak's avatar Jan Kasprzak
Browse files

Make jiffies (timer) about 100 Hz.

parent 37d45fd9
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@

volatile static unsigned char current_adc, current_slow_adc;
static uint16_t adc_sum, read_zero, drop_count, read_count, n_reads_log;
volatile uint16_t jiffies;

static void setup_mux(unsigned char n)
{
@@ -146,10 +147,15 @@ static void adc1_gain20_adc(uint16_t adcsum)

static void inline adc_based_timer()
{
	static uint16_t pattern_counter;
	static unsigned char count;

	if (++pattern_counter > 250) {
		pattern_counter = 0;
	if (++count < 40) // about 100 Hz jiffies
		return;

	count = 0;
	++jiffies;

	if ((jiffies & 0x0007) == 0) {
		patterns_next_tick();
	}
}
+1 −5
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ void inline log_word(uint16_t word) { }

/* adc.c */
#define PWMLED_ADC_SHIFT 1 /* 1<<1 measurements per single callback */
extern volatile uint16_t jiffies;
void init_adc();
void susp_adc();
void timer_start_slow_adcs();
@@ -35,11 +36,6 @@ void susp_pwm();
void pwm_off();
void pwm_set(uint8_t stride);

/* tmr.c */
extern volatile uint16_t jiffies;
void init_tmr();
void susp_tmr();

/* pwmled.c */
void init_pwmled();
void pwmled_adc(uint16_t adcval);