牛卧堂MCU技术交流
标题:
为啥这里可以这样定义一个结构常数
[打印本页]
作者:
ajzhumin
时间:
2014-4-23 16:04
标题:
为啥这里可以这样定义一个结构常数
新唐的NANO100 BSP 有以下这样的定义 不明白
typedef struct
{
uint32_t com[LCD_ALPHABET_SEGNUM]; /* LCD COM line (for multiplexing) */
uint32_t bit[LCD_ALPHABET_SEGNUM]; /* LCD SEG bit number */
} CHAR_TypeDef;
/**************************************************************************//**
* Defines segment COM and BIT fields for numeric display
*****************************************************************************/
typedef struct
{
uint32_t com[LCD_DIGIT_SEGNUM];
uint32_t bit[LCD_DIGIT_SEGNUM];
} NUMBER_TypeDef;
/**************************************************************************//**
* Defines all types of display for all segments
*****************************************************************************/
typedef struct
{
CHAR_TypeDef Text[LCD_ALPHABET_NUM];
NUMBER_TypeDef Number[LCD_DIGIT_NUM];
} NANO1XX_DISPLAY;
/**************************************************************************//**
* Defines the COM/SEG for each alphabet and numeric
*****************************************************************************/
const NANO1XX_DISPLAY NANO1XXDISPLAY = {
.Text = {
{ /* 1 */
/* A B C D */
.com[0] = 3, .com[1] = 2, .com[2] = 1, .com[3] = 0,
.bit[0] = 0, .bit[1] = 0, .bit[2] = 0, .bit[3] = 0,
/* E F G H */
.com[4] = 1, .com[5] = 2, .com[6] = 2, .com[7] = 3,
.bit[4] = 38, .bit[5] = 38, .bit[6] = 39, .bit[7] = 39,
/* J K M N */
.com[8] = 3, .com[9] = 2, .com[10] = 1, .com[11] = 0,
.bit[8] = 1, .bit[9] = 1, .bit[10] = 1, .bit[11] = 1,
/* P Q */
.com[12] = 0, .com[13] = 1,
.bit[12] = 39, .bit[13] = 39
},
{ /* 2 */
.com[0] = 3, .com[1] = 2, .com[2] = 1, .com[3] = 0,
.bit[0] = 4, .bit[1] = 4, .bit[2] = 4, .bit[3] = 4,
.com[4] = 1, .com[5] = 2, .com[6] = 2, .com[7] = 3,
.bit[4] = 2, .bit[5] = 2, .bit[6] = 3, .bit[7] = 3,
.com[8] = 3, .com[9] = 2, .com[10] = 1, .com[11] = 0,
.bit[8] = 5, .bit[9] = 5, .bit[10] = 5, .bit[11] = 5,
.com[12] = 0, .com[13] = 1,
.bit[12] = 3, .bit[13] = 3
},
.......................
}
}
为啥这里可以这样定义一个结构常数
“.com[0] = 3, .com[1] = 2, .com[2] = 1, .com[3] = 0,
.bit[0] = 0, .bit[1] = 0, .bit[2] = 0, .bit[3] = 0, ”
是ARM CC 编译器特别支持的吗?我没有找到这样的语法出处呢,哪位大神给指点一下。
作者:
a_ziliu
时间:
2014-4-24 13:31
這是c99的語法,要看compiler有沒有支援
欢迎光临 牛卧堂MCU技术交流 (http://nuvoton-mcu.com/)
Powered by Discuz! X3.2