140 likes | 166 Views
IDEANIX is a unique build of microC OS II on C8051F040, with MeRL for inter-task communication & network messaging. Learn about features & API design.
E N D
IDEANIX/ MeRL (Message Routing Layer)
IDEANIX / MeRL(Reasons for Development) • The desire to use an existing embedded operating system (uC OS II) in distributed applications • The ability to create totally independent tasks that have no “awareness” of other running tasks. • The development of a network/messaging layer that is capable of supporting a Reconfigurable Platform
IDEANIXWhat is it? • IDEANIX is a unique build of the embedded operating system microC OS II • It is currently running on the C8051F040
IDEANIX (KEY FEATURES) • It is currently configured with the standard x-bar configuration for the T.I.M. • It has both UARTs enabled (ISRs) and being configured to a #define’d baudrate • It also configures TIMER 0 as the OS clock source and is set to allow the OS to “tick” every 10ms. (100 ticks per second)
MeRLWhat is it? • MeRL stands for Message Routing Layer • It is a message handling layer built into the IDEANIX build of uC OS II
Ideanix with MeRL(KEY Features) • Stand alone inter-task communication • Joint inter-task communication and network messaging • Independent of network type • Network enabling/disabling for network code inclusion
MeRL(API to Low Layer) • UINT8 init_network ( void ); • Sets up the hardware prior to any other API calls. Returns error codes • UINT8 send_pkt ( CAN_ID_TYPE can_id , PAYLOAD_TYPE payload ); • Pumps a CAN frame containing the ID and 4-byte payload out on the bus. BLOCKING call. Yes, I said blocking. Returns error codes. • UINT8 reg_pkt ( CAN_ID_TYPE can_id ); • Tells the driver layer to capture CAN messages with the passed ID. Returns TRUE if space was successfully allocated, FALSE if not. • UINT8 unreg_pkt ( CAN_ID_TYPE can_id ); • De-allocates space (or hardware capture channel) previously allocated by reg_pkt(). • UINT8 unreg_all_pkt ( CAN_ID_TYPE can_id ); • unregisters all ids • UINT8 get_pkt ( CAN_ID_TYPE *can_id_ptr, PAYLOAD_TYPE *payload_ptr ) • Places the first can_id and payload in the pipe/queue/buffer into the memory space referred to by the pointers. Returns 0 if no packets were waiting in the buffer, 1 if a message was successfully copied, all others are error codes.
MeRL (API to OS user) • void init_taskqing (void); //init_taskqing is a function called from an initialization function from //main that initializes all existing queues to a known zero'd value • unsigned char init_messaging (void ); //init_messaging () has to be called at the beginning of each user task //it is what actually creates a message receiving queue for the task //it returns 1 meaning queue has been allocated successfully and 0 //meaning queue has not been created • unsigned int send_msg ( unsigned int id , unsigned long payload )KCREENTRANT; //send_msg successfully passes the payload to any local task who has //registered to receive data from the specific id as well as calls the low //level driver function send_pkt to broadcast the id and payload over //the low level communication bus //Error codes returned or else a 1 • unsigned int reg_msg ( unsigned int id ) ; //reg_msg must be called from the task to register for the reception //of a payload sent with the specified id this function handles //association of ids with the task queues //returns error codes
MeRL (API to OS user) continued • unsigned int unreg_msg ( unsigned int id ); // De-allocates space in hardware for this id and stops messages of this // type from being placed into the tasks' incoming buffer. // Returns error codes • void unreg_all (void); //unregisters all ids regardless of which task calls it • unsigned int get_msg ( unsigned int *id, unsigned long *payload ) KCREENTRANT; // Places the first id and payload from the queue into the memory //space referred to by the pointers. // get_msg pends meaning waits forever until a message was passed //into the task's queue //returns error codes
MeRL (API to OS user) continued • unsigned int accept_msg ( unsigned int *id, unsigned long *payload ) KCREENTRANT; //does not wait for a message to be placed into the queue simply //checks to see if there was a message in the queue if there is //grabs the id and payload passes these values back through id and //payload if not leaves the values in id and payload as that of the //variables passed into the function //returns 1 if message was waiting and 0 if no message was waiting • unsigned char num_waiting_q_msgs (unsigned int *num_msgs); //it places the number of msgs waiting in the task's queue into the //variable passed into num_msgs // the return value of num_waiting_q_msgs is any OS error that may //have occured when calling OSQQuery()
IDEANIX/MeRL(config file) #define NETCOMM_EN 0 #define TASKCOMM_EN 1 #define MAX_TASK_PRIO 25 #define MAX_ID_VAL 0x0088 #define TASK_MSG_Q_SIZE 10 //OS TASKS INFORMATION #define STK_START 0 #define STK_SIZE 512 /* Size of each task's stacks (# of WORDs) */
IDEANIXEXAMPLE TASK • void Test_task (void *dataa) KCREENTRANT // Function prototypes of Startup task • { unsigned int id =0 ; • unsigned long payload =0 ; • unsigned char error =0 ; • unsigned int num_msgs =0 ; • dataa=dataa; • if( init_messaging () ==1 ) • { printf("messaging is enabled \r\n"); } • else • { printf("Messaging is NOT enabled\r\n"); • } • reg_msg ( 4 ); • reg_msg (11); • for(;;) • { • send_msg (4 , 100); • num_waiting_q_msgs (&num_msgs); printf("number of waiting messages %u\r\n",num_msgs); • for(i=0;i<num_msgs;i++) • { get_msg (&id, &payload ); • printf("Get message id = %d and payload = %d \r\n",(int)id,(int)payload); • } • OSTimeDly(50); • } • }