Some explainations about code

Firmware/software/electronics/mechanics
Post Reply
Yaro
Member
Posts: 31
Joined: Wed May 20, 2015 11:28 am

Some explainations about code

Post by Yaro »

Hi all,

I open this thread about some part of codes I'd like to have explained(to avoid to open multiple threads with same argument). My questions are newbie so don't esitate to answer with all informations that can be usefull!

Code: Select all

configblockeeprom.c
configblockflash.c
They do almost same thing, what's their main difference? I suppose one save inside internal flash and the second on the external eeprom, it's right?

About this struct:

Code: Select all

struct configblock_v1_s {
  /* header */
  uint32_t magic;
  uint8_t  version;
  /* Content */
  uint8_t radioChannel;
  uint8_t radioSpeed;
  float calibPitch;
  float calibRoll;
  uint8_t radioAddress_upper;
  uint32_t radioAddress_lower;
  /* Simple modulo 256 checksum */
  uint8_t cksum;
} __attribute__((__packed__));
There is this variables:

Code: Select all

uint32_t magic;
  float calibPitch;
  float calibRoll;
Used in this way:

Code: Select all

cosPitch = cosf(configblockGetCalibPitch() * (float) M_PI/180);
 sinPitch = sinf(configblockGetCalibPitch() * (float) M_PI/180);
 cosRoll = cosf(configblockGetCalibRoll() * (float) M_PI/180);
 sinRoll = sinf(configblockGetCalibRoll() * (float) M_PI/180);
Can you explain me use of variable MAGIC? also, what is purpose of this calibrations and where are set/get this calibPitch/calibRoll values?

About pidctrl.c
As I understand in previous thread it's used just to set pids values when a param packet is recived. But some functions have this (void* param) as paramenters in their definition. I've looked into code references to (void* param) but found nothing. I suppose that is used from PARAM functions, but I can't understand what (void* param) means. It pass a pointer of a function?

Thank you!
Post Reply