资源简介
TI官方ADS1232评估板参考程序,硬件原理图,及相关操作手册。
代码片段和文件信息
#include “ads1232.h“
#include “anyl.h“
#include
static xTaskHandle _monitor;
static volatile struct {
unsigned int newdata:1;
} _flags;
static s32 _code;
#define GEN_OUT_FUNC(NAMEFUNCPORTPIN) \
void NAME##FUNC##H(void) { P##PORT##FUNC |=(1< void NAME##FUNC##L(void) { P##PORT##FUNC &=~(1< int NAME##FUNC##R(void) { return P##PORT##FUNC &(1<
#define GEN_PIN_FUNCS(NAMEPORTPIN) \
int NAME##IN(void) { return P##PORT##IN & (1< GEN_OUT_FUNC(NAMEOUTPORTPIN) \
GEN_OUT_FUNC(NAMEDIRPORTPIN) \
GEN_OUT_FUNC(NAMESELPORTPIN)
#define GEN_INT_FUNCS(NAMEPORTPIN) \
GEN_PIN_FUNCS(NAMEPORTPIN) \
GEN_OUT_FUNC(NAMEIFGPORTPIN) \
GEN_OUT_FUNC(NAMEIESPORTPIN) \
GEN_OUT_FUNC(NAMEIEPORTPIN)
GEN_INT_FUNCS(DRDY22)
GEN_INT_FUNCS(EXTCLK14)
GEN_INT_FUNCS(MUX112)
GEN_PIN_FUNCS(GAIN030)
GEN_PIN_FUNCS(DOUT32)
GEN_PIN_FUNCS(SCLK33)
GEN_PIN_FUNCS(SPEED34)
GEN_PIN_FUNCS(GAIN135)
GEN_PIN_FUNCS(MUX036)
GEN_PIN_FUNCS(PDWN37)
static int gain_pga;
void ads1232_init(void)
{
// init pins
SCLKOUTL(); // inhibit power-on cal
SCLKDIRH();
PDWNOUTH();
PDWNDIRH();
GAIN1OUTL(); // pga=1
GAIN0OUTL();
gain=1;
_pga=0;
GAIN1DIRH();
GAIN0DIRH();
SPEEDOUTL(); // low speed
SPEEDDIRH();
MUX0OUTL(); // ch 0
MUX1OUTL();
MUX0DIRH();
MUX1DIRH();
DRDYDIRL();
DRDYIFGL();
DRDYIEL();
DOUTDIRL();
// set up SPI
U0CTL|=1; // hold in reset
// U0CTL: 00 I2C=0 CHAR=1 LISTEN=0 SYNC=1 MM=1 SWRST=x
// 00010110 = 0X16
U0CTL=0x17;
// U0TCTL: CKPH=0 CKPL=0 SSEL0=SMCLK (10) 00 STC=1 TXEPT=1
// 00100011 = 0x23
U0TCTL=0x23;
// U0RCTL = read only
// Baud rate = /4
U0BR0=4;
U0BR1=0;
U0MCTL=0;
ME1|=USPIE0;
DOUTSELH();
SCLKSELH();
U0CTL&=~1;
// set up clock
EXTCLKSELL();
EXTCLKOUTL();
EXTCLKDIRH();
// set up interrupts
// -- start disabled though
DRDYIESH(); // trig on falling edge
// other stuff
_monitor=0;
_code=0x123456;
}
void ads1232_set_extclk(int ext)
{
if (ext)
EXTCLKSELH();
else
EXTCLKSELL();
}
int ads1232_get_extclk(void)
{
return EXTCLKIN()?1:0;
}
void ads1232_set_monitor(xTaskHandle mon)
{
_monitor=mon;
}
void ads1232_set_speed(int spd)
{
if (spd) SPEEDOUTH();
else SPEEDOUTL();
_flags.newdata=0;
}
int ads1232_get_speed(void)
{
return SPEEDIN()?1:0;
}
void ads1232_set_pga(int pga)
{
switch(pga) {
case 1:
GAIN1OUTL();
GAIN0OUTH();
_pga=1;
gain=2;
break;
case 2:
GAIN1OUTH();
GAIN0OUTL();
_pga=2;
gain=64;
break;
case 3:
GAIN1OUTH();
GAIN0OUTH();
_pga=3;
gain=128;
break;
default:
GAIN1OUTL();
GAIN0OUTL();
_pga=0;
gain=1;
break;
}
_flags.newdata=0;
}
int ads1232_get_pga(void)
{
return _pga;
}
void ads1232_set_gain(int g)
{
switch(g) {
case 1:
ads1232_set_pga(0);
break;
case 2:
ads1232_set_pga(1);
break;
case 64:
ads1232_set_pga(2);
break;
case 128:
ads1232_set_pga(3);
break;
default:
break;
}
}
int ads1232_get_gain(void)
{
return gain;
}
void ads1232_set_ch(int ch)
{
switch(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 4234 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\ads1232.c
I.A.... 788 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\ads1232.h
I.A.... 4520 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\anyl.c
I.A.... 1236 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\anyl.h
I.A.... 1620 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\CHANGELOG
I.A.... 509 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\common.h
I.A.... 3749 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\console.c
I.A.... 10421 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\core.c
I.A.... 2517 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\debug.c
I.A.... 2909 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\FreeRTOSConfig.h
I.A.... 4220 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\heap_1.c
I.A.... 3279 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\keys.c
I.A.... 1883 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\keys.h
I.A.... 4907 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\lcd.c
I.A.... 455 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\lcd.h
I.A.... 8272 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\lcdmap.sxc
I.A.... 1418 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\main.c
I.A.... 887 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\Makefile
I.A.... 5496 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\modes.sxc
I.A.... 3210 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\nconv.c
I.A.... 3615 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\nconv.h
I.A.... 1831 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\nconv.s
I.A.... 1918 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\notes.txt
I.A.... 4081 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\os\include\FreeRTOS.h
I.A.... 10894 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\os\include\list.h
I.A.... 2709 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\os\include\portable.h
I.A.... 4535 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\os\include\portmacro.h
I.A.... 1799 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\os\include\projdefs.h
I.A.... 15028 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\os\include\queue.h
I.A.... 9628 2005-10-25 17:56 ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0[1].2.1\ads1232ref_fwsrc_0.2.1\os\include\semphr.h
............此处省略21个文件信息
- 上一篇:机器学习那些事
- 下一篇:makefile中文手册
评论
共有 条评论