contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.71k stars 2.58k forks source link

Not able to use the TI functions in the contiki #2516

Open PranavD10 opened 6 years ago

PranavD10 commented 6 years ago

Here is the code

#include "contiki.h"
//#include "/os/dev/PWM.h"
#include "dev/leds.h"
#include "ti-lib.h"
#include <stdio.h> 
#include <arch/cpu/simplelink-cc13xx-cc26xx/lib/coresdk_cc13xx_cc26xx/source/ti/drivers/PWM.h>

/*---------------------------------------------------------------------------*/
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
 PWM_Handle pwm1;
    PWM_Params params;
    uint16_t   pwmPeriod = 3000;      // Period and duty in microseconds
    uint16_t   duty = 0;
    uint16_t   dutyInc = 100;

    PWM_Params_init(&params);
    params.dutyUnits = PWM_DUTY_US;
    params.dutyValue = 0;
    params.periodUnits = PWM_PERIOD_US;
    params.periodValue = pwmPeriod;
    pwm1 = PWM_open(LEDS_RED, &params);

  PROCESS_BEGIN();

     if (pwm1 == NULL) {
        // PWM_open() failed
       while (1);
   }
   PWM_start(pwm1);
    /* Loop forever incrementing the PWM duty */
    while (1) {
        PWM_setDuty(pwm1, duty);
    PWM_start(pwm1);

        duty = (duty + dutyInc);
        if (duty == pwmPeriod || (!duty)) {
            dutyInc = - dutyInc;
        }
    }
  PROCESS_END();
}

this i got-- $ make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 hello-world.upload CC ../../arch/cpu/cc26xx-cc13xx/lib/cc26xxware/startup_files/ccfg.c CC ../../arch/cpu/cc26xx-cc13xx/./ieee-addr.c CC ../../arch/cpu/cc26xx-cc13xx/./fault-handlers.c CC ../../arch/cpu/cc26xx-cc13xx/lib/cc26xxware/startup_files/startup_gcc.c CC hello-world.c LD hello-world.elf hello-world.o: In function process_thread_hello_world_process': hello-world.c:(.text.process_thread_hello_world_process+0x10): undefined reference toPWM_Params_init' hello-world.c:(.text.process_thread_hello_world_process+0x24): undefined reference to PWM_open' hello-world.c:(.text.process_thread_hello_world_process+0x32): undefined reference toPWM_start' hello-world.c:(.text.process_thread_hello_world_process+0x3e): undefined reference to PWM_setDuty' hello-world.c:(.text.process_thread_hello_world_process+0x46): undefined reference toPWM_start' collect2: error: ld returned 1 exit status ../../arch/cpu/arm/cortex-m/cm3/Makefile.cm3:27: recipe for target 'hello-world.elf' failed make: *** [hello-world.elf] Error 1 rm hello-world.o obj_srf06-cc26xx/startup_gcc.o obj_srf06-cc26xx/fault-handlers.o

firmwareguru commented 6 years ago

@PranavD10 Not sure where exactly you found #include <arch/cpu/simplelink-cc13xx-cc26xx/lib/coresdk_cc13xx_cc26xx/source/ti/drivers/PWM.h> as this path doesn't exist in Contiki. The simplelink platform was added to Contiki-NG a few days ago: https://github.com/contiki-ng/contiki-ng/pull/609. Perhaps that's where you should be writing this application!