有人可以解釋下面代碼中的行static volatile GPIO_Registers* const gpio[]
是什麼?c瞭解結構指針
和這個塊內部的語法(volatile GPIO_Registers*)
是做什麼的?
// GPIO hardware registers
//
typedef struct
{
uint32_t MODE;
uint32_t TYPE;
uint32_t SPEED;
uint32_t PUSH_PULL;
uint32_t IDR;
uint32_t ODR;
uint32_t BSRR;
uint32_t LOCK;
uint32_t ALT_FN1;
uint32_t ALT_FN2;
} GPIO_Registers;
// Ports can be selected using an enumeration
// (Port) to index into this array.
// Port addresses can be calculated using the enum since
// all ports are at the same offset from each other.
//
static volatile GPIO_Registers* const gpio[] =
{
(volatile GPIO_Registers*)(GPIO_BASE_ADDR + (PORT_A << 10)),
(volatile GPIO_Registers*)(GPIO_BASE_ADDR + (PORT_B << 10)),
(volatile GPIO_Registers*)(GPIO_BASE_ADDR + (PORT_C << 10)),
(volatile GPIO_Registers*)(GPIO_BASE_ADDR + (PORT_D << 10)),
(volatile GPIO_Registers*)(GPIO_BASE_ADDR + (PORT_E << 10)),
(volatile GPIO_Registers*)(GPIO_BASE_ADDR + (PORT_F << 10))
};
你弄明白了什麼? **特別是**你不懂C書嗎? – Olaf