#include #include #include #include #include #include #include "main.h" #include "display.h" void hardinit(){ /* initializes the hardware */ DDRB = _BV(1) | _BV(2) | _BV(0); DDRC = 0x3f; // no pullups; all digital outputs can take care of themselves PORTB = 0x00; PORTC = 0x00; PORTD = 0x00; /* hardware pwm for brightness/contrast: */ TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(WGM10); TCCR1B = _BV(WGM12) | _BV(CS11); // clk/8 prescaler, 4kHz PWM-freq. OCR1A = 15; // contrast OCR1B = 50; // brightness // init LCD: lcd_init(1); lcd_clrscr(1); // 1wire needs no own init, bus search is done in softinit sei(); } void softinit(){ lcd_defchar(1, LCD_CHAR_HALFBAR, lcd_halfbar_char); lcd_defchar(1, LCD_CHAR_BAR, lcd_bar_char); lcd_defchar(1, LCD_CHAR_DEGREE, lcd_degree_char); } usbMsgLen_t usbFunctionSetup(uchar data[8]) { usbRequest_t *rq = (void *)data; static uchar dataBuffer[4]; /* buffer must stay valid when usbFunctionSetup returns */ if(rq->bRequest == 1){ /* echo -- used for reliability tests */ dataBuffer[0] = rq->wValue.bytes[0]; dataBuffer[1] = rq->wValue.bytes[1]; dataBuffer[2] = rq->wIndex.bytes[0]; dataBuffer[3] = rq->wIndex.bytes[1]; usbMsgPtr = dataBuffer; /* tell the driver which data to return */ return 4; } return 0; /* default for not implemented requests: return no data back to host */ } int __attribute__((noreturn)) main(void){ hardinit(); softinit(); usbInit(); display_puts("Hallo, Welt!\n\n"); display_update(); for(;;){ usbPoll(); } } /* ISR(TIMER1_OVF_vect, ISR_NAKED){ asm volatile ("in %0, %1\n" : "=r" (sreg_store) : "I" (_SFR_IO_ADDR(SREG))); timer1_acc++; asm volatile ("out %1, %0\n" : "=r" (sreg_store) : "I" (_SFR_IO_ADDR(SREG))); reti(); }*/