void init_interrupts(void)
{
  init_VIC();

  //Timer0 interrupt
  install_irq( TIMER0_INT, (void *) timer0ISR );

  //UART1 interrupt
  install_irq( UART1_INT, (void *) uart1ISR );
  U1IER = 3; //=3; enable THRE and RX interrupt

  //UART0 interrupt
  install_irq( UART0_INT, (void *) uart0ISR );
  U0IER = 3; //=3; enable THRE and RX interrupt

  //I2C0 interrupt
//  install_irq( I2C0_INT, (void *) I2C0MasterHandler );
//  I20CONSET = I2CONSET_I2EN;

  //SSP interrupt
  install_irq( SPI1_INT, (void *) SSPHandler );
  /* Set SSPINMS registers to enable interrupts */
  /* enable all interrupts, Rx overrun, Rx timeout, RX FIFO half full int,
  TX FIFO half empty int */
  SSPIMSC = SSPIMSC_TXIM | SSPIMSC_RXIM | SSPIMSC_RORIM;// | SSPIMSC_RTIM;
  /* SSP Enabled */
  SSPCR1 |= SSPCR1_SSE;
}
示例#2
0
/******************************************************************************
** Function name:		TargetResetInit
**
** Descriptions:		Initialize the target board before running the main()
**						function; User may change it as needed, but may not
**						deleted it.
**
** parameters:			None
** Returned value:		None
**
******************************************************************************/
void TargetResetInit(void)
{
#ifdef __DEBUG_RAM
    MEMMAP = 0x2;			/* remap to internal RAM */
#endif

#ifdef __DEBUG_FLASH
    MEMMAP = 0x1;			/* remap to internal flash */
#endif

#if USE_USB
    PCONP |= 0x80000000;		/* Turn On USB PCLK */
#endif
    /* Configure PLL, switch from IRC to Main OSC */
    ConfigurePLL();

    /* Set system timers for each component */
#if (Fpclk / (Fcclk / 4)) == 1
    PCLKSEL0 = 0x00000000;	/* PCLK is 1/4 CCLK */
    PCLKSEL1 = 0x00000000;
#endif
#if (Fpclk / (Fcclk / 4)) == 2
    PCLKSEL0 = 0xAAAAAAAA;	/* PCLK is 1/2 CCLK */
    PCLKSEL1 = 0xAAAAAAAA;
#endif
#if (Fpclk / (Fcclk / 4)) == 4
    PCLKSEL0 = 0x55555555;	/* PCLK is the same as CCLK */
    PCLKSEL1 = 0x55555555;
#endif

    /* Set memory accelerater module*/
    MAMCR = 0;

#if Fcclk < 20000000
    MAMTIM = 1;
#else
#if Fcclk < 40000000
    MAMTIM = 2;
#else
    MAMTIM = 3;
#endif
#endif
    MAMCR = 2;

    GPIOResetInit();

    init_VIC();
}
示例#3
0
/* Main Program */
int main (void) {
  int j=0;  
  processorInit();
  init_VIC(); //necessary 5-17-2006 EDM
  //initialize the motion control subsystem
  if( !init_motion_control() )
    status_led(MOTION_INIT_ERR);
  init_status_led();
  for(j=0; j<1000000; j++); //short delay here 
  //initialize USB
  usbSetup();
  //if we made it this far, blink to show health
  status_led(HEALTHY);
  while (1)                                /* Loop forever */
  {
	  //Allow USB to send information if any needs to be send
	  SendNextBulkIn(BULK_IN_EP);
  }										   
}
示例#4
0
文件: main.c 项目: dkrishna92/ARM
/******************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{	    
    unsigned long cycle = PWM_CYCLE, offset = 0;

    INIT_LEDS();           // initialize the GPIO's connected to LEDs
    turn_off_all_leds();   // Turnoff all LEDs
    init_VIC();            // Initialize Vectored interrupts

    if ( PWM_Init( 0 ) != TRUE )
    {
		while( 1 );			/* fatal error */
    }

    PWM_Set( cycle, offset );
    PWM_Start();

    while ( 1 )
    {
		if ( match_counter != 0 )
		{
		    match_counter = 0;
		    if( offset <= PWM_CYCLE )
			{
				offset += PWM_OFFSET;
			}
		    else
			{
				offset = 0;
			}
	    	PWM_Set( cycle, offset );
		}
	}
    PWM_Stop() ;
	
    return 0;
}
示例#5
0
/*************************************************************************
 * Function Name: main
 * Parameters: none
 *
 * Return: none
 *
 * Description: main
 *
 *************************************************************************/
