From 677c370834102ae43ce19d0931cc98d8267dacc5 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 1 May 2017 12:02:08 +0200 Subject: init --- .gitignore | 29 +++++ .tfignore | 1 + .vs/floppyMusic/v14/.atsuo | Bin 0 -> 34304 bytes floppyMusic.atsln | 22 ++++ floppyMusic/floppy.c | 87 +++++++++++++++ floppyMusic/floppy.h | 30 ++++++ floppyMusic/floppyMusic.componentinfo.xml | 86 +++++++++++++++ floppyMusic/floppyMusic.cproj | 173 ++++++++++++++++++++++++++++++ floppyMusic/main.c | 22 ++++ 9 files changed, 450 insertions(+) create mode 100644 .gitignore create mode 100644 .tfignore create mode 100644 .vs/floppyMusic/v14/.atsuo create mode 100644 floppyMusic.atsln create mode 100644 floppyMusic/floppy.c create mode 100644 floppyMusic/floppy.h create mode 100644 floppyMusic/floppyMusic.componentinfo.xml create mode 100644 floppyMusic/floppyMusic.cproj create mode 100644 floppyMusic/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..176c449 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +Thumbs.db +*.obj +*.exe +*.pdb +*.user +*.aps +*.pch +*.vspscc +*_i.c +*_p.c +*.ncb +*.suo +*.sln.docstates +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug*/ +*.lib +*.sbr +obj/ +[Rr]elease*/ +_ReSharper*/ +[Tt]est[Rr]esult* +*.vssscc +$tf*/ \ No newline at end of file diff --git a/.tfignore b/.tfignore new file mode 100644 index 0000000..e37a9f1 --- /dev/null +++ b/.tfignore @@ -0,0 +1 @@ +\.git \ No newline at end of file diff --git a/.vs/floppyMusic/v14/.atsuo b/.vs/floppyMusic/v14/.atsuo new file mode 100644 index 0000000..706c20b Binary files /dev/null and b/.vs/floppyMusic/v14/.atsuo differ diff --git a/floppyMusic.atsln b/floppyMusic.atsln new file mode 100644 index 0000000..fd00043 --- /dev/null +++ b/floppyMusic.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "floppyMusic", "floppyMusic\floppyMusic.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/floppyMusic/floppy.c b/floppyMusic/floppy.c new file mode 100644 index 0000000..716502a --- /dev/null +++ b/floppyMusic/floppy.c @@ -0,0 +1,87 @@ +/* + * floppy.c + * + * Created: 29.04.2017 17:06:37 + * Author: Jonas + */ + + #include "floppy.h" + +ISR(TIMER0_OVF_vect) +{ + cli(); + + timer_overflow_counter ++; + + *fPORT = 0xff; + + for(uint8_t i = 0; i < 8; i++) + { + if(floppy_nextrun[i] == (timer_overflow_counter + 1)) //Do Stuff. Doesnt work + { + floppy_nextrun[i] += floppy_frequencies[i]; + floppy_pulse(i); + } + } + + sei(); +} + +void floppy_setup(char *_pulse_port, char *_pulse_ddr, char *_direction_port, char *_direction_ddr) + { + //Setup Ports + fPORT = _pulse_port; + fDDR = _pulse_ddr; + dPORT = _direction_port; + dDDR = _direction_ddr; + + *fDDR = 0xff; + *fPORT = 0xff; + *dDDR = 0xff; + *dPORT = 0xff; + + + + //Variable init + timer_overflow_counter = 0; + + for(uint8_t i = 0; i < 8; i++) + { + floppy_head_return_counter[i] = 0; + floppy_frequencies[i] = 0; + floppy_nextrun[i] = 0; + } + + //Return all FDDs to track 0 + + for(uint8_t i = 0; i < 200; i++) + { + _delay_ms(5); + *fPORT ^= 0xff; + } + + *fPORT = 0xff; + + //Setup Timer + TCCR0 |= (1 << CS01); // Prescaler 8, for max Frequency of 488 Hertz for F_CPU = 1MHz + TIMSK |= (1 << TOIE0); //Activate Interrupt + sei(); + } + + void floppy_set_frequency(uint8_t _floppy_id, uint8_t _freq) + { + floppy_frequencies[_floppy_id] = floppy_nextrun[_floppy_id] = _freq; + } + + void floppy_pulse(uint8_t _floppy_id) + { + *fPORT &= ~(1 << _floppy_id); //Activate pin + + floppy_head_return_counter[_floppy_id] ++; + + if(floppy_head_return_counter[_floppy_id] > 75) //Toggle direction pin if more than 75 steps performed + { + *dPORT ^= (1<<_floppy_id); + floppy_head_return_counter[_floppy_id] = 0; + } + } \ No newline at end of file diff --git a/floppyMusic/floppy.h b/floppyMusic/floppy.h new file mode 100644 index 0000000..280bb2f --- /dev/null +++ b/floppyMusic/floppy.h @@ -0,0 +1,30 @@ +/* + * floppy.h + * + * Created: 29.04.2017 17:06:28 + * Author: Jonas + */ + + +#ifndef FLOPPY_H_ +#define FLOPPY_H_ + +#include +#include +#include + +uint8_t timer_overflow_counter; +uint8_t floppy_frequencies[8]; +uint8_t floppy_nextrun[8]; +uint8_t floppy_head_return_counter[8]; + +char *fPORT, *fDDR, *dPORT, *dDDR; //Ports for floppy and Direction of Heads + +void floppy_setup(char *_pulse_port, char *_pulse_ddr, char *_direction_port, char *_direction_ddr); + +void floppy_set_frequency(uint8_t _floppy_id, uint8_t _freq); + +void floppy_pulse(uint8_t _floppy_id); + + +#endif /* FLOPPY_H_ */ \ No newline at end of file diff --git a/floppyMusic/floppyMusic.componentinfo.xml b/floppyMusic/floppyMusic.componentinfo.xml new file mode 100644 index 0000000..7c3c717 --- /dev/null +++ b/floppyMusic/floppyMusic.componentinfo.xml @@ -0,0 +1,86 @@ + + + + + + + Device + Startup + + + Atmel + 1.2.0 + C:/Program Files (x86)\Atmel\Studio\7.0\Packs + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include + + include + C + + + include + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include\avr\iom8.h + + header + C + hDXIougjReqD1inJugv1UA== + + include/avr/iom8.h + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\templates\main.c + template + source + C Exe + 6uB4FLeVljduSJojLjAg+A== + + templates/main.c + Main file (.c) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\templates\main.cpp + template + source + C Exe + YXFphlh0CtZJU+ebktABgQ== + + templates/main.cpp + Main file (.cpp) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega8 + + libraryPrefix + GCC + + + gcc/dev/atmega8 + + + + + ATmega_DFP + C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.132/Atmel.ATmega_DFP.pdsc + 1.2.132 + true + ATmega8 + + + + Resolved + Fixed + true + + + \ No newline at end of file diff --git a/floppyMusic/floppyMusic.cproj b/floppyMusic/floppyMusic.cproj new file mode 100644 index 0000000..71fa9a4 --- /dev/null +++ b/floppyMusic/floppyMusic.cproj @@ -0,0 +1,173 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATmega8 + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + floppyMusic + floppyMusic + floppyMusic + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + + + + + + + + + + + + + com.atmel.avrdbg.tool.stk500 + + 0x1E9307 + + + + + + + + custom + + + Custom Programming Tool + + ISP + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + + + 125000 + + ISP + + com.atmel.avrdbg.tool.stk500 + + + STK500 + + 125000 + + + + + -mmcu=atmega8 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega8" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + + + + + + + -mmcu=atmega8 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega8" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Default (-Wa,-g) + + + + + + compile + + + compile + + + compile + + + + \ No newline at end of file diff --git a/floppyMusic/main.c b/floppyMusic/main.c new file mode 100644 index 0000000..9743636 --- /dev/null +++ b/floppyMusic/main.c @@ -0,0 +1,22 @@ +/* + * floppyMusic.c + * + * Created: 29.04.2017 16:59:57 + * Author : Jonas + */ + +#include + +#include "floppy.h" + +int main(void) +{ + floppy_setup(&PORTC, &DDRC, &PORTD, &DDRD); + floppy_set_frequency(0, 4); + + while (1) + { + + } +} + -- cgit v1.2.3