/FollowMe/led.c |
---|
12,9 → 12,9 |
#endif |
#ifdef USE_FOLLOWME |
// set PB0 as output (control of yellow LED) |
// set PB0 as output (control of green LED) |
DDRB |= (1<<DDB0); |
LEDYELLOW_OFF; |
LEDGRN_OFF; |
// set PB1 as output (control of red LED) |
DDRB |= (1<<DDB1); |
LEDRED_OFF; |
/FollowMe/led.h |
---|
10,9 → 10,9 |
#endif |
#ifdef USE_FOLLOWME |
#define LEDYELLOW_OFF PORTB |= (1<<PORTB0) |
#define LEDYELLOW_ON PORTB &= ~(1<<PORTB0) |
#define LEDYELLOW_TOGGLE PORTB ^= (1<<PORTB0) |
#define LEDGRN_OFF PORTB |= (1<<PORTB0) |
#define LEDGRN_ON PORTB &= ~(1<<PORTB0) |
#define LEDGRN_TOGGLE PORTB ^= (1<<PORTB0) |
#define LEDRED_OFF PORTB |= (1<<PORTB1) |
#define LEDRED_ON PORTB &= ~(1<<PORTB1) |
/FollowMe/main.c |
---|
75,12 → 75,20 |
// initalize modules |
LED_Init(); |
LEDRED_ON; |
TIMER0_Init(); |
USART0_Init(); |
USART1_Init(); |
// enable interrupts global |
sei(); |
LEDRED_OFF; |
#ifdef USE_FOLLOWME |
LEDGRN_ON; |
#endif |
#ifdef USE_SDLOGGER |
printf("\n\rHW: SD-Logger"); |
#endif |
91,7 → 99,7 |
printf("\n\r=============================="); |
printf("\n\r"); |
/* |
// try to initialize the SD-Card File system |
printf("\n\rInit FAT16..."); |
if(FAT16_Init()) |
101,8 → 109,12 |
else |
{ |
printf("failed"); |
} |
}*/ |
#ifdef USE_FOLLOWME |
BeepTime = 2000; |
#endif |
LCD_Clear(); |
while (1) |
/FollowMe/makefile |
---|
13,8 → 13,8 |
#------------------------------------------------------------------- |
#OPTIONS |
# Use one of the motor setups |
#BOARD = FOLLOWME |
BOARD = SDLOGGER |
BOARD = FOLLOWME |
#BOARD = SDLOGGER |
#------------------------------------------------------------------- |
# get SVN revision |
72,11 → 72,12 |
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
OPT = s |
OPT = 2 |
########################################################################################################## |
# List C source files here. (C dependencies are automatically generated.) |
SRC = main.c uart0.c uart1.c printf_P.c timer0.c menu.c led.c ubx.c ssc.c sdc.c fat16.c |
SRC = main.c uart0.c uart1.c printf_P.c timer0.c menu.c led.c ubx.c |
#ssc.c sdc.c fat16.c |
########################################################################################################## |
/FollowMe/ssc.c |
---|
1,3 → 1,4 |
#include <avr/io.h> |
#include "fat16.h" |
#include "ssc.h" |
/FollowMe/timer0.c |
---|
5,9 → 5,12 |
#include "main.h" |
volatile uint16_t CountMilliseconds = 0; |
#ifdef USE_FOLLOWME |
volatile uint16_t BeepTime = 0; |
volatile uint16_t BeepModulation = 0xFFFF; |
#endif |
/*****************************************************/ |
/* Initialize Timer 0 */ |
/*****************************************************/ |
20,6 → 23,15 |
// disable all interrupts before reconfiguration |
cli(); |
// configure speaker port as output |
#ifdef USE_FOLLOWME |
// Speaker at PC7 |
DDRC |= (1<<DDC7); |
PORTC &= ~(1<<PORTC7); |
#endif |
// Timer/Counter 0 Control Register A |
// Waveform Generation Mode is Fast PWM (Bits WGM02 = 0, WGM01 = 1, WGM00 = 1) |
61,6 → 73,9 |
ISR(TIMER0_OVF_vect) // 9.765 kHz |
{ |
static uint8_t cnt = 0; |
#ifdef USE_FOLLOWME |
uint8_t Beeper_On = 0; |
#endif |
if(!cnt--) // every 10th run (9.765kHz/10 = 976Hz) |
{ |
67,9 → 82,36 |
cnt = 9; |
CountMilliseconds++; // increment millisecond counter |
} |
#ifdef USE_FOLLOWME |
// beeper on if duration is not over |
if(BeepTime) |
{ |
BeepTime--; // decrement BeepTime |
if(BeepTime & BeepModulation) Beeper_On = 1; |
else Beeper_On = 0; |
} |
else // beeper off if duration is over |
{ |
Beeper_On = 0; |
BeepModulation = 0xFFFF; |
} |
// if beeper is on |
if(Beeper_On) |
{ |
// set speaker port to high |
PORTC |= (1<<PORTC7); // Speaker at PC7 |
} |
else // beeper is off |
{ |
// set speaker port to low |
PORTC &= ~(1<<PORTC7);// Speaker at PC7 |
} |
#endif |
} |
// ----------------------------------------------------------------------- |
uint16_t SetDelay (uint16_t t) |
{ |
/FollowMe/timer0.h |
---|
4,7 → 4,10 |
#include <inttypes.h> |
extern volatile uint16_t CountMilliseconds; |
#ifdef USE_FOLLOWME |
extern volatile uint16_t BeepTime; |
extern volatile uint16_t BeepModulation; |
#endif |
extern void TIMER0_Init(void); |
extern void Delay_ms(uint16_t w); |
extern void Delay_ms_Mess(uint16_t w); |
/FollowMe/uart0.c |
---|
444,7 → 444,6 |
break; |
default: |
LEDRED_TOGGLE; |
//unsupported command received |
break; |
} |