Merge branch 'master' into radio
This commit is contained in:
commit
9f7ae5420d
6
Makefile
6
Makefile
@ -42,9 +42,11 @@ CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
|||||||
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
||||||
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
|
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
|
||||||
|
|
||||||
|
|
||||||
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
||||||
|
|
||||||
|
ifeq ($(BUILD),debug)
|
||||||
|
CFLAGS += -DDEBUG
|
||||||
|
endif
|
||||||
|
|
||||||
#Additional libraries.
|
#Additional libraries.
|
||||||
|
|
||||||
@ -140,6 +142,8 @@ program: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
|
|||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
||||||
|
debug:
|
||||||
|
make "BUILD=debug"
|
||||||
|
|
||||||
|
|
||||||
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
||||||
|
16
include/debug.h
Normal file
16
include/debug.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef DEBUG_H
|
||||||
|
#define DEBUG_H
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include "/usr/include/simavr/avr/avr_mcu_section.h"
|
||||||
|
|
||||||
|
AVR_MCU(F_CPU, "atmega328p");
|
||||||
|
const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = {
|
||||||
|
{ AVR_MCU_VCD_SYMBOL("DDRB"), .what = (void *) &DDRB, },
|
||||||
|
{ AVR_MCU_VCD_SYMBOL("TCCR1A"), .what = (void *) &TCCR1A, },
|
||||||
|
{ AVR_MCU_VCD_SYMBOL("TCCR1B"), .what = (void *) &TCCR1B, },
|
||||||
|
{ AVR_MCU_VCD_SYMBOL("OCR1A"), .what = (void *) &OCR1A, },
|
||||||
|
{ AVR_MCU_VCD_SYMBOL("OCR1B"), .what = (void *) &OCR1B, },
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* DEBUG_H */
|
@ -1,8 +1,6 @@
|
|||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
typedef unsigned char byte;
|
|
||||||
|
|
||||||
void initIO(void);
|
void initIO(void);
|
||||||
void blinkLed(void);
|
void blinkLed(void);
|
||||||
void readTemp(void);
|
void readTemp(void);
|
||||||
|
30
src/main.c
30
src/main.c
@ -6,8 +6,21 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#include "debug.h"
|
||||||
|
#endif /* DEBUG */
|
||||||
|
|
||||||
void initIO()
|
void initIO()
|
||||||
{
|
{
|
||||||
|
/* Servos */
|
||||||
|
DDRB |= (1 << SERVO_L);
|
||||||
|
/* Phase Correct PWM, 9-bit; Inverting mode */
|
||||||
|
TCCR1A |= 1 << WGM11 | 1 << COM1A1 | 1 << COM1A0;
|
||||||
|
/* "Clear Timer on Compare match" mode; Prescaler = 1 */
|
||||||
|
TCCR1B |= 1 << WGM13 | 1 << WGM12 | 1 << CS10;
|
||||||
|
ICR1 = 19999; // F_CPU / 50Hz - 1
|
||||||
|
|
||||||
|
/* LED */
|
||||||
DDRD |= (1 << LED_1);
|
DDRD |= (1 << LED_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,10 +40,27 @@ void readTemp()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void runServos()
|
||||||
|
{
|
||||||
|
/* Stop */
|
||||||
|
OCR1A = ICR1 - 1500;
|
||||||
|
_delay_ms(1500);
|
||||||
|
|
||||||
|
/* Reverse */
|
||||||
|
OCR1A = ICR1 - 2000;
|
||||||
|
_delay_ms(1500);
|
||||||
|
|
||||||
|
/* Forwards */
|
||||||
|
OCR1A = ICR1 - 1000;
|
||||||
|
_delay_ms(1500);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
initIO();
|
initIO();
|
||||||
|
runServos();
|
||||||
readTemp();
|
readTemp();
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user