ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: Help me to write a C code for read temperarutere on TS

To:
Subject: Re: [ts-7000] Re: Help me to write a C code for read temperarutere on TS-7200 (NetBSD 3.1)
From: Andres Gomez <>
Date: Thu, 6 Nov 2008 06:51:08 -0800 (PST)
It isn't so simple, Charlie. The Linux code tempSensor.c don't run on NetBSD, I tried it. I reed the Datasheet (www-s.ti..com/sc/ds/tmp124.pdf) but says nothing about programming code (at least about C). So, I'm trying to create my own program based on tspld.c (v1.9) of NetBSD 4.0 release, I can compile but I cannot run it. It's shows: segmentation fault.

#include "kernel.h"
#include <sys/systm.h>

#include "ep93xxvar.h"
#include "ep93xxreg.h"
#include "epgpioreg.h"
#include "sysmonvar.h"


struct tspld_softc {
        struct device           sc_dev;
        bus_space_tag_t         sc_iot;
        bus_space_handle_t      sc_wdogfeed_ioh;
        bus_space_handle_t      sc_wdogctrl_ioh;
        struct sysmon_wdog    sc_wdog;
        bus_space_handle_t      sc_ssph;
        bus_space_handle_t      sc_gpioh;
        unsigned const char *   sc_com2mode;
        unsigned const char *   sc_model;
        unsigned char           sc_pldrev[4];
        uint32_t                sc_rs485;
        uint32_t                sc_adc;
        uint32_t                sc_jp[6];
        uint32_t                sc_blaster_present;
        uint32_t                sc_blaster_boot;
        uint32_t                boardtemp;
        uint32_t                boardtemp_5s;
        uint32_t                boardtemp_30s;
        struct callout          boardtemp_callout;
};

void    tspld_callback __P((struct device *));

