0
#define NVIC_IPR_BASEADDR          (volatile)((uint32_t *)0XE000E400)

#define No_PR_Bits_Implemented     4

void GPIO_IRQPriorityConfig(uint8_t IRQNumber, uint8_t IRQPriority); 

int main(void)
{

void GPIO_IRQPriorityConfig(uint8_t IRQNumber, uint8_t IRQPriority) 

{

    //1. First lets find out the IPR register.

    uint8_t iprx= IRQNumber/4;
    uint8_t iprx_section= IRQNumber%4;
    uint8_t shift_amount = (8 * iprx_section) + (8- No_PR_Bits_Implemented);

    *(NVIC_IPR_BASEADDR + iprx * 4 ) |= (IRQPriority << shift_amount); //error line

}

}
4

1 回答 1

1
#define NVIC_IPR_BASEADDR          (volatile)((uint32_t *)0XE000E400)

这不会导致指针类型。外部(volatile)没有显式类型,因此将导致类型默认为int. 以 gcc 为例,应该会收到类似于以下内容的警告:

warning: type defaults to ‘int’ in type name [-Wimplicit-int]

正确的定义应该是:

#define NVIC_IPR_BASEADDR          ((volatile uint32_t *)0XE000E400)
于 2020-07-14T05:36:16.213 回答