/** * @brief Low level serial driver stop. * @details De-initializes the USART, stops the associated clock, resets the * interrupt vector. * * @param[in] sdp pointer to a @p SerialDriver object * * @notapi */ void sd_lld_stop(SerialDriver *sdp) { if (sdp->state == SD_READY) { usart_deinit(sdp->usart); #if USE_SAM7_USART0 if (&SD1 == sdp) { AT91C_BASE_PMC->PMC_PCDR = (1 << AT91C_ID_US0); AIC_DisableIT(AT91C_ID_US0); return; } #endif #if USE_SAM7_USART1 if (&SD2 == sdp) { AT91C_BASE_PMC->PMC_PCDR = (1 << AT91C_ID_US1); AIC_DisableIT(AT91C_ID_US1); return; } #endif #if USE_SAM7_DBGU_UART if (&SD3 == sdp) { AT91C_BASE_DBGU->DBGU_IDR = 0xFFFFFFFF; return; } #endif } }
void timer_start(Timer *t) { AIC_DisableIT(1); t->time += current_time; t->next = first_timer; first_timer = t; AIC_EnableIT(1); }
/** * @brief Deactivates the SPI peripheral. * * @param[in] spip pointer to the @p SPIDriver object * * @notapi */ void spi_lld_stop(SPIDriver *spip) { if (spip->state != SPI_STOP) { #if AT91SAM7_SPI_USE_SPI0 if (&SPID1 == spip) { AT91C_BASE_PMC->PMC_PCDR = (1 << AT91C_ID_SPI0); AIC_DisableIT(AT91C_ID_SPI0); } #endif #if AT91SAM7_SPI_USE_SPI1 if (&SPID1 == spip) { AT91C_BASE_PMC->PMC_PCDR = (1 << AT91C_ID_SPI1); AIC_DisableIT(AT91C_ID_SPI0); } #endif } }
static void prvSetupTimerInterrupt( void ) { const uint32_t ulPeriodIn_uS = ( 1.0 / ( double ) configTICK_RATE_HZ ) * port1SECOND_IN_uS; /* Setup the PIT for the required frequency. */ PIT_Init( ulPeriodIn_uS, BOARD_MCK / port1MHz_IN_Hz ); /* Setup the PIT interrupt. */ AIC_DisableIT( AT91C_ID_SYS ); AIC_ConfigureIT( AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST, vPortTickISR ); AIC_EnableIT( AT91C_ID_SYS ); PIT_EnableIT(); }
int platform_init() { int i; // Enable the peripherals we use in the PMC PMC_EnablePeripheral( AT91C_ID_US0 ); PMC_EnablePeripheral( AT91C_ID_US1 ); PMC_EnablePeripheral( AT91C_ID_PIOA ); PMC_EnablePeripheral( AT91C_ID_PIOB ); PMC_EnablePeripheral( AT91C_ID_TC0 ); PMC_EnablePeripheral( AT91C_ID_TC1 ); PMC_EnablePeripheral( AT91C_ID_TC2 ); PMC_EnablePeripheral( AT91C_ID_PWMC ); // Configure the timers AT91C_BASE_TCB->TCB_BMR = 0x15; for( i = 0; i < 3; i ++ ) TC_Configure( ( AT91S_TC* )timer_base[ i ], AT91C_TC_CLKS_TIMER_DIV5_CLOCK | AT91C_TC_WAVE ); // PWM setup (only the clocks are set at this point) PWMC_ConfigureClocks( BOARD_MCK, BOARD_MCK, BOARD_MCK ); PWMC_ConfigureChannel( 0, AT91C_PWMC_CPRE_MCKA, 0, 0 ); PWMC_ConfigureChannel( 1, AT91C_PWMC_CPRE_MCKA, 0, 0 ); PWMC_ConfigureChannel( 2, AT91C_PWMC_CPRE_MCKB, 0, 0 ); PWMC_ConfigureChannel( 3, AT91C_PWMC_CPRE_MCKB, 0, 0 ); for( i = 0; i < 4; i ++ ) { PWMC_EnableChannel( i ); PWMC_EnableChannelIt( i ); } cmn_platform_init(); #if VTMR_NUM_TIMERS > 0 // Virtual timer initialization TC_Configure( AT91C_BASE_TC2, AT91C_TC_CLKS_TIMER_DIV5_CLOCK | AT91C_TC_WAVE | AT91C_TC_WAVESEL_UP_AUTO ); AT91C_BASE_TC2->TC_RC = ( BOARD_MCK / 1024 ) / VTMR_FREQ_HZ; AIC_DisableIT( AT91C_ID_TC2 ); AIC_ConfigureIT( AT91C_ID_TC2, 0, ISR_Tc2 ); AT91C_BASE_TC2->TC_IER = AT91C_TC_CPCS; AIC_EnableIT( AT91C_ID_TC2 ); TC_Start( AT91C_BASE_TC2 ); #endif // Initialize the system timer cmn_systimer_set_base_freq( BOARD_MCK / 16 ); cmn_systimer_set_interrupt_period_us( SYSTIMER_US_PER_INTERRUPT ); platform_systimer_init(); return PLATFORM_OK; }
/** * @brief Deactivates the I2C peripheral. * * @param[in] i2cp pointer to the @p I2CDriver object * * @notapi */ void i2c_lld_stop(I2CDriver *i2cp) { /* If not in stopped state then disables the I2C clock.*/ if (i2cp->state != I2C_STOP) { #if SAM7_I2C_USE_I2C1 if (&I2CD1 == i2cp) { AT91C_BASE_TWI->TWI_IDR = AT91C_TWI_TXCOMP | AT91C_TWI_RXRDY | AT91C_TWI_TXRDY | AT91C_TWI_NACK; AT91C_BASE_PMC->PMC_PCDR = (1 << AT91C_ID_TWI); AIC_DisableIT(AT91C_ID_TWI); } #endif } }
/* _____GLOBAL FUNCTIONS_____________________________________________________ */ void usart0_init(void) { // Clear flag usart0_tx_finished_flag = FALSE; // Initialise ring buffers ring_buffer_init(&usart0_rx_ring_buffer, usart0_rx_buffer, USART0_RX_BUFFER_SIZE); ring_buffer_init(&usart0_tx_ring_buffer, usart0_tx_buffer, USART0_TX_BUFFER_SIZE); // Configure PIO pins for USART0 peripheral PIO_Configure(USART0_Pins, PIO_LISTSIZE(USART0_Pins)); // Disable the interrupt on the interrupt controller AIC_DisableIT(AT91C_ID_US0); // Enable USART0 clock PMC_EnablePeripheral(AT91C_ID_US0); // Disable all USART0 interrupts AT91C_BASE_US0->US_IDR = 0xFFFFFFFF; // Configure USART USART_Configure(AT91C_BASE_US0, AT91C_US_USMODE_NORMAL | AT91C_US_CLKS_CLOCK | AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE | AT91C_US_NBSTOP_1_BIT, 115200, BOARD_MCK); USART_SetTransmitterEnabled(AT91C_BASE_US0, 1); USART_SetReceiverEnabled(AT91C_BASE_US0, 1); // Configure the AIC for USART0 interrupts AIC_ConfigureIT(AT91C_ID_US0, AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, usart0_interrupt); // Enable the interrupt on the interrupt controller AIC_EnableIT(AT91C_ID_US0); // Enable selected USART0 interrupts AT91C_BASE_US0->US_IER = AT91C_US_RXRDY | AT91C_US_RXBRK | AT91C_US_OVRE | AT91C_US_FRAME | AT91C_US_PARE; }
void timer_stop(Timer *t) { AIC_DisableIT(1); if (t == first_timer) { first_timer = t->next; } else { for (Timer *prev = first_timer; prev; prev = prev->next) { if (prev->next == t) { prev->next = t->next; break; } } } AIC_EnableIT(1); }
//------------------------------------------------------------------------------ /// Configures the PIT to generate 1ms ticks. //------------------------------------------------------------------------------ static void ConfigurePit(void) { // Initialize and enable the PIT PIT_Init(PIT_PERIOD, BOARD_MCK / 1000000); // Disable the interrupt on the interrupt controller AIC_DisableIT(AT91C_ID_SYS); // Configure the AIC for PIT interrupts AIC_ConfigureIT(AT91C_ID_SYS, 0, ISR_Pit); // Enable the interrupt on the interrupt controller AIC_EnableIT(AT91C_ID_SYS); // Enable the interrupt on the pit PIT_EnableIT(); // Enable the pit PIT_Enable(); }
void PitInit(unsigned int msperiod) { PIT_DisableIT(); // Initialize the PIT to the desired frequency PIT_Init(0, 0); // PIT timer runs at MCK/16 // calculates the PIT Value accurate to a Millisecond interrupt // msperiod can not be larget than 349 because PIV is at a 20bit limit if(msperiod > 349) msperiod = 349; PIT_SetPIV((MCK/(16*1000))*msperiod); // Configure interrupt on PIT AIC_DisableIT(AT91C_ID_SYS); AIC_ConfigureIT(AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST, ISR_Pit); AIC_EnableIT(AT91C_ID_SYS); PIT_EnableIT(); // Enable the pit PIT_Enable(); }
/** * @brief Deactivates the EXT peripheral. * * @param[in] extp pointer to the @p EXTDriver object * * @notapi */ void ext_lld_stop(EXTDriver *extp) { /* Disable interrupt on corresponding PIO port in AIC.*/ AIC_DisableIT(extp->pid); }
//------------------------------------------------------------------------------ /// Reset/stop the touchscreen //------------------------------------------------------------------------------ void TSD_Reset(void) { AIC_DisableIT(AT91C_ID_TSADC); AT91C_BASE_PMC->PMC_PCDR = 1 << AT91C_ID_TSADC; }