/***************************************************************************** ** Main Function main() This program has been test on Keil LPC1700 board. *****************************************************************************/ int main (void) { SystemInit(); UARTInit(0, 9600); /* baud rate setting */ UARTInit(1, 9600); /* baud rate setting */ while (1) { /* Loop forever */ if ( UART0Count != 0 ) { UART0->IER = IER_THRE | IER_RLS; /* Disable RBR */ UARTSend( 0, (uint8_t *)UART0Buffer, UART0Count ); UART0Count = 0; UART0->IER = IER_THRE | IER_RLS | IER_RBR; /* Re-enable RBR */ } if ( UART1Count != 0 ) { UART1->IER = IER_THRE | IER_RLS; /* Disable RBR */ UARTSend( 1, (uint8_t *)UART1Buffer, UART1Count ); UART1Count = 0; UART1->IER = IER_THRE | IER_RLS | IER_RBR; /* Re-enable RBR */ } } }
/***************************************************************************** ** Main Function main() This program has been test on Keil LPC1700 board. *****************************************************************************/ int main (void) { /* SystemClockUpdate() updates the SystemFrequency variable */ SystemClockUpdate(); UARTInit(0, 57600); /* baud rate setting */ UARTInit(1, 57600); /* baud rate setting */ while (1) { /* Loop forever */ if ( UART0Count != 0 ) { LPC_UART0->IER = IER_THRE | IER_RLS; /* Disable RBR */ UARTSend( 0, (uint8_t *)UART0Buffer, UART0Count ); UART0Count = 0; LPC_UART0->IER = IER_THRE | IER_RLS | IER_RBR; /* Re-enable RBR */ } if ( UART1Count != 0 ) { LPC_UART1->IER = IER_THRE | IER_RLS; /* Disable RBR */ UARTSend( 1, (uint8_t *)UART1Buffer, UART1Count ); UART1Count = 0; LPC_UART1->IER = IER_THRE | IER_RLS | IER_RBR; /* Re-enable RBR */ } } }
uint8 InitDevice()//TODO:异常处理 { uint8 r=0,t=0; //GPIO PinInit(); IO0DIR=1<<29|1<<30;//P0.29,P0.30必须同为输出才能输出(SSP0的片选). //GpioSpeedHigh();//全局高速模式,因为P0.29问题无法使用。 //指示系统启动 LED1ON(); //UART0-GCS r+=UARTInit(FCUARTPORT,FCUARTBPS);//UART0-PC UARTSendChar(FCUARTPORT,0x40); UARTSendChar(FCUARTPORT,0x40); //UART2-INS r+=UARTInit(INSUARTPORT,INSUARTBPS); //UARTSendChar(2,0x40); //UARTSendChar(2,0x40); //SSP0-FPGA r+=SSP0FPGAMode(); //r+=SPIInit(); //while(1) //{ t=FPGACheck(); //} if(t==TRUE) { FCEventSend(OKFPGA); } else { FCEventSend(ErrFPGA); } r+=t; //SSP1-FLASH r+=FlashInit(FlashQueueSize); //Timer0-MainLoop r+=TimerInit(0,1000/MainLoopHz); TimerDisable(0); //TimerEnable(0); //Timer1-Time+LED1 r+=TimerInit(1,1000); TimerEnable(1); //Timer2-Working-LED2 r+=TimerInit(2,100); TimerDisable(2); //启动中断 IRQEnable(); return r; }
int main(void) { // PORTC_PCR5 = PORT_PCR_MUX(0x1); // LED is on PC5 (pin 13), config as GPIO (alt = 1) // GPIOC_PDDR = (1<<5); // make this an output pin // LED_OFF; // start with LED off UARTInit(TERM_UART, TERM_BAUD); // open UART for comms xputs(hello); xputs("\n\rEnter a string to parse...\n\r"); EnableInterrupts; while (1) { xputs("\n\rString: "); get_line(buff, MAX_STR_LEN); if (strlen(buff) > 0) { answer = 0; error = rdp(buff, &answer); if (error == RDP_OK) { xprintf("Answer = %d 0x%08x\n\r", answer, answer); } else { xprintf("ERROR: rdp() returned %d\n\r", error); } } } return 0; // should never get here! }
void DM644xInit() { // Mask all interrupts AINTC->INTCTL = 0x0; AINTC->EINT0 = 0x0; AINTC->EINT1 = 0x0; /******************* IOB01 Hardware Setup ****************/ IOB01_Init(); /******************* UART Setup **************************/ UARTInit(); /******************* System PLL Setup ********************/ PLL1Init(); /******************* DDR PLL Setup ***********************/ PLL2Init(); /******************* DDR2 Timing Setup *******************/ DDR2Init(); /******************* AEMIF Setup *************************/ // Handled in NOR or NAND init //AEMIFInit(); /******************* IRQ Vector Table Setup **************/ IVTInit(); }
int main(void) { uint32_t freq; uint32_t v1; uint32_t v2; UARTInit(TERM_UART, TERM_BAUD); // open UART for comms xprintf(hello); freq = SPIInit(1, 10, 16); xprintf("\n\rSPIInit for SPI1 returns %d", freq); freq = SPIInit(2, 99, 16); xprintf("\n\rSPIInit for SPI2 returns %d", freq); xputs("\n\rSPI1: SCK (N/A) MOSI (pin 0) MISO (pin 1)"); xputs("\n\rSPI2: SCK (pin 14) MOSI (pin 15) MISO (pin 16)"); xputs("\n\rSending 0x5555 to both SPI channels..."); xputs("\n\r\n\r"); while (1) { // SPISend(1, 0x5555); // SPISend(2, 0x5555); v1 = SPIExchange(1, 0x5555); v2 = SPIExchange(2, 0x5555); xprintf("\rSPI1: %04x SPI2: %04x ", v1, v2); } }
int main (void) { /* Initialize GPIO (sets up clock) */ GPIOInit (); /* Set LED port pin to output */ GPIOSetDir (LED_PORT, LED_BIT, 1); GPIOSetValue (LED_PORT, LED_BIT, LED_OFF); /* Init Power Management Routines */ pmu_init (); /* UART setup */ UARTInit (115200, 0); /* CDC USB Initialization */ init_usbserial (); /* Init RFID */ rfid_init (); /* Init emulation triggers */ trigger_init (); /* RUN RFID loop */ loop_rfid (); return 0; }
int main(void) { __disable_irq(); LPC_SYSCON->SYSAHBCLKCTRL |= 0xE001005FUL; //Systems activated LPC_SYSCON->SYSMEMREMAP=0x02; //Activate ISR in Flash, remapping is inactive memcpy(&udtBootloaderParamFlash,(void*)0x100,sizeof(tBootloaderParamFlash)); //copy from flash now possible because of deactivated remapping LPC_SYSCON->SYSMEMREMAP=0x01; //Re-Activate ISR in RAM *((u32*)(0x10000000 + 0x1FE4))=0; //Reset Bootloader Variable bInterruptDisableCounter=0; //reset disable counter (used for nested disable/enables) UARTInit(115200); //Initializes the Uart0 __enable_irq(); //Enable ISR InitFreeGlobalTimer(); //Initializes the software timer if (LPC_SYSCON->SYSRESSTAT&(1U<<3)) /*brown out*/ SendErrorByCode(ecBrownOutDetected); else if (LPC_SYSCON->SYSRESSTAT&(1U<<2)) /*watchdog*/ SendErrorByCode(ecWatchdogOccured); LPC_SYSCON->SYSRESSTAT=0x1F; /*reset flags*/ /*main loop never to leave*/ while(1) { if (udtUartReceiveBuffer.xPacketAvailable) Parser(); } return 0; }
int main (void) { volatile int i; /* Basic chip initialization is taken care of in SystemInit() called * from the startup code. SystemInit() and chip settings are defined * in the CMSIS system_<part family>.c file. */ /* NVIC is installed inside UARTInit file. */ UARTInit (115200, 0); /* Initialize GPIO (sets up clock) */ GPIOInit (); /* Set LED port pin to output */ GPIOSetDir (LED_PORT, LED_BIT, 1); while (1) { /* Loop forever */ if (UARTCount != 0) { LPC_UART->IER = IER_THRE | IER_RLS; /* Disable RBR */ UARTSend ((uint8_t *) UARTBuffer, UARTCount); UARTCount = 0; LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR; /* Re-enable RBR */ debug_printf ("Hello World!\n"); GPIOSetValue (LED_PORT, LED_BIT, LED_ON); for (i = 0; i < 10000; i++); GPIOSetValue (LED_PORT, LED_BIT, LED_OFF); } } }
void SystemInit(void) { /* SystemInit() is called by the startup code */ /* according to system_LPC11xx.h it is expected, that the clock freq is set here */ SystemCoreClock = F_CPU; UARTInit(); }
void vTaskLcdDisplay(void *pvParameters) { int i=0; int disp2Counter = 0; UARTInit(115200); while(1) { itoa(i, displayLine1, 10); int i = 0; for (i = 0; i < UARTCount; i++) { displayLine2[disp2Counter++%16] = UARTBuffer[i]; } UARTCount = 0; lcd_putstring(0, displayLine1); lcd_putstring(1, displayLine2); //UARTSend(displayLine1, 16); i++; vTaskDelay(configTICK_RATE_HZ * 1); } }
/**************************************************************************** MAIN APPLICATION ENTRY POINT ****************************************************************************/ int main(void) { // Initialize application specific hardware HWInit(HWDEFAULT); // Initializing the UART for the debug #if defined (STACK_USE_UART) UARTInit(1, UART_DBG_DEF_BAUD); UARTOn(1); _dbgwrite("Flyport starting..."); #endif // Queue creation - will be used for communication between the stack and other tasks xQueue = xQueueCreate(3, sizeof (int)); xSemFrontEnd = xSemaphoreCreateMutex(); // RTOS starting if (xSemFrontEnd != NULL) { // Creates the task to handle all TCPIP functions xTaskCreate(TCPIPTask, (signed char*) "TCP", STACK_SIZE_TCPIP, NULL, tskIDLE_PRIORITY + 1, &hTCPIPTask); // Start of the RTOS scheduler, this function should never return vTaskStartScheduler(); } _dbgwrite("Unexpected end of program...\r\n"); while(1); return -1; }
/**************************************************************************** MAIN APPLICATION ENTRY POINT ****************************************************************************/ int main(void) { // Queue creation - will be used for communication between the stack and other tasks xQueue = xQueueCreate(3, sizeof (int)); xSemFrontEnd = xSemaphoreCreateMutex(); // Initialize application specific hardware HWInit(HWDEFAULT); UARTInit(1,19200); UARTOn(1); // RTOS starting if (xSemFrontEnd != NULL) { // Creates the task to handle all HiLo functions xTaskCreate(GSMTask, (signed char*) "GSM", STACK_SIZE_GSM, NULL, tskIDLE_PRIORITY + 1, &hGSMTask); // Start of the RTOS scheduler, this function should never return vTaskStartScheduler(); } #if defined (STACK_USE_UART) UARTWrite(1, "Unexpected end of program...\r\n"); #endif while(1); return -1; }
int main(void) { POWKEY1 = 0x1; POWCON0 = 0x78; // Set core to max CPU speed of 10.24Mhz POWKEY2 = 0xF4; UARTInit(); // Init UART ADC0Init(); // Init ADC0 IRQEN = BIT11 + BIT10; // Enable UART interrupt (BIT11) and ADC0 interrupt (BIT10) // bit 15 = ADC ON, 14:13 current source 00, 12 HIGHEXTREF, 11 AMP_CM, 10 unipolar, 9:6 input select, // bit 5:4 reference select, 3:0 PGA gain select 0000=gain of 1. page 45 of PDF // ADC0CON = 0x8540 ; // ADC on, ADC2/ADC3 (differential mode), Int ref, gain = 1 ADC0CON = BIT15 + BIT10 + BIT8 + BIT7 + BIT4 + BIT5; // ADC on, ADC2/ADC3 (differential mode), Vdd/2 ref, gain = 1 ADCMDE = 0x81; // ADCMDE bit 7 = fullpower, bits 2:0 = 001 continous conversion mode while (1) { if (newADCdata == 1) // if new ADC data is available { newADCdata = 0; // Indicate that data has been read // sprintf((char*)szTemp, "%07.7LX\r\n",A2data ); // pad left with zeroes, 6 width, 6 precision, Long Double, HEX // nLen = strlen((char*)szTemp); // if (nLen <64) SendString(); sendPacket(); // send three-byte A2data packet via serial delay(100000); } } }
int main(void) { // init fifos fifo_init (toRS232FIFO, toRS232Buf, 100); fifo_init (toUSBFIFO, toUSBBuf, 100); USBNCallbackFIFORX1(&FromPC); //USBNCallbackFIFOTX2Ready(&USBtoRS232); sei(); // activate global interrupts UARTInit(); // only for debugging // setup usbstack with your descriptors USBNInit(usbrs232,usbrs232Conf); _USBNAddStringDescriptor(""); //pseudo lang _USBNAddStringDescriptor("Microchip Technology Inc."); //_USBNAddStringDescriptor("abcdefgh"); _USBNAddStringDescriptor("PICkit 2 Microcontroller Programmer "); //_USBNAddStringDescriptor("PICkit 2 Microcontroller Programmer"); //_USBNAddStringDescriptor("ijklmnop"); _USBNAddStringDescriptor("PIC18F2550"); //_USBNAddStringDescriptor("12345678"); _USBNCreateStringField(); USBNInitMC(); // start usb controller USBNStart(); // start device stack while(1); }
int main (void) { SystemCoreClockUpdate(); /* NVIC is installed inside UARTInit file. */ UARTInit(115200); #if AUTOBAUD_ENABLE LPC_USART->ACR = 0x01<<2; /* Auto Restart, UART mode 0 */ LPC_USART->ACR |= (0x01<<0); /* Start */ while( !UARTAutoBaud ); UARTAutoBaud = 0; UARTSend((uint8_t *)"Auto Baud detected\r\n\r\n", 22); #endif #if MODEM_TEST ModemInit(); #endif while (1) { /* Loop forever */ if ( UARTCount != 0 ) { LPC_USART->IER = IER_THRE | IER_RLS; /* Disable RBR */ UARTSend( (uint8_t *)UARTBuffer, UARTCount ); UARTCount = 0; LPC_USART->IER = IER_THRE | IER_RLS | IER_RBR; /* Re-enable RBR */ } } }
void Test() { PinInit(); IO0DIR=1<<29|1<<30;//P0.29,P0.30必须同为输出才能输出(SSP0的片选). UARTInit(0,115200); //FCMessageSend("TestMode"); CANTest(); while(1) { /* uint8 c; uint16 t=FPGARead(TESTFPGA); UARTSendChar(0,0xff); c=t; UARTSendChar(0,c); c=t>>8; UARTSendChar(0,c); SSPSendByte(0,0xff); for(t=0;t<1024;t++) {;} */ } }
int main(void) { int conf, interf; UARTInit(); USBNInit(); // setup your usbn device USBNDeviceVendorID(0x0400); USBNDeviceProductID(0x9876); USBNDeviceBCDDevice(0x0201); char lang[]={0x09,0x04}; _USBNAddStringDescriptor(lang); // language descriptor USBNDeviceManufacture ("vScopeTeam"); USBNDeviceProduct ("vScopeDevice"); USBNDeviceSerialNumber("2006-04-05"); conf = USBNAddConfiguration(); //USBNConfigurationName(conf,"StandardKonfiguration"); USBNConfigurationPower(conf,50); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,0); //USBNInterfaceName(conf,interf,"usbstorage"); USBNAddOutEndpoint(conf,interf,1,0x02,BULK,64,0,&SetGetPort); USBNAddInEndpoint(conf,interf,1,0x03,BULK,64,0); /* conf = USBNAddConfiguration(); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,1); USBNAddInEndpoint(conf,interf,1,0x02,BULK,64); USBNAddInEndpoint(conf,interf,2,0x03,BULK,8); USBNAddInEndpoint(conf,interf,3,0x04,BULK,64); */ MCUCR |= (1 << ISC01); // fallende flanke GICR |= (1 << INT0); sei(); USBNInitMC(); // start usb chip USBNStart(); DDRB=0xff; PORTB=0x00; while(1); }
void PacketInit(uint32_t Baudrate) { UARTInit(Baudrate); InBuff = 0; InCount = 0; InLength = 0; NewInData = 0; LPC_UART->IER = IER_RBR | IER_THRE; /* Enable UART interrupt */ }
/****************************************************************** * @fn Initial profile * @brief Add simple profile service and register callbacks * * @return void */ void Profile_Init(void) { //TestProfileInit(); void App_Init(void); App_Init(); UARTInit(); //dip_Init(0x1111, 0x0001, 0x1122, 0x2233); legacy_RegisterCB(AppProfileCallback); }
static void calculations_heading(void *pvParameters) { UARTInit(3, 115200); /* baud rate setting */ printf("Maintask: Running\n"); CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCGPIO, ENABLE); spiInit(); gyroInit(); for (;;) { /*Block waiting for the semaphore to become available. */ if (xSemaphoreTake( xSemaphore, 0xffff ) == pdTRUE) { /* It is time to execute. */; /* Turn the LED off if it was on, and on if it was off. */ LPC_GPIO1->FIOSET = (1 << 1); static Bool initDone = TRUE; if (initDone) { static uint16_t initIteration = 0; if (initIteration++ == 33)//not 32 since first value is dummy =0,0 { initDone = FALSE; imuInit_2(); } else imuInit_1(); } else { Matrix_update(); Normalize(); Drift_correction(); Euler_angles(); calculations_motor(); static uint16_t counter = 0; counter++; if (counter == 4) { counter = 0; xSemaphoreGive(xSemaphoreTerminal); } } LPC_GPIO1->FIOCLR = (1 << 1); } } }
/** * Standard hook function that initializes the board for the Monitor program or U-Boot. * - Initializes the UARTs * - Enables i/o to/from both UARTs. * - Initializes the PowerSpan II bridge. */ int BoardInit(void){ /* serial init */ UARTInit(); SerialSelectConsole(SERIAL_SELECT_ALL); #if defined(PRODUCTION) if(InitPowerSpan() != 0){ printf("Unable to initialize PowerSpan II!\n"); } #endif }
void user_init(void) { UARTInit(BIT_RATE_115200); console_printf("\r\n"); /* * Pin number: * ----------- * Pin 0 = GPIO16 * Pin 1 = GPIO5 * Pin 2 = GPIO4 * Pin 3 = GPIO0 * Pin 4 = GPIO2 * Pin 5 = GPIO14 * Pin 6 = GPIO12 * Pin 7 = GPIO13 * Pin 8 = GPIO15 * Pin 9 = GPIO3 * Pin 10 = GPIO1 * Pin 11 = GPIO9 * Pin 12 = GPIO10 */ #if 0 // One DHT22 sensor // Pin number 4 = GPIO2 sensor.pin = 4; sensor.type = DHT22; console_printf("DHT22 init on GPIO%d\r\n", pin_num[sensor.pin]); DHTInit(&sensor); #else // Two DHT22 sensors // Sensor 1: Pin number 3 = GPIO0 sensors[0].pin = 3; sensors[0].type = DHT22; if (DHTInit(&sensors[0])) console_printf("DHT22 #0 init on GPIO%d\r\n", pin_num[sensors[0].pin]); else console_printf("Error init DHT22 #0 on GPIO%d\r\n", pin_num[sensors[0].pin]); // Sensor 2: Pin number 4 = GPIO2 sensors[1].pin = 4; sensors[1].type = DHT22; if (DHTInit(&sensors[1])) console_printf("DHT22 #1 init on GPIO%d\r\n", pin_num[sensors[1].pin]); else console_printf("Error init DHT22 #1 on GPIO%d\r\n", pin_num[sensors[1].pin]); #endif console_printf("--------------------\r\n"); os_timer_disarm(&dht22_timer); os_timer_setfn(&dht22_timer, (os_timer_func_t *)dht22_cb, (void *)0); os_timer_arm(&dht22_timer, DELAY, 1); }
// 主函数(程序入口) int main(void) { jtagWait(); // 防止JTAG失效,重要! clockInit(); // 时钟初始化:晶振,6MHz UARTInit(); ADCInit(); KalMan(); for (;;) { } }
//****************************************************************************** // Main //****************************************************************************** int main() { //sets pin mux for PRU cape PRUCapePinmux(); //Sets and Enables clock, Zeros memory, resets PRU PRUICSSInit(); UARTInit(); MainMenu(); }
void initAll(){ SysTick_Config(SystemCoreClock / 1000); lcd_init(); lcd_home(); lcd_cls(); initPWM(PWM_TIME_PERIOD); setServoAngle(0,0); UARTInit(BAUD_RATE); ds1307Init(); eeprom_24aaInit(); eeprom24aaMemoryCheck(); initButtons(); }
/***************************************************************************** ** Main Function main() *****************************************************************************/ int main (void) { USBD_API_INIT_PARAM_T usb_param; ErrorCode_t ret; USB_CORE_DESCS_T desc; SystemCoreClockUpdate(); /* Setup UART for 115.2K, 8 data bits, no parity, 1 stop bit */ UARTInit(115200); UARTSend((uint8_t *)"\r\nLPC11Uxx USB ROMAPI example>", 31); /* get USB API table pointer */ pUsbApi = (USBD_API_T*)((*(ROM **)(0x1FFF1FF8))->pUSBD); /* enable clocks and pinmux for usb */ USB_pin_clk_init(); /* initilize call back structures */ memset((void*)&usb_param, 0, sizeof(USBD_API_INIT_PARAM_T)); usb_param.usb_reg_base = LPC_USB_BASE; usb_param.mem_base = 0x10001000; usb_param.mem_size = 0x1000; usb_param.max_num_ep = 2; usb_param.USB_Configure_Event = USB_Configure_Event; /* Initialize Descriptor pointers */ memset((void*)&desc, 0, sizeof(USB_CORE_DESCS_T)); desc.device_desc = (uint8_t *)&USB_DeviceDescriptor[0]; desc.string_desc = (uint8_t *)&USB_StringDescriptor[0]; desc.full_speed_desc = (uint8_t *)&USB_FsConfigDescriptor[0]; desc.high_speed_desc = (uint8_t *)&USB_FsConfigDescriptor[0]; /* USB Initialization */ ret = pUsbApi->hw->Init(&hUsb, &desc, &usb_param); if (ret == LPC_OK) { ret = usb_hid_init(hUsb, (USB_INTERFACE_DESCRIPTOR *)&USB_FsConfigDescriptor[sizeof(USB_CONFIGURATION_DESCRIPTOR)], &usb_param.mem_base, &usb_param.mem_size); if (ret == LPC_OK) { NVIC_EnableIRQ(USB_IRQn); // enable USB interrrupts /* now connect */ pUsbApi->hw->Connect(hUsb, 1); } } else { UARTSend((uint8_t *)"\r\nhwUSB_Init error!!!", 21); } while (1); }
int main(void) { int conf, interf; UARTInit(); USBNInit(); DDRA = (1 << DDA4); //PORTA |= (1<<PA4); //on PORTA &= ~(1<<PA4); //off USBNDeviceVendorID(0x1781); //atmel ids USBNDeviceProductID(0x0c62); // atmel ids USBNDeviceBCDDevice(0x0001); char lang[]={0x09,0x04}; _USBNAddStringDescriptor(lang); // language descriptor USBNDeviceManufacture ("B.Sauter"); USBNDeviceProduct ("LEDBLINK"); //0000A0016461 (aktuelle) //0000A0019647 //0000A0000252 conf = USBNAddConfiguration(); USBNConfigurationPower(conf,50); interf = USBNAddInterface(conf,0); USBNAlternateSetting(conf,interf,0); USBNAddInEndpoint(conf,interf,1,0x02,BULK,64,0,NULL); USBNAddOutEndpoint(conf,interf,1,0x02,BULK,64,0,&USBFlash); USBNInitMC(); // start usb chip USBNStart(); sei(); wait_ms(1000); while(1){ PORTA &= ~(1<<PA4); //off wait_ms(100); PORTA |= (1<<PA4); //on wait_ms(100); } }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ static void SetupHardware(void) { SystemInit(); Board_Init(); MyUSB_Init(); UARTInit(115200); #ifdef _MY_UNIT_TEST_ main_blinky(); #else Timer_Init(); #endif // #ifdef _MY_UNIT_TEST_ I2CInit(); ADCInit(); }
void SoftReset() { BYTE ipl_backup = SRbits.IPL; SRbits.IPL = 7; // disable interrupts log_printf("SoftReset()"); TimersInit(); PinsInit(); PWMInit(); ADCInit(); UARTInit(); SPIInit(); I2CInit(); InCapInit(); // TODO: reset all peripherals! SRbits.IPL = ipl_backup; // enable interrupts }