void LED_Init (void) { XGpio_mWriteReg(BSP_GPIO_ADDR, XGPIO_TRI_OFFSET, 0x00000000); LED_Off(0); /* Turn off all of the LEDs */ }
/** * Write to discretes register * * @param InstancePtr is a pointer to an XGpio instance to be worked on. * @param Data is the value to be written to the discretes register. * * @note * * See also XGpio_DiscreteSet() and XGpio_DiscreteClear(). * *****************************************************************************/ void XGpio_DiscreteWrite(XGpio * InstancePtr, u32 Data) { XASSERT_VOID(InstancePtr != NULL); XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); XGpio_mWriteReg(InstancePtr->BaseAddress, XGPIO_DATA_OFFSET, Data); }
/** * Set the input/output direction of all discrete signals. * * @param InstancePtr is a pointer to an XGpio instance to be worked on. * @param DirectionMask is a bitmask specifying which discretes are input and * which are output. Bits set to 0 are output and bits set to 1 are input. * * @note * * None * *****************************************************************************/ void XGpio_SetDataDirection(XGpio * InstancePtr, u32 DirectionMask) { XASSERT_VOID(InstancePtr != NULL); XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); XGpio_mWriteReg(InstancePtr->BaseAddress, XGPIO_TRI_OFFSET, DirectionMask); }
/** * Write to discretes register for the specified GPIO channel. * * @param InstancePtr is a pointer to an XGpio instance to be worked on. * @param Channel contains the channel of the GPIO (1 or 2) to operate on. * @param Data is the value to be written to the discretes register. * * @return * * None. * * @note * * The hardware must be built for dual channels if this function is used * with any channel other than 1. If it is not, this function will assert. * See also XGpio_DiscreteSet() and XGpio_DiscreteClear(). * *****************************************************************************/ void XGpio_DiscreteWrite(XGpio *InstancePtr, unsigned Channel, Xuint32 Data) { XASSERT_VOID(InstancePtr != XNULL); XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); XASSERT_VOID((Channel == 1) || ((Channel == 2) && (InstancePtr->IsDual == XTRUE))); XGpio_mWriteReg(InstancePtr->BaseAddress, ((Channel - 1) * XGPIO_CHAN_OFFSET) + XGPIO_DATA_OFFSET, Data); }
/** * Set the input/output direction of all discrete signals for the specified * GPIO channel. * * @param InstancePtr is a pointer to an XGpio instance to be worked on. * @param Channel contains the channel of the GPIO (1 or 2) to operate on. * @param DirectionMask is a bitmask specifying which discretes are input and * which are output. Bits set to 0 are output and bits set to 1 are input. * * @return * * None. * * @note * * The hardware must be built for dual channels if this function is used * with any channel other than 1. If it is not, this function will assert. * *****************************************************************************/ void XGpio_SetDataDirection(XGpio *InstancePtr, unsigned Channel, Xuint32 DirectionMask) { XASSERT_VOID(InstancePtr != XNULL); XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); XASSERT_VOID((Channel == 1) || ((Channel == 2) && (InstancePtr->IsDual == XTRUE))); XGpio_mWriteReg(InstancePtr->BaseAddress, ((Channel - 1) * XGPIO_CHAN_OFFSET) + XGPIO_TRI_OFFSET, DirectionMask); }
int main() { set_michiel_display(16); unsigned int *buffer; int h,i,j,k,c, loc; XGpio_mWriteReg(XPAR_LEDS_4BIT_BASEADDR,XGPIO_TRI_OFFSET,0); buffer = malloc(sizeof(int)*1000*500); if(!buffer) { print("aargh, could not malloc memory, quitting"); return 0; } for(i = 0;i < 10; i++) { set_michiel_display(14); for(i=0;i<1000000000;i++);;; set_michiel_display(i); c = 0; for(h=0;h<200;h++) { // wait for start while(!SNN_mReadSlaveReg0(XPAR_SNN_0_BASEADDR)) ;;; for(j=0;j<500;j++) { SNN_mWriteSlaveReg1(XPAR_SNN_0_BASEADDR, j); buffer[c++] = SNN_mReadSlaveReg1(XPAR_SNN_0_BASEADDR); } // handshaking: wait until start signal is reset again while(SNN_mReadSlaveReg0(XPAR_SNN_0_BASEADDR)) ;;; } set_michiel_display(16); for(j=0;j<200*500;j++) { xil_printf("%d\n",buffer[j]>>16); for(k=0;k<2000;k++);;; } } set_michiel_display(13); return 0; }
// // Write to LCD display // c: 8-bit character to write // mode: 'odd'=data, 'even'=instruction. If mode > 4, 4-bit write only. // void VTlcd_write( char c, char mode ) { pthread_mutex_lock( &vt_lcd_mutex ); char chigh = c >> 4; // Set LCD data bus to output XGpio_mSetDataDirection(XPAR_LCD_BASEADDR, 2, 0); XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, 0); // Transfer high nibble before low nibble XGpio_mWriteReg(XPAR_LCD_BASEADDR, 8, chigh); // Strobe E XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, 8|mode); XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, mode); sleep( 1 ); if (mode < 16) { XGpio_mWriteReg(XPAR_LCD_BASEADDR, 8, c); // Strobe E XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, 8|mode); XGpio_mWriteReg(XPAR_LCD_BASEADDR, 0, mode); sleep( 1 ); } pthread_mutex_unlock( &vt_lcd_mutex ); }
void set_michiel_display(int num) { const int disp[] = {0x5F , 0x05 , 0x6E , 0x2F , 0x35 , 0x3B , 0x7B , 0x0D , 0x7F , 0x3D , 0x7D , 0x73 , 0x5A , 0x67 , 0x7A , 0x78 , 0x00}; if(num < 17) XGpio_mWriteReg(XPAR_LEDS_4BIT_BASEADDR,XGPIO_DATA_OFFSET ,disp[num]); }