diff --git a/master/master/lib/logger.c b/master/master/lib/logger.c
--- a/master/master/lib/logger.c
+++ b/master/master/lib/logger.c
@@ -16,35 +16,6 @@
#include "logger.h"
/*
- //console prompts and responses
- * I implemented an example application providing a simple command prompt which is accessible
- * via the UART at 9600 Baud. With commands similiar to the Unix shell you can browse different
- * directories, read and write files, create new ones and delete them again. Not all commands are
- * available in all software configurations.
- * - cat \\n
- * Writes a hexdump of \ to the terminal.
- * - cd \\n
- * Changes current working directory to \.
- * - disk\n
- * Shows card manufacturer, status, filesystem capacity and free storage space.
- * - init\n
- * Reinitializes and reopens the memory card.
- * - ls\n
- * Shows the content of the current directory.
- * - mkdir \\n
- * Creates a directory called \.
- * - mv \ \\n
- * Renames \ to \.
- * - rm \\n
- * Deletes \.
- * - sync\n
- * Ensures all buffered data is written to the card.
- * - touch \\n
- * Creates \.
- * - write \ \\n
- * Writes text to \, starting from \. The text is read
- * from the UART, line by line. Finish with an empty line.
-
//config edits
* By changing the MCU* variables in the Makefile, you can use other Atmel
* microcontrollers or different clock speeds. You might also want to change
@@ -169,7 +140,7 @@ void logger_setup()
/* write text to file !! */
if(fat_write_file(fd, (uint8_t*) buffer, data_len) != data_len)
{
- uart_puts_p(PSTR("error writing to file\n"));
+ //uart_puts_p(PSTR("error writing to file\n"));
break;
}
}
diff --git a/master/master/lib/sd/sd_raw.c b/master/master/lib/sd/sd_raw.c
--- a/master/master/lib/sd/sd_raw.c
+++ b/master/master/lib/sd/sd_raw.c
@@ -11,6 +11,7 @@
#include
#include
#include "sd_raw.h"
+#include "sd_raw_config.h"
/**
* \addtogroup sd_raw MMC/SD/SDHC card raw access
@@ -184,15 +185,15 @@ uint8_t sd_raw_init()
unselect_card();
/* initialize SPI with lowest frequency; max. 400kHz during identification mode of card */
- SPCR = (0 << SPIE) | /* SPI Interrupt Enable */
- (1 << SPE) | /* SPI Enable */
- (0 << DORD) | /* Data Order: MSB first */
- (1 << MSTR) | /* Master mode */
- (0 << CPOL) | /* Clock Polarity: SCK low when idle */
- (0 << CPHA) | /* Clock Phase: sample on rising SCK edge */
- (1 << SPR1) | /* Clock Frequency: f_OSC / 128 */
- (1 << SPR0);
- SPSR &= ~(1 << SPI2X); /* No doubled clock frequency */
+ SPCR0 = (0 << SPIE0) | /* SPI Interrupt Enable */
+ (1 << SPE0) | /* SPI Enable */
+ (0 << DORD0) | /* Data Order: MSB first */
+ (1 << MSTR0) | /* Master mode */
+ (0 << CPOL0) | /* Clock Polarity: SCK low when idle */
+ (0 << CPHA0) | /* Clock Phase: sample on rising SCK edge */
+ (1 << SPR10) | /* Clock Frequency: f_OSC / 128 */
+ (1 << SPR00);
+ SPSR0 &= ~(1 << SPI2X0); /* No doubled clock frequency */
/* initialization procedure */
sd_raw_card_type = 0;
@@ -314,8 +315,8 @@ uint8_t sd_raw_init()
unselect_card();
/* switch to highest SPI frequency possible */
- SPCR &= ~((1 << SPR1) | (1 << SPR0)); /* Clock Frequency: f_OSC / 4 */
- SPSR |= (1 << SPI2X); /* Doubled Clock Frequency: f_OSC / 2 */
+ SPCR0 &= ~((1 << SPR10) | (1 << SPR00)); /* Clock Frequency: f_OSC / 4 */
+ SPSR0 |= (1 << SPI2X0); /* Doubled Clock Frequency: f_OSC / 2 */
#if !SD_RAW_SAVE_RAM
/* the first block is likely to be accessed first, so precache it here */
@@ -361,10 +362,10 @@ uint8_t sd_raw_locked()
*/
void sd_raw_send_byte(uint8_t b)
{
- SPDR = b;
+ SPDR0 = b;
/* wait for byte to be shifted out */
- while(!(SPSR & (1 << SPIF)));
- SPSR &= ~(1 << SPIF);
+ while(!(SPSR0 & (1 << SPIF0)));
+ SPSR0 &= ~(1 << SPIF0);
}
/**
@@ -377,11 +378,11 @@ void sd_raw_send_byte(uint8_t b)
uint8_t sd_raw_rec_byte()
{
/* send dummy data for receiving some */
- SPDR = 0xff;
- while(!(SPSR & (1 << SPIF)));
- SPSR &= ~(1 << SPIF);
+ SPDR0 = 0xff;
+ while(!(SPSR0 & (1 << SPIF0)));
+ SPSR0 &= ~(1 << SPIF0);
- return SPDR;
+ return SPDR0;
}
/**
diff --git a/master/master/lib/sd/sd_raw_config.h b/master/master/lib/sd/sd_raw_config.h
--- a/master/master/lib/sd/sd_raw_config.h
+++ b/master/master/lib/sd/sd_raw_config.h
@@ -106,12 +106,22 @@ extern "C"
#define select_card() PORTB &= ~(1 << PORTB0)
#define unselect_card() PORTB |= (1 << PORTB0)
+#elif defined(__AVR_ATmega164P__) || \
+ defined(__AVR_ATmega324P__) || \
+ defined(__AVR_ATmega664P__)
+ #define configure_pin_mosi() DDRB |= (1 << DDRB5) //PB5
+ #define configure_pin_sck() DDRB |= (1 << DDRB7) //PB7
+ #define configure_pin_ss() DDRB |= (1 << DDRB0) //PB0 - custom pin
+ #define configure_pin_miso() DDRB &= ~(1 << DDRB6) //PB6
+
+ #define select_card() PORTB &= ~(1 << PORTB0)
+ #define unselect_card() PORTB |= (1 << PORTB0)
#else
- //#error "no sd/mmc pin mapping available!" //commented out due to build error ??
+ #error "no sd/mmc pin mapping available!" //sends error if micro not specified
#endif
-#define configure_pin_available() DDRC &= ~(1 << DDC4)
-#define configure_pin_locked() DDRC &= ~(1 << DDC5)
+#define configure_pin_available() DDRC &= ~(1 << DDRC4)
+#define configure_pin_locked() DDRC &= ~(1 << DDRC5)
#define get_pin_available() (PINC & (1 << PINC4))
#define get_pin_locked() (PINC & (1 << PINC5))