Changeset - d429d5902330
[Not reviewed]
default
0 1 0
matthewreed - 7 years ago 2017-07-19 18:25:09

Fixed uninitialized variable.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/can_buffer.c
Show inline comments
 
#include "can_buffer.h"
 

	
 
void can_buffer_init(volatile CanBuffer *buffer)
 
{
 
    memset((void*)buffer, 0, sizeof(CanBuffer));
 
}
 

	
 
CanBufferStatus can_buffer_add(volatile CanBuffer *buffer, CanRxMsgTypeDef *msg)
 
{
 
    if ((uint16_t) buffer->count < ((uint16_t) CAN_BUFFER_SIZE)) {
 
        buffer->data[buffer->head] = *msg;
 
        buffer->head = (buffer->head + 1) % CAN_BUFFER_SIZE;
 
        buffer->count++;
 
        return CAN_BUFFER_OK;
 
    }
 
    else {
 
        return CAN_BUFFER_FULL;
 
    }
 
}
 

	
 
volatile CanRxMsgTypeDef* can_buffer_remove(volatile CanBuffer *buffer)
 
{
 
    volatile CanRxMsgTypeDef* msg;
 
    volatile CanRxMsgTypeDef* msg = NULL;
 
    if (buffer->count > 0) {
 
        msg = &buffer->data[buffer->tail];
 
        buffer->tail = (buffer->tail + 1) % CAN_BUFFER_SIZE;
 
        buffer->count--;
 
    }
 
    return msg;
 
}
 

	
 
bool can_buffer_is_empty(volatile CanBuffer *buffer)
 
{
 
    return (buffer->count < 1);
 
}
 

	
 
uint8_t can_buffer_size(volatile CanBuffer *buffer)
 
{
 
    return buffer->count;
 
}
0 comments (0 inline, 0 general)