This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: libm use in kernel


> Are you sure the math.h included is the math.h from eCos?

Well, I'm pretty sure. We simply include "#include <math.h>".

Running the following on our ecos tree shows that there is only one instance:

$ find . -name math.h
./packages/language/c/libm/current/include/math.h


> Could you provide all includes you have in this driver and the C code
> that uses the log function ?

Sure,

#include <pkgconf/system.h>
#include <cyg/kernel/kapi.h>
#include <pkgconf/io_eth_drivers.h>
#include <pkgconf/devs_eth_mxc_ktsradio.h>
#include <pkgconf/devs_eth_mxc_fec.h>

#include <cyg/infra/cyg_type.h>
#include <cyg/infra/cyg_ass.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_cache.h>
#include <cyg/hal/hal_intr.h>
#include <cyg/hal/hal_endian.h>
#include <cyg/infra/diag.h>
#include <cyg/hal/drv_api.h>
#include <cyg/hal/hal_soc.h>
#include <cyg/hal/hal_mm.h>
#include <cyg/hal/hal_if.h>
#include <cyg/io/eth/eth_drv.h>
#include <cyg/io/eth/netdev.h>
#include <cyg/io/ktsradio.h>
#include <cyg/io/ktsradio_timers.h>
#include <cyg/io/ktsradio_rfcomm.h>

// spooled debug printing
#include <cyg/debugprint/debugprint.h>

// Ethernet packet definitions
#include <net/ethernet.h>
// crc
#include <cyg/crc/crc.h>
// queues
#include <cyg/queue/queue.h>

#include <stdlib.h>
#include <math.h>


The specific line is in a function that calculates an rssi value:

cyg_int16 ktsradio_calcRSSI(rssiRegs_t rssiRegs) {

    cyg_uint32 nbAgc = rssiRegs.rxBurstAgc & 0xfffff;
    cyg_uint32 wbAgc = rssiRegs.rxBurstAgc >> 24;
    cyg_uint16 rssi = 0;

    double wbGain = (wbAgc/256.0 * 50.0);

    cyg_uint32 exponent = (nbAgc >> 16);
    double mantissa = 0.5 + ((double) (nbAgc & 0xffff)/131072.0);

    ...

    #define NBK0  (-13000.0)
    #define NBK1  (870.0)
    #define NBK2  (-79.0)

    static double   rfRssi;
    cyg_uint16      rfAuxReading = rssiRegs.rfAgc;

    ...

    rfRssi = NBK0/((double)rfAuxReading - NBK1) + NBK2;
    rssi = (cyg_uint16) round(rfRssi - 6.02*(double)exponent -
20.0*log10(mantissa) - wbGain);

   ...
}

Also, I forgot to mention that this is an eCos v2 tree. We are working
on updating to v3, but that will take some time.


Mike

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]