diff options
| -rw-r--r-- | picl-firmware/.vscode/c_cpp_properties.json | 16 | ||||
| -rw-r--r-- | picl-firmware/.vscode/tasks.json | 7 | ||||
| -rw-r--r-- | picl-firmware/fan_control.c | 34 |
3 files changed, 43 insertions, 14 deletions
diff --git a/picl-firmware/.vscode/c_cpp_properties.json b/picl-firmware/.vscode/c_cpp_properties.json index add3b91..b9c3363 100644 --- a/picl-firmware/.vscode/c_cpp_properties.json +++ b/picl-firmware/.vscode/c_cpp_properties.json @@ -4,11 +4,23 @@ "name": "AVR", "includePath": [ "${workspaceFolder}/**", - "/usr/avr/include/**" + "/usr/avr/include/**", + "/usr/include/**" + ], + "defines": [ + "__AVR_ATtiny24__" ], - "defines": ["__AVR_ATtiny24__"], "compilerPath": "/usr/bin/avr-gcc", "intelliSenseMode": "clang-x64" + }, + { + "name": "simAVR", + "includePath": [ + "${workspaceFolder}/**", + "/usr/include/**" + ], + "compilerPath": "/usr/bin/clang++", + "intelliSenseMode": "clang-x64" } ], "version": 4 diff --git a/picl-firmware/.vscode/tasks.json b/picl-firmware/.vscode/tasks.json index 069c853..5512abb 100644 --- a/picl-firmware/.vscode/tasks.json +++ b/picl-firmware/.vscode/tasks.json @@ -6,17 +6,16 @@ { "type": "shell", "label": "avr-gcc build active file", - "command": "/bin/avr-gcc", + "command": "/usr/bin/avr-gcc", "args": [ "-mmcu=attiny24", "-g", "${file}", + "-I", + "/usr/include/simavr/", "-o", "${fileDirname}/${fileBasenameNoExtension}" ], - "options": { - "cwd": "/bin" - }, "problemMatcher": [ "$gcc" ], diff --git a/picl-firmware/fan_control.c b/picl-firmware/fan_control.c index 6b0bd99..3cebd7e 100644 --- a/picl-firmware/fan_control.c +++ b/picl-firmware/fan_control.c @@ -2,6 +2,18 @@ #include <avr/interrupt.h> #include <avr/sleep.h> +#include <avr/avr_mcu_section.h> + +AVR_MCU(8000000, "attiny24"); +AVR_MCU_VOLTAGES(5000, 5000, 5000); + +const struct avr_mmcu_vcd_trace_t my_trace[] _MMCU_ = { + { AVR_MCU_VCD_SYMBOL("PORTA"), .what = (void*)&PORTA }, + { AVR_MCU_VCD_SYMBOL("PORTB"), .what = (void*)&PORTB }, + { AVR_MCU_VCD_SYMBOL("PINA"), .what = (void*)&PINA }, + { AVR_MCU_VCD_SYMBOL("PINB"), .what = (void*)&PINB } +}; + void setup_clock() { CLKPR |= (1UL << CLKPCE); //enable setting of prescaler. CLKPR &= ~(15 << CLKPS0); //set prescaler to 1, system clock 8MHz. @@ -20,11 +32,11 @@ void setup_adc() { } void setup_timers() { - //Set channel A to inverted mode + //Set channel A to non inverted mode TCCR0A &= ~(3UL << COM0A0); TCCR0A |= (2UL << COM0A0); - //Set channel B to inverted mode + //Set channel B to non inverted mode TCCR0A &= ~(3UL << COM0B0); TCCR0A |= (2UL << COM0B0); @@ -40,8 +52,8 @@ void setup_timers() { TCCR0B &= ~(7UL << CS00); TCCR0B |= (1UL << CS00); - DDRA |= (1UL << PA7); - DDRB |= (1UL << PB2); + DDRA |= (1UL << DDA7); + DDRB |= (1UL << DDB2); } void enable_ADC() { @@ -96,9 +108,11 @@ ISR(ADC_vect) { } } -volatile int b = 0; +AVR_MCU_SIMAVR_COMMAND (& GPIOR0 ) ; int main() { + GPIOR0 = SIMAVR_CMD_VCD_START_TRACE; + setup_clock(); setup_adc(); setup_timers(); @@ -106,8 +120,12 @@ int main() { OCR0A = 0x80; OCR0B = 0xB0; - while(1) { + //run for however long this takes... + uint16_t t = 0xffff; + while (t > 0) { + t--; + } - b+=1; - } + GPIOR0 = SIMAVR_CMD_VCD_STOP_TRACE; } + |
