Listing 3aAs a timer call back, the servo ISR for ETS needs to tell the OS whether to call other ISRs which all listen to the same interrupt. This is used to implement polling for interrupt sharing and implemented with the return value from the ISR. bThe QNX version of the servo ISR needs to tell the C compiler to generate a code segment that doesnt do stack overflow checks with the #pragma off/on (check_stack) compiler directive. This is necessary because this code runs on the interrupt stacknot the normal process stack, which the rest of the program runs on.
a)
#include "global.h"
#include "servo.h"
volatile int SetTime[nCHAN]; /* value for timer */
volatile int Ticks; /* value for current output */
volatile int CurrChan; /* current channel */
volatile int servomutex;
int Servo_Isr(ETS_INPUT_RECORD *r, DWORD dummy) {
/* only do something when we run out of ticks */
if(!Ticks--){
setport(SERVO_PORT, (1<<CurrChan) );
Ticks = SetTime[CurrChan++];
CurrChan %= nCHAN; }
return(ETS_CB_CONTINUE); }
b)
#include "global.h"
#include "servo.h"
volatile int SetTime[nCHAN]; /* value for timer */
volatile int Ticks; /* value for current output */
volatile int CurrChan; /* current channel */
volatile int servomutex;
#pragma off (check_stack)
pid_t far Servo_Isr() {
/* only do something when we run out of ticks */
if(!Ticks--){
setport(SERVO_PORT, (1<<CurrChan) );
Ticks = SetTime[CurrChan++];
CurrChan %= nCHAN; }
return(0); }
#pragma on (check_stack)