Zephyr: CAN support added

So far, only publishing messages are supported (no RX yet).

Logging is switched on again, but with minimal output only (suitable
for small F0 MCUs). CAN is activated by default for MPPT 2420 LC.
This commit is contained in:
Martin Jaeger
2020-01-30 16:54:58 +01:00
parent e078b87553
commit 1b6a7f82d7
11 changed files with 161 additions and 63 deletions
+16 -16
View File
@@ -4,33 +4,33 @@
* SPDX-License-Identifier: Apache-2.0
*/
#if defined(__MBED__) && !defined(UNIT_TEST)
#ifndef UNIT_TEST
#include "config.h"
#if CONFIG_EXT_THINGSET_CAN
#include "ext/can_msg_queue.h"
#include "mbed.h"
#ifdef STM32F0 // STM32L0 does not have CAN
bool CANMsgQueue::full()
bool CanMsgQueue::full()
{
return _length == CAN_QUEUE_SIZE;
}
bool CANMsgQueue::empty()
bool CanMsgQueue::empty()
{
return _length == 0;
}
void CANMsgQueue::enqueue(CANMessage msg)
void CanMsgQueue::enqueue(CanFrame frame)
{
if (!full()) {
_queue[(_first + _length) % CAN_QUEUE_SIZE] = msg;
_queue[(_first + _length) % CAN_QUEUE_SIZE] = frame;
_length++;
}
}
int CANMsgQueue::dequeue()
int CanMsgQueue::dequeue()
{
if (!empty()) {
_first = (_first + 1) % CAN_QUEUE_SIZE;
@@ -42,10 +42,10 @@ int CANMsgQueue::dequeue()
}
}
int CANMsgQueue::dequeue(CANMessage& msg)
int CanMsgQueue::dequeue(CanFrame &frame)
{
if (!empty()) {
msg = _queue[_first];
frame = _queue[_first];
_first = (_first + 1) % CAN_QUEUE_SIZE;
_length--;
return 1;
@@ -55,10 +55,10 @@ int CANMsgQueue::dequeue(CANMessage& msg)
}
}
int CANMsgQueue::first(CANMessage& msg)
int CanMsgQueue::first(CanFrame &frame)
{
if (!empty()) {
msg = _queue[_first];
frame = _queue[_first];
return 1;
}
else {
@@ -66,6 +66,6 @@ int CANMsgQueue::first(CANMessage& msg)
}
}
#endif /* STM32F0 */
#endif /* CONFIG_EXT_THINGSET_CAN */
#endif
#endif /* UNIT_TEST */