Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 270 → Rev 271

/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
}