⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 board.c

📁 AT91所有开发板的资料 AT91所有开发板的资料
💻 C
字号:
/***************************************************************************** * Copyright (C) ARM Limited 1998. All rights reserved.  *****************************************************************************//***************************************************************************** * * This file contains EVALUATOR7T specfic C code. * *****************************************************************************/#include	"uhal.h" #include        "errno.h"#include        "mmu_h.h"extern U32 uHALiv_MemorySize;extern U32 uHALiv_TimerVectors[MAX_TIMER + 1]; /* see lib/timer.c */extern struct uHALis_Timer uHALiv_TimerStatus[MAX_TIMER + 1] ; /* ditto */static U32	uHALiv_Leds = ALL_LEDS;/* Set the LED(s) to given value (or mask)*/void uHALir_SetLEDs(U32 value) {   *(U32 *)LED_BANK &= ~ALL_LEDS;   *(U32 *)LED_BANK |= value;}/* Set the state of the specified LED, the LED number passed is not   the bit number but the LED number.  */S32 uHALr_WriteLED(U32 number, U32 state) {  extern U32 uHALiv_LedMasks[uHAL_NUM_OF_LEDS + 1] ;  U32 mask ;  /* translate the LED number into a mask */  mask = uHALiv_LedMasks[number] ;  /* clear or set the bit in the saved LED mask */  if (state)     uHALiv_Leds |= mask ;  else    uHALiv_Leds &= ~mask ;    /* drive the LEDs */  uHALir_SetLEDs(uHALiv_Leds);  return (OK);} /* * Update the register on the target which masks the irq passed to the IC. * This routine is target-specific.  Turn the interrupt source off. */void uHALir_MaskIrq(U32 irq) {   *(volatile int*)INTMSK |= (1 << irq);}/* * Update the register on the target which masks the irq passed to the IC. * This routine is target-specific.  Turn the interrupt source on. */void uHALir_UnmaskIrq(U32 irq) {   *(volatile int*)INTMSK &= ~((1 << INT_GLOBAL) | (1 << irq));   /* Force global disable OFF */}/*============================================================================ * *  routine:     getPlatformId() * *  parameters:  void * *  description: this routine will return the current platform ID * *  calls:       none * *  returns:     platform ID  * */void uHALr_GetPlatformInfo(pInfoType p) {	p->memType = 0 ;	p->memSize = uHALiv_MemorySize;	p->cpuId = 0 ;	p->platformId = PLATFORM_ID ;	return;}/*============================================================================ * * routine:	uHALir_PciHost() * * parameters:	void * * description:	This routine determines if the target is PCI Host. * * calls:	none * * returns:	FALSE if not PCI Host (or PCI not defined for this target)  * */U32 uHALr_PciHost(void) {  return (FALSE) ;}/* Set up the system's timers *//*    They will start counting when Timer Mode register enables them. */static void uHALir_PlatformInitTimers(void) {   *(volatile U32 *)TMOD = 0;}void uHALir_PlatformClearTimerInterrupt(U32 timer){   struct uHALis_Timer *action = &uHALiv_TimerStatus[timer] ;   *(volatile U32 *)INTPND = ( 1 << action->irq); /* clear the pending interrupt */   }/* This routine stops the specified timer hardware. */void uHALir_PlatformDisableTimer(U32 timer) {   U32	temp;   struct uHALis_Timer *action = &uHALiv_TimerStatus[timer] ;   temp = (1 == timer) ? ~TMR_TE0: ~TMR_TE1;   *(volatile U32 *)TMOD &= temp;   /* Seems odd, but this is when we slip in the clear int handler */   action->ClearInterruptRtn = &uHALir_PlatformClearTimerInterrupt;    uHALir_PlatformClearTimerInterrupt( timer );	/* clear any pending interrupt */}/* This routine starts the specified timer hardware. */void uHALir_PlatformEnableTimer(U32 timer) {   U32	temp;   volatile U32 *pTimerDataRegister;   struct uHALis_Timer *action = &uHALiv_TimerStatus[timer] ;   /* Seems odd, but this is when we slip in the clear int handler */   action->ClearInterruptRtn = &uHALir_PlatformClearTimerInterrupt;    if (action->state == T_INTERVAL)    {      action->hw_interval = 1; /* H/W supports interval timer operation */   }   temp = (1 == timer) ? TDATA0: TDATA1;   pTimerDataRegister = (volatile U32 *)temp;   *pTimerDataRegister = action->period;   temp = (1 == timer) ? TMR_TE0: TMR_TE1;   *(volatile U32 *)TMOD |= temp;}/*============================================================================ * *  routine:     uHALir_PlatformInit() * *  parameters:  void * *  description: this routine does platform specific system initialization. * *  calls:       none * *  returns:     void * */void uHALir_PlatformInit(void) {	/* Debug - write to LEDs */	uHALir_SetLEDs((U32) ALL_LEDS) ;#ifndef SEMIHOSTED	/* Turn on MMU & caches by default */	uHALr_InitMMU( 0 ) ;#endif	/* Initialize the timers */	uHALir_PlatformInitTimers() ;	/* re-init the com port */	uHALr_ResetPort() ;	/* Thunderbirds are go.. */}/* Reset the serial port and initialize it. * NOTE: HOST_COMPORT and OS_COMPORT must be defined (see platform.[sh]) *	 * * uHALr_ResetPort() is aliased to be  * uHALir_InitSerial(OS_COMPORT, DEFAULT_OS_BAUD) */void uHALir_InitSerial(unsigned int port, unsigned int baudRate){#ifndef SEMIHOSTED   /* Disable interrupts  */   *(volatile unsigned *) (port + UCON) = 0;   /* Set port for 8 bit, one stop, no parity  */   *(volatile unsigned *) (port + ULCON) = (ULCR8bits);   /* Enable interrupt operation on UART */   *(volatile unsigned *) (port + UCON) = UCRRxM | UCRTxM;   /* Set baud rate  */   *(volatile unsigned *) (port + UBRDIV) = baudRate;#endif}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -