|
大家好,刚使用AVR的芯片,把以前的程序移植过来。
但是有点疑问:AVR存在程序存储区的常量,没法像RAM中的一样直接用指针访问么(好像要用对应的读取函数按字节,双字节....这样读取的)?如果要实现如下功能要怎么办呢?谢谢!
程序中有如下链表常数
extern void func1(void);
extern void func2(void);
......
extern void func10(void);
typedef struct _node
{
char val;
void (*func)(void);
node *next;
}node;
/* 以下结构存在程序存储区 */
const node tmp1 = {1,func1, &tmp2};
const node tmp2 = {2, func2,&tmp3};
...............
const node tmp10 = {10,func10, NULL };
const char cstr[100] = "abcdefghijk.......";
void main(void)
{
node *p = tmp2;
char *pchar = cstr;
char tmp;
p->func(); //这样可以么???
tmp = *pchar++; //这样可以么???
tmp = *pchar++; //这样可以么???
}
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|