⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mon_menu.c

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 C
字号:
//*----------------------------------------------------------------------------
//*      ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : mon_menu.c
//* Object              : Manage the monitor menu tolls dump and go
//*
//* 1.0 15/11/00 JPP    : Creation
//*----------------------------------------------------------------------------

//* --------------------------- include file ----------------------------------

#include <stdio.h>
#include <string.h>

/* Driver description  */
#include "drivers/com/com.h"                    //* Communication driver

//* --------------------------- Constant definition ---------------------------

extern void menu_monitor(void);

//* ------------------------------  extern function  --------------------------

extern int get_val( int val ,char * type );
extern int Get_Command(const char * menu);

//* ------------------------------  extern global data  -----------------------
extern ComDesc COM;

//* ------------------------------  Local variable ----------------------------
static const char main_menu[]=
{
"\n\r  COMMAND MENU: Monitor\n\r"
"  0)  Info   	1) Get\n\r"
"  2)  Dump     3) Go in THUMB\n\r"
" 99)  Quit function\n\r"
"Enter command to execute: "
};

//*----------------------------------------------------------------------------
//* Function Name       : menu
//* Object              : Get information and compute this
//* Input Parameters    : None
//* Output Parameters   : None
//*----------------------------------------------------------------------------
void monitor_menu(void)
{
int     command = 0;
int     count,cmpt;
u_int   read_value;
char    message[512];
unsigned char *pt_data;
int len;
void (*next)(void);     // Function declaration

//* init variable
pt_data = (u_char *)0x01000000;
len     = 0x400;

while(command!=99)
  {
    command = Get_Command(main_menu);
    switch(command)
    {
        case 1:
            at91_print(&COM,"Start work address:");
            pt_data = (u_char *) get_val((int )pt_data,"%08X");
            at91_print(&COM,"len:");
            len = get_val(len,"%08X");
        case 0:
            sprintf(message,"Start work address 0x%08X len 0x%08X \n\r",(int )pt_data,len);
            at91_print(&COM,message);
        break;

        case 2://* dump memory
            for (count=0, cmpt = 0  ; cmpt < len ; cmpt++,pt_data+=4 )
            {
                  // Read Data from memory
                read_value =  *((u_int *)pt_data);
                // Write address in modulo
                if ((cmpt %4)==0)
                {
                    count += sprintf(&message[count],"0x%08X:",(int)pt_data);
                }

                count += sprintf(&message[count]," 0x%08X",read_value);

                if ((cmpt %4)==3)
                {
                    sprintf(&message[count],"\n\r");
                    at91_print(&COM,message);
                    count =0;
                }
            }
          break;
          case 3://* start
            at91_print(&COM,"THUMB Application address(new val or return):");
            pt_data = (u_char *) get_val((int )pt_data,"%08X");
            next =  (void (*)(void)) pt_data;
            sprintf(message,"jmp to 0x%08X\n\r",(int )pt_data);
            at91_print(&COM,message);
            (*next)();
			break;
    }// switch command end
  }// while command end
}
//* End

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -