mikrokontrollersystemer-pro.../prosjekt.X/fan-speed.h

64 lines
1.6 KiB
C
Raw Permalink Normal View History

2024-03-13 12:39:35 +00:00
/*
* File: fanseeeed.h
2024-04-27 16:45:04 +00:00
* Author: inami, Helle Augland Grasmo
2024-03-13 12:39:35 +00:00
*
* Created on 13. mars 2024, 13:38
*/
2024-03-19 11:59:56 +00:00
2024-03-13 12:39:35 +00:00
#ifndef FANSEEEED_H
#define FANSEEEED_H
#ifdef __cplusplus
extern "C" {
#endif
2024-03-20 11:33:03 +00:00
#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>
2024-04-27 16:45:04 +00:00
/*
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
*/
2024-04-27 16:45:04 +00:00
// Fan history variables
extern volatile uint16_t fan1_history[512];
extern volatile uint16_t fan2_history[512];
// Fan history index variable
extern volatile uint16_t fan1_history_index;
extern volatile uint16_t fan2_history_index;
2024-04-09 12:53:32 +00:00
2024-04-27 15:31:00 +00:00
// INITALICE TIMER COUNTER
2024-04-24 12:24:40 +00:00
void init_TCA0();
2024-04-27 15:31:00 +00:00
2024-04-27 16:45:04 +00:00
// UPDATE TIMER PERIOD
void TCA0_update_period_ms (uint16_t timer_period);
2024-04-27 15:31:00 +00:00
// TAKES INN A TIME AND A THE COUNTED FAN DIPS
// RETURNS THE RPM OF THE FAN
2024-04-27 16:45:04 +00:00
uint16_t RPM_calculation(uint16_t edge_counter, uint16_t time_ms);
2024-04-27 15:31:00 +00:00
// INITIALISING FAN PORTS
2024-04-27 16:45:04 +00:00
void init_fan_gpio();
2024-04-27 15:31:00 +00:00
// INIT AC0 TO COMPARE PD6 AND PD7
2024-04-27 16:45:04 +00:00
void init_AC0();
2024-04-27 15:31:00 +00:00
// INIT AC1 TO COMPARE PD4 AND PD7
2024-04-27 16:45:04 +00:00
void init_AC1();
2024-04-24 12:24:40 +00:00
2024-03-13 12:39:35 +00:00
#ifdef __cplusplus
}
#endif
#endif /* FANSEEEED_H */