📄 my_init.c
字号:
/**************** (c) 1998 STMicroelectronics **********************
PROJECT : USB - ST7
COMPILER : ST7 HICROSS C (HIWARE)
MODULE : my_init.c
VERSION : V 1.0
CREATION DATE : 25/05/98
AUTHOR : / MICROCONTROLLER DIVISION / ST Rousset
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
DESCRIPTION : ST7263 USB Application initialization.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
MODIFICATIONS :
******************************************************************************/
#include "usr_var.h"
#include "map_7263.h"
#include "usb_ail.h"
#include "my_init.h"
#include "sci_drv.h"
#include "userio.h"
#include "lib_bits.h"
/*-----------------------------------------------------------------------------
ROUTINE NAME : Register_Init
INPUT/OUTPUT : None
DESCRIPTION : Port initialization
-----------------------------------------------------------------------------*/
void Register_Init(void)
{
// ADCCSR = 0x20; // A/D converter is switched on and conversion is on pin 0
TIMCR2 = 0x09; // Set the Counter to increment in every 8 clocks
TIMCR1 |= 0x20; // Set the timer overflow interrupt enable
ITRFRE |= 0x02; // Enable IT2
SCICR1 = 0; /* Force reset status of the control register 1.*/
SCICR2 = 0; /* Force reset status of the control register 2.*/
asm TNZ SCISR; /* Touch registers to remove pending interrupts.*/
asm TNZ SCIDR;
SCIBRR = NOT_FIRST_PAD_SPEED; /* Set selected data receive & transmit SCI speed.*/
SCICR1 = CR1_MODE; /* Set selected mode of control register 1.*/
SCICR2 = CR2_RX_INT;
}
/*-----------------------------------------------------------------------------
ROUTINE NAME : PortInit
INPUT/OUTPUT : None
DESCRIPTION : Port initialization
-----------------------------------------------------------------------------*/
void PortInit(void)
{
PADDR = 0x06; // Port A in input state, pin 1,2 in output 0X07-------0X06 OUTPUT ----INPUT
PBDDR = 0x60; // Port B in input state, pin 5,6, in output state
//PCDDR = 0x04; // Port C in input state, pin 2 in output state
PCDDR = 0x06; // Port C in input state, pin 2 in output state (1-11-00 0x04 to pc2)
PBDR &= 0x0f;
//PADR |= 0x01; // HC126 control C 0 to 1; 2-25-00
//PADR |= 0x00; // Switch off Mode LED and Autofire LED
//for (delay=0; delay<1000 ; delay++);
//PADR &= 0xfe; // HC126 control C 1 to 0;
}
/*-----------------------------------------------------------------------------
ROUTINE NAME : Var_Init
INPUT/OUTPUT : None
DESCRIPTION : Port initialization
-----------------------------------------------------------------------------*/
void Var_Init(void)
{
AutofireState1=0;
AutofireState2=0;
ADCsel=0;
PadTotal=1;
RT5s=200;
PadID=0;
Timer=0;
MidiCmdFlag=0;
ControllerID=0;
Toggle=0;
MidiTimeOut=0;
RTPRO=0;
}
/*-----------------------------------------------------------------------------
ROUTINE NAME : TEST
INPUT/OUTPUT : None
DESCRIPTION : Port initialization
-----------------------------------------------------------------------------*/
//void TEST(void)
//{
/*
// 7-segment test
PBDR |= 0xf0; // Set all output pins to 1
PBDR &= 0xef; // and pin 4 to 0
while ((PADR & 0xd0)==0)
{
ClrBit(PCDR,2);
PBDR |= 0x20;
SetBit(PCDR,2);
for (BitCount=0; BitCount<7 ; BitCount++)
{ for(delay=0; delay<60000; delay++);
ClrBit(PCDR,2);
PBDR &= 0xdf; // set DATA A to 0;
SetBit(PCDR,2);
}
ModeLED(AutofireLEDstate);
AutofireLED(!AutofireLEDstate);
for(delay=0; delay<60000; delay++);
}
// Special feature
PBDR |= 0xf0; // Set all output pins to 1
PBDR &= 0x7f; // and pin 4 to 0
while ((PADR & 0xc0)==0)
{
ModeLED(1);
AutofireLED(1);
SevenLED(0);
for (delay=0; delay<60000 ; delay++);
for (delay=0; delay<60000 ; delay++)
{
ModeLED(!ModeLEDstate);
AutofireLED(!AutofireLEDstate);
}
}
*/
//}
/*-----------------------------------------------------------------------------
ROUTINE NAME : My_Init
INPUT/OUTPUT : None
DESCRIPTION : Initialization
-----------------------------------------------------------------------------*/
void My_Init(void)
{
PortInit();
//SevenLED(0);
for (ADCsel=0; ADCsel<4 ; ADCsel++)
{
ADCCSR = 0x20+ADCsel;
for (delay=0; delay<30000 ; delay++);
if ((ADCCSR & COCO) == END_CONVERSION ) // Conversion complete
AXIS[ADCsel].Initial = ADCDR;
}
//TEST();
// ModeLED(0);
AutofireLED(0);
Var_Init();
Register_Init();
//SevenLED(Character[0]);
/********************************************/
/* User variable initialisation */
/********************************************/
bmRequest = 0;
bmCopyRequest = 0;
// Pressed = 0;
UsbCounter = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -