DMA for ADC implemented, mbed Ticker removed, files restructured

- DMA partly uses ST HAL API (to be improved in further versions)
- When using mbed ticker to trigger ADC, the program might stall --> use own timer instead
- C++ libraries changed to more simple C-style functions and files (better compatibility with plain C environments)
This commit is contained in:
Martin Jäger
2018-03-10 14:21:49 +01:00
parent efa5ac2bbd
commit 4aa51fbe25
25 changed files with 808 additions and 1107 deletions
+48
View File
@@ -0,0 +1,48 @@
#include "can_msg_queue.h"
bool CANMsgQueue::full() {
return _length == CAN_QUEUE_SIZE;
}
bool CANMsgQueue::empty() {
return _length == 0;
}
void CANMsgQueue::enqueue(CANMessage msg) {
if (!full()) {
_queue[(_first + _length) % CAN_QUEUE_SIZE] = msg;
_length++;
}
}
int CANMsgQueue::dequeue() {
if (!empty()) {
_first = (_first + 1) % CAN_QUEUE_SIZE;
_length--;
return 1;
} else {
return 0;
}
}
int CANMsgQueue::dequeue(CANMessage& msg) {
if (!empty()) {
msg = _queue[_first];
_first = (_first + 1) % CAN_QUEUE_SIZE;
_length--;
return 1;
} else {
return 0;
}
}
int CANMsgQueue::first(CANMessage& msg) {
if (!empty()) {
msg = _queue[_first];
return 1;
} else {
return 0;
}
}