// ----------------------------------------------------------------------------------------
//
//  avr/can/can_helpers.h
//
//  Bob Cook Development, Robotics Library
//  http://www.bobcookdev.com/rl/
//    
//  This file provides utility routines for a Controller Area Network driver.
//
//  Copyright (C) 2007 Bob Cook
//    
//      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 2 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, write to the Free Software Foundation, Inc., 
//      51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
// ----------------------------------------------------------------------------------------


#if !defined( BCDRL_AVR_CAN_CAN_HELPERS_H )
#define BCDRL_AVR_CAN_CAN_HELPERS_H


#include <stdint.h>


// ----------------------------------------------------------------------------------------
//  can_build_message_id
//
//      Convert the tuple of a source node identifier, destination node identifier, and a
//      unique data type identifer into a 29-bit message identifier.
//
//      Returns true if successfully sent.
//

uint32_t can_build_message_id
    (
        const uint8_t  node_src,
        const uint8_t  node_dst,
        const uint16_t data_type
    );


// ----------------------------------------------------------------------------------------
//  can_parse_message_id
//
//      Decomponse a 29-bit message identifier into the original parts.
//

void can_parse_message_id
    (
        const uint32_t& message_id,
        uint8_t*        node_src,
        uint8_t*        node_dst,
        uint16_t*       data_type
    );


#endif  // #if defined( BCDRL_AVR_CAN_CAN_HELPERS_H )
// ----------------------------------------------------------------------------------------
//  end of can_helpers.h
// ----------------------------------------------------------------------------------------

