/**************************************************************************** Function InitXbee Returns bool, false if error in initialization, true otherwise Description Saves away the priority, and does any other required initialization for this service Notes Author Connor Anderson and Will Roderick, 05/05/2016 ****************************************************************************/ bool InitXBee (void) { // Init UART 1 InitUart1(); return true; }
void Init44k22(void) { //OSC int 16MHz (62.5ns/inst.) OSCCONbits.IRCF2 = 1; OSCCONbits.IRCF1 = 1; OSCCONbits.IRCF0 = 1; while(!OSCCONbits.HFIOFS); //wait until ready //Uart1 ANSELCbits.ANSC7 = 0; //Port C7 select som digital port ANSELCbits.ANSC6 = 0; //Port C6 select som digital port //Uart2 ANSELDbits.ANSD7 = 0; //Port D7 select som digital port ANSELDbits.ANSD6 = 0; //Port D6 select som digital port //Leds ANSELAbits.ANSA3 = 0; //Port A3 select som digital port Red ANSELEbits.ANSE1 = 0; //Port E1 select som digital port Green ANSELEbits.ANSE2 = 0; //Port E2 select som digital port Blue //InitTimer0(); InitTimer1(); //InitTimer2(); InitTimer3(); InitUart1(); InitUart2(); Init_IO(); }
void Init26k20(){ //OSC int 16MHz (62.5ns/inst.) OSCCONbits.IRCF2 = 1; OSCCONbits.IRCF1 = 1; OSCCONbits.IRCF0 = 1; OSCCONbits.SCS1 = 1; while(!OSCCONbits.IOFS); //wait until ready //dioder ANSEL=0x00; //set ports som digitale ANSELH=0x00; //input //ANSELBbits.ANSB0 = 1; //Port B0 som analog //ANSELBbits.ANSB1 = 1; //Port B1 som analog //ANSELBbits.ANSB2 = 1; //Port B2 som analog //InitTimer0(); InitTimer1(); //InitTimer2(); InitTimer3(); InitUart1(); Init_IO(); }
void InitUart() { void* context_uart0_ptr = (void*) &context_uart0; InitUart1(UART_0_NEW_BAUD); alt_ic_isr_register(UART_0_IRQ_INTERRUPT_CONTROLLER_ID, UART_0_IRQ, IsrUart1, context_uart0_ptr, 0x0); // install UART1 ISR alt_ic_irq_enable (UART_0_IRQ_INTERRUPT_CONTROLLER_ID, UART_0_IRQ); }
int main(void) { // Set the clock to run at 40MhZ using the PLL and 16MHz external crystal SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); TERMIO_Init(); clrScrn(); ES_Return_t ErrorType; // When doing testing, it is useful to announce just which program // is running. puts("\rStarting Test Harness for \r"); printf("the 2nd Generation Events & Services Framework V2.2\r\n"); printf("%s %s\n",__TIME__, __DATE__); printf("\n\r\n"); printf("Press any key to post key-stroke events to Service 0\n\r"); printf("Press 'd' to test event deferral \n\r"); printf("Press 'r' to test event recall \n\r"); // Your hardware initialization function calls go here InitUart1(); // now initialize the Events and Services Framework and start it running ErrorType = ES_Initialize(ES_Timer_RATE_1mS); if ( ErrorType == Success ) { ErrorType = ES_Run(); } //if we got to here, there was an error switch (ErrorType){ case FailedPost: printf("Failed on attempt to Post\n"); break; case FailedPointer: printf("Failed on NULL pointer\n"); break; case FailedInit: printf("Failed Initialization\n"); break; default: printf("Other Failure\n"); break; } for(;;) ; }
//---------------------------------------------------------------------------- VOID Init_StartUp(VOID) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer __disable_interrupt(); // Disable global interrupts Init_Ports(); // Init ports (do first ports because clocks do change ports) SetVCore(3); // USB core requires the VCore set to 1.8 volt, independ of CPU clock frequency Init_Clock(); __enable_interrupt(); // enable global interrupts Port_Mapping(); #ifdef UART0_INTFNUM InitUart0(9600); #endif #ifdef UART1_INTFNUM InitUart1(9600); #endif }
int main(void) { //Ports InitPorts(); //Init Uart1 InitUart1(); //LCD initialisation LCD_Ini(); // delay_ms(2); SEND_CMD(DISP_ON); // delay_ms(10); SEND_CMD(CLR_DISP); // write SEND_STR(" www.olimex.com"); while (1) { // Uart Echo ch = ReceiveCharUart1_nonstop(); if(ch!=0) { SendCharUart1(ch); SendCharUart1('*'); ch = 0; } //Buttons scan // Button 1 if (B1==0) { RELAY_HIGH; } else { RELAY_LOW; } // Button 2 if (B2==0) { SEND_CMD(CLR_DISP); SEND_CMD(DD_RAM_ADDR); SEND_STR("Press button 2"); } // Button 3 if (B3==0) { SEND_CMD(CLR_DISP); SEND_CMD(DD_RAM_ADDR); SEND_STR("Press button 3"); } // Button 4 while (B4==0) Buzzer(); // Button 3 if (B5==0) { SEND_CMD(CLR_DISP); SEND_CMD(DD_RAM_ADDR); SEND_STR("Press button 5"); } } }
void main(void) { unsigned char ch, x, y, z; int i = 0; int j = 0; unsigned char mode = 0x00; unsigned char oldMode = 0x00; // init buttons and seven-segment displays initIO(); // init LCD initLCD(); // initialize I/O-ports PDR08 = 0x00; DDR08 = 0x00; PIER08 = 0x24; // SIN0, SIN1 input enable InitUart1(); // initialize UART Puts1("\nUART LCD Bridge\n"); // Output welcome string // reset buffer at startup //lcd_clear(); lcd_splash(); // loading splashscreen lcd_flush(); while (1) { if (SSR1_RDRF != 0) { // Wait for data received ch = RDR1; // Save receive register if ((SSR1 & 0xE0) != 0) { // Check for errors PE, ORE, FRE SCR1_CRE = 1; // Clear error flags } else { switch(mode) { case 0x00: // idle if(ch == 0xAA) { // cmd for setPixel mode if(oldMode == 0xBB || oldMode == 0x00) { lcd_clear(); lcd_flush(); } mode = 0xAA; i=0; } if(ch == 0xBB) { // cmd for framebuffer mode mode = 0xBB; i=0; j=0; } break; case 0xAA: // setPixel mode if (i == 0) { // x coordinate x = ch; i++; } else if (i == 1) { // y coordinate y = ch; i++; } else if (i == 2) { // value (1=black,0="white") z = ch; i = 0; lcd_drawPixelDirect(x, y, z); oldMode = mode; mode = 0x00; } break; case 0xBB: // framebuffer mode lcd_buffer[i][j] = ch; // write current uart buffer content to framebuffer if(j==7) { i++; j=0; } else j++; // print received framebuffer if(i>=128) { lcd_flush(); oldMode = mode; mode = 0x00; } break; } Putch1(ch); // debug output } } } }