📄 const.c
字号:
/*******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2002 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
* $Element: /project/dsp568_sdk/sdk/src/dsp56838evm/nos/config/const.c $
* $Author: saa $
* $Revision: /main/2 $
* $VOB: /project/dsp568_sdk $
* $OS: solaris $
*
* Description: SDK configurable constant in Data Flash
*
* Notes:
*
******************************************************************************/
/* general header files */
#include "port.h"
#include "arch.h"
#include "bsp.h"
#include "io.h"
/* driver dependent header files */
#include "pll.h"
#include "evmdrv.h"
#include "timerdrv.h"
#include "gpiodrv.h"
#include "scidrv.h"
#if defined(DSP56838EVM)
#include "mscan.h"
#else /* defined(DSP56838EVM) */
#include "flexcan.h"
#endif /* defined(DSP56838EVM) */
#include "flashdrv.h"
#include "arch_off.h"
//#define ArchSetTimer( tmr, chnl ) extern void SDK_stb(void)
#define ArchQuadCallBackOnCpmpare(tmr, chnl, CallBack ) extern void SDK_stb(void)
#define ArchQuadCallBackOnOverflow(tmr, chnl, CallBack ) extern void SDK_stb(void)
#define ArchQuadCallBackOnInputEdge(tmr, chnl, CallBack ) extern void SDK_stb(void)
#define ArchInstallCallback(device, type, CallBack ) extern void SDK_stb(void)
#define ArchInstall2CallBackISR(device,num, type1, type2, CallBack, prio ) extern void SDK_stb(void)
#define ArchInstall4CallBackISR(device,num, type1, type2, type3, type4, CallBack, prio ) extern void SDK_stb(void)
#define ArchInstallCallBackISR(device,num, type, CallBack, prio ) extern void SDK_stb(void)
#define ArchParameter(...) extern void SDK_stb(void)
/* include user and default configuration */
#include "config.h"
/*************************************STUB**************************************************/
void Sci0Tx_DispatchCallback(void);
void Sci0Tx_DispatchCallback(void){};
void Sci1Tx_DispatchCallback(void);
void Sci1Tx_DispatchCallback(void){};
void Sci0Rx_DispatchCallback(void);
void Sci0Rx_DispatchCallback(void){};
void Sci1Rx_DispatchCallback(void);
void Sci1Rx_DispatchCallback(void){};
void Spi0Rx_DispatchCallback(void);
void Spi0Rx_DispatchCallback(void){};
void Spi1Rx_DispatchCallback(void);
void Spi1Rx_DispatchCallback(void){};
void Spi0Tx_DispatchCallback(void);
void Spi0Tx_DispatchCallback(void){};
void Spi1Tx_DispatchCallback(void);
void Spi1Tx_DispatchCallback(void){};
void ButtonAany_DispatchCallback(void);
void ButtonAany_DispatchCallback(void){};
void ButtonBany_DispatchCallback(void);
void ButtonBany_DispatchCallback(void){};
void Decoder0HomeWatchdog_DispatchCallback(void);
void Decoder0HomeWatchdog_DispatchCallback(void){};
void Decoder0Index_DispatchCallback(void);
void Decoder0Index_DispatchCallback(void){};
void PwmAReload_DispatchCallback(void);
void PwmAReload_DispatchCallback(void){};
void PwmBReload_DispatchCallback(void);
void PwmBReload_DispatchCallback(void){};
void PwmAFault_DispatchCallback(void);
void PwmAFault_DispatchCallback(void){};
void PwmBFault_DispatchCallback(void);
void PwmBFault_DispatchCallback(void){};
void AdcAComplete_DispatchCallback(void);
void AdcAComplete_DispatchCallback(void){};
void AdcBComplete_DispatchCallback(void);
void AdcBComplete_DispatchCallback(void){};
void AdcAZeroCrossing_DispatchCallback(void);
void AdcAZeroCrossing_DispatchCallback(void){};
void AdcBZeroCrossing_DispatchCallback(void);
void AdcBZeroCrossing_DispatchCallback(void){};
void AdcALowLimit_DispatchCallback(void);
void AdcALowLimit_DispatchCallback(void){};
void AdcBLowLimit_DispatchCallback(void);
void AdcBLowLimit_DispatchCallback(void){};
void AdcAHighLimit_DispatchCallback(void);
void AdcAHighLimit_DispatchCallback(void){};
void AdcBHighLimit_DispatchCallback(void);
void AdcBHighLimit_DispatchCallback(void){};
/*****************************************************************************/
#if defined( INCLUDE_TIMER )
/* reserve POSIX timer context */
posix_tContext posix_ctx_A_0;
posix_tContext posix_ctx_A_1;
posix_tContext posix_ctx_A_2;
posix_tContext posix_ctx_A_3;
posix_tContext posix_ctx_B_0;
posix_tContext posix_ctx_B_1;
posix_tContext posix_ctx_B_2;
posix_tContext posix_ctx_B_3;
posix_tContext posix_ctx_C_0;
posix_tContext posix_ctx_C_1;
posix_tContext posix_ctx_C_2;
posix_tContext posix_ctx_C_3;
posix_tContext posix_ctx_D_0;
posix_tContext posix_ctx_D_1;
posix_tContext posix_ctx_D_2;
posix_tContext posix_ctx_D_3;
/* POSIX timer configuration table */
const posix_tConfig posixDeviceMap[] =
{
/**** Timer A ****/
{ &ArchIO.TimerA.Channel0, &posix_ctx_A_0 },
{ &ArchIO.TimerA.Channel1, &posix_ctx_A_1 },
{ &ArchIO.TimerA.Channel2, &posix_ctx_A_2 },
{ &ArchIO.TimerA.Channel3, &posix_ctx_A_3 },
/**** Timer B ****/
#if !defined(DSP56838EVM)
{ &ArchIO.TimerB.Channel0, &posix_ctx_B_0 },
{ &ArchIO.TimerB.Channel1, &posix_ctx_B_1 },
{ &ArchIO.TimerB.Channel2, &posix_ctx_B_2 },
{ &ArchIO.TimerB.Channel3, &posix_ctx_B_3 },
#endif /* !defined(DSP56838EVM) */
/**** Timer C ****/
{ &ArchIO.TimerC.Channel0, &posix_ctx_C_0 },
{ &ArchIO.TimerC.Channel1, &posix_ctx_C_1 },
{ &ArchIO.TimerC.Channel2, &posix_ctx_C_2 },
{ &ArchIO.TimerC.Channel3, &posix_ctx_C_3 },
/**** Timer D ****/
{ &ArchIO.TimerD.Channel0, &posix_ctx_D_0 },
{ &ArchIO.TimerD.Channel1, &posix_ctx_D_1 },
{ &ArchIO.TimerD.Channel2, &posix_ctx_D_2 },
{ &ArchIO.TimerD.Channel3, &posix_ctx_D_3 },
{0,0}
};
const arch_sTimerChannel * realTimer =
#if defined( SET_REAL_TIMER )
SET_REAL_TIMER;
#else
(&ArchIO.TimerA.Channel0);
#endif
/* protected constants */
/* work frequency*/
const UWord32 IP_BUS_FREQUENCY = BSP_OSCILLATOR_FREQ * PLL_MUL / 2 / 2;
/* IP_BUS_FREQUENCY = IP_BUS_FREQUENCY_1 * IP_BUS_FREQUENCY_2 */
const UWord32 IP_BUS_FREQUENCY_1 = BSP_OSCILLATOR_FREQ * PLL_MUL / 2 / 2 / 10000;/**/
const UWord32 IP_BUS_FREQUENCY_2 = 10000;
/* translate real time timer tick resolution to ns resolution => tick * 10^9 / IP_BUS_FREQUENCY =tick * (10^5 / IP_BUS_FREQUENCY_1) = (tick * 10^2 / (IP_BUS_FREQUENCY_1 / 10^3)) */
const UWord32 REAL_TIME_TIMER_RESOLUTION = REAL_TICK_TIMER_RESOLUTION * 100UL / (IP_BUS_FREQUENCY_1/1000UL);
/* const UWord32 REAL_TIME_TIMER_RESOLUTION = REAL_TICK_TIMER_RESOLUTION * (BSP_OSCILLATOR_FREQ / 1000000UL) * PLL_MUL / 2 / 2 / 1000UL; Wrong!*/
#if (REAL_TICK_TIMER_RESOLUTION <= 0xFFFF)
const UWord16 REAL_TIME_TIMER_STEP = REAL_TICK_TIMER_RESOLUTION;
const UWord16 REAL_TIME_TIMER_PRESCALER = 1;
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x1FFFE )
const UWord16 REAL_TIME_TIMER_STEP = REAL_TICK_TIMER_RESOLUTION << 1;
const UWord16 REAL_TIME_TIMER_PRESCALER = 2;
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x3FFFC )
const UWord16 REAL_TIME_TIMER_STEP = REAL_TICK_TIMER_RESOLUTION << 2;
const UWord16 REAL_TIME_TIMER_PRESCALER = 4;
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x7FFF8 )
const UWord16 REAL_TIME_TIMER_STEP = REAL_TICK_TIMER_RESOLUTION << 3;
const UWord16 REAL_TIME_TIMER_PRESCALER = 8;
#elif (REAL_TICK_TIMER_RESOLUTION <= 0xFFFF0 )
const UWord16 REAL_TIME_TIMER_STEP = REAL_TICK_TIMER_RESOLUTION << 4;
const UWord16 REAL_TIME_TIMER_PRESCALER = 16;
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x1FFFE0 )
const UWord16 REAL_TIME_TIMER_STEP = REAL_TICK_TIMER_RESOLUTION << 5;
const UWord16 REAL_TIME_TIMER_PRESCALER = 32;
,
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x3FFFC0 )
const UWord16 REAL_TIME_TIMER_STEP = REAL_TICK_TIMER_RESOLUTION << 6;
const UWord16 REAL_TIME_TIMER_PRESCALER = 64;
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x7FFF80 )
const UWord16 REAL_TIME_TIMER_STEP = REAL_TICK_TIMER_RESOLUTION << 7;
const UWord16 REAL_TIME_TIMER_PRESCALER = 128;
#endif
const union sigval sig = {0}; /* non OS version */
const qt_sQuadState timerStdFastStart =
{
/* Control Reg */
/* OutputMode :3*/ qtAssertWhileActive,
/* CoChannelInitialize :1*/ 0,
/* CountDirection :1*/ qtDown,
/* CountLength :1*/ qtUntilCompare,
/* CountOnce :1*/ qtRepeatedly,
/* SecondaryInputSource :2*/ 0,
#if (REAL_TICK_TIMER_RESOLUTION <= 0xFFFF)
/* InputSource 1 :4*/ qtPrescalerDiv1,
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x1FFFE )
/* InputSource 1 :4*/ qtPrescalerDiv2,
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x3FFFC )
/* InputSource 1 :4*/ qtPrescalerDiv4,
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x7FFF8 )
/* InputSource 1 :4*/ qtPrescalerDiv8,
#elif (REAL_TICK_TIMER_RESOLUTION <= 0xFFFF0 )
/* InputSource 1 :4*/ qtPrescalerDiv16,
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x1FFFE0 )
/* InputSource 1 :4*/ qtPrescalerDiv32,
,
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x3FFFC0 )
/* InputSource 1 :4*/ qtPrescalerDiv64,
#elif (REAL_TICK_TIMER_RESOLUTION <= 0x7FFF80 )
/* InputSource 1 :4*/ qtPrescalerDiv128,
#endif
/* Mode :3*/ qtCount,
/* status reg */
/* OutputEnable :1*/ 1,
/* OutputPolarity :1*/ qtNormal,
/* OutputOnMaster :1*/ 0,
/* Master :1*/ 0,
/* CaptureMode :2*/ qtDisabled,
/* InputPolarity :1*/ qtNormal,
};
/*****************************************************************************/
#endif /* INCLUDE_TIMER */
#if defined( INCLUDE_LED )
typedef UWord16(*ioctl_type)(handle_t , unsigned long params );
const io_sLEDInterface led_io = {no_read, ledWrite, no_close,
{ ledIoctlLED_ON, ledIoctlLED_OFF, ledIoctlLED_TOGGLE , (ioctl_type)no_ioctl}};
const io_sLEDInterface led_io_general = {no_read, ledBarWrite, no_close,
{ ledIoctlGLED_ON, ledIoctlGLED_OFF, ledIoctlGLED_TOGGLE,ledIoctlINVERT_DIRECTION}};
const io_sLEDInterface led_pwm_io = {no_read, ledPWMWrite, no_close,
{ledIoctlPWMLED_ON, ledIoctlPWMLED_OFF, (ioctl_type)no_ioctl , (ioctl_type)no_ioctl}};
const io_sLEDInterface led_pwm_io_general = {no_read, ledPWMBarWrite, no_close,
{ledIoctlPWMLED_ON, ledIoctlPWMLED_OFF, (ioctl_type)no_ioctl, ledPWMIoctlINVERT_DIRECTION }};
const led_Config ledPortMap[] =
{
{(io_sInterface*)&led_io_general, 0 },
#if defined(DSP56838EVM)
{(io_sInterface*)&led_io, &ArchIO.PortB,1<<1},
{(io_sInterface*)&led_io, &ArchIO.PortB,1<<2},
{(io_sInterface*)&led_io, &ArchIO.PortB,1<<3},
{(io_sInterface*)&led_io, &ArchIO.PortC,1<<1},
{(io_sInterface*)&led_io, &ArchIO.PortC,1<<2},
{(io_sInterface*)&led_io, &ArchIO.PortC,1<<3}
#elif defined (DSP56836EVM)
{(io_sInterface*)&led_io, &ArchIO.PortC,1<<0},
{(io_sInterface*)&led_io, &ArchIO.PortC,1<<1},
{(io_sInterface*)&led_io, &ArchIO.PortC,1<<2},
{(io_sInterface*)&led_io, &ArchIO.PortC,1<<3},
{(io_sInterface*)&led_io, &ArchIO.PortD,1<<6},
{(io_sInterface*)&led_io, &ArchIO.PortD,1<<7}
#elif defined (DSP56832XEVM)
#else /* EVM */
#error "platform is not defined"
#endif /* EVM */
};
const led_PWM_Config ledPWMMap[] =
{
{(io_sInterface*)&led_pwm_io_general, &ArchIO.PwmA,0},
{(io_sInterface*)&led_pwm_io, &ArchIO.PwmA,0x0001},
{(io_sInterface*)&led_pwm_io, &ArchIO.PwmA,0x0002},
{(io_sInterface*)&led_pwm_io, &ArchIO.PwmA,0x0004},
{(io_sInterface*)&led_pwm_io, &ArchIO.PwmA,0x0008},
{(io_sInterface*)&led_pwm_io, &ArchIO.PwmA,0x0010},
{(io_sInterface*)&led_pwm_io, &ArchIO.PwmA,0x0020},
};
const UWord16 sizeLedMap = sizeof(ledPortMap)/sizeof(ledPortMap[0]);
const UWord16 sizeLedPWMMap = sizeof(ledPWMMap)/sizeof(ledPWMMap[0]);
#endif /* INCLUDE_LED */
/******************************** ADC *****************************************************/
#if defined(INCLUDE_ADC)
#if defined(INCLUDE_IO)
const struct io_sAdcInterface adc_IO ={no_read , no_write , adcClose, ADC_IOCTL};
const struct io_sAdcInterface adc_PinBlockIO ={adcBlockRead , no_write , adcPinClose, NO_ADC_PIN_IOCTL};
const struct io_sAdcInterface adc_PinNonBlockIO ={adcNonBlockRead , no_write , adcPinClose, NO_ADC_PIN_IOCTL};
#else
const io_sInterface adc_IO ={noAdcBlockRead , noAdcBlockWrite , noAdcClose, noAdcIoctl};
const io_sInterface adc_PinBlockIO ={noAdcPinBlockRead , noAdcPinBlockWrite , noAdcPinClose, noAdcPinIoctl};
const io_sInterface adc_PinNonBlockIO ={noAdcPinNonBlockRead , noAdcPinNonBlockWrite , noAdcPinClose, noAdcPinIoctl};
#endif
struct sAdcDevice AdcADeviceContext=
{
(io_sInterface *)&adc_IO, /* IO interface */
archoff_AdcA, /* ADC arch */
0, /* nUsedSamples */
0, /* ZeroCrossing mask */
0, /* HL | LL mask */
/* queue*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -