254 lines
7.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 TCP Stack (tick.c)
- Timer2 used by general timer module (timer.c) (see GP_TIMER_USE_TIMER_X definition below)
- 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
7.0
6.3
6.2
6.1
6.0
5.3
5.2
5.1
5.0
4.3
4.2
4.1
4.0
3.3
3.2
3.1
3.0 - Wifi chip IRQ (Ext INT 0)
2.3 - TIMER2 (General purpose timer)
2.2
2.1 - Ext Interrupt 1 (Led dimming knob) NOT USED!!!
1.0
1.3
1.2
1.1
1.0
LOWEST
*****************************************************************************/
#ifndef DEFINE_H
#define DEFINE_H
/* ************************************************************************** */
/* Includes */
#include <plib.h>
//#include "CUHelperFcns.h"
enum eWiFiState
{
WIFI_MODULE_OFF_STATE = 0,
WIFI_CONNECTED_STATE,
WIFI_DISCONNECTED_STATE,
WIFI_INIT_ERROR_STATE,
WIFI_UNKNOWN_STATE
};
#define WIFI_MODULE_SPI_BAUDRATE 15000000
#define WIFI_CONNECT_TIMEOUT 10000 //The delay we allow the module to establish a connection.
/* ************************************************************************** */
/* Defines */
#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 RET_OK true
#define RET_ERROR false
#define bool unsigned int
#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 NO_EXTERNAL_UART
//Choose which timer to use for general purpose timer
#define GP_TIMER_USE_TIMER_1
//#define POLL_UART1_RX
//#define POLL_UART2_RX
//#define NO_WIFI
//Define the com port assignations
//----------------------------
#define NETWORK_UART_PORT UART_1
#define LTE_IF_UART_PORT UART_2
//
//----------------------------
//Enable only one of those 3 options
//#define USE_BLOCKING_PRINTF
//#define USE_UART_PRINTF
#define USE_SYSLOG
#ifdef USE_UART_PRINTF
#ifdef USE_SYSLOG
#error "USE_UART_PRINTF and USE_SYSLOG defined simultaneously"
#endif
#endif
//#error test
#ifdef USE_SYSLOG
#ifdef NO_WIFI
#undef USE_SYSLOG
#error "USE_SYSLOG defined with NO_WIFI"
#endif
#endif
#ifdef USE_UART_PRINTF
#define PRINTF(n, a...) printf(n, ## a)
#elif defined USE_SYSLOG
#define PRINTF(n, a...) printf(n, ## a)
#else
#define PRINTF(n, a...)
#endif
#ifndef NO_WIFI
// #define USE_WIFI_PRINTF
#endif
//#define USE_UART_PRINTF
//#else
//
// #define NO_EXTERNAL_UART
//#endif
//#define CONNECT_DEVICE_TO_NETWORK
//#define TERMINAL_USE_TELNET
//#define TERMINAL_USE_TCP_SERVER
/* ************************************************************************** */
/* Type definitions */
//----- STDINT.H TYPE DEFINITIONS -----
//(Valid for XC16 & XC32 microchip PIC compilers)
#ifndef uint8_t
typedef unsigned char uint8_t;
#endif
#ifndef int8_t
typedef signed char int8_t;
#endif
#ifndef uint16_t
typedef unsigned short uint16_t;
#endif
#ifndef int16_t
typedef signed short int16_t;
#endif
/*
#ifndef uint32_t
typedef unsigned long uint32_t;
#endif
#ifndef int32_t
typedef signed long int32_t;
#endif
*/
#ifndef uint64_t
typedef unsigned long long uint64_t;
#endif
#ifndef int64_t
typedef signed long long int64_t;
#endif
#endif
//EOF