Skip to content

Commit

Permalink
bring up ZLG CAN and test it with mpc56xx
Browse files Browse the repository at this point in the history
  • Loading branch information
parai committed Jul 13, 2018
1 parent cbd5607 commit ee7e171
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 78 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,5 @@ Rte_*.h
tensorflow
board.mpc56xx
board.any
SeedToKey.py
kerneldlls
3 changes: 2 additions & 1 deletion com/as.application/board.any/mpc563xm_nxp_autosar/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ MODULES = ['ECUM','SCHM','MCU',
'CLIB_STDIO_PRINTF',
'ASKAR','SHELL','CLIB_STRTOK_R',
'PORT','DIO','ADC',
'CAN','CANIF','PDUR','COM','COMM',
'CAN','CANIF','PDUR','COM','COMM','CANTP',
'DCM','CANNM','CANSM','NM','OSEKNM','XCP',
'MPC5634M_MLQB80'
]

Expand Down
5 changes: 3 additions & 2 deletions com/as.application/board.mpc56xx/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ ASROOT = asenv['ASROOT']
MODULES = ['ECUM','SCHM','MCU',
'DET',
'CLIB_STDIO_PRINTF',
'ASKAR','SHELL',
'ASKAR','SHELL','CLIB_STRTOK_R',
'MPC5634M_MLQB80',
'CAN','CANIF','PDUR','COM','COMM',
'CAN','CANIF','PDUR','COM','COMM','CANTP',
'DCM','CANNM','CANSM','NM','OSEKNM','XCP',
'PORT','DIO'
]

Expand Down
14 changes: 7 additions & 7 deletions com/as.application/board.mpc56xx/common/Can_Cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
#define CAN_WAKEUP_SUPPORT STD_OFF // Not supported
#define CAN_HW_TRANSMIT_CANCELLATION STD_OFF // Not supported

#define INDEX_OF_CAN_CTRL_1 0
#define INDEX_OF_CAN_CTRL_0 0

#define CAN_CTRL_A CAN_CTRL_1
#define CAN_CTRL_C CAN_CTRL_0
#define CAN_CTRL_A CAN_CTRL_0
#define CAN_CTRL_C CAN_CTRL_1

#define FLEXCAN_A CAN_CTRL_A
typedef enum {
CAN_CTRL_1 = 0,
CAN_CTRL_0 = 1,
CAN_CTRL_0 = 0,
CAN_CTRL_1 = 1,
CAN_CONTROLLER_CNT = 2
}CanControllerIdType;

Expand All @@ -59,13 +59,13 @@ typedef enum {
CAN_ARC_HANDLE_TYPE_FULL
} Can_Arc_HohType;

#define Can1Hth CanAHth
#define Can0Hth CanAHth
typedef enum {
CanAHth,
NUM_OF_HTHS
} Can_Arc_HTHType;

