To: | |
---|---|
Subject: | [ts-7000] ts-7800 dio |
From: | "rahulsunshine" <> |
Date: | Sun, 15 Apr 2012 14:24:38 -0000 |
Hello, I am quite new to ts7800 , I have to configure dio pins,actually I want digital data from dio pins , I have to feed this digital data to my device,but when I running the code tempSensor.c & spi.c (given in manual ) then every time I am getting the same value for raw temp i.e. ffoo on terminal , & on dio header pins I am getting all pins 3.3 except pin 10 on which I got 0v. code: #include<unistd.h> #include<sys/mman.h> #include<fcntl.h> #include<stdio.h> #include<stdlib.h> #include "spi.c" /* Technologic systems TS-7800 temperature sensor. Updated to utilize spi.c. */ #define DIOBASE 0xE8000000 #define CS_PIN 31 #define RW_REG(ptr) *(ptr + 0x08/sizeof(unsigned int)) float tempC(unsigned int data); float CtoF(float x); int main() { unsigned int rawtemp = 0; volatile unsigned int *dioptr; int fd = open("/dev/mem", O_RDWR|O_SYNC); dioptr = (unsigned int *)mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, DIOBASE); printf("%x\n", *dioptr); RW_REG(dioptr) &= ~(1 << CS_PIN); // make sure temp sensor not chip selected init_spi(); // call init_spi before selecting an SPI device RW_REG(dioptr) ^= (1 << CS_PIN); // temp sensor chip select rawtemp = spi8(225) << 8; printf("%x\n", rawtemp); rawtemp |= spi8(225); printf("%x\n", rawtemp); /* printf("%X\n", tempdata(dioptr)); */ printf("The temperature in Fahrenheit is %f\n", CtoF(tempC(rawtemp))); return 0; } float tempC(unsigned int data) { float ret; if (data & (1 << 15)) { /* negative temperatures: */ ret = -0.0625 * (~((data >> 3) | 0xFFFFE000) + 1); } else { /* positive temperatures: */ ret = .0625 * (data >> 3); /* 3 final bits are irrelevant */ } return ret; } float CtoF(float x) { return x*9/5 + 32; } __._,_.___
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required) Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe __,_._,___ |
<Prev in Thread] | Current Thread | [Next in Thread> |
---|---|---|
|
Previous by Date: | Re: [ts-7000] Re: TS-4800/8390 - Simple GUI programming for touchscreen, Dexter Jagula |
---|---|
Next by Date: | [ts-7000] compile sample code problem, oaox@rocketmail.com |
Previous by Thread: | [ts-7000] TS-7260 Power, ricardogabriel5 |
Next by Thread: | [ts-7000] compile sample code problem, oaox@rocketmail.com |
Indexes: | [Date] [Thread] [Top] [All Lists] |
Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU