RX600 C++ with embOS

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • RX600 C++ with embOS

    The RX600 HEW IDE supports a C++ capable compiler. I would like to use C++ for some simple C++ objects. Nothing major like design patterns, but I can use some concepts.

    I'll probably configure the app with no std_exceptions and no stream IO (it looked a bit code heavy in my initial test)

    The question is, can I use embOS seamlessly in a C++ build environment, or will I have to provide wrappers for everything?

    Will I need a source distribution or just a binary?
  • Hello,

    you can use embOS of course with C++, you don't need the source code version, the object version is enough.

    If you like you can download the embOS RX HEW trial version from our website. It has no functional limitation, so you could test by yourself that it works with C++.

    If you have any further question you are invited to contact us directly.

    Regards,
    Til
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Several issues

    I tried to create a C++ project with a resetprg.cpp and the system crashes so I reverted to the "C" version and added the C++ initializer call. Global C++ object constructors are called via _CALL_INIT() in resetprg.c. This works ok, but it is not optimal. I would like to have classes inherit from a simple lock class but since global C++ objects are initialized before the RTOS, it fails. I tried moving OS_InitKern() and the other startups into PowerOn_Reset_PC() but there are obviously stack issues as it crashes with ErrCode 0xA4.

    I finaly got it to work with this code in resetprg.c, but I am not sure if it is proper. I also am not sure about how one would write a C++ object which as a "extern C" thread function and how the thread would know about the objects "this" pointer. I assume that is the reason for OS_CREATETASKEX.

    I really need an example with YRDKRX62N C++ project. Simple blinky lights will do.



    Source Code

    1. HardwareSetup(); // Use Hardware Setup
    2. nop();
    3. set_psw(PSW_init);
    4. // OS_IncDI(); /* Initially disable interrupts */
    5. OS_InitKern(); /* Initialize OS */
    6. OS_InitHW(); /* Initialize Hardware for OS */
    7. BSP_Init(); /* Initialize LED ports */
    8. _CALL_INIT(); // Remove the comment when you use global class object
    9. // set_psw(PSW_init); // Set Ubit & Ibit for PSW


    C Source Code

    1. class Lock {
    2. public:
    3. Lock();
    4. ~Lock();
    5. void lock();
    6. void unlock();
    7. bool trylock();
    8. private:
    9. // OS_RSEMA mutex;
    10. };
    11. //#include RTOS files
    12. #include "Lock.hpp"
    13. Lock::Lock() {
    14. // OS_CREATERSEMA(mutex);
    15. }
    16. Lock::~Lock() {
    17. // OS_DeleteRSema(mutex)
    18. }
    19. void Lock::lock() {
    20. // OS_Use(mutex);
    21. }
    22. void Lock::unlock() {
    23. // OS_Unuse(mutex);
    24. }
    25. bool Lock::trylock() {
    26. // if(OS_Request(mutex))
    27. // return true;
    28. return false;
    29. }
    Display All
  • Ok, figured it out. I do need to know if the changes to resetprg.c are acceptable?

    Source Code

    1. OS_STACKPTR int StackMP[128];
    2. OS_TASK TCBMP;
    3. class thread
    4. {
    5. public:
    6. thread();
    7. ~thread() {};
    8. int Get() { return myint;};
    9. private:
    10. int myint;
    11. } Thread1;
    12. extern "C" {
    13. void MPTask(void * context) {
    14. class thread * mythis = (class thread *)context;
    15. while (1) {
    16. BSP_ToggleLED(mythis->Get());
    17. OS_Delay (100);
    18. }
    19. }
    20. }
    21. thread::thread()
    22. {
    23. myint = 2;
    24. OS_CREATETASK_EX(&TCBMP, "MP Task", MPTask, 75, StackMP, this);
    25. }
    Display All