学前班
最后登录1970-1-1
在线时间 小时
注册时间2019-4-13
|
【code】
void MY_NVIC_Init(u8 NVIC_PreemptionPriority,u8 NVIC_SubPriority,u8 NVIC_Channel,u8 NVIC_Group)
{
u8 temp;
u8 IPRADDR=NVIC_Channel/4; //ÿ×éÖ»ÄÜ´æ4¸ö,µÃµ½×éµØÖ·
u8 IPROFFSET=NVIC_Channel%4; //ÔÚ×éÄÚµÄÆ«ÒÆ
IPROFFSET=IPROFFSET*8+4; //µÃµ½Æ«ÒƵÄÈ·ÇÐλÖÃ
MY_NVIC_PriorityGroupConfig(NVIC_Group); //ÉèÖ÷Ö×é
temp=NVIC_PreemptionPriority<<(4-NVIC_Group);
temp|=NVIC_SubPriority&(0x0f>>NVIC_Group);
temp&=0xf;//È¡µÍËÄλ
if(NVIC_Channel<32)NVIC->ISER[0]|=1<<NVIC_Channel; //使能中断位
else NVIC->ISER[1]|=1<<(NVIC_Channel-32);
NVIC->IP |= temp<<IPROFFSET;出错行 invalid operands to binary expression (‘volatile uint8_t 【240】’and ‘int’)
}
typedef struct
{
__IO uint32_t ISER[8]; /*!< Offset: 0x000 Interrupt Set Enable Register */
uint32_t RESERVED0[24];
__IO uint32_t ICER[8]; /*!< Offset: 0x080 Interrupt Clear Enable Register */
uint32_t RSERVED1[24];
__IO uint32_t ISPR[8]; /*!< Offset: 0x100 Interrupt Set Pending Register */
uint32_t RESERVED2[24];
__IO uint32_t ICPR[8]; /*!< Offset: 0x180 Interrupt Clear Pending Register */
uint32_t RESERVED3[24];
__IO uint32_t IABR[8]; /*!< Offset: 0x200 Interrupt Active bit Register */
uint32_t RESERVED4[56];
__IO uint8_t IP[240]; /*!< Offset: 0x300 Interrupt Priority Register (8Bit wide) */
uint32_t RESERVED5[644];
__O uint32_t STIR; /*!< Offset: 0xE00 Software Trigger Interrupt Register */
} NVIC_Type;
【/code】
没弄懂怎么改动
|
|