int main (void) { XGpio dip, push; int i, psb_check, dip_check; xil_printf("-- Start of the Program --\r\n"); XGpio_Initialize(&dip, XPAR_SW_4BIT_DEVICE_ID); // Modify this XGpio_SetDataDirection(&dip, 1, 0xffffffff); XGpio_Initialize(&push, XPAR_BTNS_4BIT_DEVICE_ID); // Modify this XGpio_SetDataDirection(&push, 1, 0xffffffff); while (1) { psb_check = XGpio_DiscreteRead(&push, 1); xil_printf("Push Buttons Status %x\r\n", psb_check); dip_check = XGpio_DiscreteRead(&dip, 1); xil_printf("DIP Switch Status %x\r\n", dip_check); // output dip switches value on LED_ip device LED_IP_mWriteReg(XPAR_LED_IP_0_S_AXI_BASEADDR,0,dip_check); for (i=0; i<9999999; i++); } }
int main (void) { XGpio dip, push; int i, psb_check, dip_check; xil_printf("-- Start of the Program --\r\n"); XGpio_Initialize(&dip, XPAR_SW_4BIT_DEVICE_ID); XGpio_SetDataDirection(&dip, 1, 0xffffffff); XGpio_Initialize(&push, XPAR_BTNS_4BIT_DEVICE_ID); XGpio_SetDataDirection(&push, 1, 0xffffffff); while (1) { psb_check = XGpio_DiscreteRead(&push, 1); xil_printf("Push Buttons Status %x\r\n", psb_check); dip_check = XGpio_DiscreteRead(&dip, 1); xil_printf("DIP Switch Status %x\r\n", dip_check); for (i=0; i<9999999; i++); } }
/* * Read GPIO Status */ int qthRwStat() { u32 qthStatus; u32 errStatus = XST_SUCCESS; int i; qthStatus = XGpio_DiscreteRead(&gpioRO0_status, 1); if(qthStatus != 0x01) { xil_printf("qth: Transceiver Initialization Failed\r\n"); return XST_FAILURE; } for(i = 0; i < 8; i++) { qthStatus = XGpio_DiscreteRead(&gpioROs[i], 1); if(qthStatus != 0x00) { xil_printf("qth-Channel%d: Error Count %4d (0x%02x)\r\n", i, qthStatus, qthStatus); errStatus = XST_FAILURE; } } if(errStatus == XST_SUCCESS) { xil_printf("qth: Test Passed with no Errors\r\n"); } return errStatus; }
u64 get_usec_timestamp(){ u32 timestamp_high_u32; u32 timestamp_low_u32; u64 timestamp_u64; timestamp_high_u32 = XGpio_DiscreteRead(&GPIO_timestamp,TIMESTAMP_GPIO_MSB_CHAN); timestamp_low_u32 = XGpio_DiscreteRead(&GPIO_timestamp,TIMESTAMP_GPIO_LSB_CHAN); timestamp_u64 = (((u64)timestamp_high_u32)<<32) + ((u64)timestamp_low_u32); return timestamp_u64; }
void OledUpdate() { int gpioReg = 0; int ipag; uint8_t * pb; pb = rgbOledBmp; gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); for (ipag = 0; ipag < cpagOledMax; ipag++) { XGpio_DiscreteWrite(&gpioInstance, 1, gpioReg & ( RESET_MASK | VDD_CTRL_MASK | VBAT_CTRL_MASK )); /* Set the page address */ Spi2PutByte(0x22); //Set page command Spi2PutByte(ipag); //page number /* Start at the left column */ Spi2PutByte(0x00); //set low nybble of column Spi2PutByte(0x10); //set high nybble of column XGpio_DiscreteWrite(&gpioInstance, 1, gpioReg | DATA_CMD_MASK); /* Copy this memory page of display data. */ OledPutBuffer(ccolOledMax, pb); pb += ccolOledMax; } }
/***************************************************************************//** * @brief gpio_set_value *******************************************************************************/ int32_t gpio_set_value(uint8_t pin, uint8_t data) { #ifdef _XPARAMETERS_PS_H_ XGpioPs_WritePin(&gpio_instance, pin, data); #else uint32_t channel = 1; uint32_t config = 0; /* We assume that pin 32 is the first pin from channel 2 */ if (pin >= 32) { channel = 2; pin -= 32; } config = XGpio_DiscreteRead(&gpio_instance, channel); if(data) { config |= (1 << pin); } else { config &= ~(1 << pin); } XGpio_DiscreteWrite(&gpio_instance, channel, config); #endif return 0; }
void OledDisplayOff() { int gpioReg = 0; gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); XGpio_DiscreteWrite(&gpioInstance, 1, gpioReg & ( RESET_MASK | VDD_CTRL_MASK | VBAT_CTRL_MASK )); Spi2PutByte(cmdOledDisplayOff); }
/** * * This function performs a test on the GPIO driver/device with the GPIO * configured as INPUT * * @param DeviceId is the XPAR_<GPIO_instance>_DEVICE_ID value from * xparameters.h * @param DataRead is the pointer where the data read from GPIO Input is * returned * * @return XST_SUCCESS if the Test is successful, otherwise XST_FAILURE * * @note None. * ******************************************************************************/ int GpioInputExample(u16 DeviceId, u32 *DataRead) { int Status; /* * Initialize the GPIO driver so that it's ready to use, * specify the device ID that is generated in xparameters.h */ Status = XGpio_Initialize(&GpioInput, DeviceId); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Set the direction for all signals to be inputs */ XGpio_SetDataDirection(&GpioInput, LED_CHANNEL, 0xFFFFFFFF); /* * Read the state of the data so that it can be verified */ *DataRead = XGpio_DiscreteRead(&GpioInput, LED_CHANNEL); return XST_SUCCESS; }
void ledToggle() {// toggle led led = XGpio_DiscreteRead(&outGpio,1); if (led & 0x8) XGpio_DiscreteWrite(&outGpio,1,led & 0x7); else XGpio_DiscreteWrite(&outGpio,1,led | 0x8); };
int main(void){ int status; int delay = 100000; int temp=148; //INITILIZE THE GPIO status = XGpio_Initialize(&SwitchInst, SWITCH_DEVICE_ID); if(status != XST_SUCCESS) return XST_FAILURE; status = XGpio_Initialize(&DutycycleInst, DUTYCYCLE_DEVICE_ID); if(status != XST_SUCCESS) return XST_FAILURE; //SET GPIO DATA DIRECTIONS XGpio_SetDataDirection(&SwitchInst, 1, 0xFF); XGpio_SetDataDirection(&DutycycleInst, 1, 0x00); //DO SOMETHING HERE IN MAIN **EDIT** while(1){ switch_value = XGpio_DiscreteRead(&SwitchInst, 1); //for(int i = 0; i < delay; i++); temp = (100+(switch_value*5.625)); XGpio_DiscreteWrite(&DutycycleInst, 1, temp); } return 0; }
void GpioIsr(void *InstancePtr) { XGpio *GpioPtr = (XGpio *)InstancePtr; Xuint32 Led; Xuint32 LedState; Xuint32 Buttons; Xuint32 ButtonFound; Xuint32 ButtonsChanged = 0; static Xuint32 PreviousButtons; /*************************************************************** * There should not be any other interrupts occurring other than * the button changes. ***************************************************************/ if((XGpio_InterruptGetStatus(GpioPtr) & BUTTON_INTERRUPT) != BUTTON_INTERRUPT) return; /*************************************************************** * Read state of push buttons and determine which ones changed * states from the previous interrupt. Save a copy of the buttons * for the next interrupt. ****************************************************************/ Buttons = XGpio_DiscreteRead(GpioPtr, BUTTON_CHANNEL); // Clear the interrupt such that it is no longer pending in the GPIO (void) XGpio_InterruptClear(GpioPtr, BUTTON_INTERRUPT); // Do we need to clear the interrupt at the INTC? Yield(); }
/* * Read GPIO Status */ int ddr3RwTest() { u32 ddr3Status; ddr3Status = XGpio_DiscreteRead(&gpioInstance, 1); if(ddr3Status != 0x01) { u32 delay = 0; for (delay = 0; delay < 40000000; delay++) { asm("nop"); } ddr3Status = XGpio_DiscreteRead(&gpioInstance, 1); } if(ddr3Status != 0x01) { return XST_FAILURE; } return XST_SUCCESS; }
int DebouncButton( void ) { int btn; static int hitZero=0; static int btnIntegrator=0; btn = XGpio_DiscreteRead(&gpio_btn, 1); // decrement and keep track if we've touched zero if ( btn==0 ) { if (btnIntegrator > 0) btnIntegrator -= 1; if (btnIntegrator == 0) hitZero = 1; return 0; } if (btnIntegrator < 1000) btnIntegrator += 1; if (btnIntegrator < 1000) return 0; if (hitZero == 0) return 0; // we've hit 1000 so now we know we need to hit zero again hitZero = 0; return 1; }
int main(void) { u32 Data; u32 InData; int Status; volatile int Delay; char test_vect_idx =0; char charidx = 0; u8 DataWrittenDone = 0; char curchar; init_platform(); /* * Initialize the GPIO driver */ Status = XGpio_Initialize(&Gpio, GPIO_EXAMPLE_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } for (test_vect_idx=0;test_vect_idx<num_test_vectors;test_vect_idx++) { for (charidx=0;charidx<64;charidx++) { curchar = testvector[test_vect_idx][charidx]; //Read the current character Data = createDataPacket(curchar,charidx,test_vect_idx); //Send the 'A' character to byte 3 of testvector 1 print("Sending character \n"); XGpio_DiscreteWrite(&Gpio, OUPTPUT_CHANNEL, Data); //Write into the PL //Double check by reading from the PL for (Delay = 0; Delay < LED_DELAY; Delay++); //Wait for a while //Read back the data from the PL side to see its status do { InData = XGpio_DiscreteRead(&Gpio, INPUT_CHANNEL); for (Delay = 0; Delay < LED_DELAY; Delay++); //Wait for a while before recheck } while (InData&(1<<31)); if ((InData&0xFF)==(Data&0xFF)) { print("Correct\n"); } else { print("Incorrect\n"); } XGpio_DiscreteWrite(&Gpio, OUPTPUT_CHANNEL, 0x00000000); //Release the bus immediately for (Delay = 0; Delay < LED_DELAY; Delay++); //Wait for a while } } print("Done sending. Please press the center button to begin..."); cleanup_platform(); return XST_SUCCESS; }
int testSwitchesAndLEDs() { init_platform(); initGPIO(); unsigned int switch_val = XGpio_DiscreteRead(&xgpio_switches, 1); xil_printf("Switch val: %x \n\r", switch_val); while(1) { switch_val = XGpio_DiscreteRead(&xgpio_switches, 1); XGpio_DiscreteWrite(&xgpio_LEDs, 1, switch_val); } cleanup_platform(); return 0; }
void respondToGPIOInput() { const int PUSH_BUTTONS_CENTER = 0x01; const int PUSH_BUTTONS_RIGHT = 0x02; const int PUSH_BUTTONS_LEFT = 0x08; const int PUSH_BUTTONS_UP = 0x10; const int PUSH_BUTTONS_DOWN = 0x04; int buttonState = XGpio_DiscreteRead(&gpPB, 1); if (buttonState & PUSH_BUTTONS_LEFT) tank_moveTankLeft(); else if (buttonState & PUSH_BUTTONS_RIGHT) tank_moveTankRight(); if (buttonState & PUSH_BUTTONS_UP) tank_fireBullet(); if (buttonState & PUSH_BUTTONS_CENTER) sound_volumeUp(); else if (buttonState & PUSH_BUTTONS_DOWN) sound_volumeDown(); int x = mouse_getXMovement(); tank_moveTank(x / TANK_MOUSE_DIVIDER); if(mouse_getMouseButtons() == MOUSE_LEFT_BUTTON) tank_fireBullet(); // switches const int SWITCH_LD6 = 0x40; const int SWITCH_LD5 = 0x20; int oldSwitchState = switchState; switchState = XGpio_DiscreteRead(&gpswitches, 1); if ((switchState & SWITCH_LD5) != (oldSwitchState & SWITCH_LD5)) { // switch changed position if (switchState & SWITCH_LD5) displayScreenCapture(); else displayGame(); } if ((switchState & SWITCH_LD6) && !(oldSwitchState & SWITCH_LD6)) { // switch flipped up captureScreen(); } }
// After 50ms of button stability the buttons are // considered debounced and this timer is disabled void debounceButtons_tick() { if (debounceTimerEnable) { debounceTimer++; if (debounceTimer == 5) { // 50 ms debounceTimerEnable = false; displayTime_setButtonsVal(XGpio_DiscreteRead(&gpPB, 1)); } } }
/* * Read GPIO Status */ int qdrRwTest() { u32 qdrStatus; qdrStatus = XGpio_DiscreteRead(&gpioInstance, 1); if(qdrStatus != 0x01) { return XST_FAILURE; } return XST_SUCCESS; }
void PushBtnHandler(void * CallBackRef) { state1 = XGpio_DiscreteRead(&Btns, 1); pshBtn = 1; XGpio_InterruptDisable(&Btns, 1); Delay_50ms(); XGpio_InterruptClear(&Btns, 1); XGpio_InterruptEnable(&Btns, 1); }
/*** PushBtnHandler ** ** Parameters: ** CallBackRef - Pointer to the push button struct (pshBtns) initialized ** in main. ** ** Return Value: ** None ** ** Errors: ** None ** ** Description: ** This function is connected to the interrupt handler such that it is ** called whenever an interrupt is triggered by the push buttons. It ** responds to button presses by either stopping/starting the input ** feed, printing a test pattern, inverting the framebuffer, or outputting ** the input frame dimensions over UART. */ void PushBtnHandler(void *CallBackRef) { XGpio *pPushBtn = (XGpio *)CallBackRef; u32 lBtnStateNew = XGpio_DiscreteRead(pPushBtn, lBtnChannel); u32 lBtnChanges = lBtnStateNew ^ lBtnStateOld; lBtnStateOld = lBtnStateNew; if ((lBtnChanges & BUTTON_UP) && (lBtnStateNew & BUTTON_UP)) { // Up button pressed delay++; xil_printf("Delay: %2d\r\n", delay); ghPlayer_SetControl(XPAR_GH_PLAYER_0_BASEADDR, 0, TILT, strumValue, delay, type, playerEnable); } if ((lBtnChanges & BUTTON_DOWN) && (lBtnStateNew & BUTTON_DOWN)) { // Down button pressed delay--; xil_printf("Delay: %2d\r\n", delay); ghPlayer_SetControl(XPAR_GH_PLAYER_0_BASEADDR, 0, TILT, strumValue, delay, type, playerEnable); } if ((lBtnChanges & BUTTON_LEFT) && (lBtnStateNew & BUTTON_LEFT)) { // Left button pressed xil_printf("\r\nOutputting frames over Ethernet..."); // Output series of frames over Ethernet EnableVDMAFrameIntr(); } if ((lBtnChanges & BUTTON_RIGHT) && (lBtnStateNew & BUTTON_RIGHT)) { // Right button pressed xil_printf("\r\nOutputting frame over Ethernet..."); /* Output frame over Ethernet */ register int i; register u32 *vbufptr = (u32 *)(XPAR_S6DDR_0_S0_AXI_BASEADDR + 0x01000000); for (i = 0; i < 1280 * 720 ; i += 320) { ethernetSendPayload(1280, (u8*)(vbufptr + i)); } xil_printf("done"); } if ((lBtnChanges & BUTTON_CENTRE) && (lBtnStateNew & BUTTON_CENTRE)) { // Centre button pressed xil_printf("\r\nResetting VDMA setup..."); // Set up VDMA vdma_setup(btnIntCtrl); } XGpio_InterruptClear(pPushBtn, lBtnChannel); // Clear interrupt }
// This is invoked each time there is a change in the button state (result of a push or a bounce). void pb_interrupt_handler() { // Clear the GPIO interrupt. XGpio_InterruptGlobalDisable(&gpPB); // Turn off all PB interrupts for now. currentButtonState = XGpio_DiscreteRead(&gpPB, 1); // Get the current state of the buttons. // You need to do something here. XGpio_InterruptClear(&gpPB, 0xFFFFFFFF); // Ack the PB interrupt. XGpio_InterruptGlobalEnable(&gpPB); // Re-enable PB interrupts. // Because there is a change in the button state, the button counters need to be reinitialized. debounce_timer_count = 0; }
/* * Read GPIO Status */ int qthRwTest() { u32 qthStatus; int i; qthStatus = XGpio_DiscreteRead(&gpioRO0_status, 1); if(qthStatus != 0x01) { return XST_FAILURE; } for(i = 0; i < 8; i++) { qthStatus = XGpio_DiscreteRead(&gpioROs[i], 1); if(qthStatus != 0x00) { xil_printf("qth-Channel%d: Error Count %4d (0x%02x)\r\n", i, qthStatus, qthStatus); return XST_FAILURE; } } return XST_SUCCESS; }
void Mrf24j::reset(void) { int gpioReg = 0; gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); XGpio_DiscreteWrite(&gpioInstance, 1, gpioReg & RF_WAKE_MASK); //reset low usleep(10000); // just my gut XGpio_DiscreteWrite(&gpioInstance, 1, gpioReg | RF_RESET_MASK); //reset high usleep(20000); // from manual }
void OledDevInit() { int gpioReg = 0; /* We're going to be sending commands, so clear the Data/Cmd bit */ gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); XGpio_DiscreteWrite(&gpioInstance, 1, gpioReg & (RESET_MASK | VBAT_CTRL_MASK)); gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); printf("OledDevInit: d/cmd, vdd set to 0, gpioReg: %X", gpioReg); usleep(1000); /* Display off command */ Spi2PutByte(cmdOledDisplayOff); /* Bring Reset low and then high */ gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); XGpio_DiscreteWrite(&gpioInstance, 1, gpioReg & ( VBAT_CTRL_MASK | VDD_CTRL_MASK | DATA_CMD_MASK)); gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); printf("OledDevInit: reset set to 0, gpioReg: %X", gpioReg); usleep(1000); XGpio_DiscreteWrite(&gpioInstance, 1, gpioReg | RESET_MASK); gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); printf("OledDevInit: reset set to 1, gpioReg: %X", gpioReg); /* Send the Set Charge Pump and Set Pre-Charge Period commands */ Spi2PutByte(0x8D); //From Univision data sheet, not in SSD1306 data sheet Spi2PutByte(0x14); Spi2PutByte(0xD9); //From Univision data sheet, not in SSD1306 data sheet Spi2PutByte(0xF1); /* Turn on VCC and wait 100ms */ gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); XGpio_DiscreteWrite(&gpioInstance, 1, gpioReg & ( RESET_MASK | VDD_CTRL_MASK | DATA_CMD_MASK)); gpioReg = XGpio_DiscreteRead(&gpioInstance, 1); printf("OledDevInit: vbat set to 0, gpioReg: %X", gpioReg); usleep(100000); /* Send the commands to invert the display. */ Spi2PutByte(cmdOledSegRemap); //remap columns Spi2PutByte(cmdOledComDir); //remap the rows /* Send the commands to select sequential COM configuration */ Spi2PutByte(cmdOledComConfig); //set COM configuration command Spi2PutByte(0x20); //sequential COM, left/right remap enabled /* Send Display On command */ Spi2PutByte(cmdOledDisplayOn); }
/** * * This function does a minimal test on the GPIO device configured as OUTPUT * and driver as a example. * * * @param DeviceId is the XPAR_<GPIO_instance>_DEVICE_ID value from * xparameters.h * @param GpioWidth is the width of the GPIO * * @return XST_SUCCESS if successful, XST_FAILURE if unsuccessful * * @note None * ****************************************************************************/ void GpioOutputExample(Xuint16 DeviceId, Xuint32 GpioWidth) { volatile int Delay; Xuint32 LedBit; Xuint32 LedLoop; XStatus Status; int numTimes = 1; /* * Initialize the GPIO driver so that it's ready to use, * specify the device ID that is generated in xparameters.h */ Status = XGpio_Initialize(&GpioOutput, DeviceId); if (Status != XST_SUCCESS) { print("Gpio Instance Didn't Initialize!\r\n"); } /* * Set the direction for all signals to be outputs */ XGpio_SetDataDirection(&GpioOutput, 1, 0x0); /* * Set the GPIO outputs to low */ XGpio_DiscreteWrite(&GpioOutput, 1, 0x0); while (numTimes > 0) { for (LedBit = 0x0; LedBit < GpioWidth; LedBit++) { for (LedLoop = 0; LedLoop < 1; LedLoop++) { /* * Set the GPIO Output to High */ XGpio_DiscreteWrite(&GpioOutput, 1, 1 << LedBit); /* * Wait a small amount of time so the LED is visible */ for (Delay = 0; Delay < (500000/2); Delay++) { // Dummy read; to ensure the delay has no Cache effect XGpio_DiscreteRead(&GpioOutput, 1); } /* * Clear the GPIO Output */ XGpio_DiscreteClear(&GpioOutput, 1, 1 << LedBit); } } numTimes--; } }
void reset_DW1000(void) { u32 uwbIn; XGpio_Initialize(&uwbGpio,XPAR_AXI_GPIO_UWB_DEVICE_ID); XGpio_DiscreteWrite(&uwbGpio,1,0); // reset on uwbIn = XGpio_DiscreteRead(&uwbGpio,2); /* printf("UBW reset active. Inputs 0x%x. Press any key\r\n", uwbIn); getchar(); */ XGpio_DiscreteWrite(&uwbGpio,1,0xff); // reset off uwbIn = XGpio_DiscreteRead(&uwbGpio,2); while(0 == (uwbIn & 0x4)){ //printf("UBW reset inactive. Inputs 0x%x\r\n", uwbIn); uwbIn = XGpio_DiscreteRead(&uwbGpio,2); } printf("UBW reset completed\r\n"); deca_sleep(2); }
// This is invoked each time there is a change in the button state (result of a push or a bounce). void pb_interrupt_handler() { // Clear the GPIO interrupt. XGpio_InterruptGlobalDisable(&gpPB); // Turn off all PB interrupts for now. currentButtonState = XGpio_DiscreteRead(&gpPB, 1); // Get the current state of the buttons. // Reset button counter btnCounter = 0; XGpio_InterruptClear(&gpPB, 0xFFFFFFFF); // Ack the PB interrupt. XGpio_InterruptGlobalEnable(&gpPB); // Re-enable PB interrupts. }
int main() { unsigned int value=0; int i; u32 input; unsigned int my_array[] = { 1841,1371,1356,1435,1364,1474,1741,1790,1720,1770,6770,7460,3660,5045,1111,9481 ,99,100,99,92,159,163,114,177,101,44,55,192,58,81,129,193,124,76,38,181,147,182,77,71, 17,164,149,193,62,45,81,176,184,165,28,199,1,199,1,199,1,199,1,199,1,199,1,199,15,12,9,98,9,134,14,15, 16,7,2,6,1,4,7,18,1,5,20,21,22,23,24,25,15,15,15,101,199,102,198,103,197,104,196,105,195,111,189,122, 184,137,136,135,134,144,141,190,120,170,60,70,30,50,111,981,141,171 }; GPIO_0_conf.BaseAddress = XPAR_AXI_GPIO_0_BASEADDR; GPIO_0_conf.DeviceId = XPAR_GPIO_0_DEVICE_ID; GPIO_0_conf.InterruptPresent = XPAR_GPIO_0_INTERRUPT_PRESENT; GPIO_0_conf.IsDual = XPAR_GPIO_0_IS_DUAL; //Initialize the XGpio instance XGpio_CfgInitialize(&GPIO_0, &GPIO_0_conf, GPIO_0_conf.BaseAddress); init_platform(); print("*Init*\n\r"); for(i=0;i<size;i++){ value = 0xe0000000 | (i<<16) | my_array[i]; XGpio_DiscreteWrite(&GPIO_0, 1, value); print("Preencheu RAM! \n\r"); } print("Fim do preenchimento\n\r"); print("Pressionar btnC\n\r"); input = XGpio_DiscreteRead(&GPIO_0, 2); // Separar valor para mostrar outbyte((char)((input/100)+0x30)); outbyte((char)((input/10)%10+0x30)); outbyte((char)(input%10+0x30)); print("\n"); cleanup_platform(); return 0; }
int main() { XGpio gpio0, gpio1, gpio2, gpio3, gpio4; unsigned int a, b, c, d, e, f, g, h, i, j, k; init_platform(); while (1) { XGpio_Initialize(&gpio0, XPAR_AXI_GPIO_0_DEVICE_ID); XGpio_Initialize(&gpio1, XPAR_AXI_GPIO_1_DEVICE_ID); XGpio_Initialize(&gpio2, XPAR_AXI_GPIO_2_DEVICE_ID); XGpio_Initialize(&gpio3, XPAR_AXI_GPIO_3_DEVICE_ID); XGpio_Initialize(&gpio4, XPAR_AXI_GPIO_4_DEVICE_ID); a = XGpio_DiscreteRead (&gpio0, 1); // Timer LSB b = XGpio_DiscreteRead (&gpio0, 2); // Timer MSB c = XGpio_DiscreteRead (&gpio1, 1); // BRAM Single d = XGpio_DiscreteRead (&gpio1, 2); // BRAM Double e = XGpio_DiscreteRead (&gpio2, 1); // DSP Global f = XGpio_DiscreteRead (&gpio2, 2); // DSP Single g = XGpio_DiscreteRead (&gpio3, 1); // DSP Double h = XGpio_DiscreteRead (&gpio3, 2); // DSP Triple i = XGpio_DiscreteRead (&gpio4, 1); // CLB Level1 j = XGpio_DiscreteRead (&gpio4, 2); // CLB Level2 printf("T\t%d%d\n\r", b, a); printf("BS\t%d\n\r", c); printf("BD\t%d\n\r", d); printf("DG\t%d\n\r", e); printf("DS\t%d\n\r", f); printf("DD\t%d\n\r", g); printf("DT\t%d\n\r", h); printf("C1\t%d\n\r", i); printf("C2\t%d\n\r", j); for (i = 0; i < 1000; ++i); } return 0; }
/*-----------------------------------------------------------*/ static void prvRxTask( void *pvParameters ) { char Recdstring[15] = ""; int i; int Status; u32 prev_btns = 0; /* Print the received data. */ xil_printf( "Rx task starting.\r\n"); for( ;; ) { RecvFrameLength = 0; /* * Poll for receive packet. */ while ((volatile u32)RecvFrameLength == 0) { vTaskDelay(1); u32 btns = XGpio_DiscreteRead(&gpio_btns, 1); if (btns != prev_btns) { xil_printf("btns=%d\r\n", btns); if (btns == 1) { /* send a frame */ xil_printf( "Rx emac: sending a frame\r\n"); Status = EmacLiteSendFrame(&emac, 128); if (Status != XST_SUCCESS) { xil_printf( "Rx emac: send frame fail\r\n"); } } prev_btns = btns; } RecvFrameLength = XEmacLite_Recv(&emac, (u8 *)RxFrame); } xil_printf( "Rx emac: frame recv, len=%d\r\n", RecvFrameLength); /* * Check the received frame. */ Status = EmacLiteRecvFrame(128); if ((Status != XST_SUCCESS) && (Status != XST_NO_DATA)) { xil_printf( "Rx emac: frame rx check no success\r\n"); } for (i = 0; i < RecvFrameLength; ++i) { xil_printf("%02x:", RxFrame[i]); } xil_printf("\r\n"); } }