From 7b703bbd125e920f65197b9439234ead6903167c Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Mon, 9 Dec 2013 22:34:07 +0100 Subject: Restructure code a bit --- ferment.c | 130 -------------------------------------------------------------- 1 file changed, 130 deletions(-) delete mode 100644 ferment.c (limited to 'ferment.c') diff --git a/ferment.c b/ferment.c deleted file mode 100644 index 1d282d2..0000000 --- a/ferment.c +++ /dev/null @@ -1,130 +0,0 @@ -//#define F_CPU 7372800UL -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "stdio.h" -#include "pid.h" - -/* port D - * - * 4 1- (NMOS, inverted) - * 5 1+ (PMOS) - * 6 2- (NMOS, inverted) - * 7 2+ (PMOS) - * - */ - -#define D_1_MINUS (1 << 4) -#define D_1_PLUS (1 << 5) -#define D_2_MINUS (1 << 6) -#define D_2_PLUS (1 << 7) - -const int target_temp = 30; -volatile uint16_t adc_res; -volatile uint8_t adc_new; - -struct PID_DATA pid_data; - -/* Turns the H-bridge off, putting the output - * into high impedance mode. */ -static void bridge_off(void) -{ - PORTD |= D_1_MINUS | D_2_MINUS; - PORTD &= ~(D_1_PLUS | D_2_PLUS); -} - -/* Turns the H-bridge on, setting 1+ 2- */ -static void bridge_on_heat(void) -{ - bridge_off(); - _delay_ms(100); - PORTD |= D_1_PLUS; - PORTD &= ~D_2_MINUS; -} - -/* Turns the H-bridge on, setting 1- 2+ */ -static void bridge_on_cool(void) -{ - bridge_off(); - _delay_ms(100); - PORTD |= D_2_PLUS; - PORTD &= ~D_1_MINUS; -} - -/* Initializes the output port needed for the H-bridge */ -static void bridge_init(void) -{ - bridge_off(); - DDRD |= D_1_PLUS | D_1_MINUS | D_2_PLUS | D_2_MINUS; -} - -/* initializes ADC */ -static void adc_init(void) -{ - adc_new = 0; - ADMUX = (1 << REFS1) | (1 << REFS0); - /* select channel x (0 for now) */ - ADMUX |= 0x0; - ADCSRA = (1 << ADEN) | (1 << ADIE) | (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); -} - -/* reads ADC */ -static void start_temp_conv(void) -{ - ADCSRA |= (1<