📄 main.c
字号:
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0x8E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3E,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x08,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xFC,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x23,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x70,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xE1,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xC3,0xC0,0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,
0x00,0xC1,0x8F,0xF0,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,
0x01,0xF0,0x3F,0xC0,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,
0x03,0xF8,0x1F,0x80,0x70,0x00,0x0e,0x00,0xf0,0x0f,0x80,0xe0,0x0f,0x07,0x83,0xc0,
0x0f,0xf1,0x0c,0x01,0xfc,0xf6,0x3f,0x03,0xf8,0x3f,0xc3,0xf8,0x3f,0x87,0x8f,0xe0,
0x1f,0xc7,0xc0,0x01,0xfc,0xfc,0xff,0xc7,0xfc,0x7f,0xe7,0xfc,0x7f,0xcf,0x1f,0xf0,
0x0e,0x0f,0xe0,0x01,0xfc,0xfc,0xe3,0xcf,0x1c,0x71,0xcf,0x9e,0xf3,0xcf,0x3c,0xf0,
0x00,0x3f,0xc0,0x00,0xf1,0xf1,0xc1,0xce,0x0c,0xf0,0x1f,0x0c,0xf0,0xcf,0x78,0x78,
0x00,0x7f,0x00,0x00,0xf1,0xe3,0xff,0xdf,0xfe,0xfc,0x1e,0x00,0x1f,0xcf,0x7f,0xf8,
0x00,0x1c,0x00,0x00,0xf1,0xe3,0xff,0xdf,0xfe,0xff,0xde,0x00,0x7f,0x8f,0x7f,0xf8,
0x0f,0x00,0x00,0x00,0xf3,0xe3,0xff,0xdf,0xfe,0x3f,0xde,0x00,0xfb,0x8f,0x7f,0xf8,
0x1f,0xc0,0x00,0x01,0xe3,0xc3,0xc0,0x1c,0x00,0x03,0xde,0x11,0xc3,0x9e,0x70,0x00,
0x3f,0x80,0x00,0x01,0xe3,0xc3,0xc3,0xdc,0x3c,0xc3,0xde,0x3b,0xc7,0x9e,0x70,0xf0,
0xff,0x00,0x00,0x01,0xe3,0xc1,0xff,0x9f,0xfd,0xff,0x9f,0xfb,0xff,0x9e,0x7f,0xe0,
0x3c,0x00,0x00,0x01,0xe3,0xc1,0xff,0x0f,0xf1,0xff,0x8f,0xf3,0xfb,0x9e,0x3f,0xc0,
0x00,0x00,0x00,0x01,0xe3,0xc0,0xfc,0x07,0xe0,0xfe,0x07,0xc0,0xf3,0x9e,0x0f,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
const uchar CodeWarrior[1024] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xC0,0x00,0x77,0x08,0x00,0x01,0xC2,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xC0,0x00,0x77,0x38,0x00,0x01,0xCE,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xC0,0x00,0x07,0x38,0x00,0x00,0x0E,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xDC,0xE7,0x77,0x7C,0x39,0xCF,0xDF,0x77,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFE,0xE7,0x77,0x7C,0x19,0xCD,0xDF,0x7F,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xCE,0xE7,0x77,0x38,0x1D,0xDD,0xCE,0x73,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xCE,0xE7,0x77,0x38,0x1D,0x5D,0xCE,0x73,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xCE,0xE7,0x77,0x38,0x0F,0x79,0xCE,0x73,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFE,0xFF,0x77,0x3E,0x0E,0x39,0xCF,0xF3,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xDC,0x77,0x77,0x1E,0x0E,0x39,0xC7,0xF3,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0x00,0x00,0x03,0x80,0x07,0x87,0x87,0x00,0x00,0x00,0x38,0x00,0x00,0x00,
0x00,0x7F,0xC0,0x00,0x03,0x80,0x07,0x87,0x87,0x00,0x00,0x00,0x38,0x00,0x00,0x00,
0x00,0xFF,0xC0,0x00,0x03,0x80,0x03,0x87,0x86,0x00,0x00,0x00,0x38,0x00,0x00,0x00,
0x00,0xF1,0xE0,0x00,0x03,0x80,0x03,0x8F,0x8E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0xE1,0xE0,0x7B,0x87,0xC3,0xCF,0xCE,0x3F,0x0E,0xDD,0xB8,0x78,0x76,0x00,
0x01,0xE0,0xE7,0xF8,0xFF,0x9F,0xF3,0xCD,0xCE,0x7F,0x8F,0xDF,0xB9,0xFE,0x7E,0x00,
0x01,0xE0,0x07,0x39,0xE3,0x9C,0x71,0xCD,0xCC,0xE1,0xCF,0xDF,0xB9,0xCE,0x7E,0x00,
0x01,0xE0,0x0F,0x3D,0xE3,0xBC,0x39,0xDD,0xDC,0x01,0xCF,0x1E,0x3B,0xCF,0x78,0x00,
0x01,0xE0,0xEF,0x3D,0xE3,0xBF,0xF9,0xFD,0xFC,0x3F,0xCE,0x1C,0x3B,0xCF,0x70,0x00,
0x01,0xE0,0xEF,0x3D,0xE3,0xBF,0xF8,0xF8,0xF8,0xF9,0xCE,0x1C,0x3B,0xCF,0x70,0x00,
0x00,0xF1,0xEF,0x3D,0xE3,0xBC,0x00,0xF8,0xF8,0xE1,0xCE,0x1C,0x3B,0xCF,0x70,0x00,
0x00,0xFF,0xC7,0x39,0xF3,0x9C,0x38,0xF8,0xF8,0xE3,0xCE,0x1C,0x39,0xCE,0x77,0xF0,
0x00,0x7F,0x87,0xF8,0xFF,0x9E,0x70,0xF8,0x78,0xFF,0xCE,0x1C,0x39,0xFE,0x72,0xF0,
0x00,0x1F,0x01,0xE0,0x7B,0x87,0xC0,0x70,0x70,0x7D,0xCE,0x1C,0x38,0x78,0x72,0xD0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/*************************************************************************************/
static void PWMSetup(void)
{
/* Variable Declarations */
/* Begin Function PWMSetup() */
RegBase->PWMPOL = 0xff; /* output is high at the beginning of the period */
RegBase->PWMCLK = 0xff; /* use scaled clock A & B for all channels */
RegBase->PWMPRCLK = 0x22; /* /4 for clocks A & B */
RegBase->PWMSCLA = 100; /* prescaler * (PWMSCLA * 2) == 50000Hz clock into the PWM counter register */
RegBase->PWMSCLB = 100; /* prescaler * (PWMSCLB * 2) == 50000Hz clock into the PWM counter register */
RegBase->PWMPER0 = 200; /* period count of 200 allows 0.5% duty cycle control */
RegBase->PWMPER1 = 200;
RegBase->PWMPER2 = 200; /* period count of 200 allows 0.5% duty cycle control */
RegBase->PWMPER3 = 200; /* period count of 200 allows 0.5% duty cycle control */
RegBase->PWMPER4 = 200; /* period count of 200 allows 0.5% duty cycle control */
RegBase->PWMPER5 = 200; /* period count of 200 allows 0.5% duty cycle control */
RegBase->PWMPER6 = 200; /* period count of 200 allows 0.5% duty cycle control */
RegBase->PWMPER7 = 200; /* period count of 200 allows 0.5% duty cycle control */
RegBase->PWMDTY0 = 100; /* set to 50% duty cycle */
RegBase->PWMDTY1 = 100;
RegBase->PWMDTY2 = 100;
RegBase->PWMDTY3 = 100;
RegBase->PWMDTY4 = 100;
RegBase->PWMDTY5 = 100;
RegBase->PWMDTY6 = 100;
RegBase->PWMDTY7 = 100;
RegBase->PWME = 0xf0; /* enable PWM Ch. 0 - 7 */
} /* end PWMSetup */
/*************************************************************************************/
static void TimerSetup(void)
{
/* Variable Declarations */
/* Begin Function TimerSetup() */
RegBase->TIOS = 0x03; /* configure TC0 & TC1 as an output compare */
RegBase->TSCR1 = 0xB0; /* enable timer, freeze in BDM, fast flag clearing */
RegBase->TSCR2 = 0x03; /* prescaler :8 -> one tick is 200nS */
} /* end TimerSetup */
/*************************************************************************************/
static void VFDSetup(void)
{
/* Variable Declarations */
/* Begin Function VFDSetup() */
RegBase->PORTT = 0x02; /* initial value of BLK1 = 0, BLK2 = 1, LAT1/2/GLAT = 0, GBLK = 0 */
RegBase->DDRT = 0x0f; /* PortT pins 0 - 3 are outputs to the VF display */
RegBase->PORTB |= 0x03; /* PB0 = 1 (off, controls VFD 5V switcher), PB1 = 1 (off, controls VFD 55V switcher), PB2 = 0 (off, controls VFD filament supply) */
RegBase->DDRB |= 0x07; /* make all 3 pins outputs */
RegBase->PORTT |= 0xf0; /* GDIC reset lines & chip selects initially at 1 */
RegBase->DDRT |= 0xf0; /* make PT4 - PT7 outputs */
GridData[7] = 0x01; /* initial VFD grid data is 0x8000000000000001 */
GridData[0] = 0x80;
RegBase->MODRR = 0x60; /* route SPI1 & SPI2 to PortH */
RegBase->PORTB &= ~0x01; /* turn on switched 5V supply */
Delay_mSec(100); /* wait 100 mS for switched 5V to ramp up */
RegBase->PORTB |= 0x04; /* turn on VFD filament supply */
Delay_mSec(300); /* wait 300 mS for filament supply to ramp up */
RegBase->PORTB &= ~0x02; /* turn on VFD HV supply */
Delay_mSec(300); /* wait 300 mS for HV supply to ramp up */
SwLEDData.CurState = 0x00; /* assume no switches are pressed */
RegBase->ATD1DIEN1 = 0xff; /* enable A/D channels 8 - 15 as digital inputs */
RegBase->PORTS = 0x80; /* for testing */
RegBase->DDRS = 0x80;
} /* end VFDSetup */
/*************************************************************************************/
static void SPI1Setup(void)
{
/* Variable Declarations */
/* Begin Function SPI1Setup() */
RegBase->SPI1.BR = 0x41; /* setup for a 2 MHz SPI bus */
RegBase->SPI1.CR1 = 0x5c; /* SPE = 1; MSTR = 1; CPOL = 1; CPHA = 1 */
} /* end SPI1Setup */
/*************************************************************************************/
static void SPI0Setup(void)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -