Commit 0a3a6464 authored by Alexander Detsch's avatar Alexander Detsch
Browse files

Logik für LCDs implementiert, ungetestet

parent 45ff0677
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
SHELL := cmd.exe
RM := rm -rf
USER_OBJS :=
LIBS :=
PROJ :=
O_SRCS :=
C_SRCS :=
S_SRCS :=
S_UPPER_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
PREPROCESSING_SRCS :=
OBJS :=
OBJS_AS_ARGS :=
C_DEPS :=
C_DEPS_AS_ARGS :=
EXECUTABLES :=
OUTPUT_FILE_PATH :=
OUTPUT_FILE_PATH_AS_ARGS :=
AVR_APP_PATH :=$$$AVR_APP_PATH$$$
QUOTE := "
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:=
LIB_DEP:=
LINKER_SCRIPT_DEP:=
# Every subdirectory with source files must be described here
SUBDIRS := \
../lib
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../lib/i2c.c \
../lib/Lcd.cpp \
../lib/Shiftregister.cpp \
../main.cpp
PREPROCESSING_SRCS +=
ASM_SRCS +=
OBJS += \
lib/i2c.o \
lib/Lcd.o \
lib/Shiftregister.o \
main.o
OBJS_AS_ARGS += \
lib/i2c.o \
lib/Lcd.o \
lib/Shiftregister.o \
main.o
C_DEPS += \
lib/i2c.d \
lib/Lcd.d \
lib/Shiftregister.d \
main.d
C_DEPS_AS_ARGS += \
lib/i2c.d \
lib/Lcd.d \
lib/Shiftregister.d \
main.d
OUTPUT_FILE_PATH +=LCD-Treiberplatine.elf
OUTPUT_FILE_PATH_AS_ARGS +=LCD-Treiberplatine.elf
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:= ./makedep.mk
LIB_DEP+=
LINKER_SCRIPT_DEP+=
# AVR32/GNU C Compiler
lib/%.o: ../lib/%.c
@echo Building file: $<
@echo Invoking: AVR8/GNU C Compiler : 4.9.2
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
lib/%.o: ../lib/%.cpp
@echo Building file: $<
@echo Invoking: AVR8/GNU C Compiler : 4.9.2
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe$(QUOTE) -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p" -c -std=c++11 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
./%.o: .././%.cpp
@echo Building file: $<
@echo Invoking: AVR8/GNU C Compiler : 4.9.2
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe$(QUOTE) -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p" -c -std=c++11 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
# AVR32/GNU Preprocessing Assembler
# AVR32/GNU Assembler
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES)
$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP)
@echo Building target: $@
@echo Invoking: AVR8/GNU Linker : 4.9.2
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="LCD-Treiberplatine.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p"
@echo Finished building target: $@
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "LCD-Treiberplatine.elf" "LCD-Treiberplatine.hex"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "LCD-Treiberplatine.elf" "LCD-Treiberplatine.eep" || exit 0
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "LCD-Treiberplatine.elf" > "LCD-Treiberplatine.lss"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "LCD-Treiberplatine.elf" "LCD-Treiberplatine.srec"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "LCD-Treiberplatine.elf"
# Other Targets
clean:
-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)
-$(RM) $(C_DEPS_AS_ARGS)
rm -rf "LCD-Treiberplatine.elf" "LCD-Treiberplatine.a" "LCD-Treiberplatine.hex" "LCD-Treiberplatine.lss" "LCD-Treiberplatine.eep" "LCD-Treiberplatine.map" "LCD-Treiberplatine.srec" "LCD-Treiberplatine.usersignatures"
\ No newline at end of file
################################################################################
# Automatically-generated file. Do not edit or delete the file
################################################################################
lib\i2c.c
lib\Lcd.cpp
lib\Shiftregister.cpp
main.cpp
......@@ -124,6 +124,7 @@
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcccpp.compiler.optimization.DebugLevel>Default (-g2)</avrgcccpp.compiler.optimization.DebugLevel>
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
<avrgcccpp.compiler.miscellaneous.OtherFlags>-std=c++11</avrgcccpp.compiler.miscellaneous.OtherFlags>
<avrgcccpp.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
......
......@@ -10,11 +10,47 @@
#include "Lcd.h"
// default constructor
Lcd::Lcd() {
Lcd::Lcd(volatile uint8_t *shiftPort, volatile uint8_t *shiftDDR, uint8_t shiftData, uint8_t shiftSCK, uint8_t shiftRCK) {
lcds[count++] = &this;
shiftr.init(shiftPort, shiftDDR, shiftData, shiftSCK, shiftRCK); // initialize the Shiftregister-object
// initialize timer
cli();
TCNT0 = 0; // aktuellen Zhlerstand auf 0 setzen
TIMSK0 |= (1<<OCIE0A); // Compare Interrupt erlauben
TCCR0A |= (1<<WGM01); // CTC Modus
TCCR0B |= (1<<CS00) | (1<<CS02) | (1<<ICES1); // Vorteiler 1024, rising edge
OCR0A = 255; // Nach 249 Schritten berlaufen (Index 0) --> Genau jede 1ms
sei();
} //Lcd
void Lcd::setNewData(uint8_t *_data[]) {
for (int i = 0; i < 4; i++) {
data[i] = *_data[i];
dataInverted[i] = ~(*_data[i]);
}
}
void Lcd::shiftDataOut() {
if (lastTimeInverted) {
for (int i = 0; i < 3; i++) shiftr.shift(data[i]); // only until the penultimate byte.
shiftr.shift(data[3], true); // ... the last byte gets the "shift-command" with
} else {
for (int i = 0; i < 3; i++) shiftr.shift(dataInverted[i]); // only until the penultimate byte.
shiftr.shift(dataInverted[3], true); // ... the last byte gets the "shift-command" with
}
lastTimeInverted = !lastTimeInverted;
}
void Lcd::schedule() {
for (int i = 0; i < count; i++) lcds[i]->shiftDataOut();
}
// default destructor
Lcd::~Lcd() {
} //~Lcd
ISR(TIMER0_COMPA_vect) {
Lcd::schedule();
}
\ No newline at end of file
......@@ -10,6 +10,10 @@
#ifndef __LCD_H__
#define __LCD_H__
#include <inttypes.h>
#include "Shiftregister.h"
#include <avr/interrupt.h>
class Lcd {
//variables
......@@ -17,26 +21,26 @@ class Lcd {
protected:
private:
static Lcd *lcds[4]; // pointer to all instances of lcds
static uint8_t count = 0; // current number of connected lcds
static uint8_t count; // current number of connected lcds
uint8_t data[4]; // non-inverted data that has to be send
uint8_t dataInverted[4]; // inverted data to be send
volatile uint8_t data[4]; // non-inverted data that has to be send
volatile uint8_t dataInverted[4]; // inverted data to be send
bool lastTimeInverted = false; // indicates, that last time the inverted data were send
Shiftregister shiftr;
//functions
public:
Lcd(volatile uint8_t *shiftPort, volatile uint8_t *shiftDDR, volatile uint8_t *shiftData, volatile uint8_t *shiftSCK, volatile uint8_t *shiftRCK); //constructor; just pass the port-configuration
Lcd(volatile uint8_t *shiftPort, volatile uint8_t *shiftDDR, uint8_t shiftData, uint8_t shiftSCK, uint8_t shiftRCK); //constructor; just pass the port-configuration
~Lcd();
void setNewData(uint8_t *_data[]); // set new data for the buffer. We assume, that we have a static number of 4 bytes per array. Cry, if not.
protected:
void shiftDataOut(); // just shift the data out. One time the data, the other time the inverted data
private:
Lcd( const Lcd &c );
Lcd& operator=( const Lcd &c );
static void schedule(); // send out the next data to the shiftregister
static void schedule(); // send out the next data to the shiftregister
setNewData(uint8_t *data[]); // set new data for the buffer. We assume, that we have a static number of 4 bytes per array. Cry, if not.
}; //Lcd
#endif //__LCD_H__
......@@ -9,11 +9,22 @@
#include "Shiftregister.h"
// default constructor
Shiftregister::Shiftregister()
Shiftregister::Shiftregister() {} // empty constructor
Shiftregister::Shiftregister(volatile uint8_t *_shiftPort, volatile uint8_t *_shiftDDR, uint8_t _shiftData, uint8_t _shiftSCK, uint8_t _shiftRCK)
{
*shiftDDR |= ( (1<<shiftSCK) | (1<<shiftRCK) | (1<<shiftData) ); // Make that pins output
init(_shiftPort, _shiftDDR, _shiftData, _shiftSCK, _shiftRCK); // just pass the parameters
} //SHIFTREGISTER
void Shiftregister::init(volatile uint8_t *_shiftPort, volatile uint8_t *_shiftDDR, uint8_t _shiftData, uint8_t _shiftSCK, uint8_t _shiftRCK) {
shiftPort = _shiftPort;
shiftDDR = _shiftDDR;
shiftData = _shiftData;
shiftSCK = _shiftSCK;
shiftRCK = _shiftRCK;
*shiftDDR |= ( (1<<shiftSCK) | (1<<shiftRCK) | (1<<shiftData) ); // Make that pins output
}
// Sends one C-clock-wide high pulse on SCK-clock-line (Shift-clock)
// --> next bit can be shifted in
void Shiftregister::pulse() {
......
......@@ -29,13 +29,15 @@ protected:
private:
volatile uint8_t *shiftPort;
volatile uint8_t *shiftDDR;
volatile uint8_t *shiftData; // Data pin (DS) pin location
volatile uint8_t *shiftSCK; // Shift Clock (SH_CP) pin location
volatile uint8_t *shiftRCK; // Store Clock (ST_CP) pin location
uint8_t shiftData; // Data pin (DS) pin location
uint8_t shiftSCK; // Shift Clock (SH_CP) pin location
uint8_t shiftRCK; // Store Clock (ST_CP) pin location
//functions
public:
Shiftregister();
Shiftregister(volatile uint8_t *_shiftPort, volatile uint8_t *_shiftDDR, uint8_t _shiftData, uint8_t _shiftSCK, uint8_t _shiftRCK);
void init(volatile uint8_t *_shiftPort, volatile uint8_t *_shiftDDR, uint8_t _shiftData, uint8_t _shiftSCK, uint8_t _shiftRCK);
~Shiftregister();
void shift(uint8_t data, bool _latch = false);
protected:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment