Moved arduino specific C files and started working on PWM.

This commit is contained in:
Marvin Blum
2017-03-27 16:03:08 +02:00
parent 885fe1d624
commit bc2c6da436
6 changed files with 14 additions and 8 deletions

View File

View File

View File

@@ -1,8 +1,8 @@
#!/bin/bash
mkdir build
avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o build/serial.o -Wall serial.c
avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o build/pins.o -Wall pins.c
avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o build/serial.o -Wall ard/serial.c
avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o build/pins.o -Wall ard/pins.c
avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o build/main.o -Wall main.c
avr-gcc -mmcu=atmega328p build/*.o -o build/main
avr-objcopy -O ihex -R .eeprom build/main build/main.hex

18
main.c
View File

@@ -2,8 +2,8 @@
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
#include "serial.h"
#include "pins.h"
#include "ard/serial.h"
#include "ard/pins.h"
void prepare();
void loop();
@@ -27,8 +27,11 @@ void prepare(){
pin_mode(8, INPUT);*/
// anlog input example
pin_mode(A1, INPUT);
pin_mode(A2, INPUT);
/*pin_mode(A1, INPUT);
pin_mode(A2, INPUT);*/
// PWM example
pin_mode(3, OUTPUT);
}
void loop(){
@@ -41,11 +44,14 @@ void loop(){
}*/
// anlog input example
int analog1 = analog_read(A1);
/*int analog1 = analog_read(A1);
int analog2 = analog_read(A2);
char out[15];
sprintf(out, "%d %d", analog1, analog2);
serial_write(out, 15);
serial_write(out, 15);*/
// PWM example
digital_write(3, HIGH);
_delay_ms(25);
}