/* ** configures arm interrupt controller to generate raster interrupt */ void SetupIntc(void) { #ifdef _TMS320C6X IntDSPINTCInit(); IntRegister(C674X_MASK_INT4, LCDIsr); IntEventMap(C674X_MASK_INT4, SYS_INT_LCDC_INT); IntEnable(C674X_MASK_INT4); IntGlobalEnable(); #else /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); /* Register the ISR in the Interrupt Vector Table.*/ IntRegister(SYS_INT_LCDINT, LCDIsr); /* Set the channnel number 2 of AINTC for LCD system interrupt. */ IntChannelSet(SYS_INT_LCDINT, 2); /* Enable the System Interrupts for AINTC.*/ IntSystemEnable(SYS_INT_LCDINT); IntSystemEnable(SYS_INT_I2CINT0); /* Enable IRQ in CPSR.*/ IntMasterIRQEnable(); /* Enable the interrupts in GER of AINTC.*/ IntGlobalEnable(); /* Enable the interrupts in HIER of AINTC.*/ IntIRQEnable(); #endif }
void _EDMAAppRegisterEdma3Interrupts() { /* Enable IRQ in CPSR. */ IntMasterIRQEnable(); /* Intialize ARM interrupt controller */ IntAINTCInit(); /* Register Interrupts Here */ /******************** Completion Interrupt ********************************/ /* Registers Edma3ComplHandler0 Isr in Interrupt Vector Table of AINTC. */ IntRegister(SYS_INT_EDMACOMPINT , _EDMAAppEdma3ccComplIsr); /* Set priority for system interrupt in AINTC */ IntPrioritySet(SYS_INT_EDMACOMPINT, 0u, AINTC_HOSTINT_ROUTE_IRQ); /* Enable the EDMA CC0 system interrupt in AINTC.*/ IntSystemEnable(SYS_INT_EDMACOMPINT); /********************** CC Error Interrupt ********************************/ /* ** Registers the EDMA3_0 Channel Controller 0 Error Interrupt Isr in the ** Interrupt Vector Table of AINTC. */ IntRegister(SYS_INT_EDMAERRINT , _EDMAAppEdma3ccErrIsr); /* Set priority for system interrupt in AINTC */ IntPrioritySet(SYS_INT_EDMAERRINT, 0u, AINTC_HOSTINT_ROUTE_IRQ); /* Enable the EDMA CCERR system interrupt AINTC.*/ IntSystemEnable(SYS_INT_EDMAERRINT); }
/* ** This function configures the AINTC to receive EDMA3 interrupts. */ static void EDMA3AINTCConfigure(void) { /* Initializing the ARM Interrupt Controller. */ IntAINTCInit(); /* Registering EDMA3 Channel Controller transfer completion interrupt. */ IntRegister(EDMA_COMPLTN_INT_NUM, Edma3CompletionIsr); /* Setting the priority for EDMA3CC completion interrupt in AINTC. */ IntPrioritySet(EDMA_COMPLTN_INT_NUM, 0, AINTC_HOSTINT_ROUTE_IRQ); /* Registering EDMA3 Channel Controller Error Interrupt. */ IntRegister(EDMA_ERROR_INT_NUM, Edma3CCErrorIsr); /* Setting the priority for EDMA3CC Error interrupt in AINTC. */ IntPrioritySet(EDMA_ERROR_INT_NUM, 0, AINTC_HOSTINT_ROUTE_IRQ); /* Enabling the EDMA3CC completion interrupt in AINTC. */ IntSystemEnable(EDMA_COMPLTN_INT_NUM); /* Enabling the EDMA3CC Error interrupt in AINTC. */ IntSystemEnable(EDMA_ERROR_INT_NUM); /* Registering HSMMC Interrupt handler */ IntRegister(MMCSD_INT_NUM, HSMMCSDIsr); /* Setting the priority for EDMA3CC completion interrupt in AINTC. */ IntPrioritySet(MMCSD_INT_NUM, 0, AINTC_HOSTINT_ROUTE_IRQ); /* Enabling the HSMMC interrupt in AINTC. */ IntSystemEnable(MMCSD_INT_NUM); /* Enabling IRQ in CPSR of ARM processor. */ IntMasterIRQEnable(); }
int main(void) { /* Setup the MMU and do necessary MMU configurations. */ MMUConfigAndEnable(); /* Enable all levels of CACHE. */ CacheEnable(CACHE_ALL); /* Initialize the UART console */ ConsoleUtilsInit(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); ConsoleUtilsPrintf("McASP Example Application. "); ConsoleUtilsPrintf("Please connect headphone/speaker to the LINE OUT"); ConsoleUtilsPrintf(" of the EVM to listen to the audio tone."); /* Enable the module clock for I2C0 Instance. */ I2C0ModuleClkConfig(); /* Set up the pin mux for I2C0 instance. */ I2CPinMuxSetup(0); /* Enable the module clock for McASP1 Instance. */ McASP1ModuleClkConfig(); /* Enable pin-mux for McASP1 instance. */ McASP1PinMuxSetup(); /* Enable the EDMA module clocks. */ EDMAModuleClkConfig(); /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); /* Enable EDMA Interrupt. */ EDMA3IntSetup(); /* Enable McASP Interrupt. */ McASPIntSetup(); /* Initialize the I2C interface for the codec AIC31 */ I2CCodecIfInit(I2C_INST_BASE, I2C_SLAVE_CODEC_AIC31); /* Enable the interrupts generation at global level */ IntMasterIRQEnable(); /* Configure the Codec for I2S mode */ AudioCodecInit(); /* Initialize the looping of tone. */ ToneLoopInit(); /* Start playing tone. */ AudioTxActivate(); while(1); }
/* ** Configures arm/dsp interrupt controller to generate frame interrupt */ static void SetupIntc(void) { #ifdef _TMS320C6X /* Initialize the DSP interrupt controller */ IntDSPINTCInit(); /* Register VPIF ISR to vector table */ IntRegister(C674X_MASK_INT5, VPIFIsr); /* Map system interrupt to DSP maskable interrupt for VPIF */ IntEventMap(C674X_MASK_INT5, SYS_INT_VPIF_INT); /* Enable DSP maskable interrupt for VPIF */ IntEnable(C674X_MASK_INT5); /* Register LCD ISR to vector table */ IntRegister(C674X_MASK_INT6, LCDIsr); /* Map system interrupt to DSP maskable interrupt for LCD */ IntEventMap(C674X_MASK_INT6, SYS_INT_LCDC_INT); /* Enable DSP maskable interrupt for LCD */ IntEnable(C674X_MASK_INT6); /* Enable DSP interrupts */ IntGlobalEnable(); #else /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); /* Register the ISR in the Interrupt Vector Table.*/ IntRegister(SYS_INT_VPIF, VPIFIsr); /* Set the channel number 2 of AINTC for LCD system interrupt. */ IntChannelSet(SYS_INT_VPIF, 2); /* Enable the System Interrupts for AINTC.*/ IntSystemEnable(SYS_INT_VPIF); /* Register the ISR in the Interrupt Vector Table.*/ IntRegister(SYS_INT_LCDINT, LCDIsr); /* Set the channnel number 2 of AINTC for LCD system interrupt. */ IntChannelSet(SYS_INT_LCDINT, 3); /* Enable the System Interrupts for AINTC.*/ IntSystemEnable(SYS_INT_LCDINT); /* Enable IRQ in CPSR.*/ IntMasterIRQEnable(); /* Enable the interrupts in GER of AINTC.*/ IntGlobalEnable(); /* Enable the interrupts in HIER of AINTC.*/ IntIRQEnable(); #endif }
int main(void) { MMUConfigAndEnable(); CacheEnable(CACHE_ALL); IntMasterIRQEnable(); IntAINTCInit(); /* Initialize console for communication with the Host Machine */ ConsoleUtilsInit(); // //Delay timer setup // DelayTimerSetup(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); ConsoleUtilsPrintf("LCDC Controller\r\n"); LCDAINTCConfigure(); LCDBackLightEnable(); SetUpLCD(); /* Configuring the base ceiling */ RasterDMAFBConfig(LCDC_INSTANCE, (unsigned int)curr_image, (unsigned int)curr_image + sizeof(image1) - 2, 0); RasterDMAFBConfig(LCDC_INSTANCE, (unsigned int)curr_image, (unsigned int)curr_image + sizeof(image1) - 2, 1); /* Enable End of frame0/frame1 interrupt */ RasterIntEnable(LCDC_INSTANCE, RASTER_END_OF_FRAME0_INT | RASTER_END_OF_FRAME1_INT); /* Enable raster */ RasterEnable(LCDC_INSTANCE); while(1) { if (curr_image == image1) { curr_image = image2; } else { curr_image = image1; } delay(5000); } }
static void USBInterruptEnable(int usbInstance) { /* Enabling IRQ in CPSR of ARM processor. */ IntMasterIRQEnable(); /* Initializing the ARM Interrupt Controller. */ IntAINTCInit(); /* Configuring AINTC to receive UART0 interrupts. */ USBAINTCConfigure(usbInstance); LCDAINTCConfigure(); }
/* ** Do the necessary DMTimer configurations on to AINTC. */ static void DMTimerAintcConfigure(void) { /* Initialize the ARM interrupt control */ IntAINTCInit(); /* Registering DMTimerIsr */ IntRegister(SYS_INT_TINT2, DMTimerIsr); /* Set the priority */ IntPrioritySet(SYS_INT_TINT2, 0, AINTC_HOSTINT_ROUTE_IRQ); /* Enable the system interrupt */ IntSystemEnable(SYS_INT_TINT2); }
/* ** This function configures the AINTC to receive UART interrupts. */ static void UART0AINTCConfigure(void) { /* Initializing the ARM Interrupt Controller. */ IntAINTCInit(); /* Registering the Interrupt Service Routine(ISR). */ IntRegister(SYS_INT_UART0INT, UARTIsr); /* Setting the priority for the system interrupt in AINTC. */ IntPrioritySet(SYS_INT_UART0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); /* Enabling the system interrupt in AINTC. */ IntSystemEnable(SYS_INT_UART0INT); }
/* Interrupt mapping to AINTC and registering McSPI ISR */ static void McSPI0AintcConfigure(void) { /* Initialze ARM interrupt controller */ IntAINTCInit(); /* Register McSPIIsr interrupt handler */ IntRegister(SYS_INT_SPI0INT, McSPIIsr); /* Set Interrupt Priority */ IntPrioritySet(SYS_INT_SPI0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); /* Enable system interrupt in AINTC */ IntSystemEnable(SYS_INT_SPI0INT); }
static void SetupIntc(void) { /* Enable IRQ in CPSR.*/ IntMasterIRQEnable(); /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); IntRegister(SYS_INT_ADC_TSC_GENINT, ADCIsr); IntPrioritySet(SYS_INT_ADC_TSC_GENINT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_ADC_TSC_GENINT); }
static void SetupAINTCInt(void) { /*Initialize the ARM Interrupt Controller(AINTC). */ IntAINTCInit(); /* Enable IRQ in CPSR.*/ IntMasterIRQEnable(); /* Enable the interrupts in GER of AINTC.*/ IntGlobalEnable(); /* Enable the interrupts in HIER of AINTC.*/ IntIRQEnable(); }
static void USBInterruptEnable(void) { /* Enabling IRQ in CPSR of ARM processor. */ IntMasterIRQEnable(); /* Initializing the ARM Interrupt Controller. */ IntAINTCInit(); /* Configuring AINTC to receive USB0 interrupts. */ USB0AINTCConfigure(); /*Configuring AINTC to receive LCD interrupts. */ LCDAINTCConfigure(); }
/** * \brief Initialize the AINTC by enabling normal interrupts (IRQ) and fast interrupts (FIQ) on all required levels * * \return none **/ void interrupt_init(void) { /* Initialize AINTC - this should only be done once per application */ IntAINTCInit(); /* Enable IRQ for ARM (in CPSR)*/ IntMasterIRQEnable(); /* Enable AINTC interrupts in GER */ IntGlobalEnable(); /* Enable IRQ in AINTC */ IntIRQEnable(); IntMasterFIQEnable(); IntFIQEnable(); }
/* ** configures arm interrupt controller to generate PWM interrupts */ static void SetupIntc(void) { #ifdef _TMS320C6X // Initialize the DSP interrupt controller IntDSPINTCInit(); // Register the ISRs to the vector table IntRegister(C674X_MASK_INT4, PWMEventIsr); IntRegister(C674X_MASK_INT5, PWMTZIsr); // Map system events to the DSP maskable interrupts IntEventMap(C674X_MASK_INT4, SYS_INT_EHRPWM1); IntEventMap(C674X_MASK_INT5, SYS_INT_EHRPWM1TZ); // Enable the DSP maskable interrupts IntEnable(C674X_MASK_INT4); IntEnable(C674X_MASK_INT5); // Enable DSP interrupts globally IntGlobalEnable(); #else /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); IntSystemStatusClear(SYS_INT_EHRPWM1); EHRPWMETIntClear(SOC_EHRPWM_1_REGS); /************************PWM1****************************************/ IntRegister(SYS_INT_EHRPWM1, PWMEventIsr); IntChannelSet(SYS_INT_EHRPWM1, 2); IntSystemEnable(SYS_INT_EHRPWM1); /********************************************************************/ IntRegister(SYS_INT_EHRPWM1TZ, PWMTZIsr); IntChannelSet(SYS_INT_EHRPWM1TZ, 2); IntSystemEnable(SYS_INT_EHRPWM1TZ); /********************************************************************/ /* Enable IRQ in CPSR.*/ IntMasterIRQEnable(); /* Enable the interrupts in GER of AINTC.*/ IntGlobalEnable(); /* Enable the interrupts in HIER of AINTC.*/ IntIRQEnable(); #endif }
/* ** Set up the ARM Interrupt Controller for generating timer interrupt */ static void TimerIntrSetUp(void) { #ifdef _TMS320C6X /* Initialize the DSPINTC */ IntDSPINTCInit(); /* Register the Timer ISR */ IntRegister(C674X_MASK_INT4, TimerIsr); /* Map Timer interrupts to DSP maskable interrupt */ IntEventMap(C674X_MASK_INT4, SYS_INT_T64P2_TINTALL); /* Enable DSP interrupt in DSPINTC */ IntEnable(C674X_MASK_INT4); /* Enable DSP interrupts */ IntGlobalEnable(); #else /* Initialize AINTC and register timer interrupt */ IntAINTCInit(); /* Register the Timer ISR */ IntRegister(SYS_INT_TIMR2_ALL, TimerIsr); /* Set the channel number for Timer interrupt, it will map to IRQ */ IntChannelSet(SYS_INT_TIMR2_ALL, 2); /* Enable IRQ for ARM (in CPSR)*/ IntMasterIRQEnable(); /* Enable AINTC interrupts in GER */ IntGlobalEnable(); /* Enable IRQ in AINTC */ IntIRQEnable(); /* Enable timer interrupts in AINTC */ IntSystemEnable(SYS_INT_TIMR2_ALL); #endif }
static void SetupInt(void) { #ifdef _TMS320C6X // Initialize the DSP INTC IntDSPINTCInit(); // Enable DSP interrupts globally IntGlobalEnable(); #else /* Initialize the ARM Interrupt Controller(AINTC). */ IntAINTCInit(); /* Enable IRQ in CPSR.*/ IntMasterIRQEnable(); /* Enable the interrupts in GER of AINTC.*/ IntGlobalEnable(); /* Enable the interrupts in HIER of AINTC.*/ IntIRQEnable(); #endif }
/* ** This function configures the AINTC to receive EDMA3 interrupts. */ static void EDMA3INTCConfigure(void) { /* Initializing the ARM Interrupt Controller. */ IntAINTCInit(); /* Registering EDMA3 Channel Controller 0 transfer completion interrupt. */ IntRegister(SYS_INT_EDMACOMPINT, Edma3CompletionIsr); /* Setting the priority for EDMA3CC0 completion interrupt in AINTC. */ IntPrioritySet(SYS_INT_EDMACOMPINT, 0, AINTC_HOSTINT_ROUTE_IRQ); /* Registering EDMA3 Channel Controller 0 Error Interrupt. */ IntRegister(SYS_INT_EDMAERRINT, Edma3CCErrorIsr); /* Setting the priority for EDMA3CC0 Error interrupt in AINTC. */ IntPrioritySet(SYS_INT_EDMAERRINT, 0, AINTC_HOSTINT_ROUTE_IRQ); /* Enabling the EDMA3CC0 completion interrupt in AINTC. */ IntSystemEnable(SYS_INT_EDMACOMPINT); /* Enabling the EDMA3CC0 Error interrupt in AINTC. */ IntSystemEnable(SYS_INT_EDMAERRINT); }
/* ** configures arm interrupt controller to generate raster interrupt */ static void SetupIntc(void) { /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); /* Register the ISR in the Interrupt Vector Table.*/ IntRegister(SYS_INT_LCDINT, LCDIsr); /* Set the channnel number 2 of AINTC for LCD system interrupt. */ IntChannelSet(SYS_INT_LCDINT, 2); /* Enable the System Interrupts for AINTC.*/ IntSystemEnable(SYS_INT_LCDINT); /* Enable IRQ in CPSR.*/ IntMasterIRQEnable(); /* Enable the interrupts in GER of AINTC.*/ IntGlobalEnable(); /* Enable the interrupts in HIER of AINTC.*/ IntIRQEnable(); }
/* ** The main function */ int main() { unsigned int divisorValue = 0; /* Configuring the system clocks for UART0 instance. */ UART0ModuleClkConfig(); /* Initializing the ARM Interrupt Controller. */ IntAINTCInit(); /* Performing the Pin Multiplexing for UART0 instance. */ UARTPinMuxSetup(0); /* Performing a module reset. */ UARTModuleReset(UART_INST_BASE); UARTFIFOConfig(UART_INST_BASE, UART_FIFO_CONFIG(UART_TRIG_LVL_GRANULARITY_1, UART_TRIG_LVL_GRANULARITY_1, 1, 1, 1, 1, UART_DMA_EN_PATH_SCR, UART_DMA_MODE_0_ENABLE)); /* Computing the Divisor Value. */ divisorValue = UARTDivisorValCompute(UART_MODULE_INPUT_CLK, BAUD_RATE_115200, UART16x_OPER_MODE, UART_MIR_OVERSAMPLING_RATE_42); /* Programming the Divisor Latches. */ UARTDivisorLatchWrite(UART_INST_BASE, divisorValue); /* Switching to Configuration Mode B. */ UARTRegConfigModeEnable(UART_INST_BASE, UART_REG_CONFIG_MODE_B); /* Programming the Line Characteristics. */ UARTLineCharacConfig(UART_INST_BASE, (UART_FRAME_WORD_LENGTH_8 | UART_FRAME_NUM_STB_1), UART_PARITY_NONE); /* Disabe write access to Divisor Latches. */ UARTDivisorLatchDisable(UART_INST_BASE); /* Disable Break Control. */ UARTBreakCtl(UART_INST_BASE, UART_BREAK_COND_DISABLE); /* Switch to UART16x operating mode. */ UARTOperatingModeSelect(UART_INST_BASE, UART16x_OPER_MODE); UARTIntEnable(UART_INST_BASE, (UART_INT_LINE_STAT | UART_INT_THR | UART_INT_RHR_CTI)); /* Register the Interrupt Service Routines */ IntRegister(RTC_INT_NUM, RTCIsr); IntRegister(UART_INT_NUM, UARTIsr); IntRegister(TIMER_INT_NUM, DMTimerIsr); /* ** Setting the priority for the system interrupt in AINTC. ** Timer interrupt is given highest priority - 1 ** RTC interrupt is given medium priority - 2 ** UART interrupt is given lowest priority - 4 */ IntPrioritySet(TIMER_INT_NUM, IRQ_PRIORITY_TIMER, AINTC_HOSTINT_ROUTE_IRQ); IntPrioritySet(RTC_INT_NUM, IRQ_PRIORITY_RTC, AINTC_HOSTINT_ROUTE_IRQ); IntPrioritySet(UART_INT_NUM, IRQ_PRIORITY_UART, AINTC_HOSTINT_ROUTE_IRQ); /* Enabling the system interrupt in AINTC for UART */ IntSystemEnable(UART_INT_NUM); IntMasterIRQEnable(); while(1); }
/* ** Main function. The application starts here. */ int main(void) { unsigned int index; unsigned int j; int result = 0; /* ** Sets up Section page tables. This is only first level ** page table, each page is of size 1MB */ for(index = 0; index < (4*1024); index++) { /* Set the cacheable memory attributes */ if((index >= 0x800 && index < 0x880) || (index == 0x403)) { pageTable[index] = (index << 20) | CACHEABLE_TLB_ATTR; } /* Set the non-cacheable memory attributes */ else { pageTable[index] = (index << 20) | NORM_TLB_ATTR; } } /* Invalidate the TLB, pipeline */ CP15TlbInvalidate(); CP15BranchPredictorInvalidate(); CP15BranchPredictionEnable(); CP15DomainAccessClientSet(); /* Set TTB0 value. We use only TTB0 here (N = 0) */ CP15Ttb0Set(((unsigned int )pageTable) | RGN_L2_WBWA); /* Enables MMU */ CP15MMUEnable(); /* Flush and enable Instruction Cache */ CP15ICacheFlush(); CP15ICacheEnable(); PeripheralsSetUp(); /* Initialize the ARM Interrupt Controller */ IntAINTCInit(); /* Register the ISRs */ Timer2IntRegister(); Timer4IntRegister(); EnetIntRegister(); RtcIntRegister(); HSMMCSDIntRegister(); IntRegister(127, dummyIsr); IntMasterIRQEnable(); /* Enable system interrupts */ IntSystemEnable(SYS_INT_RTCINT); IntPrioritySet(SYS_INT_RTCINT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_3PGSWTXINT0); IntPrioritySet(SYS_INT_3PGSWTXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_3PGSWRXINT0); IntPrioritySet(SYS_INT_3PGSWRXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_TINT2); IntPrioritySet(SYS_INT_TINT2, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_TINT4); IntPrioritySet(SYS_INT_TINT4, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_MMCSD0INT); IntPrioritySet(SYS_INT_MMCSD0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_EDMACOMPINT); IntPrioritySet(SYS_INT_EDMACOMPINT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(127); IntPrioritySet(127, 0, AINTC_HOSTINT_ROUTE_IRQ); RtcInit(); UARTStdioInit(); HSMMCSDContolInit(); DelayTimerSetup(); Timer2Config(); Timer4Config(); LedIfConfig(); Timer2IntEnable(); Timer4IntEnable(); RtcSecIntEnable(); InitI2C(); Timer4Start(); // Read config from files HSMMCSDCardAccessSetup(); configRead(); LedOn( USER_LED_1 ); for( j = 0; j < 1000000; ++j ); LedOff( USER_LED_1 ); LedOn( USER_LED_2 ); for( j = 0; j < 1000000; ++j ); LedOff( USER_LED_2 ); LedOn( USER_LED_3 ); for( j = 0; j < 1000000; ++j ); LedOff( USER_LED_3 ); LedOn( USER_LED_4 ); for( j = 0; j < 1000000; ++j ); LedOff( USER_LED_4 ); // TEMP //i2cTest(); /* ** Loop for ever. Necessary actions shall be taken ** after detecting the click. */ while( 1 ) { EnetStatusCheckNUpdate(); if( runCommand ) { // Command blink LedOn( USER_LED_1 ); if( runData[ runIndex + 1 ] == 'D' ) { if( runData[ runIndex + 2 ] == 'S' ) { UARTPuts( "** DAC SET\n\r", -1 ); if( runData[ runIndex + 3 ] == 'A' ) { i2cDAC_Set( 0, runData[ runIndex + 4 ], runData[ runIndex + 5 ] ); } if( runData[ runIndex + 6 ] == 'B' ) { i2cDAC_Set( 1, runData[ runIndex + 7 ], runData[ runIndex + 8 ] ); } if( runData[ runIndex + 9 ] == 'C' ) { i2cDAC_Set( 2, runData[ runIndex + 10 ], runData[ runIndex + 11 ] ); } if( runData[ runIndex + 12 ] == 'D' ) { i2cDAC_Set( 3, runData[ runIndex + 13 ], runData[ runIndex + 14 ] ); } } else if( runData[ runIndex + 2 ] == 'G' ) { UARTPuts( "** DAC GET\n\r", -1 ); uartData[ 0 ] = 15; uartData[ 1 ] = 'D'; uartData[ 2 ] = 'G'; uartData[ 3 ] = 'A'; i2cDAC_Get( 0, &uartData[ 4 ] ); uartData[ 6 ] = 'B'; i2cDAC_Get( 1, &uartData[ 7 ] ); uartData[ 9 ] = 'C'; i2cDAC_Get( 2, &uartData[ 10 ] ); uartData[ 12 ] = 'D'; i2cDAC_Get( 3, &uartData[ 13 ] ); net_ext_send( uartData, 15 ); } } else if( runData[ runIndex + 1 ] == 'G' ) { if( runData[ runIndex + 2 ] == 'S' ) { if( runData[ runIndex + 3 ] == 0 ) // Off { UARTPuts( "** GPIO OFF\n\r", -1 ); i2cGPIO_Off( 0, 1 << runData[ runIndex + 4 ] ); } else if( runData[ runIndex + 3 ] == 1 ) // On { UARTPuts( "** GPIO ON\n\r", -1 ); i2cGPIO_On( 0, 1 << runData[ runIndex + 4 ] ); } } else if( runData[ runIndex + 2 ] == 'G' ) { UARTPuts( "** GPIO GET\n\r", -1 ); uartData[ 0 ] = 5; uartData[ 1 ] = 'G'; uartData[ 2 ] = 'G'; i2cGPIO_Get( &uartData[ 3 ] ); net_ext_send( uartData, 5 ); } } else if( runData[ runIndex + 1 ] == 'U' ) { UARTPuts( "** UART\n\r", -1 ); i2cUART_Send( &(runData[ runIndex + 2 ]), 6 ); } runCommand -= runData[ runIndex + 0 ]; if( runCommand > 0 ) { runIndex += runData[ runIndex + 0 ]; } else { runIndex = 0; } LedOff( USER_LED_1 ); } result = i2cUART_Recv( &( uartData[ 2 ] ), 30 ); if( result > 0 ) { UARTPuts( "** UART Recv: ", -1 ); for( index = 0; index < result; ++index ) { UARTPutHexNum( uartData[ index + 2 ] ); UARTPutc( ' ' ); } UARTPutc( '\n' ); UARTPutc( '\r' ); // Return the stage position info to the GUI if( uartData[ 3 ] == 0x0A || uartData[ 3 ] == 0x3C ) { uartData[ 0 ] = result + 2; uartData[ 1 ] = 'U'; net_ext_send( uartData, result + 2 ); } } } }
/*#####################################################*/ bool board_init() { //MMUConfigAndEnable(); CacheEnable(CACHE_ICACHE); CacheEnable(CACHE_ALL); L3L4_init(); /* Enable IRQ for ARM (in CPSR)*/ IntMasterIRQEnable(); IntAINTCInit(); timer_init(); /*-----------------------------------------------------*/ /* Set up the Uart 0 like debug interface with RxBuff = 256, TxBuff = 256, 115200b/s*/ DebugCom = new_(new_uart); DebugCom->TxPin = Uart0_Tx_PinMux_E16; DebugCom->RxPin = Uart0_Rx_PinMux_E15; DebugCom->BaudRate = 115200; DebugCom->RxBuffSize = 256; DebugCom->TxBuffSize = 256; DebugCom->rxFifoTrigLevel = 1; DebugCom->txFifoTrigLevel = 1; DebugCom->UartNr = 0; uart_open(DebugCom); /*-----------------------------------------------------*/ /* LED[0] = gpio_assign(1, 21, GPIO_DIR_OUTPUT, false); LED[1] = gpio_assign(1, 22, GPIO_DIR_OUTPUT, false); LED[2] = gpio_assign(1, 23, GPIO_DIR_OUTPUT, false); LED[3] = gpio_assign(1, 24, GPIO_DIR_OUTPUT, false);*/ /*-----------------------------------------------------*/ /* Display board message*/ #if defined(BOARD_MESSAGE) UARTprintf(DebugCom, "Use %s Board.\n\r", BOARD_MESSAGE); #endif /*-----------------------------------------------------*/ /* Set up the Twi 0 to communicate with PMIC and the Onboard serial EEprom memory */ //UARTPuts(DebugCom, "Setup TWI 0 with RxBuff = 258, TxBuff = 258....." , -1); TWI = new_(new_twi); TWI->SdaPin = Twi0_Sda_PinMux_C17; TWI->SclPin = Twi0_Scl_PinMux_C16; TWI->BaudRate = 100000; TWI->TwiNr = 0; TWI->Priority = 0; TWI->WithInterrupt = TRUE; TWI->RxBuffSize = 258; TWI->TxBuffSize = 258; twi_open(TWI); //UARTPuts(DebugCom, "OK.\n\r" , -1); /*-----------------------------------------------------*/ //if(!detect_if_is_beaglebone()) return false; /*-----------------------------------------------------*/ //beaglebone_detect_extension_boards(); /*-----------------------------------------------------*/ //UARTPuts(DebugCom, "Init MMCSD0 Host.......", -1); mmcsd_init(&sdCtrl, 0, 6, NULL /*LED[0]*/); //UARTPuts(DebugCom, "OK.\n\r", -1); /*-----------------------------------------------------*/ //UARTPuts(DebugCom, "Init USBMSC1 Host.......", -1); //usb_host_init(1, LED2); //UARTPuts(DebugCom, "OK.\n\r", -1); /*-----------------------------------------------------*/ return true; }
/* ** Main function. The application starts here. */ int main(void) { unsigned char rxByte; unsigned int value = (unsigned int)E_FAIL; #ifdef __TMS470__ /* Relocate the required section to internal RAM */ memcpy((void *)(&relocstart), (const void *)(&iram_start), (unsigned int)(&iram_size)); #elif defined(__IAR_SYSTEMS_ICC__) #pragma section = "CodeRelocOverlay" #pragma section = "DataRelocOverlay" #pragma section = "DataOverlayBlk" #pragma section = "CodeOverlayBlk" char* srcAddr = (__section_begin("CodeRelocOverlay")); char* endAddr = (__section_end("DataRelocOverlay")); memcpy((void *)(__section_begin("CodeRelocOverlay")), (const void *)(__section_begin("CodeOverlayBlk")), endAddr - srcAddr); #else memcpy((void *)&(relocstart), (const void *)&(iram_start), (unsigned int)(((&(relocend)) - (&(relocstart))) * (sizeof(unsigned int)))); #endif MMUConfigAndEnable(); /* Enable Instruction Cache */ CacheEnable(CACHE_ALL); PeripheralsSetUp(); /* Initialize the ARM Interrupt Controller */ IntAINTCInit(); /* Register the ISRs */ Timer2IntRegister(); Timer4IntRegister(); EnetIntRegister(); RtcIntRegister(); CM3IntRegister(); HSMMCSDIntRegister(); IntRegister(127, dummyIsr); IntMasterIRQEnable(); pageIndex = 0; prevAction = 0; /* Enable system interrupts */ IntSystemEnable(SYS_INT_RTCINT); IntPrioritySet(SYS_INT_RTCINT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_3PGSWTXINT0); IntPrioritySet(SYS_INT_3PGSWTXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_3PGSWRXINT0); IntPrioritySet(SYS_INT_3PGSWRXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_TINT2); IntPrioritySet(SYS_INT_TINT2, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_TINT4); IntPrioritySet(SYS_INT_TINT4, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_MMCSD0INT); IntPrioritySet(SYS_INT_MMCSD0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_EDMACOMPINT); IntPrioritySet(SYS_INT_EDMACOMPINT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntPrioritySet(SYS_INT_M3_TXEV, 0, AINTC_HOSTINT_ROUTE_IRQ ); IntSystemEnable(SYS_INT_M3_TXEV); IntSystemEnable(127); IntPrioritySet(127, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_UART0INT); IntPrioritySet(SYS_INT_UART0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntRegister(SYS_INT_UART0INT, uartIsr); /* GPIO interrupts */ IntSystemEnable(SYS_INT_GPIOINT0A); IntPrioritySet(SYS_INT_GPIOINT0A, 0, AINTC_HOSTINT_ROUTE_IRQ); IntRegister(SYS_INT_GPIOINT0A, gpioIsr); IntSystemEnable(SYS_INT_GPIOINT0B); IntPrioritySet(SYS_INT_GPIOINT0B, 0, AINTC_HOSTINT_ROUTE_IRQ); IntRegister(SYS_INT_GPIOINT0B, gpioIsr); BoardInfoInit(); deviceVersion = DeviceVersionGet(); CM3EventsClear(); CM3LoadAndRun(); waitForM3Txevent(); /* Initialize console for communication with the Host Machine */ ConsoleUtilsInit(); /* ** Select the console type based on compile time check ** Note: This example is not fully complaint to semihosting. It is ** recommended to use Uart console interface only. */ ConsoleUtilsSetType(CONSOLE_UART); /* Print Board and SoC information on console */ ConsoleUtilsPrintf("\n\r Board Name : %s", BoardNameGet()); ConsoleUtilsPrintf("\n\r Board Version : %s", BoardVersionGet()); ConsoleUtilsPrintf("\n\r SoC Version : %d", deviceVersion); /* On CM3 init firmware version is loaded onto the IPC Message Reg */ ConsoleUtilsPrintf("\n CM3 Firmware Version: %d", readCM3FWVersion()); I2CIntRegister(I2C_0); IntPrioritySet(SYS_INT_I2C0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_I2C0INT); I2CInit(I2C_0); IntSystemEnable(SYS_INT_TINT1_1MS); IntPrioritySet(SYS_INT_TINT1_1MS, 0, AINTC_HOSTINT_ROUTE_IRQ); IntRegister(SYS_INT_TINT1_1MS,clearTimerInt); configVddOpVoltage(); RtcInit(); HSMMCSDContolInit(); DelayTimerSetup(); initializeTimer1(); ConsoleUtilsPrintf("\r\n After intializing timer"); Timer2Config(); Timer4Config(); LedIfConfig(); MailBoxInit(); Timer2IntEnable(); Timer4IntEnable(); RtcSecIntEnable(); Timer4Start(); while(FALSE == tmr4Flag); tmr4Flag = FALSE; Timer4Stop(); ConsoleUtilsPrintf("\n\r Configuring for maximum OPP"); mpuOpp = ConfigMaximumOPP(); mpuFreq = FrequencyGet(mpuOpp); mpuVdd1 = VddVoltageGet(mpuOpp); PrintConfigDVFS(); /* Create menu page */ pageIndex = MENU_IDX_MAIN; ActionEnetInit(); /* ** Loop for ever. Necessary actions shall be taken ** after detecting the click. */ while(1) { /* ** Check for any any activity on Uart Console and process it. */ if (true == UARTCharsAvail(SOC_UART_0_REGS)) { /* Receiving bytes from the host machine through serial console. */ rxByte = UARTGetc(); /* ** Checking if the entered character is a carriage return. ** Pressing the 'Enter' key on the keyboard executes a ** carriage return on the serial console. */ if('\r' == rxByte) { ConsoleUtilsPrintf("\n"); UartAction(value); value = (unsigned int)E_FAIL; rxByte = 0; } /* ** Checking if the character entered is one among the decimal ** number set 0,1,2,3,....9 */ if(('0' <= rxByte) && (rxByte <= '9')) { ConsoleUtilsPrintf("%c", rxByte); if((unsigned int)E_FAIL == value) { value = 0; } value = value*10 + (rxByte - 0x30); } } /* ** Check if click is detected */ if(clickIdx != 0) { /* ** Take the Action for click */ ClickAction(); clickIdx = 0; } /* ** Check if the Timer Expired */ if(TRUE == tmrFlag) { /* Toggle the LED state */ LedToggle(); tmrFlag = FALSE; } /* ** Check if RTC Time is set */ if(TRUE == rtcSetFlag) { if(TRUE == rtcSecUpdate) { rtcSecUpdate = FALSE; RtcTimeCalDisplay(); ConsoleUtilsPrintf(" --- Selected: "); } } if(TRUE == tmr4Flag) { tmr4Flag = FALSE; /* Make sure that interrupts are disabled and no lwIP functions are executed while calling an lwIP exported API */ IntMasterIRQDisable(); etharp_tmr(); IntMasterIRQEnable(); } } }
/* ** The main function. Application starts here. */ int main(void) { unsigned short parToSend; unsigned short parToLink; /* Set up pin mux for I2C module 0 */ I2CPinMuxSetup(0); McASPPinMuxSetup(); /* Power up the McASP module */ PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_MCASP0, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE); /* Power up EDMA3CC_0 and EDMA3TC_0 */ PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_CC0, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE); PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_TC0, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE); #ifdef _TMS320C6X // Initialize the DSP interrupt controller IntDSPINTCInit(); #else /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); #endif /* Initialize the I2C 0 interface for the codec AIC31 */ I2CCodecIfInit(SOC_I2C_0_REGS, INT_CHANNEL_I2C, I2C_SLAVE_CODEC_AIC31); EDMA3Init(SOC_EDMA30CC_0_REGS, 0); EDMA3IntSetup(); McASPErrorIntSetup(); #ifdef _TMS320C6X IntGlobalEnable(); #else /* Enable the interrupts generation at global level */ IntMasterIRQEnable(); IntGlobalEnable(); IntIRQEnable(); #endif /* ** Request EDMA channels. Channel 0 is used for reception and ** Channel 1 is used for transmission */ EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_CHA_MCASP0_TX, EDMA3_CHA_MCASP0_TX, 0); EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_CHA_MCASP0_RX, EDMA3_CHA_MCASP0_RX, 0); /* Initialize the DMA parameters */ I2SDMAParamInit(); /* Configure the Codec for I2S mode */ AIC31I2SConfigure(); /* Configure the McASP for I2S */ McASPI2SConfigure(); /* Activate the audio transmission and reception */ I2SDataTxRxActivate(); /* ** Looop forever. if a new buffer is received, the lastFullRxBuf will be ** updated in the rx completion ISR. if it is not the lastSentTxBuf, ** buffer is to be sent. This has to be mapped to proper paRAM set. */ while(1) { if(lastFullRxBuf != lastSentTxBuf) { /* ** Start the transmission from the link paramset. The param set ** 1 will be linked to param set at PAR_TX_START. So do not ** update paRAM set1. */ parToSend = PAR_TX_START + (parOffTxToSend % NUM_PAR); parOffTxToSend = (parOffTxToSend + 1) % NUM_PAR; parToLink = PAR_TX_START + parOffTxToSend; lastSentTxBuf = (lastSentTxBuf + 1) % NUM_BUF; ByteBuftoFloatBuf(rxBufPtr[lastFullRxBuf]); /* Copy the buffer */ memcpy((void *)txBufPtr[lastSentTxBuf], (void *)rxBufPtr[lastFullRxBuf], AUDIO_BUF_SIZE); /* ** Send the buffer by setting the DMA params accordingly. ** Here the buffer to send and number of samples are passed as ** parameters. This is important, if only transmit section ** is to be used. */ BufferTxDMAActivate(lastSentTxBuf, NUM_SAMPLES_PER_AUDIO_BUF, (unsigned short)parToSend, (unsigned short)parToLink); } } }
int main(void) { /* Configuring the system clocks for EDMA. */ EDMAModuleClkConfig(); /* Configuring the system clocks for UART0 instance. */ UART0ModuleClkConfig(); /* Performing Pin Multiplexing for UART0 instance. */ UARTPinMuxSetup(0); /* Enabling IRQ in CPSR of ARM processor. */ IntMasterIRQEnable(); /* Initializing the ARM Interrupt Controller. */ IntAINTCInit(); /* Initializing the EDMA. */ EDMA3Initialize(); /* Initializing the UART0 instance for use. */ UARTInitialize(); /* ** Configuring the EDMA. */ /* Request DMA Channel and TCC for UART Transmit*/ EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_UART_TX_CHA_NUM, EDMA3_UART_TX_CHA_NUM, EVT_QUEUE_NUM); /* Registering Callback Function for TX*/ cb_Fxn[EDMA3_UART_TX_CHA_NUM] = &callback; /* Request DMA Channel and TCC for UART Receive */ EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_UART_RX_CHA_NUM, EDMA3_UART_RX_CHA_NUM, EVT_QUEUE_NUM); /* Registering Callback Function for RX*/ cb_Fxn[EDMA3_UART_RX_CHA_NUM] = &callback; /******************** Transmission of a string **************************/ /* Configuring EDMA PaRAM sets to transmit 'welcome' message. */ UartEDMATxConfTransfer(EDMA3_UART_TX_CHA_NUM, EDMA3_UART_TX_CHA_NUM, welcome, sizeof(welcome) - 1); /* Wait for return from callback */ while(0 == clBackFlag); clBackFlag = 0; /******************** Transmission of a string **************************/ /* Enabling DMA Mode 1. */ UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE); /* Configuring EDMA PaRAM sets to transmit 'enter' message. */ UartEDMATxConfTransfer(EDMA3_UART_TX_CHA_NUM, EDMA3_UART_TX_CHA_NUM, enter, sizeof(enter) - 1); /* Wait for return from callback */ while(0 == clBackFlag); clBackFlag = 0; /********************* Receiving Data from User *************************/ /* Enabling DMA Mode 1. */ UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE); /* Configuring the PaRAM set for reception. */ UartEDMARxConfTransfer(EDMA3_UART_RX_CHA_NUM, EDMA3_UART_RX_CHA_NUM, rxBuffer, sizeof(rxBuffer)); /* Wait for return from callback */ while(0 == clBackFlag); clBackFlag = 0; /******************* Echoing received bytes *****************************/ /* Enabling DMA Mode 1. */ UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE); /* Configuring the PaRAM set to transmit the bytes that were received. */ UartEDMATxConfTransfer(EDMA3_UART_TX_CHA_NUM, EDMA3_UART_TX_CHA_NUM, rxBuffer, sizeof(rxBuffer)); /* Wait for return from callback */ while(0 == clBackFlag); clBackFlag = 0; /******************* Freeing of allocated channels **********************/ /* Free EDMA3 Channels for TX and RX */ EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_UART_TX_CHA_NUM, EDMA3_TRIG_MODE_EVENT, EDMA3_UART_TX_CHA_NUM, EVT_QUEUE_NUM); EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_UART_RX_CHA_NUM, EDMA3_TRIG_MODE_EVENT, EDMA3_UART_RX_CHA_NUM, EVT_QUEUE_NUM); while(1); }
/* ** Main function. */ int main(void) { unsigned int numByteChunks = 0; unsigned char *pBuffer = NULL; unsigned int remainBytes = 0; /* Configure and enable the MMU. */ MMUConfigAndEnable(); /* Enable all levels of Cache. */ CacheEnable(CACHE_ALL); /* Configuring the system clocks for EDMA. */ EDMAModuleClkConfig(); /* Configuring the system clocks for UART0 instance. */ UART0ModuleClkConfig(); /* Performing Pin Multiplexing for UART0 instance. */ UARTPinMuxSetup(0); /* Enabling IRQ in CPSR of ARM processor. */ IntMasterIRQEnable(); /* Initializing the ARM Interrupt Controller. */ IntAINTCInit(); /* Initializing the EDMA. */ EDMA3Initialize(); /* Initializing the UART0 instance for use. */ UARTInitialize(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); /* ** Configuring the EDMA. */ /* Request DMA Channel and TCC for UART Transmit*/ EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_UART_TX_CHA_NUM, EDMA3_UART_TX_CHA_NUM, EVT_QUEUE_NUM); /* Registering Callback Function for TX*/ cb_Fxn[EDMA3_UART_TX_CHA_NUM] = &callback; /* Request DMA Channel and TCC for UART Receive */ EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_UART_RX_CHA_NUM, EDMA3_UART_RX_CHA_NUM, EVT_QUEUE_NUM); /* Registering Callback Function for RX*/ cb_Fxn[EDMA3_UART_RX_CHA_NUM] = &callback; /******************** Transmission of a string **************************/ numByteChunks = (sizeof(welcome) - 1) / txBytesPerEvent; remainBytes = (sizeof(welcome) - 1) % txBytesPerEvent; /* Configuring EDMA PaRAM sets to transmit data. */ UARTTxEDMAPaRAMSetConfig(welcome, numByteChunks * txBytesPerEvent, EDMA3_UART_TX_CHA_NUM, EDMA3CC_OPT(DUMMY_CH_NUM), EDMA3_UART_TX_CHA_NUM); /* Configuring the PaRAM set for Dummy Transfer. */ TxDummyPaRAMConfEnable(); /* Enable EDMA Transfer */ EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_TX_CHA_NUM, EDMA3_TRIG_MODE_EVENT); /* Wait for return from callback */ while(0 == clBackFlag); clBackFlag = 0; /* Remaining bytes are transferred through polling method. */ if(0 != remainBytes) { pBuffer = welcome + (sizeof(welcome) - 1) - remainBytes; UARTPuts((char*)pBuffer, remainBytes); } /******************** Transmission of a string **************************/ numByteChunks = (sizeof(intent) - 1) / txBytesPerEvent; remainBytes = (sizeof(intent) - 1) % txBytesPerEvent; /* Enabling DMA Mode 1. */ UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE); /* Configuring EDMA PaRAM sets to transmit data. */ UARTTxEDMAPaRAMSetConfig(intent, numByteChunks * txBytesPerEvent, EDMA3_UART_TX_CHA_NUM, EDMA3CC_OPT(DUMMY_CH_NUM), EDMA3_UART_TX_CHA_NUM); /* Configuring the PaRAM set for Dummy Transfer. */ TxDummyPaRAMConfEnable(); /* Enable EDMA Transfer */ EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_TX_CHA_NUM, EDMA3_TRIG_MODE_EVENT); /* Wait for return from callback */ while(0 == clBackFlag); clBackFlag = 0; /* Remaining bytes are transferred through polling method. */ if(0 != remainBytes) { pBuffer = intent + (sizeof(intent) - 1) - remainBytes; UARTPuts((char*)pBuffer, remainBytes); } /******************** Transmission of a string **************************/ numByteChunks = (sizeof(enter) - 1) / txBytesPerEvent; remainBytes = (sizeof(enter) - 1) % txBytesPerEvent; /* Enabling DMA Mode 1. */ UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE); /* Configuring EDMA PaRAM sets to transmit data. */ UARTTxEDMAPaRAMSetConfig(enter, numByteChunks * txBytesPerEvent, EDMA3_UART_TX_CHA_NUM, EDMA3CC_OPT(DUMMY_CH_NUM), EDMA3_UART_TX_CHA_NUM); /* Configuring the PaRAM set for Dummy Transfer. */ TxDummyPaRAMConfEnable(); /* Enable EDMA Transfer */ EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_TX_CHA_NUM, EDMA3_TRIG_MODE_EVENT); /* Wait for return from callback */ while(0 == clBackFlag); clBackFlag = 0; /* Remaining bytes are transferred through polling method. */ if(0 != remainBytes) { pBuffer = enter + (sizeof(enter) - 1) - remainBytes; UARTPuts((char*)pBuffer, remainBytes); } /********************* Receiving Data from User *************************/ /* Enabling DMA Mode 1. */ UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE); /* Configuring the PaRAM set for reception. */ UARTRxEDMAPaRAMSetConfig(rxBuffer, NUM_RX_BYTES, EDMA3_UART_RX_CHA_NUM, 0xFFFF, EDMA3_UART_RX_CHA_NUM); /* Enable EDMA Transfer */ EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_RX_CHA_NUM, EDMA3_TRIG_MODE_EVENT); /* Wait for return from callback */ while(0 == clBackFlag); clBackFlag = 0; /******************* Echoing received bytes *****************************/ numByteChunks = (NUM_RX_BYTES) / txBytesPerEvent; remainBytes = (NUM_RX_BYTES) % txBytesPerEvent; /* Enabling DMA Mode 1. */ UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE); /* Configuring EDMA PaRAM sets to transmit data. */ UARTTxEDMAPaRAMSetConfig(rxBuffer, numByteChunks * txBytesPerEvent, EDMA3_UART_TX_CHA_NUM, EDMA3CC_OPT(DUMMY_CH_NUM), EDMA3_UART_TX_CHA_NUM); /* Configuring the PaRAM set for Dummy Transfer. */ TxDummyPaRAMConfEnable(); /* Enable EDMA Transfer */ EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_TX_CHA_NUM, EDMA3_TRIG_MODE_EVENT); /* Wait for return from callback */ while(0 == clBackFlag); clBackFlag = 0; /* Remaining bytes are transferred through polling method. */ if(0 != remainBytes) { pBuffer = rxBuffer + NUM_RX_BYTES - remainBytes; UARTPuts((char*)pBuffer, remainBytes); } /******************* Freeing of allocated channels **********************/ /* Free EDMA3 Channels for TX and RX */ EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_UART_TX_CHA_NUM, EDMA3_TRIG_MODE_EVENT, EDMA3_UART_TX_CHA_NUM, EVT_QUEUE_NUM); EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, EDMA3_UART_RX_CHA_NUM, EDMA3_TRIG_MODE_EVENT, EDMA3_UART_RX_CHA_NUM, EVT_QUEUE_NUM); /* Support for Automation Testing. */ PRINT_STATUS(S_PASS); while(1); }