FreeRTOS TCB_t is conflicting with Timer TCB_t

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

 

I am trying to port FreeRTOS for mega4808. It ended up in a conflict of TCB_t between FreeRTOS and Timer. What would be the best way to overcome this conflict? Please suggest!

 

This topic has a solution.

--TintuVayalattu

Last Edited: Sun. Jan 20, 2019 - 09:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is the conflict?

 

Can't you just use a different name (that is, edit the source) in the typedef and all of the uses of that variable?

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is it fine to edit the source? I was looking for a better way to do it(if there is any), to avoid renaming.
If we want to rename it, which would be the preferred one? device header or the FreeRTOS content?

--TintuVayalattu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could write the code in C++ and apply a namespace to one or both types. 

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you! 
I was looking for a C code solution. Fortunately, I got this from atmel START example - http://start.atmel.com/#example/...
 

/*
 * #define TCB_t to avoid conflicts between the
 * FreeRTOS task control block type (TCB_t) and the
 * AVR Timer Counter B type (TCB_t)
 */
#define TCB_t avrTCB_t
#include <avr/io.h>
#undef TCB_t

 

--TintuVayalattu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting that the AN does not mention the naming conflict between TimerCounterB and TaskControlBlock naming.

 

Jim

 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unfortunately you can't use the the TCBx defines because the preprocessor only replaces the typedef TCB_t

with avrTCB_t but not the other defines like #define TCB0  (*(TCB_t *) 0x0B00).

 

Try this:

 

#define TCB_t avrTCB_t

typedef struct TCB_struct
{
    char CTRLA;  /* Control A */
    char CTRLB;  /* Control Register B */
    char reserved_1[2];
    char EVCTRL;  /* Event Control */
    char INTCTRL;  /* Interrupt Control */
    char INTFLAGS;  /* Interrupt Flags */
    char STATUS;  /* Status */
    char DBGCTRL;  /* Debug Control */
    char TEMP;  /* Temporary Value */
    short CNT;  /* Count */
    short CCMP;  /* Compare or Capture */
    char reserved_2[2];
} TCB_t;

#define TCB0                  (*(TCB_t *) 0x0B00) /* 16-bit Timer Type B */

#undef TCB_t

/*
 *
 */
int main(int argc, char** argv) {

    TCB0.DBGCTRL = 1;
    return (0);
}

 

You will get this error:

 

main.c: In function 'main':
main.c:35:8: error: 'TCB_t' undeclared (first use in this function)
     TCB0.DBGCTRL = 1;

 

I assumed that these other defines are replaced too.

 

The used toolchain is:

avr-gcc (AVR_8_bit_GNU_Toolchain_3.6.1_1752) 5.4.0

 

Is this a potential preprocessor error?

Or is there a compiler switch wrong?

 

Meanwhile I use my own defines.

 

G.E.O.