void dump_mem(void) { int i; char *ptr = (char *) FRAMES_BASE_ADDR; for (i=0; i<100000; i++) { XUartLite_SendByte(sUartLite.RegBaseAddress, *(ptr+i)); } }
unsigned char serXmit1(unsigned char *str, unsigned char n) { unsigned int i; i = 0; while(n>i){ //if(XUartLite_IsReceiveEmpty(UARTLITE_BASEADDRESS)) XUartLite_SendByte(UARTLITE_BASEADDRESS, str[i++]); } return n; }
/* * Call back function for write channel * * This callback only clears the interrupts and updates the transfer status. * * @param CallbackRef is the call back reference pointer * @param Mask is the interrupt mask passed in from the driver * * @return None * ******************************************************************************/ static void WriteCallBack(void *CallbackRef, u32 Mask) { if (Mask & XAXIVDMA_IXR_COMPLETION_MASK) { // Add 1 frame on to counteract buffer at start if (vBufferCounter < (VBUFFER_FRAMES+1)) { vbufptr = (u32 *)(VBUFFER_BASE_ADDR + (vBufferCounter * VBUFFER_HEIGHT * VBUFFER_WIDTH * sizeof(u32))); for (vBufferY = 0; vBufferY < VBUFFER_HEIGHT; vBufferY++) { for (vBufferX = 0; vBufferX < VBUFFER_WIDTH; vBufferX++) { vbufptr[vBufferX + (vBufferY * VBUFFER_WIDTH)] = frmptr[vBufferX + (vBufferY * FRAME_HORIZONTAL_LEN)]; } } vBufferCounter++; } else { XAxiVdma_IntrDisable(&AxiVdma, XAXIVDMA_IXR_COMPLETION_MASK, XAXIVDMA_WRITE); StopParking(0); // Output over UART register int i; u8 r, g, b; register u32 *vbufptr = (u32 *)(VBUFFER_BASE_ADDR); // Skip the first frame, as it may be from earlier in time (due to buffer) for (i = VBUFFER_WIDTH * VBUFFER_HEIGHT; i < VBUFFER_WIDTH * VBUFFER_HEIGHT * (VBUFFER_FRAMES+1); i++) { u32 pixel = vbufptr[i]; b = (u8)pixel; g = (u8)(pixel >> 8); r = (u8)(pixel >> 16); XUartLite_SendByte(XPAR_UARTLITE_1_BASEADDR, r); XUartLite_SendByte(XPAR_UARTLITE_1_BASEADDR, g); XUartLite_SendByte(XPAR_UARTLITE_1_BASEADDR, b); } } } // xil_printf("w."); }
/* target_putchar(): * When buffer has space available, load the incoming character * into the UART. */ int target_putchar(char c) { XUartLite_SendByte(UART_BASE, c); return((int)c); }
void outbyte(char c) { XUartLite_SendByte(STDOUT_BASEADDRESS, c); }
unsigned char serGetOSCmd1(unsigned char *str) { unsigned char j, *dummy; unsigned char node_dest; int i; uint8_t *slen,len; j=0; bootLoadCmd1G = BLC_DL_WAITING; //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,0x1A); if (bootLoadCmd1G == BLC_NORMAL){ return 0; } else if (bootLoadCmd1G == BLC_DL_WAITING){ //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,0x1B); /* Check if data is available */ //if (!XUartLite_IsReceiveEmpty(UARTLITE_BASEADDRESS)){ //*slen = XUartLite_ReadReg(UARTLITE_BASEADDRESS, XUL_RX_FIFO_OFFSET); j = Zigbee_Receive(); if (j==1) { slen = rfRxInfo.pPayload; if ((slen[0] != '!')&&(slen[1] != 'O')&&(slen[2] != 'S')){ XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,0xFF); bootLoadCmd1G = *slen; return 0; } bootLoadCmd1G = BLC_DL_RECVD; } else{ return 0; } } // If we made it here, a char has been received if (bootLoadCmd1G == BLC_DL_RECVD){ // '!' has been received i = 0; str[2] = 0; //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,0x1D); // get first two chars to determine destination node while(i<2) { str[i] = slen[i+3]; i++; //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,0x1D); } //check if this message is meant for me // XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,0x1E); node_dest = (unsigned char)strtol(str,&dummy,16); //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,node_dest); if(node_dest != myNodeG) return 0; i = 0; str[2] = 0; //get the next two chars to determine data length while(i < 2){ str[i] = slen[i+15]; i++; } //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,0x1F); len = (uint8_t)strtol(str,&dummy,16); //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,len); i =0; //XUartLite_SendByte(XPAR_RS232_UART_1_BASEADDR,len); // Now get the 1-byte record type, 1-byte comp_ID, and data bytes while(i < (12 + (len <<1))){ str[i] = slen[i+5] ; i++; } str[i] = 0; // place the end-of-string char bootLoadCmd1G = BLC_DL_WAITING; return 1; } else{ return 0; } }
int main(void) { while (1) { unsigned char c, d, e; c = 0x00; d = 0x00; e = 0x00; while(c == 0x00){ c = XUartLite_RecvByte(0x84000000); //receive letter } XUartLite_SendByte(0x84000000, c); while(d == 0x00){ d = XUartLite_RecvByte(0x84000000); //receive letter } XUartLite_SendByte(0x84000000, d); while(e == 0x00){ e = XUartLite_RecvByte(0x84000000); //receive letter } XUartLite_SendByte(0x84000000, e); XUartLite_SendByte(0x84000000, 0x20); //send space char //led command if((c == 0x6C) && (d == 0x65) && (e == 0x64)){ c = 0x00; d = 0x00; e = 0x00; while(c == 0x00){ c = XUartLite_RecvByte(0x84000000) - 0x30; //receive letter d = c - 0x27; if((c >= 0x0) && (c <= 0x9)){ e = c; } else if((d >= 0xA) && (d <= 0xF)){ e = d; } else{ e = 0x0; } } XUartLite_SendByte(0x84000000, c + 0x30); e = e << 4; c = 0x00; d = 0x00; while(c == 0x00){ c = XUartLite_RecvByte(0x84000000) - 0x30; //receive letter d = c - 0x27; if((c >= 0x0) && (c <= 0x9)){ e += c; } else if((d >= 0xA) && (d <= 0xF)){ e += d; } else{ e = e; } } XUartLite_SendByte(0x84000000, c + 0x30); Xil_Out8(0x83000000, e); } //switch command if((c == 0x73) && (d == 0x77) && (e == 0x74)){ c = 0x00; d = 0x00; e = 0x00; c = Xil_In8(0x83000004) & 0xF; d = Xil_In8(0x83000004) & 0xF0; d = d >> 4; if(c <= 0x9){ c = c + 0x30; } else{ c = c + 0x57; } if(d <= 0x9){ d = d + 0x30; } else{ d = d + 0x57; } XUartLite_SendByte(0x84000000, d); XUartLite_SendByte(0x84000000, c); } XUartLite_SendByte(0x84000000, 0xA); //send new line char XUartLite_SendByte(0x84000000, 0xD); //send return char }