3 回答
TA貢獻1847條經驗 獲得超7個贊
typedef struct{
int command;
int data;
int isbusy;} MyHardwareGadget;void SendCommand (MyHardwareGadget * gadget, int command, int data){
// wait while the gadget is busy:
while (gadget->isbusy)
{
// do nothing here.
}
// set data first:
gadget->data = data;
// writing the command starts the action:
gadget->command = command;} void SendCommand (volatile MyHardwareGadget * gadget, int command, int data)
{
// wait while the gadget is busy:
while (gadget->isbusy)
{
// do nothing here.
}
// set data first:
gadget->data = data;
// writing the command starts the action:
gadget->command = command;
}TA貢獻1816條經驗 獲得超6個贊
volatilevolatilevolatile
TA貢獻1848條經驗 獲得超6個贊
volatilevolatilevolatile
- 3 回答
- 0 關注
- 668 瀏覽
添加回答
舉報
