Commit 9c4da11f authored by Petr's avatar Petr

initial commit

parents
This diff is collapsed.
Debug/
Release/
.settings
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cardreader</name>
<comment></comment>
<projects>
<project>lpc_chip_11cxx_lib</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
//*****************************************************************************
// crp.c
//
// Source file to create CRP word expected by LPCXpresso IDE linker
//*****************************************************************************
//
// Copyright(C) NXP Semiconductors, 2013
// All rights reserved.
//
// Software that is described herein is for illustrative purposes only
// which provides customers with programming information regarding the
// LPC products. This software is supplied "AS IS" without any warranties of
// any kind, and NXP Semiconductors and its licensor disclaim any and
// all warranties, express or implied, including all implied warranties of
// merchantability, fitness for a particular purpose and non-infringement of
// intellectual property rights. NXP Semiconductors assumes no responsibility
// or liability for the use of the software, conveys no license or rights under any
// patent, copyright, mask work right, or any other intellectual property rights in
// or to any products. NXP Semiconductors reserves the right to make changes
// in the software without notification. NXP Semiconductors also makes no
// representation or warranty that such application will be suitable for the
// specified use without further testing or modification.
//
// Permission to use, copy, modify, and distribute this software and its
// documentation is hereby granted, under NXP Semiconductors' and its
// licensor's relevant copyrights in the software, without fee, provided that it
// is used in conjunction with NXP Semiconductors microcontrollers. This
// copyright, permission, and disclaimer notice must appear in all copies of
// this code.
//*****************************************************************************
#if defined (__CODE_RED)
#include <NXP/crp.h>
// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
#endif
/*
===============================================================================
Name : main.c
Author : $(author)
Version :
Copyright : $(copyright)
Description : main definition
===============================================================================
*/
#include "board.h"
//#include "canopen_driver.h"
#include "weigand.h"
/* Kernel includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "timers.h"
/*****************************************************************************
* Private types/enumerations/variables
****************************************************************************/
/* The configCHECK_FOR_STACK_OVERFLOW setting in FreeRTOSConifg can be used to
check task stacks for overflows. It does not however check the stack used by
interrupts. This demo has a simple addition that will also check the stack used
by interrupts if mainCHECK_INTERRUPT_STACK is set to 1. Note that this check is
only performed from the tick hook function (which runs in an interrupt context).
It is a good debugging aid - but won't catch interrupt stack problems until the
tick interrupt next executes. */
#define mainCHECK_INTERRUPT_STACK 0
#if mainCHECK_INTERRUPT_STACK == 1
const unsigned char ucExpectedInterruptStackValues[] = { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC };
#endif
/*****************************************************************************
* Public types/enumerations/variables
****************************************************************************/
/*****************************************************************************
* Private functions
****************************************************************************/
static void setup_hardware(void)
{
extern unsigned long _vStackTop[], _pvHeapStart[];
unsigned long ulInterruptStackSize;
// Read clock settings and update SystemCoreClock variable
SystemCoreClockUpdate();
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init();
Board_LED_Set(0, false);
Board_LED_Set(1, false);
Board_LED_Set(2, false);
weigand_init(CARD_READER1_PORT, CARD_READER1_D0_PIN, CARD_READER1_D1_PIN);
/* The size of the stack used by main and interrupts is not defined in
the linker, but just uses whatever RAM is left. Calculate the amount of
RAM available for the main/interrupt/system stack, and check it against
a reasonable number. If this assert is hit then it is likely you don't
have enough stack to start the kernel, or to allow interrupts to nest.
Note - this is separate to the stacks that are used by tasks. The stacks
that are used by tasks are automatically checked if
configCHECK_FOR_STACK_OVERFLOW is not 0 in FreeRTOSConfig.h - but the stack
used by interrupts is not. Reducing the conifgTOTAL_HEAP_SIZE setting will
increase the stack available to main() and interrupts. */
ulInterruptStackSize = ( ( unsigned long ) _vStackTop ) - ( ( unsigned long ) _pvHeapStart );
configASSERT( ulInterruptStackSize > 350UL );
}
static void alive_task(void *pvParameters)
{
Board_LED_Set(0, true);
while (1)
{
vTaskDelay(1500 / portTICK_PERIOD_MS);
Board_LED_Toggle(0);
}
}
/*****************************************************************************
* Public functions
****************************************************************************/
int main(void)
{
setup_hardware();
xTaskCreate(alive_task, "alive_task",configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 1UL), NULL);
printf("started\n");
NVIC_EnableIRQ(EINT3_IRQn);
__enable_irq();
/* Start the kernel. From here on, only tasks and interrupts will run. */
vTaskStartScheduler();
return 1;
}
void vApplicationMallocFailedHook(void)
{
/* vApplicationMallocFailedHook() will only be called if
configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
function that will get called if a call to pvPortMalloc() fails.
pvPortMalloc() is called internally by the kernel whenever a task, queue,
timer or semaphore is created. It is also called by various parts of the
demo application. If heap_1.c or heap_2.c are used, then the size of the
heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
to query the size of free heap space that remains (although it does not
provide information on how the remaining heap might be fragmented). */
taskDISABLE_INTERRUPTS();
for( ;; );
}
void vApplicationIdleHook(void)
{
/* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
task. It is essential that code added to this hook function never attempts
to block in any way (for example, call xQueueReceive() with a block time
specified, or call vTaskDelay()). If the application makes use of the
vTaskDelete() API function (as this demo application does) then it is also
important that vApplicationIdleHook() is permitted to return to its calling
function, because it is the responsibility of the idle task to clean up
memory allocated by the kernel to any task that has since been deleted. */
}
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
{
( void ) pcTaskName;
( void ) pxTask;
/* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected. */
taskDISABLE_INTERRUPTS();
for( ;; );
}
void vApplicationTickHook( void )
{
/* This function will be called by each tick interrupt if
configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be
added here, but the tick hook is called from an interrupt context, so
code must not attempt to block, and only the interrupt safe FreeRTOS API
functions can be used (those that end in FromISR()). */
}
/*
* @brief Common SystemInit function for LPC11xx chips
*
* @note
* Copyright(C) NXP Semiconductors, 2012-14
* All rights reserved.
*
* @par
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* LPC products. This software is supplied "AS IS" without any warranties of
* any kind, and NXP Semiconductors and its licensor disclaim any and
* all warranties, express or implied, including all implied warranties of
* merchantability, fitness for a particular purpose and non-infringement of
* intellectual property rights. NXP Semiconductors assumes no responsibility
* or liability for the use of the software, conveys no license or rights under any
* patent, copyright, mask work right, or any other intellectual property rights in
* or to any products. NXP Semiconductors reserves the right to make changes
* in the software without notification. NXP Semiconductors also makes no
* representation or warranty that such application will be suitable for the
* specified use without further testing or modification.
*
* @par
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, under NXP Semiconductors' and its
* licensor's relevant copyrights in the software, without fee, provided that it
* is used in conjunction with NXP Semiconductors microcontrollers. This
* copyright, permission, and disclaimer notice must appear in all copies of
* this code.
*/
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
/*****************************************************************************
* Private types/enumerations/variables
****************************************************************************/
/*****************************************************************************
* Public types/enumerations/variables
****************************************************************************/
#if defined(NO_BOARD_LIB)
const uint32_t OscRateIn = 12000000;
const uint32_t ExtRateIn = 0;
#endif
/*****************************************************************************
* Private functions
****************************************************************************/
/*****************************************************************************
* Public functions
****************************************************************************/
/* Set up and initialize hardware prior to call to main */
void SystemInit(void)
{
#if defined(NO_BOARD_LIB)
/* Chip specific SystemInit */
Chip_SystemInit();
#else
/* Board specific SystemInit */
Board_SystemInit();
#endif
}
/***********************************************************************
* $Id:: CAN_Node_Def.c 1604 2012-04-24 11:34:47Z nxp31103 $
*
* Project: CANopen Application Example for LPC11Cxx (slave)
*
* Description:
* CANopen definition source file
*
* Copyright(C) 2012, NXP Semiconductor
* All rights reserved.
*
***********************************************************************
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
**********************************************************************/
#include "CAN_Node_Def.h"
#include <stdint.h>
/* Application variables used in variable OD */
uint8_t error_register;
uint8_t LEDArray;
volatile SDOS_Buffer_t SDOS_2200 =
{
(uint8_t*)SDOS_2200_Data,
sizeof(SDOS_2200_Data),
};
volatile uint8_t SDOS_2200_Data[255] = "Boot-up value of SDO 2200h";
uint32_t CANopen_Heartbeat_Producer_Value;
WatchNode_t WatchList[1];
uint8_t WatchListLength = sizeof(WatchList)/sizeof(WatchList[0]);
/* CANopen read-only (constant) Object Dictionary (OD) entries
Used with Expedited SDO only. Lengths = 1/2/4 bytes */
CAN_ODCONSTENTRY myConstOD [] =
{
/* index, subindex, length, value */
{ 0x1000, 0x00, 4, 0x00000000UL },
{ 0x1018, 0x00, 1, 0x00000001UL }, /* only vendor ID is specified */
{ 0x1018, 0x01, 4, 0x000002DCUL }, /* NXP vendor ID for CANopen */
};
uint32_t NumberOfmyConstODEntries = sizeof(myConstOD)/sizeof(myConstOD[0]);
/* CANopen list of variable Object Dictionary (OD) entries
Expedited SDO with length=1/2/4 bytes and segmented SDO */
CAN_ODENTRY myOD [] =
{
/* index, subindex, access_type | length, value_pointer */
{ 0x1001, 0x00, OD_EXP_RO | 1, (uint8_t *)&error_register },
{ 0x1016, 0x00, OD_EXP_RO | 1, (uint8_t *)&WatchListLength},
{ 0x1016, 0x01, OD_EXP_RW | 4, (uint8_t *)&WatchList[0].value},
{ 0x1017, 0x00, OD_EXP_RW | 2, (uint8_t *)&CANopen_Heartbeat_Producer_Value},
{ 0x2000, 0x00, OD_EXP_RW | 1, (uint8_t *)&LEDArray},
{ 0x2200, 0x00, OD_SEG_RW, (uint8_t *)&SDOS_2200},
};
uint32_t NumberOfmyODEntries = sizeof(myOD)/sizeof(myOD[0]);
/***********************************************************************
* $Id:: CAN_Node_Def.h 1604 2012-04-24 11:34:47Z nxp31103 $
*
* Project: CANopen Application Example for LPC11Cxx (slave)
*
* Description:
* CANopen definition header file
*
* Copyright(C) 2012, NXP Semiconductor
* All rights reserved.
*
***********************************************************************
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
**********************************************************************/
#ifndef _CAN_NODE_DEF_H
#define _CAN_NODE_DEF_H
#include <stdint.h>
#include "canopen_driver.h"
#define CAN_MASTER_NODE 0x7D /* 125 */
#define CAN_SLAVE1_NODE 0x01 /* 1 */
#define CAN_SLAVE2_NODE 0x02 /* 2 */
#define CAN_NODE_ID CAN_SLAVE1_NODE /* make sure to change this when using 2 slaves */
#define CANOPEN_TIMEOUT_VAL 100 /* in ms */
/* Application variables used in variable OD */
extern uint8_t error_register; /* CANopen error register */
extern uint8_t LEDArray; /* LEDs of MCB11C14 board */
extern uint32_t CANopen_Heartbeat_Producer_Value; /* heartbeat producer value */
extern volatile SDOS_Buffer_t SDOS_2200; /* buffer structure associated with segmented entry 2200h */
extern volatile uint8_t SDOS_2200_Data[255]; /* buffer associated with segmented entry 2200h */
/* Watchlist */
extern WatchNode_t WatchList[]; /* for watching nodes */
extern uint8_t WatchListLength; /* number of nodes in watchlist must be known */
/* OD */
extern CAN_ODCONSTENTRY myConstOD[]; /* constant OD entries */
extern uint32_t NumberOfmyConstODEntries; /* required so that the number of entries in the constant OD is known */
extern CAN_ODENTRY myOD[]; /* non-constant OD entries */
extern uint32_t NumberOfmyODEntries; /* required so that the number of entries in the non-constant OD is known */
#endif /* _CAN_NODE_DEF_H */
This diff is collapsed.
/***********************************************************************
* $Id:: canopen_driver.h 1604 2012-04-24 11:34:47Z nxp31103 $
*
* Project: CANopen Application Example for LPC11Cxx
*
* Description:
* CANopen driver header file
*
* Copyright(C) 2012, NXP Semiconductor
* All rights reserved.
*
***********************************************************************
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
**********************************************************************/
#ifndef CANOPEN_DRIVER_H_
#define CANOPEN_DRIVER_H_
#include "rom_drivers.h"
/* Message buffers used by CANopen library:
CANopen driver RX 1
CANopen driver TX 2
heartbeat RX 3
heartbeat TX 4
NMT RX 5
NMT TX 6
SDO Client RX 7
SDO Client TX 8
*/
#ifndef NULL
#define NULL ((void *)0)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (1)
#endif
/* NMT module control command */
#define NMT_CMD_START 1
#define NMT_CMD_STOP 2
#define NMT_CMD_ENTER_PRE_OP 128
#define NMT_CMD_RESET_NODE 129
#define NMT_CMD_RESET_COMM 130
/* Node State */
#define NMT_STATE_INTIALIZING 0
#define NMT_STATE_STOPPED 4
#define NMT_STATE_OPERATIONAL 5
#define NMT_STATE_PRE_OPERATIONAL 127
/* SDOC State */
#define CANopen_SDOC_Fail 0
#define CANopen_SDOC_Succes 1
#define CANopen_SDOC_Exp_Read_Busy 2
#define CANopen_SDOC_Exp_Write_Busy 3
#define CANopen_SDOC_Seg_Read_Busy 4
#define CANopen_SDOC_Seg_Write_Busy 5
typedef struct _SDOS_Buffer_t {
uint8_t* data; /* pointer to buffer */
uint32_t length; /* length in buffer */
}SDOS_Buffer_t;
typedef struct _WatchNode_t {
uint32_t value; /* heartbeat consumer value, accessible via SDO */
uint32_t counter; /* used for keeping track of heartbeat */
uint8_t status; /* status of node to watch, e.g. NMT_STATE_INTIALIZING, NMT_STATE_STOPPED, etc. */
uint8_t heartbeatFail; /* set when heartbeat was not received in time */
uint8_t BootupAfterHBF; /* set when bootup message has been received after a heartbeat failure */
uint8_t NodeID; /* when != NULL, the software will automatically reconfigure the node specified by NodeID after a heartbeat failure of the node NodeID */
uint16_t ProducerTime; /* when != NULL together with NodeID != NULL, heartbeat producer time will be automatically restored after heartbeat failure of node NodeID */
uint16_t ConsumerTime; /* when != NULL together with NodeID != NULL, heartbeat consumer time will be automatically restored after heartbeat failure of node NodeID */
}WatchNode_t;
/* General CANopen functions */
void CANopenInit(void);
void CANopen_1ms_tick(void);
extern void CANopen_Init_SDO(void);
/* General CAN functions */
void CAN_IRQHandler (void);
void CAN_RX(uint8_t msg_obj_num);
void CAN_TX(uint8_t msg_obj_num);
void CAN_Error(uint32_t error_info);
/* CANopen NMT / Heartbeat functions */
void CANopen_NMT_Send_CMD(uint8_t ID, uint8_t CMD);
void CANopen_NMT_Change_MyState(uint8_t NMT_Command);
void CANopen_Heartbeat_Send(void);
extern void CANopen_NMT_Reset_Node_Received(void);
extern void CANopen_NMT_Reset_Comm_Received(void);
extern void CANopen_NMT_Consumer_Bootup_Received(uint8_t Node_ID);
extern void CANopen_Heartbeat_Consumer_Failed(uint8_t Node_ID);
/* CANopen SDO server-side functions. Read/write functions are called by callback mechanism */
uint32_t CANopen_SDOS_Exp_Read(uint16_t index, uint8_t subindex);
uint32_t CANopen_SDOS_Exp_Write(uint16_t index, uint8_t subindex, uint8_t *dat_ptr);
uint32_t CANopen_SDOS_Seg_Read(uint16_t index, uint8_t subindex, uint8_t openclose, uint8_t *length, uint8_t *data, uint8_t *last);
uint32_t CANopen_SDOS_Seg_Write(uint16_t index, uint8_t subindex, uint8_t openclose, uint8_t length, uint8_t *data, uint8_t *fast_resp);
void CANopen_SDOS_Find_Buffer(uint16_t index, uint8_t subindex, SDOS_Buffer_t** SDOS_Buffer, uint8_t* access_type);
/* CANopen SDO client-side functions */
uint8_t CANopen_SDOC_Exp_Read(uint8_t node_id, uint16_t index, uint8_t subindex, uint8_t* data, uint8_t* valid_data_bytes);
uint8_t CANopen_SDOC_Exp_Write(uint8_t node_id, uint16_t index, uint8_t subindex, uint8_t* data, uint8_t length);
uint8_t CANopen_SDOC_Seg_Read(uint8_t node_id, uint16_t index, uint8_t subindex, void* buff, uint32_t buffSize);
uint8_t CANopen_SDOC_Seg_Write(uint8_t node_id, uint16_t index, uint8_t subindex, void* buff, uint32_t Length);
/* Global Variables */
extern volatile uint8_t CANopen_NMT_MyState; /* Present state of NMT state machine */
extern volatile uint8_t CANopen_SDOC_State; /* Present state of SDO client state machine for controlling SDO client transfers */
extern volatile uint32_t CANopen_Heartbeat_Producer_Counter; /* heartbeat producer counter, used for generating heartbeat */
#endif /* CANOPEN_DRIVER_H_ */
/****************************************************************************
* $Id:: rom_driver_CAN.h 1604 2012-04-24 11:34:47Z nxp31103 $
* Project: NXP LPC11xx CAN example
*
* Description:
* This file is part of the CAN and CANopen on-chip driver examples.
*
****************************************************************************
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
****************************************************************************/
#ifndef __ROM_DRIVER_CAN_H__
#define __ROM_DRIVER_CAN_H__
#include "lpc_types.h"
#include "cmsis.h"
/* error status bits */
#define CAN_ERROR_NONE 0x00000000UL
#define CAN_ERROR_PASS 0x00000001UL
#define CAN_ERROR_WARN 0x00000002UL
#define CAN_ERROR_BOFF 0x00000004UL
#define CAN_ERROR_STUF 0x00000008UL
#define CAN_ERROR_FORM 0x00000010UL
#define CAN_ERROR_ACK 0x00000020UL
#define CAN_ERROR_BIT1 0x00000040UL
#define CAN_ERROR_BIT0 0x00000080UL
#define CAN_ERROR_CRC 0x00000100UL
/* control bits for CAN_MSG_OBJ.mode_id */
#define CAN_MSGOBJ_STD 0x00000000UL /* CAN 2.0a 11-bit ID */
#define CAN_MSGOBJ_EXT 0x20000000UL /* CAN 2.0b 29-bit ID */
#define CAN_MSGOBJ_DAT 0x00000000UL /* data frame */
#define CAN_MSGOBJ_RTR 0x40000000UL /* rtr frame */
typedef struct _CAN_MSG_OBJ {
uint32_t mode_id;
uint32_t mask;
uint8_t data[8];
uint8_t dlc;
uint8_t msgobj;
}CAN_MSG_OBJ;
/**************************************************************************
SDO Abort Codes
**************************************************************************/
#define SDO_ABORT_TOGGLE 0x05030000UL /* Toggle bit not alternated */
#define SDO_ABORT_SDOTIMEOUT 0x05040000UL /* SDO protocol timed out */
#define SDO_ABORT_UNKNOWN_COMMAND 0x05040001UL /* Client/server command specifier not valid or unknown */
#define SDO_ABORT_UNSUPPORTED 0x06010000UL /* Unsupported access to an object */
#define SDO_ABORT_WRITEONLY 0x06010001UL /* Attempt to read a write only object */
#define SDO_ABORT_READONLY 0x06010002UL /* Attempt to write a read only object */
#define SDO_ABORT_NOT_EXISTS 0x06020000UL /* Object does not exist in the object dictionary */
#define SDO_ABORT_PARAINCOMP 0x06040043UL /* General parameter incompatibility reason */
#define SDO_ABORT_ACCINCOMP 0x06040047UL /* General internal incompatibility in the device */
#define SDO_ABORT_TYPEMISMATCH 0x06070010UL /* Data type does not match, length of service parameter does not match */
#define SDO_ABORT_UNKNOWNSUB 0x06090011UL /* Sub-index does not exist */
#define SDO_ABORT_VALUE_RANGE 0x06090030UL /* Value range of parameter exceeded (only for write access) */
#define SDO_ABORT_TRANSFER 0x08000020UL /* Data cannot be transferred or stored to the application */
#define SDO_ABORT_LOCAL 0x08000021UL /* Data cannot be transferred or stored to the application because of local control */
#define SDO_ABORT_DEVSTAT 0x08000022UL /* Data cannot be transferred or stored to the application because of the present device state */
typedef struct _CAN_ODCONSTENTRY {
uint16_t index;
uint8_t subindex;
uint8_t len;
uint32_t val;
}CAN_ODCONSTENTRY;
/* upper-nibble values for CAN_ODENTRY.entrytype_len */
#define OD_NONE 0x00 /* Object Dictionary entry doesn't exist */
#define OD_EXP_RO 0x10 /* Object Dictionary entry expedited, read-only */
#define OD_EXP_WO 0x20 /* Object Dictionary entry expedited, write-only */
#define OD_EXP_RW 0x30 /* Object Dictionary entry expedited, read-write */
#define OD_SEG_RO 0x40 /* Object Dictionary entry segmented, read-only */
#define OD_SEG_WO 0x50 /* Object Dictionary entry segmented, write-only */
#define OD_SEG_RW 0x60 /* Object Dictionary entry segmented, read-write */
typedef struct _CAN_ODENTRY {
uint16_t index;
uint8_t subindex;
uint8_t entrytype_len;
uint8_t *val;
}CAN_ODENTRY;
typedef struct _CAN_CANOPENCFG {
uint8_t node_id;
uint8_t msgobj_rx;
uint8_t msgobj_tx;
uint8_t isr_handled;
uint32_t od_const_num;
CAN_ODCONSTENTRY *od_const_table;
uint32_t od_num;
CAN_ODENTRY *od_table;
}CAN_CANOPENCFG;
/* Return values for CANOPEN_sdo_req() callback */
#define CAN_SDOREQ_NOTHANDLED 0 /* process regularly, no impact */
#define CAN_SDOREQ_HANDLED_SEND 1 /* processed in callback, auto-send returned msg */
#define CAN_SDOREQ_HANDLED_NOSEND 2 /* processed in callback, don't send response */
/* Values for CANopen_SDOS_Seg_Read/write() callback 'openclose' parameter */
#define CAN_SDOSEG_SEGMENT 0 /* segment read/write */
#define CAN_SDOSEG_OPEN 1 /* channel is opened */
#define CAN_SDOSEG_CLOSE 2 /* channel is closed */
typedef struct _CAN_CALLBACKS {
void (*CAN_rx)(uint8_t msg_obj_num);
void (*CAN_tx)(uint8_t msg_obj_num);
void (*CAN_error)(uint32_t error_info);
uint32_t (*CANOPEN_sdo_read)(uint16_t index, uint8_t subindex);
uint32_t (*CANOPEN_sdo_write)(uint16_t index, uint8_t subindex, uint8_t *dat_ptr);
uint32_t (*CANOPEN_sdo_seg_read)(uint16_t index, uint8_t subindex, uint8_t openclose, uint8_t *length, uint8_t *data, uint8_t *last);
uint32_t (*CANOPEN_sdo_seg_write)(uint16_t index, uint8_t subindex, uint8_t openclose, uint8_t length, uint8_t *data, uint8_t *fast_resp);
uint8_t (*CANOPEN_sdo_req)(uint8_t length_req, uint8_t *req_ptr, uint8_t *length_resp, uint8_t *resp_ptr);
}CAN_CALLBACKS;
/* API function prototypes */
extern void init_can(uint32_t * can_cfg, uint8_t isr_ena);
extern void isr(void);
extern void config_rxmsgobj(CAN_MSG_OBJ * msg_obj);
extern uint8_t can_receive(CAN_MSG_OBJ * msg_obj);
extern void can_transmit(CAN_MSG_OBJ * msg_obj);
extern void config_canopen(CAN_CANOPENCFG * canopen_cfg);
extern void canopen_handler(void);
extern void config_calb(CAN_CALLBACKS * callback_cfg);
typedef struct _CAND {
void (*init_can)(uint32_t * can_cfg, uint8_t isr_ena);
void (*isr)(void);
void (*config_rxmsgobj)(CAN_MSG_OBJ * CANopen_Msg_Obj);
uint8_t (*can_receive)(CAN_MSG_OBJ * CANopen_Msg_Obj);
void (*can_transmit)(CAN_MSG_OBJ * CANopen_Msg_Obj);
void (*config_canopen)(CAN_CANOPENCFG * canopen_cfg);
void (*canopen_handler)(void);
void (*config_calb)(CAN_CALLBACKS * callback_cfg);
}CAND;
void CANInit(void);
#endif /* __ROM_DRIVER_CAN_H__ */
/****************************************************************************
* $Id:: rom_drivers.h 1604 2012-04-24 11:34:47Z nxp31103 $
* Project: NXP LPC11xx CAN example
*
* Description:
* This file is part of the CAN and CANopen on-chip driver examples.
*
****************************************************************************
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
****************************************************************************/
#ifndef ROM_DRIVERS_H_
#define ROM_DRIVERS_H_
#define CAN 0
#define USB 1
#define PERIPHERAL CAN