#define Can1Hrh CanAHrh
#define Can0Hrh CanAHrh
typedef enum {
CanAHrh,
NUM_OF_HRHS
Expand Down
34 changes: 0 additions & 34 deletions com/as.infrastructure/include/Can.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,6 @@
#define CAN_CBK_CHECKWAKEUP_SERVICE_ID 0x0b
//@}


#if defined(CFG_PPC)

/* HOH flags */
#define CAN_HOH_FIFO_MASK (1UL<<0)
//#define CAN_HOH_EOL_MASK (1<<9)

/* Controller flags */
#define CAN_CTRL_RX_PROCESSING_INTERRUPT (1UL<<0)
#define CAN_CTRL_RX_PROCESSING_POLLING 0
#define CAN_CTRL_TX_PROCESSING_INTERRUPT (1UL<<1)
#define CAN_CTRL_TX_PROCESSING_POLLING 0
#define CAN_CTRL_WAKEUP_PROCESSING_INTERRUPT (1UL<<2)
#define CAN_CTRL_WAKEUP_PROCESSING_POLLING 0
#define CAN_CTRL_BUSOFF_PROCESSING_INTERRUPT (1UL<<3)
#define CAN_CTRL_BUSOFF_PROCESSING_POLLING 0
#define CAN_CTRL_ACTIVATION (1UL<<4)

#define CAN_CTRL_LOOPBACK (1UL<<5)
#define CAN_CTRL_FIFO (1UL<<6)

#define CAN_CTRL_ERROR_PROCESSING_INTERRUPT (1UL<<7)
#define CAN_CTRL_ERROR_PROCESSING_POLLING 0

#endif

#include "Std_Types.h"
#include "CanIf_Types.h"
#include "ComStack_Types.h"
Expand All @@ -103,14 +77,6 @@ typedef struct {
uint32 fifoWarning;
} Can_Arc_StatisticsType;


#if defined(CFG_CAN_TEST)
typedef struct {
uint64_t mbMaskTx;
uint64_t mbMaskRx;
} Can_TestType;
#endif

// uint16: if only Standard IDs are used
// uint32: if also Extended IDs are used
typedef uint32 Can_IdType;
Expand Down
4 changes: 2 additions & 2 deletions com/as.tool/config.infrastructure.system/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ def PrepareBuilding(env):
menuconfig(env)

if(0 != os.system('%s --version'%(env['pkgconfig']))):
raise Exception('no pkg-config installed, fix the path maybe!')
print('WARNING: no pkg-config installed, fix the path maybe, or run command to install GTK\n\tpacman -S mingw-w64-x86_64-glib2 mingw-w64-x86_64-gtk3')
if(0 != os.system('%s --version'%(env['CC']))):
raise Exception('no C Compiler installed, fix the path maybe!')
print('WARNING: no C Compiler installed, fix the path maybe, or run command to install GCC\n\tpacman -S mingw-w64-x86_64-gcc')

def mk_rtconfig(filename):
try:
Expand Down
60 changes: 28 additions & 32 deletions com/as.tool/lua/can/zlg_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "asdebug.h"
/* ============================ [ MACROS ] ====================================================== */
#define Kbps *1000

#define AS_LOG_ZLG 1
/* ============================ [ TYPES ] ====================================================== */
struct Can_ZLGHandle_s
{
Expand Down Expand Up @@ -58,16 +60,16 @@ const Can_DeviceOpsType can_zlg_ops =
};
static struct Can_ZLGHandleList_s* zlgH = NULL;
static uint32_t zlg_bauds[][2] = {
{1000 Kbps,0x060003 },
{800 Kbps,0x060004 },
{500 Kbps,0x060007 },
{250 Kbps,0x1C0008 },
{125 Kbps,0x1C0011 },
{100 Kbps,0x160023 },
{50 Kbps,0x1C002C },
{20 Kbps,0x1600B3 },
{10 Kbps,0x1C00E0 },
{5 Kbps,0x1C01C1 }
{1000 Kbps,0x0014 },
{800 Kbps,0x0016 },
{500 Kbps,0x001C },
{250 Kbps,0x011C },
{125 Kbps,0x031C },
{100 Kbps,0x041C },
{50 Kbps,0x091C },
{20 Kbps,0x181C },
{10 Kbps,0x311C },
{5 Kbps,0xBFFF }
};
/* ============================ [ LOCALS ] ====================================================== */
static struct Can_ZLGHandle_s* getHandle(uint32_t port)
Expand All @@ -93,23 +95,20 @@ static boolean get_zlg_param(uint32_t port,uint32_t* DeviceType,uint32_t* CANInd
uint32_t i;
boolean rv = TRUE;

printf("CAN ZLG support list:\n");
printf("\tport 0 --> VCI_USBCAN_2E_U CAN0\n");
printf("\tport 1 --> VCI_USBCAN_2E_U CAN1\n");
printf("\tport 3 --> VCI_USBCAN_E_U CAN0\n");
if(port < 2)
char* pVCI_USBCAN = getenv("VCI_USBCAN");

if(NULL != pVCI_USBCAN)
{
*DeviceType = VCI_USBCAN_2E_U;
*DeviceType = strtoul(pVCI_USBCAN, NULL, 10);
*CANInd = port;
}
else if(port < 3)
{
*DeviceType = VCI_USBCAN_E_U;
*CANInd = port - 2;
ASLOG(ZLG, "open VCI_USBCAN %d port %d\n", *DeviceType, *CANInd);
}
else
{
ASWARNING("CAN ZLG port=%d is not in the support list!\n",port);
ASWARNING("please set env VCI_USBCAN according to the device type value specified in ConttrolCAN.h!\n"
" set VCI_USBCAN=4 REM for VCI_USBCAN2\n"
" set VCI_USBCAN=21 REM for VCI_USBCAN_2E_U\n"
);
rv = FALSE;
}

Expand Down Expand Up @@ -156,7 +155,6 @@ static boolean zlg_probe(uint32_t busid,uint32_t port,uint32_t baudrate,can_devi
uint32_t CANInd;
uint32_t baud = baudrate;
VCI_INIT_CONFIG init_config;
init_config.Mode=0; /* normal mode */
uint32_t status;

rv = get_zlg_param(port, &DeviceType, &CANInd,&baud);
Expand All @@ -168,22 +166,20 @@ static boolean zlg_probe(uint32_t busid,uint32_t port,uint32_t baudrate,can_devi
if(STATUS_OK != status)
{
ASWARNING("CAN ZLG port=%d is not able to be opened,error=%X!\n",port,status);
ASWARNING("maybe you forgot about the ControlCAN\64\kerneldlls to be copied to local directory!\n");
rv = FALSE;
}
}

if(rv)
{
status = VCI_SetReference(DeviceType,0,CANInd,0,&baud);
if(STATUS_OK != status)
{
ASWARNING("CAN ZLG port=%d is not able to set baudrate,error=%X!\n",port,status);
rv = FALSE;
}
}
init_config.AccCode=0x00000000;
init_config.AccMask=0xFFFFFFFF;
init_config.Filter=0;
init_config.Mode=0; /* normal mode */
init_config.Timing0=(UCHAR)(baud>>8)&0xFF;
init_config.Timing1=(UCHAR)baud&0xFF;

if(rv)
{
status = VCI_InitCAN(DeviceType,0,CANInd,&init_config);
if(STATUS_OK != status)
{
Expand Down
3 changes: 3 additions & 0 deletions release/aslua/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ endif
aszlg:$(download)/ControlCAN
ifeq ($(host),Linux)
else
@(echo ">>>> maybe the ControlCAN has been updated,")
@(echo ">>>> please manually make things working by make sure")
@(echo ">>>> that there is path $(download)/ControlCAN/64/ControlCAN.dll")
ifeq ($(msys2),yes)
@(cp -fv $(download)/ControlCAN/64/ControlCAN.dll $(prj-dir)/com/as.tool/as.one.py)
else
Expand Down

0 comments on commit ee7e171

Please sign in to comment.