您好,我是在task中调用Task_sleep的。
在task中首先我注册按键下降沿中断
const PIN_Config keyPinTable[] = [
KEY | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
PIN_TERMINATE
];
keyPinHandle = PIN_open(&keyPinState, keyPinTable);
if (keyPinHandle != 0)
[
PIN_registerIntCb(keyPinHandle, &keyCallbackFxn);
]
然后再一个大循环中每睡眠5秒后进行一次RF发送
while(1)
[
RF_TxPacket txPacket = [0];
/* Create packet with incrementing sequence number and random payload */
txPacket.payload[0] = (uint8_t)(seqNumber >> 8);
txPacket.payload[1] = (uint8_t)(seqNumber++);
txPacket.payload[2] = battMeasure();
uint8_t i;
for (i = 3; i < PAYLOAD_LENGTH; i++)
[
txPacket.payload
= i;//rand();
]
txPacket.len = PAYLOAD_LENGTH;
txPacket.dstAddr[0] = 0xaa;
txPacket.dstAddr[1] = 0x55;
txPacket.absTime = 0;/*RF_getCurrentTime() + RF_ms_To_RadioTime(1000);*/
LED_Set(Led_Red,1); //红灯亮
RF_transmit(rfHandle, &txPacket);
LED_Set(Led_Red,0); //红灯灭
Task_sleep(5000000 / Clock_tickPeriod);
]
在按键中断函数中让蓝灯反转
void keyCallbackFxn(PIN_Handle handle, PIN_Id pinId)
[
LED_Set(Led_Blue, !PIN_getOutputValue(LED_BLUE));
]
结果的现象是:我在进入待机时,按下按键,蓝色灯反转,说明进入中断,但红色灯不会亮即不发送RF,需等待机5秒后才发送RF
您好,我是在task中调用Task_sleep的。
在task中首先我注册按键下降沿中断
const PIN_Config keyPinTable[] = [
KEY | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
PIN_TERMINATE
];
keyPinHandle = PIN_open(&keyPinState, keyPinTable);
if (keyPinHandle != 0)
[
PIN_registerIntCb(keyPinHandle, &keyCallbackFxn);
]
然后再一个大循环中每睡眠5秒后进行一次RF发送
while(1)
[
RF_TxPacket txPacket = [0];
/* Create packet with incrementing sequence number and random payload */
txPacket.payload[0] = (uint8_t)(seqNumber >> 8);
txPacket.payload[1] = (uint8_t)(seqNumber++);
txPacket.payload[2] = battMeasure();
uint8_t i;
for (i = 3; i < PAYLOAD_LENGTH; i++)
[
txPacket.payload
= i;//rand();
]
txPacket.len = PAYLOAD_LENGTH;
txPacket.dstAddr[0] = 0xaa;
txPacket.dstAddr[1] = 0x55;
txPacket.absTime = 0;/*RF_getCurrentTime() + RF_ms_To_RadioTime(1000);*/
LED_Set(Led_Red,1); //红灯亮
RF_transmit(rfHandle, &txPacket);
LED_Set(Led_Red,0); //红灯灭
Task_sleep(5000000 / Clock_tickPeriod);
]
在按键中断函数中让蓝灯反转
void keyCallbackFxn(PIN_Handle handle, PIN_Id pinId)
[
LED_Set(Led_Blue, !PIN_getOutputValue(LED_BLUE));
]
结果的现象是:我在进入待机时,按下按键,蓝色灯反转,说明进入中断,但红色灯不会亮即不发送RF,需等待机5秒后才发送RF
举报