/* This functions gets a user input from terminal and display the memory data for the correspendign SA */ void display_brt_sa ( void) { uint8_t subaddr; while (1) { dp_display_text("Sub Address #(1 to 31 ): "); rx_char_ptr = rx_char; read_user_input(rx_char_ptr); xatoi ( &rx_char_ptr, &subaddr); dp_display_text("\r\nInput recived : "); dp_display_value(subaddr,HEX); if ((subaddr > 0 ) && (subaddr < 32)) { display_brt_data(CORE1553BRT_0 ,subaddr); break; } else { dp_display_text("\r\n\Invaid input !!!!! Enter the Sub Address # ( 1 to 31)to display Data: "); } } }
void display_brt_data(uint32_t brt_baseaddr,uint8_t subaddr){ uint16_t mem_addr,mem_data; uint16_t tx_sub_address,rx_sub_address; uint8_t i,m; mem_addr = (APB3_BASE_ADDRESS + brt_baseaddr); // 16 location from here onwards rx_sub_address = mem_addr + (BRT_RX_SA1 * subaddr); //0x1080 tx_sub_address = rx_sub_address + BRT_RX_TX_ADDR_OFSET; dp_display_text("\n\r BRT SA"); dp_display_value(subaddr,DEC); dp_display_text(" RX Buffer\r\n"); for ( i=1; i <= 4 ;i++) { dp_display_text("\r\n"); dp_display_value(i,DEC); dp_display_text("\t"); dp_display_value(rx_sub_address ,HEX);// ( 8* i) for calculating current address of the total 32 location dp_display_text("\t"); for (m=1; m <=8 ;m++){ mem_data= HW_get_16bit_reg(rx_sub_address); dp_display_value(mem_data,HEX); dp_display_text("\t"); rx_sub_address = rx_sub_address + 1; } } dp_display_text("\n\r BRT SA"); dp_display_value(subaddr,DEC); dp_display_text(" TX Buffer\r\n"); for ( i=1; i <= 4 ;i++) { dp_display_text("\r\n"); dp_display_value(i,DEC); dp_display_text("\t"); dp_display_value(tx_sub_address,HEX); dp_display_text("\t"); for (m=1; m <=8 ;m++){ mem_data= HW_get_16bit_reg(tx_sub_address); dp_display_value(mem_data,HEX); dp_display_text("\t"); tx_sub_address = tx_sub_address + 1; } } }
void dp_display_array(DPUCHAR *value,DPUINT bytes, DPUINT descriptive) { int idx; for (idx=bytes;idx>0;idx--) { dp_display_value(*value++,DEC); dp_display_text(" "); } }
void display_brt_regs(void){ uint32_t mem_addr,mem_data; //uint32_t bc_reg[16]; uint8 i; mem_addr = ( CORE1553BRT_BASE_ADDR + BRT_REG_OFFSET) ; // base address of BRT instance, 32location from here onwards dp_display_text("\n\r BRT Register Contents\r\n "); for ( i=0; i < 32 ;i++) { dp_display_text("\r\n"); dp_display_value(i,DEC); dp_display_text("\t"); dp_display_value(mem_addr,HEX); dp_display_text("\t"); mem_data = HW_get_16bit_reg(mem_addr); dp_display_value(mem_data,HEX); mem_addr = mem_addr + 1; } }
uint8_t get_data_input ( void) { uint8_t data_in; rx_char_ptr = rx_char; read_user_input(rx_char_ptr); xatoi ( &rx_char_ptr, &data_in); dp_display_value(data_in,HEX); return data_in; //display_brt_data(CORE1553BRT_0 ,subaddr); }
/* This function will get teh Input from Terminal and check for valid input for the SA */ uint8_t validate_brt_sa_input ( void) { uint8_t subaddr; dp_display_text("Sub Address #(1 to 31 ): "); rx_char_ptr = rx_char; read_user_input(rx_char_ptr); xatoi ( &rx_char_ptr, &subaddr); dp_display_value(subaddr,HEX); if ((subaddr > 0 ) && (subaddr < 32)) { return subaddr; //display_brt_data(CORE1553BRT_0 ,subaddr); } else { dp_display_text("\r\n\Invaid input !!!!! Enter the Sub Address # ( 1 to 31)to display Data: "); return 0; } }
void modify_mem_data (uint16_t addr,uint8_t ByteCount){ uint16_t mem_addr,mem_data; uint8_t recv_char=0; uint8_t size, index = 0; uint16_t input_data; uint8_t i=0; uint8_t m=0; uint8_t key; /* Clear the buffer before getting any new data */ for(index = 0; index < 10; index++) { rx_char[index] = '0'; } index = 0; mem_addr = addr; dp_display_text("Enter New data(0x10fe,1234, 0b1010110)\r\n"); for ( i=0; i <= ByteCount ;i++) { dp_display_text("\r\n"); dp_display_value(i,DEC); dp_display_text("\t"); dp_display_value(mem_addr,HEX); dp_display_text(":"); mem_data= HW_get_16bit_reg(mem_addr); dp_display_value(mem_data,HEX); dp_display_text("->"); key = get_key_selection(); if ( key == CHAR_ESC){ // ESC key == exit from writing return; }else if ( key == CHAR_LINE_FEED) // Return key, move to next address { mem_addr = mem_addr + 1; } else { rx_char[0] = key; // put the previosly rxvd character to buffer; index = 1; while(recv_char != CHAR_LINE_FEED) //'\n' { size = UART_get_rx(&g_stdio_uart, &recv_char,1); if(size > 0) { rx_char[index] = recv_char; UART_send (&g_stdio_uart, (uint8_t *)&recv_char,sizeof(recv_char)); index++; size = 0; // clear the rcvd flag } } rx_char_ptr = rx_char; xatoi ( &rx_char_ptr, &input_data); HW_set_16bit_reg(mem_addr,input_data); mem_addr = mem_addr + 1; recv_char = '-'; // DUMMY VALUE TO CHANGE THE DETECTION OF NEW LINE CHAR } } }