/*****************************************************************************
* Copyright (c) 2007 Digi International Inc., All Rights Reserved
* 
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others,
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
* 
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
*****************************************************************************/

#ifndef NACBUS_PRIVATE_H
#define NACBUS_PRIVATE_H
/*
 * This file contains private definitions used by the CAN driver.
 */

#ifdef __cplusplus
extern "C"
{
#endif


#define NA_CBUS_BUS_STATE_REGISTER              (0)
#define NA_CBUS_TRANSMIT_ERROR_COUNT_REGISTER   (1)
#define NA_CBUS_RECEIVE_ERROR_COUNT_REGISTER    (2)
#define NA_CBUS_FATAL_ERROR_REGISTER            (3)

#define NA_CBUS_MAX_RTRS                        (16)        /* completely arbitrary*/



#define NA_CBUS_MAX_FILTERS                     (8)

#define NACBUS_MIN_RECV_STACK_SIZE              (4096)


#define NA_CBUS_NO_ERROR                        (0)
#define NA_CBUS_CONTROLLER_RESET                (0x1)
#define NA_CBUS_INVALID_COMMAND_RECEIVED        (0x40)
#define NA_CBUS_PIC_HW_FAILURE                  (0x41)
#define NA_CBUS_INVALID_FILTER_COMMAND          (0x42)
#define NA_CBUS_INVALID_CONFIG_COMMAND          (0x43)


#define NA_CBUS_ERROR_PASSIVE_FLAG              (0x01)
#define NA_CBUS_BUS_OFF_FLAG                    (0x02)


#define NA_CBUS_DOMINANT                        (0x00000000)
#define NA_CBUS_RECESSIVE                       (0xffffffff)

#define NA_CBUS_CANID_BYTE0_IS_RTR              (1 << 7)


#define NA_CBUS_CANID_STANDARD_ID_SHIFT         (18)
#define NA_CBUS_CANID_STANDARD_ID_BIT_COUNT     (11)

#define NA_CBUS_CANID_EXTENDED_ID_BIT_COUNT     (18)
#define NA_CBUS_CANID_EXTENDED_ID_SHIFT         (0)


#define NA_CBUS_MAX_BIT_RATE    (1000000)
#define NA_CBUS_MIN_BIT_RATE    (10000)

#define NA_CBUS_MIN_SYNC_PERIOD     (5)
#define NA_CBUS_MAX_SYNC_PERIOD     (25)

#define NA_CBUS_MIN_SAMPLE_POINT    (60)
#define NA_CBUS_MAX_SAMPLE_POINT    (90)

#define NA_CBUS_MIN_SJW     (10)
#define NA_CBUS_MAX_SJW     (40)

#define NA_CBUS_CANID_ALWAYS_ZERO_BIT           (1 << 29)

/*
 * Different states of the CAN driver.
 */
typedef enum
{
    CAN_STATE_STOPPED,
    CAN_STATE_RUNNING,
    CAN_STATE_SHUTTING_DOWN
} NACanDriverState_t;



#ifdef __cplusplus
}
#endif 


#endif /* NACBUS_PRIVATE_H */


