]> jspc29.x-matter.uni-frankfurt.de Git - avr.git/commitdiff
first version of pt100
authorJan Michel <j.michel@gsi.de>
Mon, 3 Aug 2015 16:20:04 +0000 (18:20 +0200)
committerJan Michel <j.michel@gsi.de>
Mon, 3 Aug 2015 16:20:04 +0000 (18:20 +0200)
.gitignore
pt100/Makefile
pt100/main.c
pt100/main.h

index bad5cf93b880f2c6bcf7988fa1c03dd69b2043c2..884d762f475798713ad4a40d7faa7ef3fe7ffd0c 100644 (file)
@@ -4,3 +4,6 @@
 *.o
 *.d
 .kateproject.d
+*lss
+*.font
+LICENSE
index 143fc012e74dad39e9f0d74081059c8c2fe0f337..61201f887d4061b3f54d3c2e216ce59a6b2a676b 100644 (file)
@@ -5,12 +5,16 @@
 # (GNU make, BSD make, SysV make)
 
 
-MCU = attiny441
+MCU = atmega1284p
 FORMAT = ihex
-TARGET = PowerSwitch
-SRC = $(TARGET).c
+TARGET = main
+SRC = $(TARGET).c lcdlib/lcd-color-graphic.c lcdlib/font.c \
+      lcdlib/Fonts/digits_24px.c lcdlib/Fonts/digits_32px.c lcdlib/Fonts/font_proportional_16px.c \
+      lcdlib/Fonts/font_proportional_8px.c lcdlib/Fonts/symbols_16px.c
 ASRC = 
-OPT = s
+OPT = 2
+
+#usb/usb_serial.c        1wire.c 
 
 # Name of this Makefile (used for "make depend").
 MAKEFILE = Makefile
@@ -28,17 +32,17 @@ DEBUG = stabs
 CSTANDARD = -std=gnu99
 
 # Place -D or -U options here
-CDEFS =
+CDEFS = -DF_CPU=8000000UL
 
 # Place -I options here
-CINCS =
+CINCS = 
 
 
 CDEBUG = -g$(DEBUG)
-CWARN = -Wall -Wstrict-prototypes
-CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CWARN = -Wall -Wstrict-prototypes 
+CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums  -Wl,--relax
 #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
-CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
+CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) $(CTUNING)
 
 
 #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
@@ -82,7 +86,7 @@ LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
 
 # Programming support using avrdude. Settings and variables.
 
-AVRDUDE_PROGRAMMER = usbtiny
+AVRDUDE_PROGRAMMER = dragon_jtag
 AVRDUDE_PORT = usb
 
 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
@@ -96,7 +100,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
 
 # Uncomment the following if you do /not/ wish a verification to be
 # performed after programming the device.
-#AVRDUDE_NO_VERIFY = -V
+AVRDUDE_NO_VERIFY = -V
 
 # Increase verbosity level.  Please use this when submitting bug
 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
@@ -131,7 +135,7 @@ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 # Default target.
 all: build
 
-build: elf hex eep
+build: elf hex eep lss
 
 elf: $(TARGET).elf
 hex: $(TARGET).hex
@@ -145,8 +149,9 @@ program: $(TARGET).hex $(TARGET).eep
        $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
 
 
-
-
+size: 
+       $(SIZE)  $(TARGET).elf
+#-C --mcu=$(MCU)  
 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
 COFFCONVERT=$(OBJCOPY) --debugging \
 --change-section-address .data-0x800000 \
@@ -220,4 +225,10 @@ depend:
                >> $(MAKEFILE); \
        $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
 
-.PHONY:        all build elf hex eep lss sym program coff extcoff clean depend
+.PHONY:        all build elf hex eep lss sym program coff extcoff clean depend program_bootloader program_arduino
+
+program_bootloader: all
+       dfu-programmer $(MCU) erase && dfu-programmer $(MCU) flash $(TARGET).hex && dfu-programmer $(MCU) start
+
+program_arduino: all
+       avrdude -patmega32u4 -cavr109 -P$(PORT) -b57600 -D -Uflash:w:$(TARGET).hex:i
index 607918406c7b157295985355d1b44e12fef5cf44..92553811de12579a5058705ece3486b4b1253015 100644 (file)
@@ -1,4 +1,4 @@
-#define F_CPU 8000000UL
+
 
 #include <avr/interrupt.h>
 #include <util/delay.h>
@@ -6,15 +6,59 @@
 #include <avr/eeprom.h>
 #include <string.h>
 
-#define FIRMWARE_VERSION 0x01
+#include "main.h"
+#include "lcdlib/lcd-color-graphic.h"
+#include "lcdlib/font.h"
+
 
 
+
+/******************
+ * Init USART for LCD
+ *****************/
+void init_spi_lcd(void) {
+  UCSR1B = (1 << TXEN1);
+  UCSR1C = (1 << UMSEL10) | (0 << UDORD1) | (0 << UCPHA1) | (0 << UCPOL1);
+  UBRR1L = 0;
+  UBRR1H = 0;
+}
+
+
+/******************
+ * Init all functions
+ *****************/
 void init(void) {
+  
+//Init ADC SPI
+  SPCR  = (0 << SPIE) | (1 << SPE ) | (0 << DORD) | (1 << MSTR) | (0 << CPOL) | (0 << CPHA) | (0 << SPR0);
+  SPSR  = (1 << SPI2X);  //fcpu/8
+  DDRB |= (1 << PB7) | (1 << PB5) | (1 << PB4); //ADC has three control lines
+//Init ADC for presence measurement
+  ADMUX  = (3 << REFS0) | (1 << ADLAR) | (3 << MUX0);
+  ADCSRA = (1 << ADEN) | (0 << ADIE) | (5 << ADPS0);  //fcpu/32
+  DIDR0  = 0x08;  //PA3 is analog only
+
+//Init UART  
+  
+//GPIO
+  PORTD |= (0xc0);  //pull-up for switches
+  PORTA |= (0x07);  //spare I/O have pull-up
+  
+  DDRB  |= (0x03);  //LED are output
+  DDRA  |= (0x70);  //select outputs
+  DDRC  |= (0xc0);  //outputs for Inhibit signals
+  
+  
 }
 
 
-void main(void) {
+int main(void) {
+  
  init();
+ lcd_init();
 
  while(1);
+ return 0;
 }
\ No newline at end of file
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ce689988e6514874715646f9b67bbe6fa2fef8fd 100644 (file)
@@ -0,0 +1,24 @@
+
+
+#define FIRMWARE_VERSION 0x01
+
+#define UDORD1 2
+#define UCPHA1 1
+
+#define ADC_SELECT()     PORTB &= ~(1<< PB4)
+#define ADC_UNSELECT()   PORTB |=  (1<< PB4)
+
+#define LED1_ON()         PORTB |=  (1<< PB1)
+#define LED1_OFF()        PORTB &= ~(1<< PB1)
+#define LED2_ON()         PORTB |=  (1<< PB0)
+#define LED2_OFF()        PORTB &= ~(1<< PB0)
+
+#define SWITCH1()         ((PIND>>PD6)&1)
+#define SWITCH2()         ((PIND>>PD7)&1)
+
+#define SELECT(i)         (PORTA = (PORTA & 0x8F) | (((i)&0x7) << 4)
+
+#define MUX_C_ON()        PORTC &= ~(1<<PC7)
+#define MUX_C_OFF()       PORTC |=  (1<<PC7)
+#define MUX_T_ON()        PORTC &= ~(1<<PC6)
+#define MUX_T_OFF()       PORTC |=  (1<<PC6)
\ No newline at end of file