int timer_get_conf(unsigned long timer, unsigned char *st) { unsigned char temp; //Initialize ReadBack Command temp = TIMER_RB_CMD | TIMER_RB_SEL(timer) |TIMER_RB_COUNT_; // Read Back Command sys_outb(TIMER_CTRL,temp); //execute previous command unsigned char timer_sel=TIMER_0+timer; unsigned long temp_st; // Auxiliar long variable, to be filled sys_inb(timer_sel,&temp_st); // There is no need for a cast this way *st = temp_st; // The original variable st is filled as supposed and the unimportant bits are truncated while passing a long to a char return 0; }
int timer_get_conf(unsigned long timer, unsigned char *st) { // Configura o read-back command unsigned char read_back = TIMER_RB_CMD | TIMER_RB_SEL(timer) | TIMER_RB_COUNT_; // invoca sys_outb sys_outb(TIMER_CTRL, read_back); if (timer == 0 || timer == 1 || timer == 2) // 0 <= timer <= 2 { // invoca sys_inb sys_inb(TIMER_0 + timer, (unsigned long int *) st); return 0; } return 1; }
int getTimerConfig(unsigned long timer, unsigned char *st) { if (timer < 0 || timer > 2) return -1; unsigned char byte = 0; unsigned long stl; byte |= TIMER_RB_CMD | TIMER_RB_SEL(timer); sys_outb(TIMER_CTRL, byte); sys_inb(TIMER_0 + timer, &stl); *st = stl; return 0; }
int timer_get_conf(unsigned long timer, unsigned long *st) { if (sys_outb(TIMER_CTRL, TIMER_RB_SEL(timer) | TIMER_RB_CMD | TIMER_RB_COUNT_)) { return 1; } switch(timer) { case 0: return sys_inb(TIMER_0, st); case 1: return sys_inb(TIMER_1, st); case 2: return sys_inb(TIMER_2, st); default: return 1; } }
int timer_get_conf(unsigned long timer, unsigned char *st) { unsigned long temporario; int x; temporario = TIMER_RB_CMD | TIMER_RB_COUNT_ |TIMER_RB_SEL(timer) ; if(sys_outb(TIMER_CTRL, temporario) != 0) { return 1; } if(sys_inb(TIMER_0+timer, (unsigned long *) st )!= 0) { return 1; } //printf("%X",*st); //printf("\n"); return 0; }
static int get_timer_BCD(unsigned long timer) { if (sys_outb(TIMER_CTRL, TIMER_RB_SEL(timer) | TIMER_RB_CMD | TIMER_RB_COUNT_)) { return -1; } unsigned long st; switch(timer) { case 0: if (sys_inb(TIMER_0, &st)) return -1; break; case 1: if (sys_inb(TIMER_1, &st)) return -1; break; case 2: if (sys_inb(TIMER_2, &st)) return -1; break; default: return -1; } return (st & TIMER_BCD) == TIMER_BCD; }