static void closeUart(Portal* p) { if (p->crumb.flags & CRUMB_ISDIR) return; NodeInfo ni; if (getNodeInfoStaticNS(p, uartSNS, WalkSelf, &ni) == NULL) { errno = ENODEV; return; } UartFileType t = ni.length; /* overloaded this field for private use */ if (t == UartCtlFile || t == UartDataFile) { Uart* uart = (Uart*)ni.contents; disableUart(uart); } }
void init() { //disable watch dog (required in addition to conf bits above) RCONbits.SWDTEN = 0; //configure clock PLLFBD = 150; // m = 217 CLKDIVbits.PLLPRE = 5; // n1 = 10 CLKDIVbits.PLLPOST = 0; //n2 = 2 OSCTUN = 0; // tune FRC __builtin_write_OSCCONH(1); //init clock switch to internal __builtin_write_OSCCONL(1); //start clock switch process while (OSCCONbits.LOCK != 1) {} //wait for clock switching TRISA = 0b0000000000011100; // 3 and 4 for input buttons //init ports TRISB = 0b0001010000010000; disableUart(); //then handle UART config initTimer(); }