#define GPIO_GET(x)     bus_space_read_4(sc->sc_iot, sc->sc_gpioh, \
        (EP93XX_GPIO_ ## x))

#define GPIO_SET(x, y)  bus_space_write_4(sc->sc_iot, sc->sc_gpioh, \
        (EP93XX_GPIO_ ## x), (y))

#define GPIO_SETBITS(x, y)      bus_space_write_4(sc->sc_iot, sc->sc_gpioh, \
        (EP93XX_GPIO_ ## x), GPIO_GET(x) | (y))

#define GPIO_CLEARBITS(x, y)    bus_space_write_4(sc->sc_iot, sc->sc_gpioh, \
        (EP93XX_GPIO_ ## x), GPIO_GET(x) & (~(y)))

#define SSP_GET(x)      bus_space_read_4(sc->sc_iot, sc->sc_ssph, \
        (EP93XX_SSP_ ## x))

#define SSP_SET(x, y)   bus_space_write_4(sc->sc_iot, sc->sc_ssph, \
        (EP93XX_SSP_ ## x), (y))

#define SSP_SETBITS(x, y)       bus_space_write_4(sc->sc_iot, sc->sc_ssph, \
        (EP93XX_SSP_ ## x), SSP_GET(x) | (y))

#define SSP_CLEARBITS(x, y)     bus_space_write_4(sc->sc_iot, sc->sc_ssph, \
        (EP93XX_SSP_ ## x), SSP_GET(x) & (~(y)))


int main(void){
        struct tspld_softc *sc ;
        u_int16_t val;

        GPIO_SET(PFDDR, 0x0);

        /* Disable chip select */
        GPIO_SET(PFDDR, 0x0);

        val = SSP_GET(SSPDR) & 0xffff;
        int boardtemp = ((int16_t)val >> 3) * 62500;

        /* Enable chip select */
        GPIO_SET(PFDDR, 0x4);

        /* Send read command */
        SSP_SET(SSPDR, 0x8000);
}

But, when I run it, it show this messages:

toaster# ./dev
[1]   Segmentation fault (core dumped) ./dev


--- El jue 6-nov-08, charliem_1216 <> escribiÃ:
De: charliem_1216 <>
Asunto: [ts-7000] Re: Help me to write a C code for read temperarutere on TS-7200 (NetBSD 3.1)
Para:
Fecha: jueves, 6 de noviembre de 2008, 1:50 pm

--- In .com, Andres Gomez <andres.gomez08@ ...> wrote:
>
> Thanks for your response. But I can't install NetBSD 4.0 in my
TS-7200, only 3.X releases, I don't know why is it, but I think
because I have got 8 MB Flash and not 16 MB, perhaps is it.
> But I need a simple program to read TMP124 sensor on NetBSD 3.1 and
not found a possible solution for this moment. Please, help me.
> Thanks.
>

Andres,

If you can't run NetBSD 4.0, and you don't want to back-port the
changes to NetBSD 3.1, the only remaining option would be user-space
access to the sensor.

Earlier I gave you a pointer to the linux user-space program that
would read the temperature for you. Perhaps you should pursue getting
that to compile & run? Between the info on the sensor data sheet, the
linux user-space code example, and the netBSD 4.0 kernel code driver
example, you should have enough info to write a netBSD user space program.

Regards, ........ Charlie

> --- El jue 6-nov-08, ali <> escribiÃÂ:
> De: ali <>
> Asunto: Re: [ts-7000] Help me to write a C code for read
temperarutere on TS-7200 (NetBSD 3.1)
> Para: .com
> Fecha: jueves, 6 de noviembre de 2008, 12:28 pm
>
>
> On Wed, 5 Nov 2008, Andres Gomez wrote:
>
>
> > Date: Wed, 5 Nov 2008 08:39:03 -0800 (PST)
>
> > From: Andres Gomez <andres.gomez08@ yahoo.com. ar>
>
> > Reply-To: .com
>
> > To: .com
>
> > Subject: [ts-7000] Help me to write a C code for read
temperarutere on TS-7200
>
> > (NetBSD 3.1)
>
> >
>
> > I'm trying to write my own TMP124 (temperature reader) for NetBSD
3.1 on
>
> > TS-7200. As Jesse off no respond my messages about this question and
>
> > anyone helps me and I don't know how to read the temperature on
TS-7200
>
> > with NetBSD 3.1 I'm writting a code to read it, based on Jesse Off's
>
> > file: tspld.c. This script run on NetBSD 4.0 (NOT IN 3.X
releases). This
>
> > is the original script:
>
>
>
> Your program cannot possibly work -- the code you have tried to modify
>
> is the NetBSD kernel device driver for the CPLD used to implement
various
>
> functions on the TS72XX boards, and no part of the kernel is
accessible to
>
> user programs.
>
>
>
> Support for the temperature sensor appeared in v1.9 of tspld.c, see:
>
>
>
> http://cvsweb. netbsd.org/ bsdweb.cgi/ src/sys/arch/ evbarm/tsarm/
tspld.c?rev= 1.9&content- type=text/ x-cvsweb- markup&only_ with_tag= MAIN
>
>
>
> I don't know how difficult it would be to backport that file to 3.x and
>
> teach sysctl about the new nodes -- I suspect it might Just Work(tm) if
>
> you backport the file, as it creates the necessary sysctl nodes at
attach
>
> time.
>
>
>
> An easier solution is to simply run a recent version of NetBSD instead..
>
> I run NetBSD-current on my TS7250 board with great success,
netbooting it
>
> from my desktop machine with the filesystem on NFS. Cross-building
NetBSD
>
> from any supported architecture to any other is fully supported out
of the
>
> box, and *exactly* the same procedure as a native build -- so it
really is
>
> a no-brainer to rebuild your own distribution from source.
>
>
>
> /ali:)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Yahoo! Cocina
> Recetas prÃÂcticas y comida saludable
> http://ar.mujer. yahoo.com/ cocina/
>




Yahoo! Cocina
Recetas prÃcticas y comida saludable
Visità http://ar.mujer.yahoo.com/cocina/ __._,_.___

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>
Admin

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