void main() { int i; SetGpioFunction(16, 1); while (1) { SetGpio(16, 1); for (i=0; i<0x3f0000; i++); SetGpio(16, 0); for (i=0; i<0x3f0000; i++); } }
void execute(){ /* Obtaing the address of the frame buffer structure */ int fbInfoAddress = InitialiseFrameBuffer(1024, 768, 16); /* if GPU has accepted our request to create a frame buffer then*/ if( fbInfoAddress != 0 ){ int fbAddr, y=0, x=0, color; while( 1 ){ /* Obtaing the pointer to the frame buffer from the fram buffer structure */ fbAddr = *((unsigned int*)(fbInfoAddress+32)); y = 768; while( y != 0 ){ x = 1024; while( x != 0 ){ /* Drwaing the pixel by putting in the color information at location pointed by frame buffer */ *((unsigned int*)(fbAddr)) = color; fbAddr = (fbAddr+2); x = x-1; } y = y-1; /* Changing the color */ color = color+1; } } } /* If GPU has denied our request to create a fram buffer then */ else{ /* Turn on the ACT LED */ SetGpioFunction(16,1); SetGpio(16, 0); while(1); } }
int main(void) { int pos = 0; int value = 0; SetGpioFunction(16, 1); while (1) { value = PATTERN & (1 << pos); SetGpio(16, value); Wait(50000); } }
void task1() { int i = 0; while(1) { i++; SetGpio(47, 1); vTaskDelay(200); } }
void task1(void *pParam) { int i = 0; while(1) { i++; SetGpio(16, 1); vTaskDelay(200); } }
void task2() { int i = 0; while(1) { i++; vTaskDelay(100); SetGpio(47, 0); vTaskDelay(100); } }
bool SrSetGpio(HANDLE hCom, unsigned char cMask, unsigned char cStata, unsigned int *pdwErr) { int ret = SetGpio(hCom, cMask, cStata, pdwErr); if (ret == -1) { *pdwErr = ERR_CODE_SET_GPIO; return false; } return true; }
void task2(void *pParam) { int i = 0; while(1) { i++; vTaskDelay(100); SetGpio(16, 0); vTaskDelay(100); } }
static void initialize(intptr_t unused) { /** * Reset 64-bit GP timer */ TIMERP1.TGCR = 0x0; AINTC.SICR = INTNO_I2C_TIMER; TIMERP1.TIM12 = 0x0; TIMERP1.TIM34 = 0x0; TIMERP1.PRD12 = 0x0; TIMERP1.PRD34 = 0x0; TIMERP1.REL12 = 0x0; TIMERP1.REL34 = 0x0; // TIMERP1.INTCTLSTAT = 0x30003; TIMERP1.TGCR = 0x3; //TIMERP1.TCR = 0x0; //TIMERP1.TGCR = 0x3; ModuleInit(); for(int i = 0; i < TNUM_INPUT_PORT; ++i) { driver_data_i2c_sensor[i].raw = IicCtrl.data_package[i].data; driver_data_i2c_sensor[i].status = &(IicCtrl.data_package[i].transfer_state); } global_brick_info.i2c_sensors = driver_data_i2c_sensor; #if defined(DEBUG_I2C_SENSOR) || 1 syslog(LOG_NOTICE, "i2c_dri initialized."); #if 0 SetGpio(GP8_11); SetGpio(UART1_TXD); SetGpio(UART1_RXD); SetGpio(GP0_2); SetGpio(GP0_15); #endif #endif }
//----------------------------------------------------------------------------- // Function: Initialize the general-purpose I/O // // Parameters: none // // Returns: none // //----------------------------------------------------------------------------- int main(void) { float yc_new, yc_old; // Cosine Samples float ys_new, ys_old; // Sine Sample float cosw, sinw; // Sin/Cos Fractions EVMOMAPL138_init(); // Initialize the board EVMOMAPL138_initRAM(); // Set up the RAM EVMOMAPL138_enableDsp(); // Wake up the DSP // init the i2c for all to use. USTIMER_init(); // General use timers I2C_init(I2C0, I2C_CLK_400K); // I2C initialization // set gpio output SetGpio(); // Configure the General Purpose I/O McASP_Init(); // Initialize McASP AIC3106_Init(); // Initialize AIC3106 McASP_Start(); // Start McASP // Initialize oscillators ys_new = AMPLITUDE; yc_new = 0.0f; cosw = cos(THETA_INC); sinw = sin(THETA_INC); // Infinite loop: Each loop reads/writes one sample to the left and right channels. while (1){ // Save old samples yc_old = yc_new; ys_old = ys_new; // Generate new samples yc_new = cosw*yc_old - sinw*ys_old; ys_new = cosw*ys_old + sinw*yc_old; // wait for xmit ready and send a sample to the left channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = (int16_t)yc_old; // wait for xmit ready and send a sample to the right channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = (int16_t)ys_old; } }
/** * This is the systems main entry, some call it a boot thread. * * -- Absolutely nothing wrong with this being called main(), just it doesn't have * -- the same prototype as you'd see in a linux program. **/ int main(void) { SetGpioFunction(47, 1); // RDY led initFB(); SetGpio(47, 1); videotest(); DisableInterrupts(); InitInterruptController(); xTaskCreate(task1, "LED_0", 128, NULL, 0, NULL); xTaskCreate(task2, "LED_1", 128, NULL, 0, NULL); vTaskStartScheduler(); /* * We should never get here, but just in case something goes wrong, * we'll place the CPU into a safe loop. */ while(1) { ; } }
//----------------------------------------------------------------------------- // Function: Initialize the general-purpose I/O // // Parameters: none // // Returns: none // //----------------------------------------------------------------------------- int main(void) { int i; float fir_coeffs[FILTER_LEN] = { FIR_FILT_32 }; float lat_coeffs[FILTER_LEN] = {0.0f}; float f_prev=0.0f, g_new=0.0f, g_prev=0.0f; float g[FILTER_LEN+1]={0.0f}; int16_t dataInput; // Sine Sample int16_t oldDataInput; // Sine Sample delayed // // Compute reflection coefficients for lattice filter // MakeLatticeCoeffs(fir_coeffs, lat_coeffs); EVMOMAPL138_init(); // Initialize the board EVMOMAPL138_initRAM(); // Set up the RAM EVMOMAPL138_enableDsp(); // Wake up the DSP // init the i2c for all to use. USTIMER_init(); // General use timers I2C_init(I2C0, I2C_CLK_400K); // I2C initialization // set gpio output SetGpio(); // Configure the General Purpose I/O McASP_Init(); // Initialize McASP AIC3106_Init(); // Initialize AIC3106 McASP_Start(); // Start McASP // Infinite loop: Each loop reads/writes one sample to the left and right channels. while (1){ /* The following code is here to allow a test signal to be generated. THIS IS NOT HOW LAB 1 IS TO BE DONE! Remove the code up to the indicated spot and insert your own code. */ // Store the last sample because of the one sample delay between channels. oldDataInput = dataInput; // // Update the first stage of the lattice filter // f_prev = dataInput; // Set f_0 equal to the input sample g_prev = g[0]; // Save the value stored in g[0] g[0] = dataInput; // Update g[0] // // Iteratively compute next filter output for remaining stages // for( i=1; i<=FILTER_LEN; i++ ) { // Save the value currently stored in the i-th delay element g_new = g[i]; // Compute g, and store it in the i-th delay element g[i] = g_prev + f_prev*lat_coeffs[i-1]; // Compute f f_prev += g_prev*lat_coeffs[i-1]; // Pass the saved value from the delay element to the next stage g_prev = g_new; } // // Subtract the current input sample (Due to FIR to Lattice conversion) // dataInput = (int16_t) f_prev - dataInput; // wait for xmit ready and send a sample to the left channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = oldDataInput; oldDataInput = MCASP->XBUF12; // Read the left channel input samples. // wait for xmit ready and send a sample to the right channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = dataInput; dataInput = MCASP->XBUF12; // Read the right channel input samples. } }
//----------------------------------------------------------------------------- // Function: Initialize the general-purpose I/O // // Parameters: none // // Returns: none // //----------------------------------------------------------------------------- int main(void) { int16_t sample = 0; // Sample index into the buffer array int16_t dataInput; // Sine Sample int16_t oldDataInput; // Sine Sample delayed float theta = 0; // Argument of the sine wave int16_t buffer[BUFF_SIZE] = {0};// Buffer to hold the sine samples float amplitude = AMPLITUDE; // Amplitude of the generated sin wave EVMOMAPL138_init(); // Initialize the board EVMOMAPL138_initRAM(); // Set up the RAM EVMOMAPL138_enableDsp(); // Wake up the DSP // init the i2c for all to use. USTIMER_init(); // General use timers I2C_init(I2C0, I2C_CLK_400K); // I2C initialization // set gpio output SetGpio(); // Configure the General Purpose I/O McASP_Init(); // Initialize McASP AIC3106_Init(); // Initialize AIC3106 McASP_Start(); // Start McASP // Infinite loop: Each loop reads/writes one sample to the left and right channels. while (1){ /* The following code is here to allow a test signal to be generated. THIS IS NOT HOW LAB 1 IS TO BE DONE! Remove the code up to the indicated spot and insert your own code. */ // Store the last sample because of the one sample delay between channels. oldDataInput = dataInput; // Calculate the next sine wave sample... dataInput = ((int16_t) amplitude*sin(theta)); // Increment the argument... theta += THETA_INC; if (theta > 2*PI) theta -= 2*PI; // Wrap around 2pi // Store the new sample in the buffer, for viewing... buffer[sample] = dataInput; sample = (sample+1)%BUFF_SIZE; // Update the sample indx /* Before writing the 16-bit samples, you must insert your own processing here. */ // wait for xmit ready and send a sample to the left channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = oldDataInput; // oldDataInput = MCASP->XBUF12; // Read the left channel input samples. // wait for xmit ready and send a sample to the right channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = dataInput; // dataInput = MCASP->XBUF12; // Read the right channel input samples. } }
/* Sets the GPIO pin addressed to high if value is different than zero and * low otherwise.*/ void gpio_set_register(unsigned int gpio_register, unsigned int value) { SetGpio(gpio_register, value); }
void setup_i2c_port(int port) { SetGpio(IicPortPin[port][IIC_PORT_BUFFER_CTRL].Pin); SetGpio(IicPortPin[port][IIC_PORT_DATA].Pin); IicPortEnable(port); }
static void softreset(intptr_t unused) { SetGpio(GP8_14); //SetGpio(GP8_3); SetGpio(GP0_13); debug_i2c_sensor(); }
//----------------------------------------------------------------------------- // Function: Initialize the general-purpose I/O // // Parameters: none // // Returns: none // //----------------------------------------------------------------------------- int main(void) { int i, k; float out; int circ_idx = FILTER_LEN-1; float coeffs[FILTER_LEN] = { FIR_FILT_32 }; float z[FILTER_LEN]; int16_t dataInput; // Sine Sample int16_t oldDataInput; // Sine Sample delayed EVMOMAPL138_init(); // Initialize the board EVMOMAPL138_initRAM(); // Set up the RAM EVMOMAPL138_enableDsp(); // Wake up the DSP // init the i2c for all to use. USTIMER_init(); // General use timers I2C_init(I2C0, I2C_CLK_400K); // I2C initialization // set gpio output SetGpio(); // Configure the General Purpose I/O McASP_Init(); // Initialize McASP AIC3106_Init(); // Initialize AIC3106 McASP_Start(); // Start McASP // Infinite loop: Each loop reads/writes one sample to the left and right channels. while (1){ /* The following code is here to allow a test signal to be generated. THIS IS NOT HOW LAB 1 IS TO BE DONE! Remove the code up to the indicated spot and insert your own code. */ // Store the last sample because of the one sample delay between channels. oldDataInput = dataInput; // // Update the circular buffer index and insert the latest sample // circ_idx++; z[circ_idx & 0x1F] = (float)dataInput; // // Compute next filter output // out = 0.0f; // Zero the accumulator for( i=0; i<FILTER_LEN; i++ ) { k = (circ_idx - i) & 0x1F; // Index into circular buffer out += coeffs[i]*z[k]; // Multiply by coefficient } dataInput = (int16_t) out; // wait for xmit ready and send a sample to the left channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = oldDataInput; oldDataInput = MCASP->XBUF12; // Read the left channel input samples. // wait for xmit ready and send a sample to the right channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = dataInput; dataInput = MCASP->XBUF12; // Read the right channel input samples. } }
/* Turns the ACT LED off */ void ledoff() { SetGpioFunction(16, 1); SetGpio(16, 1); }
/* Turns the ACT LED on */ void ledon() { SetGpioFunction(16, 1); SetGpio(16, 0); }