Project

General

Profile

Revision 5

implemented functions for 1st part

View differences:

lab2/lab2.c
30 30
}
31 31

  
32 32
int(timer_test_read_config)(uint8_t timer, enum timer_status_field field) {
33
  /* To be implemented by the students */
34
  printf("%s is not yet implemented!\n", __func__);
33
    /* To be implemented by the students */
35 34

  
36
  return 1;
35
    uint8_t state = 0;
36
    if(timer_get_conf(timer, &state)) return 1;
37
    //printf("%x\n", state);
38

  
39
    return 0;
37 40
}
38 41

  
39 42
int(timer_test_time_base)(uint8_t timer, uint32_t freq) {
lab2/timer.c
6 6
#include "i8254.h"
7 7

  
8 8
int (timer_set_frequency)(uint8_t timer, uint32_t freq) {
9
  /* To be implemented by the students */
10
  printf("%s is not yet implemented!\n", __func__);
9
    /* To be implemented by the students */
10
    printf("%s is not yet implemented!\n", __func__);
11 11

  
12
  return 1;
12
    return 1;
13 13
}
14 14

  
15 15
int (timer_subscribe_int)(uint8_t *bit_no) {
16 16
    /* To be implemented by the students */
17
  printf("%s is not yet implemented!\n", __func__);
17
    printf("%s is not yet implemented!\n", __func__);
18 18

  
19
  return 1;
19
    return 1;
20 20
}
21 21

  
22 22
int (timer_unsubscribe_int)() {
23
  /* To be implemented by the students */
24
  printf("%s is not yet implemented!\n", __func__);
23
    /* To be implemented by the students */
24
    printf("%s is not yet implemented!\n", __func__);
25 25

  
26
  return 1;
26
    return 1;
27 27
}
28 28

  
29 29
void (timer_int_handler)() {
30
  /* To be implemented by the students */
31
  printf("%s is not yet implemented!\n", __func__);
30
    /* To be implemented by the students */
31
    printf("%s is not yet implemented!\n", __func__);
32 32
}
33 33

  
34 34
int (timer_get_conf)(uint8_t timer, uint8_t *st) {
35
  /* To be implemented by the students */
36
  printf("%s is not yet implemented!\n", __func__);
35
    int write_port = TIMER_CTRL;
36
    u32_t cmd = TIMER_RB_CMD | TIMER_RB_COUNT_ | TIMER_RB_SEL(timer);
37
    if(sys_outb(write_port, cmd)) return 1;
37 38

  
38
  return 1;
39
    int read_port;
40
    switch(timer){
41
        case 0: read_port = TIMER_0; break;
42
        case 1: read_port = TIMER_1; break;
43
        case 2: read_port = TIMER_2; break;
44
        default: return 1;      break;
45
    }
46
    if(util_sys_inb(read_port, st)) return 1;
47
    return 0;
39 48
}
40 49

  
41 50
int (timer_display_conf)(uint8_t timer, uint8_t st,
42
                        enum timer_status_field field) {
43
  /* To be implemented by the students */
44
  printf("%s is not yet implemented!\n", __func__);
51
    enum timer_status_field field) {
52
        /* To be implemented by the students */
53
        printf("%s is not yet implemented!\n", __func__);
45 54

  
46
  return 1;
47
}
55
        return 1;
56
    }
lab2/utils.c
3 3
#include <stdint.h>
4 4

  
5 5
int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
6
  /* To be implemented by the students */
7
  printf("%s is not yet implemented!\n", __func__);
6
    /* To be implemented by the students */
7
    printf("%s is not yet implemented!\n", __func__);
8 8

  
9
  return 1;
9
    return 1;
10 10
}
11 11

  
12 12
int(util_get_MSB)(uint16_t val, uint8_t *msb) {
13
  /* To be implemented by the students */
14
  printf("%s is not yet implemented!\n", __func__);
13
    /* To be implemented by the students */
14
    printf("%s is not yet implemented!\n", __func__);
15 15

  
16
  return 1;
16
    return 1;
17 17
}
18 18

  
19 19
int (util_sys_inb)(int port, uint8_t *value) {
20
  /* To be implemented by the students */
21
  printf("%s is not yet implemented!\n", __func__);
22

  
23
  return 1;
20
    /* To be implemented by the students */
21
    uint32_t n = 0;
22
    int ret = sys_inb(port, &n);
23
    *value = n;
24
    return ret;
24 25
}

Also available in: Unified diff