Merge branch 'master' of ghostdub.de:gg-button

master
Nidan 14 years ago
commit 9a3632e153

33
gg.c

@ -54,40 +54,63 @@ ISR(TIMER1_OVF1_vect){
// next try: simplistic, not too much looking at speed
uint16_t next = 0;
// OCR1B += 1; // test pwm
if(!--cnt_to_next){
ringbuf_get(&rb, &next);
OCR1B = next>>8;
cnt_to_ocr_incr = 8 - (next & 0x7);
cnt_to_next = 8;
if(!--length)
/* if(!--length)
{
/* shut down */
// shut down
PORTA &= ~(1 << PA7);
}
}*/
} else {
if(!--cnt_to_ocr_incr){
OCR1B += 1;
}
}
}
int main(void) __attribute__((noreturn));
int main(void)
{
_delay_ms(30); // wait for card to get power
uint8_t debug=0;
DDRA |= (1 << PA7);
PORTA |= (1 << PA7);
ringbuf_init(&rb, buffer, BUFFER_SIZE);
if(mmc_init() != 0) {/* mmc fail */;}
debug = 1;
// while(debug){
debug=mmc_init();
// }
// debug = 2;
mmc_read_part(0, (unsigned char *) &length, 4);
timer_init_tiny26();
sei();
/*
unsigned long block = 0;
for(;; block++)
{
mmc_read_to_ringbuffer(block, &rb);
}
} // */
// debug = 0;
uint8_t i,r;
uint16_t a;
for(;;){
i += debug*8;
a = i<<8;
r=1;
while(r){
r=ringbuf_put(&rb, a);
}
}// */
}

14
mmc.c

@ -92,6 +92,17 @@ unsigned char mmc_init ()
return(0);
}
//set MMC_Chip_Select to high (MMC/SD-Karte Inaktiv)
void MMC_Disable(){
WAIT_HALF_CLOCK; MMC_Write|= (1<<MMC_Chip_Select); WAIT_HALF_CLOCK;
}
//set MMC_Chip_Select to low (MMC/SD-Karte Aktiv)
void MMC_Enable(){
WAIT_HALF_CLOCK; MMC_Write&=~(1<<MMC_Chip_Select); WAIT_HALF_CLOCK;
}
//############################################################################
//Sendet ein Commando an die MMC/SD-Karte
unsigned char mmc_write_command (unsigned char *cmd)
@ -167,6 +178,7 @@ void mmc_write_byte (unsigned char Byte)
#else //Routine für Software SPI
for(uint8_t current_bit = 1 << 7; current_bit; current_bit >>= 1) //das Byte wird Bitweise nacheinander Gesendet MSB First
{
MMC_Write &= ~(1<<SPI_Clock); //erzeugt ein Clock Impuls (LOW)
if(Byte & current_bit) //Ist Bit a in Byte gesetzt
{
MMC_Write |= (1<<SPI_DO); //Set Output High
@ -175,9 +187,9 @@ void mmc_write_byte (unsigned char Byte)
{
MMC_Write &= ~(1<<SPI_DO); //Set Output Low
}
MMC_Write &= ~(1<<SPI_Clock); //erzeugt ein Clock Impuls (LOW)
WAIT_HALF_CLOCK;
MMC_Write |= (1<<SPI_Clock); //setzt Clock Impuls wieder auf (High)
// bei dieser flanke werden die daten von der karte gelesen
WAIT_HALF_CLOCK;
}
MMC_Write |= (1<<SPI_DO); //setzt Output wieder auf High

11
mmc.h

@ -14,7 +14,7 @@ Copyright (C) 2004 Ulrich Radig
//#define SPI_Mode 1 //1 = Hardware SPI | 0 = Software SPI
#define SPI_Mode 0
#define WAIT_HALF_CLOCK _delay_us(1)
#define WAIT_HALF_CLOCK _delay_us(50)
#define MMC_Write PORTA //Port an der die MMC/SD-Karte angeschlossen ist also des SPI
#define MMC_Read PINA
@ -80,12 +80,9 @@ extern unsigned char mmc_read_csd (unsigned char *);
extern unsigned char mmc_read_cid (unsigned char *);
//set MMC_Chip_Select to high (MMC/SD-Karte Inaktiv)
#define MMC_Disable() MMC_Write|= (1<<MMC_Chip_Select);
//set MMC_Chip_Select to low (MMC/SD-Karte Aktiv)
#define MMC_Enable() MMC_Write&=~(1<<MMC_Chip_Select);
#define nop() __asm__ __volatile__ ("nop" ::)
void MMC_Disable();
void MMC_Enable();
#endif //_MMC_H_

Loading…
Cancel
Save