void or1k_uart_set_read_cb(void (*cb)(char c)) { _or1k_uart_read_cb = cb; // Enable interrupt REG8(IER) = 1 << IER_RDAI; or1k_interrupt_handler_add(_or1k_board_uart_IRQ, _or1k_uart_interrupt_handler, 0); or1k_interrupt_enable(_or1k_board_uart_IRQ); }
void or1k_uart_set_read_cb(void (*cb)(char c)) { // Set callback function _or1k_uart_read_cb = cb; // Enable interrupt REG8(IER) = 1 << IER_RDAI; // Add the interrupt handler that calls the callback function or1k_interrupt_handler_add(_or1k_board_uart_IRQ, _or1k_uart_interrupt_handler, 0); // Enable UART interrupt or1k_interrupt_enable(_or1k_board_uart_IRQ); }
int main(int arcg,char * argv[]){ int i = or1k_mfspr(17); char * newline = "\n"; //_cust_print_int((int)newline); *(volatile char*)0x80000000 = 'm'; *(volatile char*)0x80000000 = 'a'; *(volatile char*)0x80000000 = 'i'; *(volatile char*)0x80000000 = 'n'; *(volatile char*)0x80000000 = ' '; *(volatile char*)0x80000000 = 'c'; *(volatile char*)0x80000000 = 'a'; *(volatile char*)0x80000000 = 'l'; *(volatile char*)0x80000000 = 'l'; *(volatile char*)0x80000000 = 'e'; *(volatile char*)0x80000000 = 'd'; *(volatile char*)0x80000000 = '\n'; for (int i = 0;i<32;i++) global_irqhandler[i] = 0; global_irqhandler[2] = irq2; or1k_exception_handler_add (0x8, &interrupt_handler); or1k_interrupt_enable(2); /*__asm__( ".byte 0x7C,0x00,0x00,0x00" );*/ // Timer interrupt int or1k_timer_period = 40000; or1k_exception_handler_add(0x5, &timer_isr); // Install handler for Timer interrupt or1k_mtspr(10<<11, 0x00<<24 | or1k_timer_period); // Set Timer Mode Register or1k_mtspr(17, or1k_mfspr(17) | 2 ); // Set Special Purpose Register: Enable Timer interrupt or1k_mtspr((10<<11) + 1, 0); // reset counter register (qemu bug: automatic counter reset does not work) for (int i = 1;i<10000; i = i * 2){ _cust_print_int(i); _cust_print(newline); } //or1k_exception_handler_add (0x8, &or1k_interrupt_handler); //or1k_interrupt_handler_add(11, &irq2); //or1k_interrupt_enable(10); /* float x = 0; for (int j = 0;j<(1<<16);j++){ for (int i = 0;i<(100);i++){ x += 0.1; } *((int*)0x0000A000) = (int) x; } *((int*)0x10000000) = 0; */ float p = 2 * F(1); _cust_print("pi 1: "); _cust_print_float(p); _cust_print("\n"); _cust_print("pi 2: "); _cust_print_float(pi()); _cust_print("\n"); //if (pi > 0.0) //_cust_print("\n\n3-pi > 0\n\n\n"); //float c = 0; //for (int i = 0;i < 10000000;i++){ // c+=0.1; //} //return (int)c; return 0; }