mikrokontrollersystemer-pro.../prosjekt.X/fan_speeeed.h
2024-04-29 08:57:02 +02:00

58 lines
1.3 KiB
C

/*
* File: fanseeeed.h
* Author: inami, Helle Augland Grasmo
*
* Created on 13. mars 2024, 13:38
*/
#ifndef FANSEEEED_H
#define FANSEEEED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <avr/interrupt.h>
#include <avr/io.h>
/*
The code has inspiration from "Getting Started with Analog comparator(AC)" by Microchip for setting up analog comparrator.
* web link: https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ApplicationNotes/ApplicationNotes/TB3211-Getting-Started-with-AC-DS90003211.pdf
* and inspiration form practice 6 for TCA0 setup
*/
// INITALICE TIMER COUNTER
void init_TCA0();
// UPDATE TIMER PERIOD
void TCA0_update_period_ms (uint16_t timer_period);
// TAKES INN A TIME AND A THE COUNTED FAN DIPS
// RETURNS THE RPM OF THE FAN
uint16_t RPM_calculation(uint16_t edge_counter, uint16_t time_ms);
// INITIALISING FAN PORTS
void init_fan_gpio();
// INIT AC0 TO COMPARE PD6 AND PD7
void init_AC0();
// INIT AC1 TO COMPARE PD4 AND PD7
void init_AC1();
#ifdef __cplusplus
}
#endif
#endif /* FANSEEEED_H */