Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
hawson1997
PostPosted: May 22, 2012 - 09:20 AM
Wannabe


Joined: May 17, 2006
Posts: 64


Hi,

I want to blink an LED all time in BCB board with the same source code wsndemo application, but I did not find where I must put my code

Code:

  BSP_OpenLeds();
  BSP_OnLed(LED_RED);


tnx
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: May 22, 2012 - 04:12 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4872
Location: San Jose, CA

WSNDemo has a timer that blinks an LED. This timer is stopped when network is started, but you don't have to stop it.

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
hawson1997
PostPosted: May 22, 2012 - 05:00 PM
Wannabe


Joined: May 17, 2006
Posts: 64


thank you for your answer.

but if I just want to turn it on, where I should put my code ? in any file ?

NB: I want to turn it on, in an and-device.
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: May 22, 2012 - 05:04 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4872
Location: San Jose, CA

End device will disable all the peripherals before going to sleep, so you need to disable this logic. Search for everything related to BSP and LED in the end device file. Once you've disabled it put this code in the initialization function.

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
hawson1997
PostPosted: May 22, 2012 - 05:12 PM
Wannabe


Joined: May 17, 2006
Posts: 64


thank you so much, I will try Smile
I will try now, and I will answer
 
 View user's profile Send private message  
Reply with quote Back to top
hawson1997
PostPosted: May 23, 2012 - 09:59 AM
Wannabe


Joined: May 17, 2006
Posts: 64


I do not know why it does not work

Here's the code "WSNEndDeviceApp.c"

I don't have located the good place to put my code for turning the LED On

Code:

/**********************************************************************//**
  \file WSNEndDeviceApp.c

  \brief

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
  History:
    13/06/07 I. Kalganova - Modified
**************************************************************************/
#ifdef _ENDDEVICE_
#include <WSNDemoApp.h>
#include <WSNVisualizer.h>

//request parameters for APS_DataReq primitive
extern APS_DataReq_t messageParams;
extern AppMessageRequest_t appMessage;
extern AppState_t appState;
extern bool subTaskRequested;
extern void appLeaveNetwork(void);

static ZDO_SleepReq_t sleepReq;

static void APS_DataConf(APS_DataConf_t *confInfo);
static void ZDO_SleepConf(ZDO_SleepConf_t *conf);
static void appSensorsesGot(void);
void APS_DataIndDevice(APS_DataInd_t *indData);
void appInitDeviceEndDevice(void);


/***********************************************************************************
  Process end device functionality.

  Parameters:
    none

  Return:
    none

 ***********************************************************************************/
