Ejemplo n.º 1
0
void us_ticker_init(void) {
    if (us_ticker_inited) return;
    us_ticker_inited = 1;
    
    pit_init();
    lptmr_init();
}
Ejemplo n.º 2
0
int timer_init(tim_t dev, unsigned long freq, timer_cb_t cb, void *arg)
{
    if ((unsigned int)dev >= TIMER_NUMOF) {
        /* invalid timer */
        return -1;
    }
    /* demultiplex to handle two types of hardware timers */
    switch (_timer_variant(dev)) {
        case TIMER_PIT:
            return pit_init(_pit_index(dev), freq, cb, arg);
        case TIMER_LPTMR:
            return lptmr_init(_lptmr_index(dev), freq, cb, arg);
        default:
            return -1;
    }
}
void main (void)
{
#ifndef RAM16 
        int i;
        int counter = 0;
#endif
        
#ifdef KEIL
	start();
#endif
        
                
        LLWU_Init();
       
        SW_LED_Init(); 
        LED0_ON;
        LED1_ON;
        LED2_ON;
        LED3_ON;

        // Dynamic interrupt vector modification whilst those interrupts are disabled
//        __VECTOR_RAM[INT_ADC0] = (uint32)adc0_isr;  // plug isr into vector table in case not there already
        
         
        if ((RCM_SRS0 & RCM_SRS0_POR_MASK) || (RCM_SRS0 & RCM_SRS0_PIN_MASK))
        {
            printf("\nRunning VLPR LLS ADC Demo Project");
//           ch = in_char();
//	   out_char(ch);
  //       disable_uart();
        
           init_ADC16();            
            
        }
        lptmr_init(100,  LPTMR_USE_LPOCLK); 
        
        /* Enable LPTMR wakeup interrupt */
        enable_irq(LPTMR_irq_no);
        
        /* Enable ADC ready for this interrupt. */
//        enable_irq(ADC0_irq_no) ;    
        
        EnableInterrupts;
           
        //Set the STOPM field to 0b011 for LLS mode  
        SMC_PMCTRL |= SMC_PMCTRL_STOPM(0x3) ; 
        dummyread=SMC_PMCTRL;
      
        // Set the SLEEPDEEP bit to enable deep sleep mode (STOP) 
        SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;	         
#ifdef RAM16
       ram_main();        
#else
       while(1)
        {            
            // WFI instruction will start entry into LLS mode
          counter++;
	  if (counter & 0x0001)
	   	      F_LED0_ON;
	  else
	   	      F_LED0_OFF;
	  if (counter & 0x0002)
	   	      F_LED3_ON;
	  else
	   		  F_LED3_OFF;
	  if (counter & 0x0004)
	   	      F_LED2_ON;
	  else
	   	      F_LED2_OFF;
          if (counter & 0x0008)
	   	      F_LED1_ON;
          else
        	      F_LED1_OFF;
	       
	  asm("WFI");
          for (i=0;i<1000;i++){
             if (ADC0_SC2 & ADACT_ACTIVE)
                F_LED2_TOGGLE;
             else
                break;
          }
          result0A = ADC0_RA ;    
        }
#endif       
}