void initKeyboardHardware() { // This function sets up the IO ports for the keyboard hardware DDRB = 0x00; // port B is all input PORTB = 0xff; // pullups enabled srInit(); // It also needs to handle the LEDS... NUMLEDPORT &= ~(_BV(NUMLEDPIN)); NUMLEDDDR |= _BV(NUMLEDPIN); CAPSLEDPORT &= ~(_BV(CAPSLEDPIN)); CAPSLEDDDR |= _BV(CAPSLEDPIN); SCRLLEDPORT &= ~(_BV(SCRLLEDPIN)); SCRLLEDDDR |= _BV(SCRLLEDPIN); COMPLEDPORT &= ~(_BV(COMPLEDPIN)); COMPLEDDDR |= _BV(COMPLEDPIN); KANALEDPORT &= ~(_BV(KANALEDPIN)); KANALEDDDR |= _BV(KANALEDPIN); DEBUGLEDPORT &= 0x0f; DEBUGLEDDDR |= 0xf0; }
int main(int argc, char** argv) { // Get width and height if (argc > 1) { width = atoi(argv[1]); if (argc > 2) height = atoi(argv[2]); } // Set up the rasteriser srInitParams params; params.width = width; params.height = height; params.outputContext = SR_CTX_SDL; srInit(¶ms); width = srGetWidth(); height = srGetHeight(); srSetMaxFPS(60); // srSetRenderState(SR_WIREFRAME, SR_TRUE); // Set projectino matrix float aspect = (float)width / height; kmMat4PerspectiveProjection(&proj, 60.0f, aspect, 0.1f, 100.0f); // Initialise the scene init(); // Enter rendering loop kmVec3 eye; kmVec3 centre; kmVec3 up; float angle = 0.0f; while (srContextActive()) { // Calculate view matrix kmMat4LookAt(&view, kmVec3Fill(&eye, 0.0f, 0.0f, 3.0f), kmVec3Fill(¢re, 0.0f, 0.0f, 0.0f), kmVec3Fill(&up, 0.0f, 1.0f, 0.0f)); // Draw scene srBegin(0); render(angle); srEnd(); // Update rotation angle += M_PI / 2.0f * 0.01f; } // Clean-up cleanup(); srShutdown(); return 0; }
void initHardware(void) { /* disable watchdog */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* clock full speed */ clock_prescale_set(clock_div_1); /* Hardware Initialization */ vrefInit(); srInit(); srClear(); srEnable(); USB_Init(); }