/******************************************************************************* * * PROCEDURE NAME: * lptmr_init - * *******************************************************************************/ void lptmr_isr(void* p_arg) { //GPIOB_PSOR = 0x00080000; // clear Port B 19 indicate wakeup // GPIOA_PDOR ^= (1<<16); //APP_TRACE("\n****LPT ISR entered*****\r\n"); // enable timer // enable interrupts // clear the flag LPTMR0_CSR |= LPTMR_CSR_TCF_MASK; // write 1 to TCF to clear the LPT timer compare flag LPTMR0_CSR = ( LPTMR_CSR_TEN_MASK | LPTMR_CSR_TIE_MASK | LPTMR_CSR_TCF_MASK ); dma_setup(); if(GetSysStatus()==ACTIVE_OPEN && GetAccStatus()==ACC_STILL) { sleepcounter++; if(sleepcounter>CPU_STOP_TICK) { sleepcounter=0; SetSysStatus(ACTIVE_STILL); } } _lwsem_post(&g_lptmr_int_sem); }
static void setup_dma_dsp(struct net_device *dev, struct sm_state *sm, int send) { unsigned long flags; static const unsigned char sbcmode[2][2] = { { SBC_LO_INPUT_AUTOINIT, SBC_LO_OUTPUT_AUTOINIT }, { SBC_HI_INPUT_AUTOINIT, SBC_HI_OUTPUT_AUTOINIT } }; static const unsigned char sbc4mode[2] = { SBC4_IN8_AI, SBC4_OUT8_AI }; static const unsigned char sbcskr[2] = { SBC_SPEAKER_OFF, SBC_SPEAKER_ON }; unsigned int nsamps; send = !!send; if (!reset_dsp(dev)) { printk(KERN_ERR "%s: sbc: cannot reset sb dsp\n", sm_drvname); return; } save_flags(flags); cli(); sbc_int_ack_8bit(dev); write_dsp(dev, SBC_SAMPLE_RATE); /* set sampling rate */ write_dsp(dev, SCSTATE->fmt[send]); write_dsp(dev, sbcskr[send]); nsamps = dma_setup(sm, send, dev->dma) - 1; sbc_int_ack_8bit(dev); if (SCSTATE->revhi >= 4) { write_dsp(dev, sbc4mode[send]); write_dsp(dev, SBC4_MODE_UNS_MONO); write_dsp(dev, nsamps & 0xff); write_dsp(dev, nsamps >> 8); } else {
int main(void) { clock_setup(); gpio_setup(); tim_setup(); spi_setup(); dac_setup(); dma_setup(); usb_setup(); /* Attach the device to USB. */ syscfg_enable_usb_pullup(); /* Clear interrupt. */ usbdevfs_clear_interrupt(USBDEVFS_ALL_INTERRUPT); /* Enable interrupt. */ usbdevfs_enable_interrupt(USBDEVFS_CORRECT_TRANSFER | USBDEVFS_ERROR | USBDEVFS_RESET | USBDEVFS_SOF); /* Wait forever and do nothing. */ while (1) __asm__ ("nop"); return 0; }
static int setup_devices() { // Basic prerequisites for everything else miu_setup(); power_setup(); clock_setup(); // Need interrupts for everything afterwards interrupt_setup(); gpio_setup(); // For scheduling/sleeping niceties timer_setup(); event_setup(); wdt_setup(); // Other devices usb_shutdown(); uart_setup(); i2c_setup(); dma_setup(); spi_setup(); return 0; }
static int setup_devices() { // Basic prerequisites for everything else miu_setup(); power_setup(); clock_setup(); // Need interrupts for everything afterwards interrupt_setup(); // gpio_setup(); // Not yet // For scheduling/sleeping niceties timer_setup(); event_setup(); #ifndef CONFIG_IPHONE_4 wdt_setup(); #endif // Other devices usb_shutdown(); #ifndef CONFIG_IPHONE_4 uart_setup(); i2c_setup(); dma_setup(); spi_setup(); #endif return 0; }
void platform_init() { arm_setup(); mmu_setup(); tasks_setup(); // Basic prerequisites for everything else miu_setup(); power_setup(); clock_setup(); // Need interrupts for everything afterwards interrupt_setup(); gpio_setup(); // For scheduling/sleeping niceties timer_setup(); event_setup(); // Other devices uart_setup(); i2c_setup(); dma_setup(); LeaveCriticalSection(); displaypipe_init(); framebuffer_setup(); framebuffer_setdisplaytext(TRUE); }
void main(void) { adc_init(); dma_init(); enter_thread_mode(); sema_wait(&adc_start_sema); struct dma_ctx *ctx; ctx = dma_setup(DMAMUX_ADC0, &ADC_R_REG(ADC0, 0), dstbuf, 2, sizeof(dstbuf)/2, DMA_SRC_STICKY | DMA_DOUBLEBUF | DMA_LOOP, dma_done, NULL); adc_sample_prepare(ADC_MODE_CONTINUOUS); bf_set_reg(ADC_SC2_REG(ADC0), ADC_SC2_DMAEN, 1); ADC_SC1_REG(ADC0, 0) = ADC_SC1_ADCH(0) | ADC_SC1_DIFF_MASK; wait(main); }
static void platform_hardware_setup(void) { // Enable CPU caching setcr0(getcr0() & ~(CR0_CD|CR0_NW)); // Make sure legacy DMA isn't running. dma_setup(); // Init base pc hardware. pic_setup(); mathcp_setup(); timer_setup(); clock_setup(); // Platform specific setup qemu_platform_setup(); coreboot_platform_setup(); }
static void read_thread(void *arg) { USE_SPD_REGS; volatile iop_dmac_chan_t *dev9_chan = (volatile iop_dmac_chan_t *)DEV9_DMAC_BASE; struct eng_args *args = (struct eng_args *)arg; ata_dma_transfer_t *t = &dma_transfer; u32 res; while (1) { while (SleepThread() || WaitSema(args->semid)) ; ClearEventFlag(args->evflg, 0); dma_setup(0); EnableIntr(IOP_IRQ_DMA_DEV9); } }
static int vino_grab(struct vino_device *v, int frame) { int err = 0; spin_lock_irq(&v->state_lock); if (v->buffer_state == VINO_BUF_GRABBING) err = -EBUSY; v->buffer_state = VINO_BUF_GRABBING; spin_unlock_irq(&v->state_lock); if (err) return err; spin_lock_irq(&Vino->vino_lock); dma_setup(v); dma_go(v); spin_unlock_irq(&Vino->vino_lock); return 0; }
static void write_thread(void *arg) { USE_SPD_REGS; volatile iop_dmac_chan_t *dev9_chan = (volatile iop_dmac_chan_t *)DEV9_DMAC_BASE; struct eng_args *args = (struct eng_args *)arg; ata_dma_transfer_t *t = &dma_transfer; u32 res; while (1) { while (SleepThread() || WaitSema(args->semid)) ; ClearEventFlag(args->evflg, 0); dma_setup(1); EnableIntr(IOP_IRQ_DMA_DEV9); /* Initiate the DMA transfer. */ dev9_chan->madr = (u32)dma_buffer; dev9_chan->bcr = ((t->size / 128) << 16) | 32; dev9_chan->chcr = 0x01000201; SPD_REG8(0x4e) = t->command; /* ATA command register. */ SPD_REG8(SPD_R_PIO_DIR) = 1; SPD_REG8(SPD_R_PIO_DATA) = 0; SPD_REG8(SPD_R_XFR_CTRL) |= 0x80; WaitEventFlag(args->evflg, (EF_DMA_DONE|EF_ATA_DONE), 0x11, &res); SPD_REG8(SPD_R_XFR_CTRL) &= 0x7f; DisableIntr(IOP_IRQ_DMA_DEV9, NULL); /* If we got the ATA end signal, force stop the transfer. */ if (res & EF_ATA_DONE) dma_stop(1); SignalSema(args->semid); } }
/*--------------------------------------------------------------------*/ int main(void) { uint32_t i,j; cntr=4; clock_setup(); gpio_setup(); adc_setup(); dma_setup(); /* Start of the ADC. Should continue indefinitely with DMA in circular mode */ adc_start_conversion_regular(ADC1); while (1) { /* Blink the LED (PB8, PB9) on the board. */ uint32_t count = 500*v[1]; gpio_toggle(GPIOD, GPIO12); for (i = 0; i < count; i++) __asm__("nop"); gpio_toggle(GPIOD, GPIO13); for (i = 0; i < count; i++) __asm__("nop"); } return 0; }
static void platform_hardware_setup(void) { // Make sure legacy DMA isn't running. dma_setup(); // Init base pc hardware. pic_setup(); thread_setup(); mathcp_setup(); // Platform specific setup qemu_platform_setup(); coreboot_platform_setup(); // Setup timers and periodic clock interrupt timer_setup(); clock_setup(); // Initialize TPM tpm_setup(); }
void vga_setup ( unsigned char use_dma ) { /* Enable TIM2 clock. */ rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM2EN); //__enable_irq(); //cm_enable_interrupts(); /* Without this the timer interrupt routine will never be called. */ nvic_enable_irq ( NVIC_TIM2_IRQ ); //nvic_set_priority(NVIC_TIM2_IRQ, 0); timer2_setup(); vga_gpio_setup(); if ( use_dma ) { dma_setup(); vga_pixelclock_setup(); } return; }
void platform_init() { arm_setup(); mmu_setup(); tasks_setup(); // Basic prerequisites for everything else miu_setup(); power_setup(); //framebuffer_hook(); // TODO: Remove once LCD implemented -- Ricky26 //framebuffer_setdisplaytext(TRUE); clock_setup(); // Need interrupts for everything afterwards interrupt_setup(); gpio_setup(); // For scheduling/sleeping niceties timer_setup(); event_setup(); // Other devices dma_setup(); //usb_shutdown(); uart_setup(); i2c_setup(); spi_setup(); LeaveCriticalSection(); aes_setup(); }
void rcar_dma_init(void) { dma_enable(); dma_setup(); }
int main(void) { int counter_tx = 0; int counter_rx = 0; cnt_state counter_state = TX_UP_RX_HOLD; int i = 0; /* Transmit and Receive packets, set transmit to index and receive to known unused value to aid in debugging */ #if USE_16BIT_TRANSFERS uint16_t tx_packet[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; uint16_t rx_packet[16] = {0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42}; #else uint8_t tx_packet[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; uint8_t rx_packet[16] = {0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42}; #endif transceive_status = DONE; clock_setup(); gpio_setup(); usart_setup(); usart_print_string("SPI-DMA Test\n\r"); spi_setup(); dma_setup(); /* Blink the LED (PA8) on the board with every transmitted byte. */ while (1) { /* LED on/off */ gpio_toggle(GPIOA, GPIO1); /* Print what is going to be sent on the SPI bus */ usart_print_string("Sending packet (tx len: "); usart_print_int(counter_tx); usart_print_string(")\n\r"); for (i = 0; i < counter_tx; i++) { usart_print_int(tx_packet[i]); usart_print_string(" "); } usart_print_string("\r\n"); /* Start a transceive */ if (spi_dma_transceive(tx_packet, counter_tx, rx_packet, counter_rx)) { usart_print_string("Attempted 0 length tx and rx packets\r\n"); } /* Wait until transceive complete. * This checks the state flag as well as follows the * procedure on the Reference Manual (RM0008 rev 14 * Section 25.3.9 page 692, the note.) */ while (transceive_status != DONE) ; while (!(SPI_SR(SPI2) & SPI_SR_TXE)) ; while (SPI_SR(SPI2) & SPI_SR_BSY) ; /* Print what was received on the SPI bus */ usart_print_string("Received Packet (rx len "); usart_print_int(counter_rx); usart_print_string(")\n\r"); for (i = 0; i < 16; i++) { usart_print_int(rx_packet[i]); usart_print_string(" "); } usart_print_string("\r\n\r\n"); /* Update counters * If we use the loopback method, we can not * have a rx length longer than the tx length. * Testing rx lengths longer than tx lengths * requires an actual slave device that will * return data. */ switch (counter_state) { case TX_UP_RX_HOLD: counter_tx++; if (counter_tx > 15) { counter_state = TX_HOLD_RX_UP; } break; case TX_HOLD_RX_UP: counter_rx++; if (counter_rx > 15) { counter_state = TX_DOWN_RX_DOWN; } break; case TX_DOWN_RX_DOWN: counter_tx--; counter_rx--; if (counter_tx < 1) { counter_state = TX_UP_RX_HOLD; } break; default: ; } /* Reset receive buffer for consistency */ for (i = 0; i < 16; i++) { rx_packet[i] = 0x42; } } return 0; }
int main ( void ) { #if 1 // go for 120MHz, built into libopencm3 // requires: external 8MHz crystal on pin5/6 with associated caps to ground rcc_clock_setup_hse_3v3 ( &hse_8mhz_3v3 [ CLOCK_3V3_120MHZ ] ); #endif #if 1 // fill framebuffer with offset squares //unsigned char i; unsigned int x, y; unsigned char v; for ( y = 0; y < FBHEIGHT; y++ ) { //i = 0; i = ( y / 10 ) % 5; for ( x = 0; x < FBWIDTH; x++ ) { if ( x % 10 == 0 ) { i++; } if ( i == 0 ) { v = (unsigned char) GPIO0; } else if ( i == 1 ) { v = (unsigned char) GPIO1; } else if ( i == 2 ) { v = (unsigned char) GPIO2; } else if ( i == 3 ) { v = (unsigned char) GPIO3; } else if ( i == 4 ) { v = (unsigned char) GPIO4; } else if ( i == 5 ) { v = (unsigned char) GPIO5; } else { i = 0; v = (unsigned char) GPIO0; } *( framebuffer + ( y * FBWIDTH ) + x ) = v; //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char) 0; //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char)( GPIO3 ); //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char)( GPIO5 ); //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char)( GPIO1 | GPIO3 ); //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char)( GPIO1 | GPIO0 ); //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char)( GPIO0 | GPIO1 ); //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char)( GPIO0 | GPIO1 | GPIO2 | GPIO3 ); //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char)( GPIO2 | GPIO3 ); //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char)( GPIO4 | GPIO5 ); } // x } // y #endif #if 0 // fill framebuffer with vertical stripes of all colours (1px per colour) //unsigned char i; unsigned int x, y; unsigned char v; for ( y = 0; y < FBHEIGHT; y++ ) { i = 0; for ( x = 0; x < FBWIDTH; x++ ) { *( framebuffer + ( y * FBWIDTH ) + x ) = i / 6; //*( framebuffer + ( y * FBWIDTH ) + x ) = (unsigned char)( GPIO0 | GPIO1 ); i++; } // x } // y #endif #if 0 // vertical strip every 10 pixels //unsigned char i; unsigned int x, y; for ( y = 0; y < FBHEIGHT; y++ ) { i = 0; for ( x = 0; x < FBWIDTH; x++ ) { if ( i >= 9 ) { *( framebuffer + ( y * FBWIDTH ) + x ) = GPIO0; } if ( i == 12 ) { i = 0; } i++; } // x } // y #endif gpio_setup(); /* Enable TIM2 clock. */ rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM2EN); //__enable_irq(); //cm_enable_interrupts(); nvic_setup(); timer2_setup(); dma_setup(); gpio_set ( GPIOB, GPIO12 ); TIM_SR(TIM2) &= ~TIM_SR_UIF; /* Clear interrrupt flag. */ while ( 1 ) { __asm__("nop"); } // while forever return 0; }