示例#1
0
/*! \brief Enable an EIC interrupt line.
 *
 * This routine maps a GPIO pin and peripheral function to a specified EIC line.
 *
 * \param eic_line      Line number to enable
 * \param eic_pin       GPIO module pin
 * \param eic_func      GPIO module function
 * \param eic_irq       IRQ of the interrupt handler
 * \param eic_handler   Interrupt handler to register
 */
static void eic_irq_connect(uint32_t eic_line, uint32_t eic_pin,
		uint32_t eic_func, uint32_t eic_irq, __int_handler eic_handler)
{
	eic_options_t const eic_options = {
		.eic_line   = eic_line,
		.eic_mode   = EIC_MODE_EDGE_TRIGGERED,
		.eic_edge   = EIC_EDGE_RISING_EDGE,
		.eic_level  = EIC_LEVEL_HIGH_LEVEL,
		.eic_filter = EIC_FILTER_ENABLED,
		.eic_async  = EIC_ASYNCH_MODE
	};

	sysclk_enable_pba_module(SYSCLK_EIC);

	gpio_enable_module_pin(eic_pin, eic_func);
	irq_register_handler(eic_handler, eic_irq, 0);

	eic_init(&AVR32_EIC, &eic_options, 1);
	eic_enable_line(&AVR32_EIC, eic_line);
	eic_enable_interrupt_line(&AVR32_EIC, eic_line);
}
示例#2
0
文件: macb.c 项目: motion55/LWIPTEST2
static void prvSetupMACBInterrupt(volatile avr32_macb_t *macb)
{
#ifdef FREERTOS_USED
  // Create the semaphore used to trigger the MACB task.
  if (xSemaphore == NULL)
  {
    vSemaphoreCreateBinary( xSemaphore );
  }
#else
  // Init the variable counting the number of received frames not yet read.
  DataToRead = 0;
#endif


#ifdef FREERTOS_USED
  if( xSemaphore != NULL)
  {
    // We start by 'taking' the semaphore so the ISR can 'give' it when the
    // first interrupt occurs.
    xSemaphoreTake( xSemaphore, 0 );
#endif
    // Setup the interrupt for MACB.
    // Register the interrupt handler to the interrupt controller at interrupt level 2
    INTC_register_interrupt((__int_handler)&vMACB_ISR, AVR32_MACB_IRQ, AVR32_INTC_INT2);

#if ETHERNET_CONF_USE_PHY_IT == 1
	#if EXTPHY_MACB_USE_EXTINT
	static const gpio_map_t EIC_GPIO_MAP =
	{
		{EXTPHY_MACB_INTERRUPT_PIN, EXTPHY_MACB_INTERRUPT_FUNCTION},
	};
	gpio_enable_module(EIC_GPIO_MAP, sizeof(EIC_GPIO_MAP) / sizeof(EIC_GPIO_MAP[0]));
	// Enable GPIO pull ups for the interrupt pin.
	gpio_enable_pin_pull_up(EXTPHY_MACB_INTERRUPT_PIN);
    // Setup the interrupt for PHY.
    // Register the interrupt handler to the interrupt controller at interrupt level 2
    INTC_register_interrupt((__int_handler)&vPHY_ISR, EXTPHY_MACB_INTERRUPT_IRQ, AVR32_INTC_INT2);
	
	// Enable edge-triggered interrupt.
	eic_options.eic_mode  = EIC_MODE_EDGE_TRIGGERED;
	// Interrupt will trigger on falling edge (this is a must-do for the keypad scan
	// feature if the chosen mode is edge-triggered).
	eic_options.eic_edge  = EIC_EDGE_FALLING_EDGE;
	// Initialize in synchronous mode : interrupt is synchronized to the clock
	eic_options.eic_async = EIC_SYNCH_MODE;
	// Set the interrupt line number.
	eic_options.eic_line  = EXTPHY_MACB_INTERRUPT;
	// Init the EIC controller with the options
	eic_init(&AVR32_EIC, &eic_options, 1);
	// Enable the EIC line.
	eic_enable_line(&AVR32_EIC, EXTPHY_MACB_INTERRUPT);
	// Enable the interrupt for the EIC line.
	eic_enable_interrupt_line(&AVR32_EIC, EXTPHY_MACB_INTERRUPT);
	#else
    /* GPIO enable interrupt upon rising edge */
    gpio_enable_pin_interrupt(EXTPHY_MACB_INTERRUPT_PIN, GPIO_FALLING_EDGE);
    // Setup the interrupt for PHY.
    // Register the interrupt handler to the interrupt controller at interrupt level 2
    INTC_register_interrupt((__int_handler)&vPHY_ISR, (AVR32_GPIO_IRQ_0 + (EXTPHY_MACB_INTERRUPT_PIN/8)), AVR32_INTC_INT2);
	#endif
    /* enable interrupts on INT pin */
    vWriteMDIO( macb, PHY_MICR , ( MICR_INTEN | MICR_INTOE ));
    /* enable "link change" interrupt for Phy */
    vWriteMDIO( macb, PHY_MISR , MISR_LINK_INT_EN );
#endif

    // We want to interrupt on Rx and Tx events
    macb->ier = AVR32_MACB_IER_RCOMP_MASK | AVR32_MACB_IER_TCOMP_MASK;
#ifdef FREERTOS_USED
  }
#endif
}
示例#3
0
///< Initializes ADC (configures Pins, starts Clock, sets defaults)
void ads1274_init_DAC(void) 
{
	function_generator = NULL;
	
	///< set mode to "high resolution"
	gpio_configure_pin(ADC_MODE0,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);	
	gpio_configure_pin(ADC_MODE1,GPIO_DIR_OUTPUT | GPIO_INIT_LOW);	
	
	///< set Format to Fixed-position TDM via SPI
	gpio_configure_pin(ADC_FORMAT0,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);	
	gpio_configure_pin(ADC_FORMAT1,GPIO_DIR_OUTPUT | GPIO_INIT_LOW);	
	gpio_configure_pin(ADC_FORMAT2,GPIO_DIR_OUTPUT | GPIO_INIT_LOW);	
	
	///< configure the four channels
	gpio_configure_pin(ADC_PWDN1,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);	
	gpio_configure_pin(ADC_PWDN2,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);	
	gpio_configure_pin(ADC_PWDN3,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);	
	gpio_configure_pin(ADC_PWDN4,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);	

	//gpio_configure_pin(AVR32_TC1_B0_0_0_PIN,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);	
	//gpio_configure_pin(AVR32_PIN_PC19, GPIO_DIR_OUTPUT| GPIO_INIT_HIGH);	

	ads1274_ADC_switch_clock(true);	
	
	//tc_init_waveform(tc, &waveform_opt);  ///< Initialize the timer/counter .

	///< Set the compare triggers.
	//tc_write_rb(tc, EXAMPLE_TC_CHANNEL_ID, 0x1);     ///< Set RA value.
	//tc_write_rc(tc, EXAMPLE_TC_CHANNEL_ID, 0x2);     ///< Set RC value.
	
	///< Start the timer/counter.
	//tc_start(tc, EXAMPLE_TC_CHANNEL_ID);
	
	///< Enable edge-triggered interrupt.
	eic_options[0].eic_mode   = EIC_MODE_EDGE_TRIGGERED;
	///< Interrupt will trigger on falling edge.
	eic_options[0].eic_edge  = EIC_EDGE_FALLING_EDGE;
	///< Initialize in synchronous mode : interrupt is synchronized to the clock
	eic_options[0].eic_async  = EIC_SYNCH_MODE;
	///< Set the interrupt line number.
	eic_options[0].eic_line   = EXT_NMI;
	
	gpio_enable_module_pin(AVR32_EIC_EXTINT_0_1_PIN, AVR32_EIC_EXTINT_0_1_FUNCTION);
	
	///<Disable_global_interrupt();
	///< Initialize interrupt vectors.
	
	eic_init(&AVR32_EIC, eic_options, 1);

	///<INTC_init_interrupts();
	///< initialize SPI0 interface
	spi_buffered_init(&AVR32_SPI0, ADC_SPI_INDEX);
	spi_buffered_init_DMA(0, 12);
	spi_buffered_set_callback(ADC_SPI_INDEX, &process_data);
	
	///< Register the EIC interrupt handlers to the interrupt controller.
	//INTC_register_interrupt(&eic_int_handler1, AVR32_EIC_IRQ_1, AVR32_INTC_INT1);
	///< Enable the chosen lines and their corresponding interrupt feature.
	eic_enable_line(&AVR32_EIC, eic_options[0].eic_line);
	eic_enable_interrupt_line(&AVR32_EIC, eic_options[0].eic_line);
	
	///< Enable_global_interrupt();
	eic_clear_interrupt_line(&AVR32_EIC, EXT_NMI);
	
	///< activate sync and clkdiv
	gpio_configure_pin(ADC_CLKDIV,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);	
}