打印

DSP281x_Adc.h修改以便访问

[复制链接]
1734|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
益友电子|  楼主 | 2012-8-4 20:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
ADC, DSP, IO, se, RS
改写DSP281x_Adc.h,得到2种访问方式,不破坏原TI之习惯

struct ADC_REGS {
union ADCTRL1_REG ADCTRL1; // ADC Control 1
union ADCTRL2_REG ADCTRL2; // ADC Control 2
union ADCMAXCONV_REG ADCMAXCONV; // Max conversions
union ADCCHSELSEQ1_REG ADCCHSELSEQ1; // Channel select sequencing control 1
union ADCCHSELSEQ2_REG ADCCHSELSEQ2; // Channel select sequencing control 2
union ADCCHSELSEQ3_REG ADCCHSELSEQ3; // Channel select sequencing control 3
union ADCCHSELSEQ4_REG ADCCHSELSEQ4; // Channel select sequencing control 4
union ADCASEQSR_REG ADCASEQSR; // Autosequence status register
Uint16 ADCRESULT[16];
/*
Uint16 ADCRESULT0; // Conversion Result Buffer 0
Uint16 ADCRESULT1; // Conversion Result Buffer 1
Uint16 ADCRESULT2; // Conversion Result Buffer 2
Uint16 ADCRESULT3; // Conversion Result Buffer 3
Uint16 ADCRESULT4; // Conversion Result Buffer 4
Uint16 ADCRESULT5; // Conversion Result Buffer 5
Uint16 ADCRESULT6; // Conversion Result Buffer 6
Uint16 ADCRESULT7; // Conversion Result Buffer 7
Uint16 ADCRESULT8; // Conversion Result Buffer 8
Uint16 ADCRESULT9; // Conversion Result Buffer 9
Uint16 ADCRESULT10; // Conversion Result Buffer 10
Uint16 ADCRESULT11; // Conversion Result Buffer 11
Uint16 ADCRESULT12; // Conversion Result Buffer 12
Uint16 ADCRESULT13; // Conversion Result Buffer 13
Uint16 ADCRESULT14; // Conversion Result Buffer 14
Uint16 ADCRESULT15; // Conversion Result Buffer 15
*/
union ADCTRL3_REG ADCTRL3; // ADC Control 3
union ADCST_REG ADCST; // ADC Status Register
};

#define ADCRESULT0 ADCRESULT[0]
#define ADCRESULT1 ADCRESULT[1]
#define ADCRESULT2 ADCRESULT[2]
#define ADCRESULT3 ADCRESULT[3]
#define ADCRESULT4 ADCRESULT[4]
#define ADCRESULT5 ADCRESULT[5]
#define ADCRESULT6 ADCRESULT[6]
#define ADCRESULT7 ADCRESULT[7]
#define ADCRESULT8 ADCRESULT[8]
#define ADCRESULT9 ADCRESULT[9]
#define ADCRESULT10 ADCRESULT[10]
#define ADCRESULT11 ADCRESULT[11]
#define ADCRESULT12 ADCRESULT[12]
#define ADCRESULT13 ADCRESULT[13]
#define ADCRESULT14 ADCRESULT[14]
#define ADCRESULT15 ADCRESULT[15]

相关帖子

沙发
益友电子|  楼主 | 2012-8-4 20:57 | 只看该作者
应用例如:
for (int i = 0; i < sizeof(Result); i ++)
{
Result[i] = 0;
}
for (int i = 0; i < 16; i ++)
{
AdcRegs.ADCRESULT[i] = 0;
}
AdcRegs.ADCRESULT[0] = 0;
AdcRegs.ADCRESULT0 = 0;
AdcRegs.ADCRESULT[1] = 0;
AdcRegs.ADCRESULT1 = 0;

此思路可在其他类型一致连续的结构中都可利用~~~
例如:
在DSP281x_ECan.h中

struct ECAN_MBOXES {
struct MBOX MBOX0;
//..........................
struct MBOX MBOX31;
};

改为:
struct ECAN_MBOXES {
struct MBOX MBOXS[32];
};

#define MBOX0 MBOXS[0]
//.......................
#define MBOX31 MBOXS[31]


在DSP281x_SysCtrl.h中
/* Password locations */
struct CSM_PWL {
Uint16 PSWD0; // PSWD bits 15-0
Uint16 PSWD1; // PSWD bits 31-16
Uint16 PSWD2; // PSWD bits 47-32
Uint16 PSWD3; // PSWD bits 63-48
Uint16 PSWD4; // PSWD bits 79-64
Uint16 PSWD5; // PSWD bits 95-80
Uint16 PSWD6; // PSWD bits 111-96
Uint16 PSWD7; // PSWD bits 127-112
};

可改为:
/* Password locations */
struct CSM_PWL {
Uint16 PSWD[8]; // PSWD bits 15-0
};

#define PSWD0 PSWD[0]
//...................
#define PSWD7 PSWD[7]

/* CSM Register File */
struct CSM_REGS {
Uint16 KEY0; // KEY reg bits 15-0
Uint16 KEY1; // KEY reg bits 31-16
Uint16 KEY2; // KEY reg bits 47-32
Uint16 KEY3; // KEY reg bits 63-48
Uint16 KEY4; // KEY reg bits 79-64
Uint16 KEY5; // KEY reg bits 95-80
Uint16 KEY6; // KEY reg bits 111-96
Uint16 KEY7; // KEY reg bits 127-112
Uint16 rsvd1; // reserved
Uint16 rsvd2; // reserved
Uint16 rsvd3; // reserved
Uint16 rsvd4; // reserved
Uint16 rsvd5; // reserved
Uint16 rsvd6; // reserved
Uint16 rsvd7; // reserved
union CSMSCR_REG CSMSCR; // CSM Status & Control register
};

改为:
struct CSM_REGS {
Uint16 KEY[8];
//.................................

使用特权

评论回复
板凳
益友电子|  楼主 | 2012-8-4 20:58 | 只看该作者
#define KEY0 KEY[0]
//...........................
#define KEY7 KEY[7]






**录入:admin    责任编辑:admin

发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

7

主题

445

帖子

0

粉丝