void appEndDeviceTaskHandler(AppEvent_t event, void *param)
{
   
  switch (appDeviceState)
  {
 
    case WAITING_DEVICE_STATE:
      switch (event)
      {
        case APP_SENDING_DONE:
          if (APS_SUCCESS_STATUS == ((APS_DataConf_t *)param)->status)
          {
            visualizeAirTxFInished();

            failedTransmission = 0;
            appDeviceState = SLEEPPING_DEVICE_STATE;
          }
          else
          {
            if (APP_THRESHOLD_FAILED_TRANSMISSION < ++failedTransmission)
            {
              appDeviceState = INITIAL_DEVICE_STATE;
              failedTransmission = 0;
              appLeaveNetwork();
              return;
            }
            else
              appDeviceState = SENDING_DEVICE_STATE;
          }
          appPostSubTaskTask();
          break;

        case APP_SLEEP_DONE:
          if (ZDO_SUCCESS_STATUS == ((ZDO_SleepConf_t *)param)->status)
          {
            appDeviceState = SLEEPPING_DEVICE_STATE;
//            visualizeSleep();
          }
          else
          {
            appDeviceState = SLEEPPING_DEVICE_STATE;
            appPostSubTaskTask();
          }
          break;

        case APP_READING_DONE:
          appStopSensorManager();
          appDeviceState = SENDING_DEVICE_STATE;
          appPostSubTaskTask();
          break;

        default:
          break;
      }
      break;

    case READING_SENSORS_STATE:
      switch (event)
      {
        case APP_PROCESS:
          appStartSensorManager();
          appReadLqiRssi();
           appDeviceState = WAITING_DEVICE_STATE;
          appGetSensorData(appSensorsesGot);
          break;

        default:
          break;
      }
      break;

    case SENDING_DEVICE_STATE:
      switch (event)
      {
        case APP_PROCESS:
          visualizeAirTxStarted();
          APS_DataReq(&messageParams);
          appDeviceState = WAITING_DEVICE_STATE;
          break;

        default:
          break;
      }
      break;

    case SLEEPPING_DEVICE_STATE:
      switch (event)
      {
        case APP_PROCESS:
          visualizeSleep();
          appDeviceState = WAITING_DEVICE_STATE;
          ZDO_SleepReq(&sleepReq);
          break;

        case APP_WOKEUP:
          visualizeWakeUp();

          appDeviceState = READING_SENSORS_STATE;
          appPostSubTaskTask();
          break;

        default:
          break;
      }
      break;

    case INITIAL_DEVICE_STATE:
      switch (event)
      {
        case APP_PROCESS:
          sleepReq.ZDO_SleepConf = ZDO_SleepConf;
          // Prefilling request parameters
          messageParams.profileId               = simpleDescriptor.AppProfileId;
          messageParams.dstAddrMode             = APS_SHORT_ADDRESS;
          messageParams.dstAddress.shortAddress = CPU_TO_LE16(0);
          messageParams.dstEndpoint             = 1;
          messageParams.clusterId               = CPU_TO_LE16(1);
          messageParams.srcEndpoint             = simpleDescriptor.endpoint;
          messageParams.asduLength              = sizeof(appMessage.data);
          messageParams.asdu                    = (uint8_t *)(&appMessage.data);
          messageParams.txOptions.acknowledgedTransmission = 1;
#ifdef _APS_FRAGMENTATION_
          messageParams.txOptions.fragmentationPermitted = 1;
#endif // _APS_FRAGMENTATION_
#ifdef _LINK_SECURITY_
          messageParams.txOptions.securityEnabledTransmission = 1;
#endif     
          messageParams.radius                  = 0x0;
          messageParams.APS_DataConf            = APS_DataConf;

          appDeviceState = READING_SENSORS_STATE;
          appPostSubTaskTask();
          break;

        default:
          break;
      }
      break;

    case REINITIAL_DEVICE_STATE:
      switch (event)
      {
        case APP_PROCESS:
          break;

        default:
          appDeviceState = INITIAL_DEVICE_STATE;
          appPostSubTaskTask();
          break;
      }

    default:
      break;
 
  }
}

// appEndDeviceTaskHandler must be called from main state machine after this function
void appInitDeviceEndDevice(void)
{
  if (WAITING_DEVICE_STATE == appDeviceState)
    appDeviceState = REINITIAL_DEVICE_STATE;
  else
  {
    appDeviceState = INITIAL_DEVICE_STATE;
    appPostSubTaskTask();
  }
}

static void appSensorsesGot(void)
{
  appEndDeviceTaskHandler(APP_READING_DONE, NULL);
}

void ZDO_SleepConf(ZDO_SleepConf_t *conf)
{
  appEndDeviceTaskHandler(APP_SLEEP_DONE, conf);
}

static void APS_DataConf(APS_DataConf_t *confInfo)
{
  appEndDeviceTaskHandler(APP_SENDING_DONE, confInfo);
}

void APS_DataIndDevice(APS_DataInd_t *indData)
{
  indData = indData;
}

#endif

//eof WSNEndDevice.c


plz i need a help :s
 
 View user's profile Send private message  
Reply with quote Back to top
hawson1997
PostPosted: May 23, 2012 - 02:18 PM
Wannabe


Joined: May 17, 2006
Posts: 64


it works very well the program
I have turned the LED On .

Smile Smile Smile Smile
 
 View user's profile Send private message  
Reply with quote Back to top
hawson1997
PostPosted: May 23, 2012 - 02:18 PM
Wannabe


Joined: May 17, 2006
Posts: 64


thank you so much alexru Smile
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits