Revision 197
reverted changes in proj
proj/include/timer.h | ||
---|---|---|
1 |
/** |
|
2 |
* This file concerns everything related to the timer |
|
3 |
*/ |
|
4 |
|
|
5 |
#ifndef TIMER_H_INCLUDED |
|
6 |
#define TIMER_H_INCLUDED |
|
7 |
|
|
8 |
int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
|
9 |
|
|
10 |
uint32_t no_interrupts; |
|
11 |
|
|
12 |
#endif //TIMER_H_INCLUDED |
|
0 | 13 |
proj/include/utils.h | ||
---|---|---|
1 |
#ifndef UTILS_H_INCLUDED |
|
2 |
#define UTILS_H_INCLUDED |
|
3 |
|
|
4 |
/** |
|
5 |
* @brief Gets the least significant byte of a 16-bit variable |
|
6 |
* @param val 16-bit variable |
|
7 |
* @param lsb Pointer to a 8-bit variable to store the value of the LSB |
|
8 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
9 |
*/ |
|
10 |
int(util_get_LSB)(uint16_t val, uint8_t *lsb); |
|
11 |
|
|
12 |
/** |
|
13 |
* @brief Gets the most significant byte of a 16-bit variable |
|
14 |
* @param val 16-bit variable |
|
15 |
* @param lsb Pointer to a 8-bit variable to store the value of the MSB |
|
16 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
17 |
*/ |
|
18 |
int(util_get_MSB)(uint16_t val, uint8_t *msb); |
|
19 |
|
|
20 |
/** |
|
21 |
* @brief sys_inb wrapper |
|
22 |
* @param port Port to read from |
|
23 |
* @param value Pointer to byte to store value read |
|
24 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
25 |
*/ |
|
26 |
int (util_sys_inb)(int port, uint8_t *value); |
|
27 |
|
|
28 |
/** |
|
29 |
* @brief Unsubcribes Interrupts |
|
30 |
* @param interrupt_id Interrupt ID, value via arguments on subscription of the interrupt_id |
|
31 |
* @see subscribe_kbc_interrupt, subscribe_timer_interrupt |
|
32 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
|
33 |
*/ |
|
34 |
int (unsubscribe_interrupt)(int *interrupt_id); |
|
35 |
|
|
36 |
/** |
|
37 |
* @brief Gets the minimum value out of two values. |
|
38 |
* @param a First value |
|
39 |
* @param b Second value |
|
40 |
* @return The minimum of the two values |
|
41 |
*/ |
|
42 |
int32_t min(int32_t a, int32_t b); |
|
43 |
|
|
44 |
/** |
|
45 |
* @brief Gets the maximum value out of two values. |
|
46 |
* @param a First value |
|
47 |
* @param b Second value |
|
48 |
* @return The maximum of the two values |
|
49 |
*/ |
|
50 |
int32_t max(int32_t a, int32_t b); |
|
51 |
|
|
52 |
|
|
53 |
#endif //UTILS_H_INCLUDED |
|
0 | 54 |
proj/src/timer.c | ||
---|---|---|
1 |
#include <lcom/lcf.h> |
|
2 |
|
|
3 |
#include "timer.h" |
|
4 |
#include "graph.h" |
|
5 |
#include "sprite.h" |
|
6 |
|
|
7 |
#include "i8254.h" |
|
8 |
|
|
9 |
int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id) { |
|
10 |
if (interrupt_id == NULL) return 1; |
|
11 |
*interrupt_id = interrupt_bit; |
|
12 |
return (sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE, interrupt_id)); |
|
13 |
} |
|
14 |
|
|
15 |
uint32_t no_interrupts = 0; |
|
16 |
void (timer_int_handler)() { |
|
17 |
no_interrupts++; |
|
18 |
} |
|
0 | 19 |
proj/src/utils.c | ||
---|---|---|
1 |
#include <lcom/lcf.h> |
|
2 |
|
|
3 |
#include "utils.h" |
|
4 |
|
|
5 |
#include <stdint.h> |
|
6 |
#include "errors.h" |
|
7 |
|
|
8 |
int(util_get_LSB)(uint16_t val, uint8_t *lsb) { |
|
9 |
if (lsb == NULL) return NULL_PTR; |
|
10 |
*lsb = val; |
|
11 |
return SUCCESS; |
|
12 |
} |
|
13 |
|
|
14 |
int(util_get_MSB)(uint16_t val, uint8_t *msb) { |
|
15 |
if (msb == NULL) return NULL_PTR; |
|
16 |
*msb = (val >> 8); |
|
17 |
return SUCCESS; |
|
18 |
} |
|
19 |
|
|
20 |
int (util_sys_inb)(int port, uint8_t *value) { |
|
21 |
if(value == NULL) return NULL_PTR; |
|
22 |
uint32_t n = 0; |
|
23 |
if(sys_inb(port, &n)) return READ_ERROR; |
|
24 |
*value = n; |
|
25 |
return SUCCESS; |
|
26 |
} |
|
27 |
|
|
28 |
int (unsubscribe_interrupt)(int *interrupt_id) { |
|
29 |
if (interrupt_id == NULL) return NULL_PTR; |
|
30 |
if(sys_irqrmpolicy(interrupt_id)) return UNSBCR_ERROR; |
|
31 |
return SUCCESS; |
|
32 |
} |
|
33 |
|
|
34 |
int32_t min(int32_t a, int32_t b){ return (b < a ? b : a); } |
|
35 |
int32_t max(int32_t a, int32_t b){ return (a < b ? b : a); } |
|
0 | 36 |
proj/DR.mk | ||
---|---|---|
1 | 1 |
PROG=proj |
2 | 2 |
|
3 | 3 |
.PATH: ${.CURDIR}/src |
4 |
.PATH: ${.CURDIR}/../lab2/src |
|
5 |
.PATH: ${.CURDIR}/../lab3/src |
|
6 |
.PATH: ${.CURDIR}/../lab4/src |
|
7 |
.PATH: ${.CURDIR}/../lab5/src |
|
8 | 4 |
|
9 | 5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c |
10 | 6 |
|
11 |
CPPFLAGS += -pedantic -I./include -I../lab2/include -I./bmp -I./xpm -D LCOM_MACRO -D DIOGO -D __LCOM_OPTIMIZED_
|
|
7 |
CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D LCOM_MACRO -D DIOGO -D __LCOM_OPTIMIZED_ |
|
12 | 8 |
|
13 | 9 |
DPADD += ${LIBLCF} |
14 | 10 |
LDADD += -llcf |
proj/Makefile | ||
---|---|---|
1 | 1 |
PROG=proj |
2 | 2 |
|
3 | 3 |
.PATH: ${.CURDIR}/src |
4 |
.PATH: ${.CURDIR}/../lab2/src |
|
5 |
.PATH: ${.CURDIR}/../lab3/src |
|
6 |
.PATH: ${.CURDIR}/../lab4/src |
|
7 |
.PATH: ${.CURDIR}/../lab5/src |
|
8 | 4 |
|
9 | 5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c |
10 | 6 |
|
11 |
CPPFLAGS += -pedantic -I./include -I../lab2/include -I./bmp -I./xpm -D LCOM_MACRO -D __LCOM_OPTIMIZED_
|
|
7 |
CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D LCOM_MACRO -D __LCOM_OPTIMIZED_ |
|
12 | 8 |
|
13 | 9 |
DPADD += ${LIBLCF} |
14 | 10 |
LDADD += -llcf |
proj/TB.mk | ||
---|---|---|
1 | 1 |
PROG=proj |
2 | 2 |
|
3 | 3 |
.PATH: ${.CURDIR}/src |
4 |
.PATH: ${.CURDIR}/../lab2/src |
|
5 |
.PATH: ${.CURDIR}/../lab3/src |
|
6 |
.PATH: ${.CURDIR}/../lab4/src |
|
7 |
.PATH: ${.CURDIR}/../lab5/src |
|
8 | 4 |
|
9 | 5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c |
10 | 6 |
|
11 |
CPPFLAGS += -pedantic -I./include -I../lab2/include -I./bmp -I./xpm -D LCOM_MACRO -D TELMO #-D __LCOM_OPTIMIZED_
|
|
7 |
CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D LCOM_MACRO -D TELMO #-D __LCOM_OPTIMIZED_ |
|
12 | 8 |
|
13 | 9 |
DPADD += ${LIBLCF} |
14 | 10 |
LDADD += -llcf |
Also available in: Unified diff