Commit 699b58ab authored by Snorre Nilssen Vestli's avatar Snorre Nilssen Vestli

initial commit

parents

Microsoft Visual Studio Solution File, Format Version 12.00
# Atmel Studio Solution File, Format Version 11.00
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "unfuck", "unfuck\unfuck.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
/*
* gpio_config.h
*
* Created: 14/07/2016 16:54:34
* Author: Snorre
*/
#ifndef GPIO_CONFIG_H_
#define GPIO_CONFIG_H_
#include <avr/io.h>
#warning dummy values!
#define GPIO_SIGNAL_INPUT_PORT PORTC
#define GPIO_SIGNAL_INPUT_PIN PINC
#define GPIO_SIGNAL_INPUT_PIN0 0
#define GPIO_ONTIME_HEX_PORT (PORTB)
#define GPIO_ONTIME_HEX_PIN (PINB)
#define GPIO_ONTIME_HEX_PIN0 0
#define GPIO_ONTIME_HEX_PIN1 1
#define GPIO_ONTIME_HEX_PIN2 2
#define GPIO_ONTIME_HEX_PIN3 3
#define GPIO_OFFTIME_HEX_PORT (PORTB)
#define GPIO_OFFTIME_HEX_PIN (PINB)
#define GPIO_OFFTIME_HEX_PIN0 4
#define GPIO_OFFTIME_HEX_PIN1 5
#define GPIO_OFFTIME_HEX_PIN2 6
#define GPIO_OFFTIME_HEX_PIN3 7
#define GPIO_SIGNAL_INPUT_PIN0_bm (1 << GPIO_SIGNAL_INPUT_PIN0)
#define GPIO_ONTIME_HEX_PIN0_bm (1 << GPIO_ONTIME_HEX_PIN0)
#define GPIO_ONTIME_HEX_PIN1_bm (1 << GPIO_ONTIME_HEX_PIN1)
#define GPIO_ONTIME_HEX_PIN2_bm (1 << GPIO_ONTIME_HEX_PIN2)
#define GPIO_ONTIME_HEX_PIN3_bm (1 << GPIO_ONTIME_HEX_PIN3)
#define GPIO_OFFTIME_HEX_PIN0_bm (1 << GPIO_OFFTIME_HEX_PIN0)
#define GPIO_OFFTIME_HEX_PIN1_bm (1 << GPIO_OFFTIME_HEX_PIN1)
#define GPIO_OFFTIME_HEX_PIN2_bm (1 << GPIO_OFFTIME_HEX_PIN2)
#define GPIO_OFFTIME_HEX_PIN3_bm (1 << GPIO_OFFTIME_HEX_PIN3)
#endif /* GPIO_CONFIG_H_ */
\ No newline at end of file
/*
* tesla_config.h
*
* Created: 14/07/2016 16:56:53
* Author: Snorre
*/
#ifndef TESLA_CONFIG_H_
#define TESLA_CONFIG_H_
#warning dummy values!
uint8_t ontime_table[16] = {
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0
};
uint8_t offtime_table[16] = {
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0
};
#endif /* TESLA_CONFIG_H_ */
\ No newline at end of file
/*
* adc.c
*
* Created: 14/07/2016 16:33:10
* Author: Snorre
*/
#include <avr/io.h>
#include "adc.h"
#define SMOOOTH 4
#define ADC_ONTIME_SELECT 0
#define ADC_OFFTIME_SELECT 1
uint16_t adc_val_ontime = 0,adc_val_offtime = 0, adc_buf_ontime[SMOOOTH], adc_buf_offtime[SMOOOTH];
uint8_t adc_ontime_iterator, adc_offtime_iterator, adc_channel_select;
void adc_init()
{
//TODO:
//enable
//set divisor
//set mode
//set mux
//start
}
void adc_update()
{
//TODO:if done {
if (adc_channel_select = ADC_OFFTIME_SELECT) {
adc_buf_offtime[adc_offtime_iterator] = ADC;
adc_offtime_iterator++;
adc_offtime_iterator %= SMOOTH;
//TODO:change channel
adc_channel_select = ADC_ONTIME_SELECT;
adc_val_offtime = 0;
for (uint8_t i = 0; i < SMOOOTH; i++){
adc_val_offtime += adc_buf_offtime[i];
}
} else {
adc_buf_ontime[adc_ontime_iterator] = ADC;
adc_ontime_iterator++;
adc_ontime_iterator %= SMOOTH;
//TODO:change channel
adc_channel_select = ADC_OFFTIME_SELECT;
adc_val_offtime = 0;
for (uint8_t i = 0; i < SMOOOTH; i++){
adc_val_ontime += adc_buf_ontime[i];
}
}
//TODO:start sampler
//}
}
uint16_t adc_ontime()
{
return adc_val_ontime;
}
uint16_t adc_offtime()
{
return adc_val_offtime;
}
\ No newline at end of file
/*
* adc.h
*
* Created: 14/07/2016 16:28:35
* Author: Snorre
*/
#ifndef ADC_H_
#define ADC_H_
#include <inttypes.h>
void adc_init();
void adc_update();
uint16_t adc_ontime();
uint16_t adc_offtime();
#endif /* ADC_H_ */
\ No newline at end of file
/*
* gpio.c
*
* Created: 14/07/2016 16:33:28
* Author: Snorre
*/
#include "gpio.h"
#include "../config/gpio_config.h"
uint8_t gpio_offtime = 0, gpio_ontime = 0;
void gpio_init()
{
//turn on a bunch of pullups
GPIO_ONTIME_HEX_PORT |= GPIO_ONTIME_HEX_PIN0_bm| GPIO_ONTIME_HEX_PIN1_bm| GPIO_ONTIME_HEX_PIN2_bm| GPIO_ONTIME_HEX_PIN3_bm;
GPIO_OFFTIME_HEX_PORT |= GPIO_OFFTIME_HEX_PIN0_bm|GPIO_OFFTIME_HEX_PIN1_bm|GPIO_OFFTIME_HEX_PIN2_bm|GPIO_OFFTIME_HEX_PIN3_bm;
}
void gpio_update()
{
//Donthing?
}
uint8_t gpio_get_offtime()
{
uint8_t pinvalue = GPIO_OFFTIME_HEX_PIN;
uint8_t retval;
retval = (((pinvalue & GPIO_OFFTIME_HEX_PIN0_bm) >> GPIO_OFFTIME_HEX_PIN0) << 0);
retval += (((pinvalue & GPIO_OFFTIME_HEX_PIN1_bm) >> GPIO_OFFTIME_HEX_PIN1) << 1);
retval += (((pinvalue & GPIO_OFFTIME_HEX_PIN2_bm) >> GPIO_OFFTIME_HEX_PIN2) << 2);
retval += (((pinvalue & GPIO_OFFTIME_HEX_PIN3_bm) >> GPIO_OFFTIME_HEX_PIN3) << 3);
return retval;
}
uint8_t gpio_get_ontime()
{
uint8_t pinvalue = GPIO_ONTIME_HEX_PIN;
uint8_t retval;
retval = (((pinvalue & GPIO_ONTIME_HEX_PIN0_bm) >> GPIO_ONTIME_HEX_PIN0) << 0);
retval += (((pinvalue & GPIO_ONTIME_HEX_PIN1_bm) >> GPIO_ONTIME_HEX_PIN1) << 1);
retval += (((pinvalue & GPIO_ONTIME_HEX_PIN2_bm) >> GPIO_ONTIME_HEX_PIN2) << 2);
retval += (((pinvalue & GPIO_ONTIME_HEX_PIN3_bm) >> GPIO_ONTIME_HEX_PIN3) << 3);
return retval;
}
uint8_t gpio_get_input()
{
return !!(GPIO_SIGNAL_INPUT_PIN&GPIO_SIGNAL_INPUT_PIN0_bm);
}
\ No newline at end of file
/*
* gpio.h
*
* Created: 14/07/2016 16:32:00
* Author: Snorre
*/
#ifndef GPIO_H_
#define GPIO_H_
#include <inttypes.h>
void gpio_init();
void gpio_update();
uint8_t gpio_get_offtime();
uint8_t gpio_get_ontime();
uint8_t gpio_get_input();
#endif /* GPIO_H_ */
\ No newline at end of file
/*
* timer.c
*
* Created: 14/07/2016 16:33:20
* Author: Snorre
*/
#include "timer.h"
void timer_init()
{
//one timer for 1/2 us ticks, one for optic pwm
//16bit timer set to /8
}
\ No newline at end of file
/*
* timer.h
*
* Created: 14/07/2016 16:28:21
* Author: Snorre
*/
#ifndef TIMER_H_
#define TIMER_H_
void timer_init();
void timeout_us(uint8_t time);
void timeout_done();
void timer_pwm_start();
void timer_pwm_set(uint8_t pw);
void timer_pwm_stop();
#endif /* TIMER_H_ */
\ No newline at end of file
/*
* optic.c
*
* Created: 14/07/2016 16:58:11
* Author: Snorre
*/
#include "optic.h"
#include "../drivers/timer.h"
#include "../drivers/adc.h"
#include "../drivers/gpio.h"
void optic_init()
{
}
void optic_update()
void optic_pulse()
{
//calculate pulse length
//start timer
//loop until
//pulse timer end
//or gpio down.
}
void optic_deadtime_wait()
{
//calculate deadtime length
//start timer
//loop until deadtime timer end
}
\ No newline at end of file
/*
* optic.h
*
* Created: 14/07/2016 16:58:01
* Author: Snorre
*/
#ifndef OPTIC_H_
#define OPTIC_H_
void optic_init();
void optic_update();
void optic_pulse();
void optic_deadtime_wait();
#endif /* OPTIC_H_ */
\ No newline at end of file
/*
* unfuck.c
*
* Created: 14/07/2016 16:20:37
* Author : Snorre
*/
#include <avr/io.h>
#include "drivers/timer.h"
#include "drivers/gpio.h"
#include "drivers/adc.h"
#include "logic/optic.h"
int main(void)
{
optic_init();
gpio_init();
timer_init();
adc_init();
while (1)
{
adc_update();
gpio_update();
optic_update();
if (gpio_get_input()){
optic_pulse();
optic_deadtime_wait();
while(gpio_get_input()) {
};
}
}
}
/*
* main.h
*
* Created: 14/07/2016 16:22:22
* Author: Snorre
*/
#ifndef MAIN_H_
#define MAIN_H_
/*
* Kjapp braindump/spec:
* 1x Programmeringsheader (husk plass til shroud).
* 1x spenningsingang + egnet nettverk. noen bør synse om egnet connector.
* 1x Optikk-ut med nødvendig kretsverk, koblet til en 16-bit PWM-pinne.
* Gjerne legg på gode probepunkter på linjen, evt. også et probehull.
* 1x 2-pins connector koblet til en annen PWM-pinne på samme timer
* 1x (I utgangspunktet:) Atmega328P http://no.farnell.com/atmel/atmega328p-au/mcu-8bit-atmega-20mhz-tqfp-32/dp/1715486
* Se AVR042 for egnet avkobling og annet gøy.
* 1x: 16MHz XTAL + caps
* 2x Hex-brytere: http://no.farnell.com/multicomp/mcrs3af-16r-v-b/switch-rotary-kink-10x10-16-pos/dp/2083018 koblet til 2x4 IO-pinner..
* 4x: 3-pins connector (låsbar) koblet til VCC og GND i endene, og en analog-kapabel IO-pinne i midten. husk plass til fingre eller helst plasser på rekke med låsen ut.
* 1x optokoblet signalingang (2-pin connector)
* Husk å ikke koble GND sammen på utsiden av optokobleren
* 4x M3 monteringshull pent plassert i hjørnene.(gjerne med en rund-ish avstand mellom senter av hullene)
* Kortet skal være i underkant av 5x5cm evt. 10x5cm om nødvendig.(utgangen på kort side)
* De fire analog-pinnene kan kobles til potmetere, brytere leds, for å gjøre ting justerbart. og fancy.
* Vribryterene setter ekstremverdier for påtid og dødtid.
* Den ekstra pwm-pinnen er ment for debug/expansion.
* Kjør spec-review!
* -Snorre
*/
#endif /* MAIN_H_ */
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>7.0</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
<ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>
<avrdevice>ATmega328P</avrdevice>
<avrdeviceseries>none</avrdeviceseries>
<OutputType>Executable</OutputType>
<Language>C</Language>
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
<OutputFileExtension>.elf</OutputFileExtension>
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
<AssemblyName>unfuck</AssemblyName>
<Name>unfuck</Name>
<RootNamespace>unfuck</RootNamespace>
<ToolchainFlavour>Native</ToolchainFlavour>
<KeepTimersRunning>true</KeepTimersRunning>
<OverrideVtor>false</OverrideVtor>
<CacheFlash>true</CacheFlash>
<ProgFlashFromRam>true</ProgFlashFromRam>
<RamSnippetAddress />
<UncachedRange />
<preserveEEPROM>true</preserveEEPROM>
<OverrideVtorValue />
<BootSegment>2</BootSegment>
<eraseonlaunchrule>0</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data xmlns="">
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.31.0" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
<Compile Include="config\gpio_config.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="config\optic_config.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="drivers\adc.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="drivers\adc.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="drivers\gpio.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="drivers\gpio.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="drivers\timer.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="drivers\timer.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="logic\optic.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="logic\optic.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="main.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="main.h">
<SubType>compile</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="drivers" />
<Folder Include="config" />
<Folder Include="logic" />
</ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
</Project>
\ No newline at end of file
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