/**************************************************
*FILENAME:8SEG.C
*
*
*
*
***************************************************/
#define SEGMENT_A 0x01 // Bitmaps for 7-segment
#define SEGMENT_B 0x02
#define SEGMENT_C 0x04
#define SEGMENT_D 0x08
#define SEGMENT_DP 0x10
#define SEGMENT_E 0x20
#define SEGMENT_F 0x40
#define SEGMENT_G 0x80
#define SYS_BASE 0x03ff0000
#define SRAM_BASE 0x03fe0000
#define IO_BASE 0x03600000
#define IO_BANK0 (*(volatile unsigned int *)(IO_BASE + 0x0000))
#define IO_BANK1 (*(volatile unsigned int *)(IO_BASE + 0x4000))
#define IO_BANK2 (IO_BASE + 0x8000)
#define IO_BANK3 (IO_BASE + 0xc000)
#define NONCACHEABLE_BASE 0x04000000
/*
#define DIGIT_F ((SEGMENT_A | SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_E | SEGMENT_F) << 24)
#define DIGIT_E ((SEGMENT_B | SEGMENT_C) << 24)
#define DIGIT_D ((SEGMENT_A | SEGMENT_B | SEGMENT_G | SEGMENT_E | SEGMENT_D) << 24)
#define DIGIT_C ((SEGMENT_A | SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_G) << 24)
#define DIGIT_B ((SEGMENT_F | SEGMENT_G | SEGMENT_B | SEGMENT_C) << 24)
#define DIGIT_A ((SEGMENT_A | SEGMENT_F | SEGMENT_G | SEGMENT_C | SEGMENT_D) << 24)
#define DIGIT_9 ((SEGMENT_A | SEGMENT_F | SEGMENT_E | SEGMENT_D | SEGMENT_C | SEGMENT_G) << 24)
#define DIGIT_8 ((SEGMENT_A | SEGMENT_B | SEGMENT_C) << 24)
#define DIGIT_7 ((SEGMENT_A | SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_E | SEGMENT_F | SEGMENT_G) << 24)
#define DIGIT_6 ((SEGMENT_G | SEGMENT_F | SEGMENT_A | SEGMENT_B | SEGMENT_C) << 24)
#define DIGIT_5 ((SEGMENT_E | SEGMENT_F | SEGMENT_A | SEGMENT_B | SEGMENT_C | SEGMENT_G) << 24)
#define DIGIT_4 ((SEGMENT_F | SEGMENT_E | SEGMENT_D | SEGMENT_C | SEGMENT_G) << 24)
#define DIGIT_3 ((SEGMENT_A | SEGMENT_F | SEGMENT_E | SEGMENT_D) << 24)
#define DIGIT_2 ((SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_E | SEGMENT_G) << 24)
#define DIGIT_1 ((SEGMENT_A | SEGMENT_F | SEGMENT_E | SEGMENT_D | SEGMENT_G) << 24)
#define DIGIT_0 ((SEGMENT_A | SEGMENT_F | SEGMENT_E | SEGMENT_G) << 24)
*/
#define DIGIT_F ((SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_DP)<<24)
#define DIGIT_E ((SEGMENT_B | SEGMENT_C | SEGMENT_DP) <<24)
#define DIGIT_D ((SEGMENT_A | SEGMENT_F | SEGMENT_DP)<<24)
#define DIGIT_C ((SEGMENT_B | SEGMENT_C | SEGMENT_G | SEGMENT_DP)<<24)
#define DIGIT_B ((SEGMENT_A | SEGMENT_B | SEGMENT_DP) <<24)
#define DIGIT_A ((SEGMENT_D | SEGMENT_DP) << 24)
#define DIGIT_9 ((SEGMENT_E | SEGMENT_DP) <<24)
#define DIGIT_8 ((SEGMENT_DP) <<24)
#define DIGIT_7 ((SEGMENT_D | SEGMENT_E | SEGMENT_F | SEGMENT_G | SEGMENT_DP) <<24)
#define DIGIT_6 ((SEGMENT_B | SEGMENT_DP) <<24)
#define DIGIT_5 ((SEGMENT_E | SEGMENT_B | SEGMENT_DP) <<24)
#define DIGIT_4 ((SEGMENT_A | SEGMENT_E | SEGMENT_D | SEGMENT_DP) <<24)
#define DIGIT_3 ((SEGMENT_F | SEGMENT_E | SEGMENT_DP)<<24)
#define DIGIT_2 ((SEGMENT_C | SEGMENT_F | SEGMENT_DP) <<24)
#define DIGIT_1 ((SEGMENT_A | SEGMENT_F | SEGMENT_E | SEGMENT_D | SEGMENT_G | SEGMENT_DP) <<24)
#define DIGIT_0 ((SEGMENT_G | SEGMENT_DP)<<24 )
void Set8Led(int n)
{
unsigned int ctrl [] =
{ DIGIT_0, DIGIT_1, DIGIT_2, DIGIT_3, DIGIT_4, DIGIT_5, DIGIT_6, DIGIT_7,
DIGIT_8, DIGIT_9, DIGIT_A, DIGIT_B, DIGIT_C, DIGIT_D, DIGIT_E, DIGIT_F };
if( (0<=n) && (n<(sizeof(ctrl)/sizeof(unsigned char))) )
{
// IO_BANK0 = ~ctrl[n];
IO_BANK0 = ctrl[n];
}
// IO_BANK0 = ctrl[0];
}