/***** * do_init() - initialize the system * * This function is executed once at start-up and after a reset. It initializes * the peripherals and registers the interrupt handlers *****/ XStatus do_init(void) { XStatus Status; // status from Xilinx Lib calls // initialize the N3EIF driver // rotary encoder is set to increment from 0 by 1 // NOTE: it's the relative change from the last time the rotary encoder was sampled // not the absolute change that matters. The actual change is handled in main() so we // can apply a "speedup" factor if the knob is being turned quickly. N3EIF_init(N3EIF_BASEADDR); ROT_init(1, false); ROT_clear(); // initialize the GPIO instance Status = XGpio_Initialize(&GPIOInst, GPIO_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } // GPIO channel 1 is an 8-bit output port that your application can // use. None of the bits are used by this program XGpio_SetDataDirection(&GPIOInst, GPIO_OUTPUT_CHANNEL, 0xF0); XGpio_DiscreteWrite(&GPIOInst, GPIO_OUTPUT_CHANNEL, gpio_port); // initialize the PWM timer/counter instance but do not start it // do not enable PWM interrupts Status = PWM_Initialize(&PWMTimerInst, PWM_TIMER_DEVICE_ID, false); if (Status != XST_SUCCESS) { return XST_FAILURE; } // initialize the PmodCtlSys Status = PmodCtlSys_init(&SPIInst, SPI_DEVICEID); if (Status != XST_SUCCESS) { return XST_FAILURE; } // initialize the interrupt controller Status = XIntc_Initialize(&IntrptCtlrInst, INTC_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } // connect the fixed interval timer (FIT) handler to the interrupt Status = XIntc_Connect(&IntrptCtlrInst, FIT_INTERRUPT_ID, (XInterruptHandler) FIT_Handler, (void *) 0); if (Status != XST_SUCCESS) { return XST_FAILURE; } // start the interrupt controller such that interrupts are enabled for // all devices that cause interrupts, specifically real mode so that // the the FIT can cause interrupts thru the interrupt controller. Status = XIntc_Start(&IntrptCtlrInst, XIN_REAL_MODE); if (Status != XST_SUCCESS) { return XST_FAILURE; } // enable the FIT interrupt XIntc_Enable(&IntrptCtlrInst, FIT_INTERRUPT_ID); return XST_SUCCESS; }
/***** * do_init() - initialize the system * * This function is executed once at start-up and after resets. It initializes * the peripherals and registers the interrupt handlers *****/ XStatus do_init(void) { XStatus Status; // status from Xilinx Lib calls // initialize the S3E starter board interface // rotary encoder is set to increment from 0 by DUTY_CYCLE_CHANGE N3EIF_init(N3EIF_BASEADDR); ROT_init(DUTY_CYCLE_CHANGE, true); ROT_clear(); // initialize the GPIO instance Status = XGpio_Initialize(&GPIOInst, GPIO_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } // GPIO channel 1 is an 8-bit input port. bit[7:1] = reserved, bit[0] = PWM output (for duty cycle calculation) // GPIO channel 2 is an 8-bit output port. bit[7:1] = reserved, bit[0] = FIT clock XGpio_SetDataDirection(&GPIOInst, GPIO_OUTPUT_CHANNEL, 0xFE); // initialize the PWM timer/counter instance but do not start it // do not enable PWM interrupts Status = PWM_Initialize(&PWMTimerInst, PWM_TIMER_DEVICE_ID, false); if (Status != XST_SUCCESS) { return XST_FAILURE; } // initialize the interrupt controller Status = XIntc_Initialize(&IntrptCtlrInst,INTC_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } // connect the fixed interval timer (FIT) handler to the interrupt Status = XIntc_Connect(&IntrptCtlrInst, FIT_INTERRUPT_ID, (XInterruptHandler)FIT_Handler, (void *)0); if (Status != XST_SUCCESS) { return XST_FAILURE; } // start the interrupt controller such that interrupts are enabled for // all devices that cause interrupts. Status = XIntc_Start(&IntrptCtlrInst, XIN_REAL_MODE); if (Status != XST_SUCCESS) { return XST_FAILURE; } // enable the FIT interrupt XIntc_Enable(&IntrptCtlrInst, FIT_INTERRUPT_ID); return XST_SUCCESS; }
void HINT_init () { BTN_init(); BTQ_init(); P24_init(); DISP_init(); LED_init(); TIM7_init(); ROT_init(); reset(); }
/***** * do_init() - initialize the system * * This function is executed once at start-up and after a reset. It initializes * the peripherals and registers the interrupt handlers *****/ XStatus do_init(void) { XStatus Status; // status from Xilinx Lib calls // initialize the N3EIF hardware and driver // rotary encoder is set to increment duty cycle from 0 by 5 w/ // no negative counts N3EIF_init(N3EIF_BASEADDR); ROT_init(DUTY_CYCLE_CHANGE, true); ROT_clear(); // initialize the GPIO instance Status = XGpio_Initialize(&GPIOInst, GPIO_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } // GPIO channel 1 is an 8-bit output port that your application can // use. None of the bits are used by this program XGpio_SetDataDirection(&GPIOInst, GPIO_OUTPUT_CHANNEL, 0xF0); XGpio_DiscreteWrite(&GPIOInst, GPIO_OUTPUT_CHANNEL, gpio_port); // initialize the PWM timer/counter instance but do not start it // do not enable PWM interrupts Status = PWM_Initialize(&PWMTimerInst, PWM_TIMER_DEVICE_ID, false); if (Status != XST_SUCCESS) { return XST_FAILURE; } //Initialize LIGHTSENSOR peripheral Status = LIGHTSENSOR_Init(LIGHTSENSOR_BASEADDR); if (Status != XST_SUCCESS) { return XST_FAILURE; } // initialize the interrupt controller Status = XIntc_Initialize(&IntrptCtlrInst,INTC_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } // connect the fixed interval timer (FIT) handler to the interrupt Status = XIntc_Connect(&IntrptCtlrInst, FIT_INTERRUPT_ID, (XInterruptHandler)FIT_Handler, (void *)0); if (Status != XST_SUCCESS) { return XST_FAILURE; } // start the interrupt controller such that interrupts are enabled for // all devices that cause interrupts, specifically real mode so that // the the FIT can cause interrupts thru the interrupt controller. Status = XIntc_Start(&IntrptCtlrInst, XIN_REAL_MODE); if (Status != XST_SUCCESS) { return XST_FAILURE; } // start the lightsensor Status = LIGHTSENSOR_Start(LIGHTSENSOR_BASEADDR); if (Status != XST_SUCCESS) { return XST_FAILURE; } // enable the FIT interrupt XIntc_Enable(&IntrptCtlrInst, FIT_INTERRUPT_ID); return XST_SUCCESS; }