This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RL-ARM Real-Time Library and C++

Hello there,

I'm planning a project involving some real-time code running on an ARM9 MCU. At the moment I'm looking for a suitable development suite for this project. Looking through the documentation of armcc and the rl-arm library I was not able to figure out whether it is possible to interface the RTX Real-Time Kernel from C++ code.
I would appreciate if anyone could give me a hint whether it is possible (intended) to write rt-code in C++ with the given lib and compiler. Also I'd be interested very much in any known issues doing so.

Best,
Tobias

  • Yes, you can interface RTX Real-Time Kernel from C++. It was not designed with C++ in mind but nothing was done to prohibit this or make it cumbersome. Most of the items became either a simple class containing the OS item or a Base class with a template class to define varaiable length items. (Mailbox example given below.)

    class Cmbx_base {
    protected:
        U32 mbx[4];
    public:
        Cmbx_base() {}
        ~Cmbx_base() {}
        OS_MBX *getMbx() { return (OS_MBX *) &mbx;}
        OS_RESULT send(void *message_ptr, U16 timeout)
            { return os_mbx_send(mbx, (void *) message_ptr, timeout); }
        OS_RESULT wait(void **message_ptr, U16 timeout)
            { return os_mbx_wait(mbx, message_ptr, timeout); }
        OS_RESULT check()
            { return os_mbx_check( &mbx ); }
        OS_RESULT isr_send(void *message_ptr)
            {isr_mbx_send( &mbx, message_ptr); return OS_R_OK;}
        U32 getNumEntries(void)
            { return mbx[3] >> 16; }
    };
    
    template <U32 entries> class Cmbx : public Cmbx_base {
        U32 mbx_entries[entries];
    public:
        Cmbx() { os_mbx_init(mbx, sizeof(mbx) + sizeof(mbx_entries)); }
        ~Cmbx() {}
        void reInit() { os_mbx_init(mbx, sizeof(mbx) + sizeof(mbx_entries)); }
    };
    

    this has the advantage of initializing the mailbox at construction time removing any issue of who should actually initialize it. (At the moment, all OS "object" can be initialized BEFORE the OS is running except tasks.

    Tasks make for a more interesting template class, but it is well worth it to have Stack Sizes easily associated with a Task Object, and not just a generic task size.