169 lines
6.1 KiB
C
169 lines
6.1 KiB
C
/*******************************************************************************
|
|
* *
|
|
* Copyright 2010 Rheinmetall Canada Inc. *
|
|
* *
|
|
* No part of this document may be reproduced, stored in *
|
|
* a retrieval system, or transmitted, in any form or by any means, *
|
|
* electronic, mechanical, photocopying, recording, or otherwise, *
|
|
* without the prior written permission of Rheinmetall Canada Inc. *
|
|
* *
|
|
*******************************************************************************/
|
|
/* ¤Revision:
|
|
000 20100616 HCAM,
|
|
Original version.
|
|
|
|
|
|
,----.. ,----..
|
|
/ / \ / / \ ,--,
|
|
| : : __ ,-. ,---. | : : ,--.'| ,---,
|
|
. | ;. / ,' ,'/ /| ' ,'\ .--.--. . | ;. / | |, ,-+-. / |
|
|
. ; /--` ' | |' | / / | / / ' . ; /--` `--'_ ,--.'|' |
|
|
; | ; __ | | ,'. ; ,. :| : /`./ ; | ; __ ,' ,'| | | ,"' |
|
|
| : |.' .'' : / ' | |: :| : ;_ | : |.' .'' | | | | / | |
|
|
. | '_.' :| | ' ' | .; : \ \ `. . | '_.' :| | : | | | | |
|
|
' ; : \ |; : | | : | `----. \ ' ; : \ |' : |__ | | | |/
|
|
' | '/ .'| , ; \ \ / / /`--' / ' | '/ .'| | '.'|| | |--'
|
|
| : / ---' `----' '--'. / | : / ; : ;| |/
|
|
\ \ .' `--'---' \ \ .' | , / '---'
|
|
`---` `---` ---`-'
|
|
|
|
### YYYYMMDD Initial, Bug Identification
|
|
Change description.
|
|
*/
|
|
|
|
|
|
|
|
|
|
/****************************** NOTES ***************************************
|
|
-> Timers assignment <-
|
|
|
|
- Timer1 used by general timer module (timer.c)
|
|
- Timer2 used by time based Resolver data acquisition module (resolver.c)
|
|
- timer3 used by input capture to detect PWM
|
|
- timer4 used by hall acquisition module (HallAcquisition.c)
|
|
- timer5 used by FPGAInterface to time-base SPI the transfer to the FPGA
|
|
|
|
|
|
-> Interrupt priority assignment <-
|
|
|
|
Priority.SubPriority - Assignment
|
|
HIGHEST
|
|
7.3
|
|
7.2
|
|
7.1 - UART1
|
|
7.0 - UART2
|
|
6.3 - TIMER2 (Resolver acquisition & halls computation)
|
|
6.2 - PMP
|
|
6.1
|
|
6.0 - Input Capture
|
|
5.3 - ADC
|
|
5.2 - SPI
|
|
5.1
|
|
5.0
|
|
4.3 - Drive Enable pin interrupt
|
|
4.2 - AD2S DOS Pin
|
|
4.1 - AD2S LOT Pin
|
|
4.0
|
|
3.3
|
|
3.2
|
|
3.1
|
|
3.0 - TIMER5 (FPGA TX)
|
|
2.3 - TIMER1 (General purpose timer)
|
|
2.2 - TIMER3 (PWM Detection)
|
|
2.1
|
|
1.0
|
|
1.3
|
|
1.2
|
|
1.1
|
|
1.0
|
|
LOWEST
|
|
|
|
*****************************************************************************/
|
|
|
|
#ifndef DEFINE_H
|
|
#define DEFINE_H
|
|
|
|
/* ************************************************************************** */
|
|
/* Includes */
|
|
#include <plib.h>
|
|
//#include "CUHelperFcns.h"
|
|
|
|
/* ************************************************************************** */
|
|
/* Defines */
|
|
#define SYS_FREQ (77824000L) //Clock period = 12.85 ns
|
|
#define PERIPHERAL_FREQ (77824000L)
|
|
#define PIN_INPUT 1
|
|
#define PIN_OUTPUT 0
|
|
#define LED_ON 0
|
|
#define LED_OFF 1
|
|
#define false 0
|
|
#define true 1
|
|
#define MSB8(x) ((x >> 8) & 0xFF)
|
|
#define LSB8(x) (x & 0xFF)
|
|
|
|
#define PI 3.1415926536
|
|
|
|
//#define ENABLE_DEBUG_LOG
|
|
#ifdef ENABLE_DEBUG_LOG
|
|
#include "util.h"
|
|
#endif
|
|
|
|
//#define USE_HALL_ACQ_SIMULATOR //Use this switch for development to test hall acquisition traces
|
|
#define USE_ENGINEERING_MODE //Use this switch to disable speed, position and halls traces and traces buffer allocation (all traces !)
|
|
//#define USE_TRACE_SIMULATOR //Use this switch to simulate trace data for development
|
|
//#define USE_SPI_DONGLE_SIMULATOR //Use this switch if you use the CUMUX as a SPI dongle instead of the CS16IS74 dongle.
|
|
//#define USE_PMP_AUTOINCREMENT //Use to speed-up AD2S data transfer
|
|
#define USE_PWM_DETECTION //Use PWM detection to enable/disable bridge
|
|
#define USE_AUTO_BRIDGE_CONTROL //Execute drive bridge control
|
|
//#define FORCE_BRIDGE_ON
|
|
//#define DRIVE_BOARD_NOT_INSTALLED
|
|
#define DISABLE_PRINT_FAULT
|
|
#define SPI_FAST
|
|
//#define USE_DMA_WITH_PMP
|
|
//#define USE_RESOLVER_STATEMACHINE
|
|
//#define DISABLE_DRIVE_PARAM_MGMT // uncomment to avoid setting the drive at power-up
|
|
|
|
#define POLL_UART1_RX
|
|
#define POLL_UART2_RX
|
|
|
|
// Uncomment next #define for testing with ICCA board
|
|
// #define USE_ICCA_CU_PA_UART_SNOOPING
|
|
|
|
|
|
//Define the com port assignations
|
|
//----------------------------
|
|
#define DRIVE_UART_PORT UART_1
|
|
#ifdef USE_ICCA_CU_PA_UART_SNOOPING
|
|
// Note: With this configuration there is no CU command going to the PA
|
|
#define CU_UART_PORT UART_3
|
|
#define CONSOLE_UART_PORT UART_2
|
|
#else
|
|
// Normal setting using PA SPI for UART_3 (CONSOLE_UART_PORT)
|
|
#define CU_UART_PORT UART_2
|
|
#define CONSOLE_UART_PORT UART_3
|
|
#endif
|
|
|
|
#define ACTUATOR_WITTENSTEIN
|
|
//#define ACTUATOR_DS50
|
|
|
|
//
|
|
//----------------------------
|
|
//#define USE_BLOCKING_PRINTF
|
|
#define USE_PRINTF
|
|
|
|
#ifdef USE_PRINTF
|
|
#define PRINTF(n, a...) printf(n, ## a)
|
|
#else
|
|
#define PRINTF(n, a...)
|
|
#define NO_EXTERNAL_UART
|
|
#endif
|
|
|
|
|
|
/* ************************************************************************** */
|
|
/* Type definitions */
|
|
typedef int bool;
|
|
|
|
#endif
|
|
//EOF
|
|
|