//LED display matrix demo Main Program
#include "me32f103.h"
#include "me32f103_sys.h"
#include "me32f103_ioconfig.h"
#include "me32f103_led.h"
extern uint32_t PCLK;
//Main function entry
//a b c d e f g dp
//seg 0~7
// 0 1 2 3 4 5 6 7
8 9 dp
uint8_t led[11]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x80};
int main(void)
{
uint8_t graytemp=0;
uint8_t grayinc=1;
SYSCON->CLKBYPASSEN=3;
SystemCoreClockUpdate ();
//initial LED pin
PA9_INIT(PA9_LED_COM0);
PA10_INIT(PA10_LED_COM1);
PA11_INIT(PA11_LED_COM2);
PA12_INIT(PA12_LED_COM3);
// PB8_INIT(PB8_LED_COM4);
// PB9_INIT(PB9_LED_COM5);
// PC14_INIT(PC14_LED_COM6);
// PC15_INIT(PC15_LED_COM7);
PB3_INIT(PB3_LED_SEG0);
PB4_INIT(PB4_LED_SEG1);
PB5_INIT(PB5_LED_SEG2);
PB6_INIT(PB6_LED_SEG3);
PA4_INIT(PA4_LED_SEG4);
PA5_INIT(PA5_LED_SEG5);
PA6_INIT(PA6_LED_SEG6);
PA7_INIT(PA7_LED_SEG7);
// PB15_INIT(PB15_LED_COMSEG8);
// PB14_INIT(PB14_LED_COMSEG9);
// PB13_INIT(PB13_LED_COMSEG10);
// PB12_INIT(PB12_LED_COMSEG11);
// PD2_INIT(PD2_LED_COMSEG12);
// PC12_INIT(PC12_LED_COMSEG13);
// PC11_INIT(PC11_LED_COMSEG14);
// PC10_INIT(PC10_LED_COMSEG15);
LED_Init (COM0_3,CATHODE,0);
while(1)
{
if (grayinc)
graytemp++;
else
graytemp--;
if (graytemp==0xFF)
grayinc=0;
if (graytemp==0)
grayinc=1;
LED_Fill(COM3,led[0],graytemp);
LED_Fill(COM2,led[1],graytemp);
LED_Fill(COM1,led[2],graytemp);
LED_Fill(COM0,led[3],graytemp);
SYS_Delay(0x3fff);
}
}