/*
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
Copyright (C) 2016..2018 Thomas Schöpping et al.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include
#include
#include
#include
#include
#include
#define True 1
#define False 0
#define NRT 1111111
#define HRT 0000000
/*
* @brief transmit Message over CAN
*/
msg_t rtcan_transmit(CANDriver *canp, canmbx_t mailbox, const CANTxFrame *ctfp){
// call cantransmit, needed params driver, mailbox and tx frame
msg_t transmit = canTransmitTimeout(canp,mailbox,ctfp,TIME_IMMEDIATE);
return transmit;
}
/*
* @brief receive Message over CAN
*/
msg_t rtcan_receive(CANDriver *canp, canmbx_t mailbox,CANRxFrame *crfp){
// call lld cantransmit, needed params driver, mailbox and rx frame
return canReceiveTimeout(canp,mailbox,crfp,TIME_IMMEDIATE);
}
// Handling Message Queues
bool enqueueMsg(uint8_t *payload, uint8_t msgType, systime_t deadline){
return false;
}
bool pushRTCanMsgSorted(rtcan_msg_t *msg,msgqueue_t* msgqueue){
return false;
}
/*
* @brief push Message to its Queue, based on type of Message
*/
void pushRTCanMsg(rtcan_msg_t *msg,msgqueue_t* msgqueue){
if(msg != NULL){
if(msgqueueEmpty(msgqueue)){
msgqueue->head = msg;
msgqueue->tail= msg;
msg->next = msg;
return;
}
//todo special case handling
if(msgqueue->tail != NULL){
if(msg->msgType == 10){
if(pushRTCanMsgSorted(msg,msgqueue) == true){
return;
};
}
msgqueue->tail->next = msg;
msg->next = msg;
msgqueue->tail = msg;
msgqueue->size++;
}
}
}
/*
* @brief dequeue Message from Queue
*/
rtcan_msg_t* popRTCanMsg(msgqueue_t* msgqueue){
if(!msgqueueEmpty(msgqueue)){
return msgqueue->head;
}
return NULL;
}
/**
* @brief schedule rtcan messages into mailboxes
*/
void schedule(){
}
/** empty or clear?*/
int msgqueueEmpty(msgqueue_t* mqueue){
if(mqueue == NULL){
return True;
}
return False;
}
//TODO: ISR
//TODO: Params