Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 270 → Rev 271

/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,23 → 1,24
 
#include <avr/io.h>
#include "fat16.h"
#include "ssc.h"
 
//________________________________________________________________________________________________________________________________________
// Module name: fat16.c
// Module name: fat16.c
// Compiler used: avr-gcc 3.4.5
// Last Modifikation: 24.07.2007
// Version: 1.03
// Authors: Stephan Busker
// Authors: Stephan Busker
// Description: Source files for access to the synchrnous serial channel.
// Copyright (C) 2007 Stephan Busker
//........................................................................................................................................
// Functions: extern void SSC_Init(void);
// Functions: extern void SSC_Init(void);
// extern u8 SSC_GetChar (void);
// extern void SSC_PutChar (u8 Byte);
// extern void SSC_Disable(void);
// extern void SSC_Enable(void);
// extern void SSC_Disable(void);
// extern void SSC_Enable(void);
//........................................................................................................................................
// ext. functions: extern u8 SDC_GetSector (u32,u8*);
// ext. functions: extern u8 SDC_GetSector (u32,u8*);
// extern u8 SDC_PutSector (u32,u8*);
//........................................................................................................................................
//
30,10 → 31,10
 
//________________________________________________________________________________________________________________________________________
// Funtion: SSC_Init(void);
//
// Description: This function initialises the synchronus serial channel to the sdcard.
//
//
// Description: This function initialises the synchronus serial channel to the sdcard.
//
//
// Returnvalue: none
//________________________________________________________________________________________________________________________________________
 
42,7 → 43,7
MMC_Direction_REG &=~(1<<SPI_DI); // Set the direction of the ssc-port
MMC_Direction_REG |= (1<<SPI_Clock); // _______ _______
MMC_Direction_REG |= (1<<SPI_DO); // CS \________________________/
MMC_Direction_REG |= (1<<MMC_Chip_Select); //
MMC_Direction_REG |= (1<<MMC_Chip_Select); //
MMC_Direction_REG |= (1<<SPI_SS); // ___ ___ ___
// clk __________/ \___/ \___/ \_________
//
51,7 → 52,7
 
// initialise ssc, clock = Idel low
// devide clock by 32
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<CPOL); // Enable SSC in mastermode, invert clockpolarity (idle high)
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<CPOL); // Enable SSC in mastermode, invert clockpolarity (idle high)
SPSR = SPSR|(1<<SPI2X);
}
 
60,10 → 61,10
 
//________________________________________________________________________________________________________________________________________
// Funtion: void SSC_ClearRxFifo(void);
//
//
// Description: Clears the fifo of the ssc if the controller used has a builtin fifo.
//
//
//
// Returnvalue: none
//________________________________________________________________________________________________________________________________________
 
70,7 → 71,7
 
void SSC_ClearRxFifo(void)
{
// enter your code here to clear the rx-fifo of the ssc.
// enter your code here to clear the rx-fifo of the ssc.
}
 
 
77,10 → 78,10
 
//________________________________________________________________________________________________________________________________________
// Funtion: SSC_GetChar(void);
//
//
// Description: This function reads one byte from the SSC
//
//
//
// Returnvalue: the byte received.
//________________________________________________________________________________________________________________________________________
 
93,21 → 94,21
Byte = SPDR;
 
#ifdef __MMC_INTERFACE_INVERTED
return (~Byte);
return (~Byte);
#else
return (Byte); // the byte received
return (Byte); // the byte received
#endif
 
 
}
 
 
//________________________________________________________________________________________________________________________________________
// Funtion: SSC_PutChar(u8 Byte);
//
// Description: This function writes one byte to the SSC
//
//
// Description: This function writes one byte to the SSC
//
//
// Returnvalue: none
//________________________________________________________________________________________________________________________________________
 
127,19 → 128,19
 
//________________________________________________________________________________________________________________________________________
// Funtion: SSC_Disable(void);
//
// Description: This function enables chipselect of the sdcard (active low)
//
//
// Description: This function enables chipselect of the sdcard (active low)
//
//
// Returnvalue: none
//________________________________________________________________________________________________________________________________________
 
void SSC_Disable(void)
{
void SSC_Disable(void)
{
#ifdef __MMC_INTERFACE_INVERTED
MMC_Write &= ~(1<<MMC_Chip_Select); // disable chipselect of the sdcard (active low).
MMC_Write &= ~(1<<MMC_Chip_Select); // disable chipselect of the sdcard (active low).
#else
MMC_Write |= (1<<MMC_Chip_Select); // enable chipselect of the sdcard (active low).
MMC_Write |= (1<<MMC_Chip_Select); // enable chipselect of the sdcard (active low).
#endif
}
 
148,19 → 149,19
 
//________________________________________________________________________________________________________________________________________
// Funtion: SSC_Enable(void);
//
// Description: This function disables chipselect of the sdcard (active low)
//
//
// Description: This function disables chipselect of the sdcard (active low)
//
//
// Returnvalue: none
//________________________________________________________________________________________________________________________________________
 
void SSC_Enable(void)
{
void SSC_Enable(void)
{
#ifdef __MMC_INTERFACE_INVERTED
MMC_Write |= (1<<MMC_Chip_Select); // enable chipselect of the sdcard (active low).
MMC_Write |= (1<<MMC_Chip_Select); // enable chipselect of the sdcard (active low).
#else
MMC_Write &= ~(1<<MMC_Chip_Select); // disable chipselect of the sdcard (active low).
MMC_Write &= ~(1<<MMC_Chip_Select); // disable chipselect of the sdcard (active low).
#endif
}
 
/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,6 → 82,33
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
}
 
 
/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;
}