int main(void)
{
  MamInit();
  // Init clock
  InitClock();
  // Init GPIO
  GpioInit();
  // Init VIC
  init_VIC();

  // Enable TIM0 clocks  
  PCONP_bit.PCTIM0 = 1; // enable clock  
  PCLKSEL0_bit.PCLK_TIMER0 = 1; //timer clock = pclk

  // Init Time0
  T0TCR_bit.CE = 0;     // counting  disable
  T0TCR_bit.CR = 1;     // set reset
  T0TCR_bit.CR = 0;     // release reset
  T0CTCR_bit.CTM = 0;   // Timer Mode: every rising PCLK edge
  T0MCR_bit.MR0I = 1;   // Enable Interrupt on MR0
  T0MCR_bit.MR0R = 1;   // Enable reset on MR0
  T0MCR_bit.MR0S = 0;   // Disable stop on MR0
  // set timer 0 period
  T0PR = 18-1;
  T0MR0 = (TIMER0_IN_FREQ)/(18 * TIMER0_TICK_PER_SEC);
  // init timer 0 interrupt
  T0IR_bit.MR0INT = 1;  // clear pending interrupt
  VIC_SetVectoredIRQ(Timer0IntrHandler,0,VIC_TIMER0);
  VICINTENABLE |= 1UL << VIC_TIMER0;
  T0TCR_bit.CE = 1;     // counting Enable
  
  __enable_interrupt();
  
  LcdInitPio();
  BoardInit();
  SysSpiInitPio();
  DacInitPio();
  AdcInitPio();
  InitAdc();
  LcdInitModule();
  LcdClear();
  
 // LcdLine(10,32,130, 32);
//  LcdLine(60,10,60, 60);
//  LcdLine(70,10,70, 60);
//  LcdRect(10,20,40, 50);
 // LcdRect(10,1,80, 7);

 /* SetFont(BIG_FONT);

  LcdLine(10, 28, 120, 28);
  LcdLine(10, 45, 120, 45);
 // LcdRect(10, 30, 50, 43);
  
  LcdText(50, 20, 200, 36, "-123456789.0");
  */
  /*
  LcdBmp(10, 20, BMP_HN_WIDTH, BMP_HN_HEIGHT, bmp_hn); 
  LcdBmp(10, 35, BMP_O2_WIDTH, BMP_O2_HEIGHT, bmp_o2); 
  DrawCheckBox(8, 8, 0, 1);
  DrawCheckBox(20, 8, 1, 1);*/
  
 // DrawMainScreen();
  DrawParamScreen();
  LcdClear();
  //DrawMenuScreen();
  
  DrawDOutTestScreen();
  
  LcdDraw();
  
  OutputSet(LCD_LED);

  InitMessages();
  InitKeyb();
  InitCursor();
  InitAdc();
  
//  SetCursorPos(100, 32);
  SendMessage(MSG_EDITOR_SCREEN_ACTIVATE);
  
  int debug = 0, debug2 = 0;
  char s[4];
  
  /*
      LcdClear();
      for(char i = 0; i < 16; i++)
        LcdLine(i * 8, 0, i * 8, 63);
      LcdDraw();
    */  
 // debug = ReadTemp() / 32;
  debug = 3855.0 + 20.0 * ((402.0 - 3855.0) / 20.0);
  unsigned int dac_codes[4] = {0, 0, 0, 0};
  dac_codes[0] = debug;
//  unsigned int dac_codes[4] = {0, 0, 0, 4095};
   WriteToDac(dac_codes);  
 // char adc_codes[4] = {0x58, 0, 0, 0};
 // char adc_codes2[4] = {0, 0, 0, 0,};
  
  char state = 0;
  while(1)
  {
/*
  WriteIntToFram(0, 100);
 
  ReadIntFromFram(0, &debug);  
 */ 
    /*
  WriteToDac(dac_codes);
    */
  /*
  switch(state)
    {
    case 0:
      //if(GetTimer(KEYB_TIMER) > 100)
      if(GetMessage(MSG_R_ENCODER_PRESSED))
      {
           OutputSet(LED11);
           OutputClr(LED12);
           OutputClr(LED13);
           OutputSet(LED15);
           ResetTimer(KEYB_TIMER);
           SendMessage(MSG_CUR_DEACTIVATE);
           state = 1;
      };
      break;
    case 1:
    //  if(GetTimer(KEYB_TIMER) > 100)
      if(GetMessage(MSG_R_ENCODER_PRESSED))      
      {
           OutputClr(LED11);
           OutputSet(LED12);
           OutputClr(LED13);
           OutputClr(LED15);           
           ResetTimer(KEYB_TIMER);
           SendMessage(MSG_CUR_ACTIVATE);
           state = 0;
      };
      break;
    case 2:
//      if(GetTimer(KEYB_TIMER) > 100)
      if(GetMessage(MSG_KEY_PRESSED))      
      {
           OutputClr(LED11);
           OutputClr(LED12);
           OutputSet(LED13);
           OutputClr(LED15);           
           ResetTimer(KEYB_TIMER);
           state = 3;
      };
      break;
    case 3:
     // if(GetTimer(KEYB_TIMER) > 100)
      if(GetMessage(MSG_KEY_PRESSED))      
      {
           OutputClr(LED11);
           OutputClr(LED12);
           OutputClr(LED13);
           OutputSet(LED15);           
           ResetTimer(KEYB_TIMER);
           state = 0;
      };
      break;      
    };
  
    if (GetMessage(MSG_L_ENCODER_CW))
    {
      debug++;
      sprintf(s, "%d", debug);
   //   LcdClear();
      LcdText(0, 0, 63, 9, s);  
      LcdDraw();
    };
     if (GetMessage(MSG_L_ENCODER_CCW))
    {
      debug--;
      sprintf(s, "%d", debug);
    //  LcdClear();
      LcdText(0, 0, 63, 9, s);  
      LcdDraw();      
    };
    
    if (GetMessage(MSG_R_ENCODER_CW))
    {
      debug2++;
      sprintf(s, "%d", debug2);
    //  LcdClear();
      LcdText(100, 0, 127, 9, s);  
      LcdDraw();
    };
     if (GetMessage(MSG_R_ENCODER_CCW))
    {
      debug2--;
      sprintf(s, "%d", debug2);
   //   LcdClear();
      LcdText(100, 0, 127, 9, s);  
      LcdDraw();      
    };
    */
 //   ProcessEditorScreen();
 //   ProcessEditor();
    
    ProcessAdc();
    ProcessCursor();
    ProcessKeyb();
    ProcessMessages();
  }
}