📄 bsp.h
字号:
#ifndef __BSP_H__
#define __BSP_H__
#include "plibdefs_mmc2107.h"
#include "itcn_b.h"
#include "core_b.h"
#include "pll_b.h"
#include "watchdog_a.h"
#include "pit_b.h"
#include "sci_d.h"
#include "tim_a.h"
/* --- CS --- */
/* CS variables */
#define CS_CSCR0 0x1303
#define CS_CSCR3 0x1303
/* --- PLL --- */
#define SYSTEM_CLOCK (CRYSTAL_FREQ*(PLL_MFD+2)/(1<<PLL_RFD))/* Calculation of System Clock */
/* out of PLL devider fields */
#define uSEC(uS) (uS*SYSTEM_CLOCK/1000000) /* uS micro seconds in terms of system clocks */
#define mSEC(mS) (mS*SYSTEM_CLOCK/1000 ) /* mS micro seconds in terms of system clocks */
/* PLL variables */
#define CRYSTAL_FREQ 8000000 /* Quartz (FPX 8.00) frequency 8MHz */
#define PLL_B_WAIT_TIME 0x1000 /* Delay time to wait for phase lock */
#define PLL_MFD PLL_B_VCO_X_4 /* Multiplication Factor Divider of PLL ( SYNCR[14:12] ) */
#define PLL_RFD PLL_B_VCO_DIV_1 /* Reduced Frequency Divider of PLL ( SYNCR[10: 8] ) */
/* --- SCI --- */
/* SCI variables */
#define SCI_BAUDRATE (SYSTEM_CLOCK/(16 * SCIBD))
#define SCI1_BAUDRATE /* SCI 1 baudrate, used by Picobug monitor */
#define SCI2_BAUDRATE 19200 /* SCI 2 baudrate, used by Operating System Tick */
/* --- TIM --- */
#define TIM_CLOCK(tim_prescaler) (SYSTEM_CLOCK / (1<<tim_prescaler)) /* Calculation of PIT Clock */
#define PWM_CLOCK(tim_pre) (TIM_CLOCK( tim_pre ) / TIM_A_MAX_COMPARE_VALUE) /* Number of PWM periods per sec */
/* TIM variables */
#define TIM1_PRE TIM_A_SCALAR_00 /* TIM 1 prescaler (TIM 1 TIMSCR2[2:0]) */
#define TIM2_PRE TIM_A_SCALAR_00 /* TIM 2 prescaler (TIM 2 TIMSCR2[2:0]) */
/* --- PIT --- */
#define PIT_CLOCK(pit_prescaler) (SYSTEM_CLOCK / (1<<pit_prescaler)) /* Calculation of PIT Clock*/
#define PITuSEC(uS, pit_pre) (uS*PIT_CLOCK(pit_pre)/1000000)
#define PITmSEC(mS, pit_pre) (mS*PIT_CLOCK(pit_pre)/1000 )
/* PIT variables */
#define PIT1_PRE PIT_B_SCALAR_00 /* PIT 1 prescaler (PIT 1 PCSR[11:8]) */
#define PIT2_PRE PIT_B_SCALAR_00 /* PIT 2 prescaler (PIT 2 PCSR[11:8]) */
#define PIT1_MODULUS PITmSEC(1, PIT1_PRE) /* First argument is a value in */
#define PIT2_MODULUS PITmSEC(0, PIT2_PRE) /* ... micro or milli-seconds */
/* --- ITCN --- */
/* ITCN variables */
#define ITCN_B_HIGHEST_INTERRUPT_PRIORITY_LEVEL 31
/* common macro to handle error checking and response */
#define HANDLE_ERROR(err) if (err != SCI_D_ERR_NONE) return(__LINE__);
#endif __BSP_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -