예제 #1
0
int main(void)
{
    int i;
	wrc_initialize();

    while (1) { 
        uart_write_string("LED on!\n");
        for (i = 0; i < 125000000; ++i) { asm(""); }
            //*codr = 1;
        uart_write_string("LED off!\n");
        for (i = 0; i < 125000000; ++i) { asm(""); }
            //*sodr = 1;
    }
}
예제 #2
0
void wrc_initialize()
{
	int ret, i;
    char sfp_pn[17];
	
	uart_init();

	uart_write_string(__FILE__ " is up (compiled on "
			  __DATE__ " " __TIME__ ")\n");

	//mprintf("wr_core: starting up (press G to launch the GUI and D for extra debug messages)....\n");
}
예제 #3
0
int kernel_main (void){
	unsigned int register_a;
	unsigned int register_b;

	//Pull-up/pull-down thingy procedure enabling us to write on GPIO addresses...
	write_to_address(GPPUD,0);
	for(register_a = 0; register_a < 150; register_a++){
		delay(register_a);
	}
	//... specifically, GPIO pins 4, 22, 24, 25 and 27
	write_to_address(GPPUDCLK0, (1<<14)|(1<<15)|(1<<21));
	for(register_a = 0; register_a < 150; register_a++){
		delay(register_a);
	}
	write_to_address(GPPUDCLK0,0);

	//Initialization of UART
	//Disable the UART (if it should be enabled already).
	//TODO: Below line does not work if we are not in U-Boot.
	//write_to_address(UART0_CR, (0 << 0));

	//The rest of initialization
	write_to_address(UART0_ICR, 0x7FF);
	write_to_address(UART0_IBRD, 1); //NOTE: Number not in hexadecimal
	write_to_address(UART0_FBRD, 40); //NOTE: Number not in hexadecimal
	write_to_address(UART0_LCRH, (1 << 4) | (1 << 5) | (1 << 6));
	write_to_address(UART0_IMSC, (1 << 1) | (1 << 4) | (1 << 5) | (1 << 6) |
	                       (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10));
	write_to_address(UART0_CR, (1 << 0) | (1 << 8) | (1 << 9));

	//Initialization of timer
	write_to_address(ARM_TIMER_CTL, 0x00F90000);
	write_to_address(ARM_TIMER_CTL, 0x00F90200);

	//Initialize LED
	register_a = read_from_address(LED_GPFSEL);
	register_a |= (1 << 21);
	write_to_address(LED_GPFSEL, register_a);

	//Infinite loop with timed blinks
	register_b = read_from_address(ARM_TIMER_CNT);
	while(1){
		//LED on!
		write_to_address(LED_GPSET, 1<<15);
		uart_write_string("Hello, kernel world!\r\n");
		while(1){
			register_a = read_from_address(ARM_TIMER_CNT);
			if((register_a - register_b) >= TIMEOUT){
				break;
			}
		}
		register_b += TIMEOUT;
		//LED off!
		write_to_address(LED_GPCLR, 1<<15);
		uart_write_string("Goodbye, kernel world!\r\n");
		while(1){
			register_a = read_from_address(ARM_TIMER_CNT);
			if((register_a - register_b) >= TIMEOUT){
				break;
			}
		}
		register_b += TIMEOUT;
	}
	return(0);
}
예제 #4
0
파일: main.c 프로젝트: stefanrauch/scu_demo
void scu_init()
{
  	uchar FamilySN[MAXDEVICES][8];
	int current_temp;
	int c_frac;
  	int i = 0;
  	int j = 0;
	int cnt = 0;
  	int NumDevices = 0;
  	SMALLINT didRead = 0;
	uchar read_buffer[32];
	uchar write_buffer[32];

	owInit();
	uart_init();
	uart_write_string("SCU\n");
 
  	//use port number for 1-wire
  	uchar portnum = ONEWIRE_PORT;
     j = 0;
     // Find the device(s)
     NumDevices  = 0;
     NumDevices += FindDevices(portnum, &FamilySN[NumDevices], 0x42, MAXDEVICES-NumDevices);
     NumDevices += FindDevices(portnum, &FamilySN[NumDevices], 0x20, MAXDEVICES-NumDevices);
     NumDevices += FindDevices(portnum, &FamilySN[NumDevices], 0x43, MAXDEVICES-NumDevices);
     if (NumDevices)
     {
        mprintf("\r\n");

        // read the temperature and print serial number and temperature
        for (i = NumDevices; i; i--)
        {
           mprintf("(%d) ", j++);
           DisplaySerialNum(FamilySN[i-1]);
           if (FamilySN[i-1][0] == 0x43) {
//		if(!Write43(portnum, FamilySN[i-1], write_buffer))
//			mprintf("write failed!\n");
	  	owLevel(portnum, MODE_NORMAL); 
		if (ReadMem43(portnum, FamilySN[i-1], read_buffer))
		{
			for(cnt = 0; cnt < 32; cnt++)
			{
				mprintf("read_buffer[%x]: %x\n",cnt, read_buffer[cnt]);
			}
		}
		continue;
	   }

	   if (FamilySN[i-1][0] == 0x42) {
             didRead = ReadTemperature42(portnum, FamilySN[i-1],&current_temp,&c_frac);
	   }
           if (didRead)
           {
             	mprintf(" %d",current_temp);
		if (c_frac)
			mprintf(".5");
		else
			mprintf(".0");
		mprintf(" deegree celsius\r\n");
	   }
           else
           {
             mprintf("  Convert failed.  Device is");
             if(!owVerify(portnum, FALSE))
                mprintf(" not");
             mprintf(" present.\r\n");
#ifdef SOCKIT_OWM_ERR_ENABLE
             while(owHasErrors())
                 mprintf("  - Error %d\r\n", owGetErrorNum());
#endif
           }
 
        }
     }
     else
        mprintf("No temperature devices found!\r\n");
	
}