Project

General

Profile

Revision 334

added more docs

View differences:

proj/libs/graph/include/menu.h
13 13

  
14 14
#include "font.h"
15 15

  
16
/**
17
 * @brief Menu.
18
 */
16 19
typedef struct menu menu_t;
17

  
20
/**
21
 * @brief Construct menu.
22
 * @param   fnt Font to use when rendering menu options text
23
 * @return      Pointer to constructed menu, or NULL if failed.
24
 */
18 25
menu_t* (menu_ctor)(const font_t *fnt);
19

  
26
/**
27
 * @brief Destruct menu.
28
 * @param   p   Pointer to menu to destruct
29
 */
30
void (menu_dtor)(menu_t *p);
31
/**
32
 * @brief Add item to menu.
33
 * @param   menu    Pointer to menu
34
 * @param   s       String to be used as text for the new item
35
 * @return  SUCCESS if operation was successful, other value otherwise
36
 */
20 37
int (menu_add_item)(menu_t *menu, const char *s);
21

  
38
/**
39
 * @brief Update menu state.
40
 *
41
 * This function allows to check if the mouse is hovering over an item, and knowing
42
 * if an item was clicked.
43
 * @param   menu    Pointer to menu
44
 * @param   click   0 if mouse right button is clicked, other value otherwise
45
 * @return  selected option if clicked, -1 otherwise
46
 */
22 47
int (menu_update_state)(menu_t *menu, int click);
23

  
48
/**
49
 * @brief Draw menu on screen buffer.
50
 * @param   menu    Pointer to menu to be drawn
51
 */
24 52
void (menu_draw)(menu_t *menu);
25 53

  
26
void (menu_dtor)(menu_t *p);
27

  
28 54
/**
29 55
 * @}
30 56
 */
proj/libs/graph/include/rectangle.h
9 9
 * @{
10 10
 */
11 11

  
12
/**
13
 * @brief Rectangle.
14
 */
12 15
typedef struct rectangle rectangle_t;
13

  
16
/**
17
 * @brief Construct rectangle.
18
 * @param   x   X-position of upper-left corner
19
 * @param   y   Y-position of upper-left corner
20
 * @param   w   Width
21
 * @param   h   Height
22
 * @return      Pointer to constructed rectangle, or NULL if failed
23
 */
14 24
rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h);
25
/**
26
 * @brief Destruct rectangle.
27
 * @param   p   Pointer to rectangle to be destructed
28
 */
15 29
void         (rectangle_dtor)(rectangle_t *p);
16

  
30
/**
31
 * @brief Set rectangle position.
32
 * @param   p   Pointer to rectangle
33
 * @param   x   X-position of the upper-left corner
34
 * @param   y   Y-position of the upper-left corner
35
 */
17 36
void (rectangle_set_pos)          (rectangle_t *p,  int16_t x,  int16_t y);
37
/**
38
 * @brief Set rectangle size.
39
 * @param   p   Pointer to rectangle
40
 * @param   w   Width
41
 * @param   h   Height
42
 */
18 43
void (rectangle_set_size)         (rectangle_t *p, uint16_t w, uint16_t h);
44
/**
45
 * @brief Set rectangle fill color.
46
 * @param   p       Pointer to rectangle
47
 * @param   color   Color to fill rectangle
48
 */
19 49
void (rectangle_set_fill_color)   (rectangle_t *p, uint32_t color);
50
/**
51
 * @brief Set rectangle fill transparency.
52
 * @param   p       Pointer to rectangle
53
 * @param   alpha   Value of the alpha-channel
54
 */
20 55
void (rectangle_set_fill_trans)   (rectangle_t *p, uint8_t  alpha);
56
/**
57
 * @brief Set rectangle outline color.
58
 * @param   p       Pointer to rectangle
59
 * @param   color   Color to outline rectangle
60
 */
21 61
void (rectangle_set_outline_color)(rectangle_t *p, uint32_t color);
62
/**
63
 * @brief Set rectangle outline width.
64
 * @param   p       Pointer to rectangle
65
 * @param   width   Width of the rectangle border/outline
66
 */
22 67
void (rectangle_set_outline_width)(rectangle_t *p,  int16_t width);
23

  
68
/**
69
 * @brief Get rectangle x-position.
70
 * @param   p   Pointer to rectangle
71
 * @return      Rectangle x-position
72
 */
24 73
int16_t  (rectangle_get_x)(const rectangle_t *p);
74
/**
75
 * @brief Get rectangle y-position.
76
 * @param   p   Pointer to rectangle
77
 * @return      Rectangle y-position
78
 */
25 79
int16_t  (rectangle_get_y)(const rectangle_t *p);
80
/**
81
 * @brief Get rectangle width.
82
 * @param   p   Pointer to rectangle
83
 * @return      Rectangle width
84
 */
26 85
uint16_t (rectangle_get_w)(const rectangle_t *p);
86
/**
87
 * @brief Get rectangle height.
88
 * @param   p   Pointer to rectangle
89
 * @return      Rectangle height
90
 */
27 91
uint16_t (rectangle_get_h)(const rectangle_t *p);
92
/**
93
 * @brief Know if point in screen coordinates lies inside rectangle.
94
 * @param   p   Pointer to rectangle
95
 * @param   x   X-position of the point
96
 * @param   y   Y-position of the point
97
 * @return      True if the point lies inside the rectangle, false otherwise.
98
 */
28 99
int      (rectangle_collide_point)(const rectangle_t *p, int x, int y);
29

  
100
/**
101
 * Draw rectangle in screen buffer.
102
 * @param   p   Pointer to rectangle to be drawn
103
 */
30 104
void (rectangle_draw)(const rectangle_t *p);
31 105

  
32 106
/**
proj/libs/kbc/include/kbc.h
1
#ifndef KBC_H_INCLUDED
2
#define KBC_H_INCLUDED
3

  
1 4
/**
2
 * This file concerns everything related to the KBC (KeyBoard Controller, which
3
 * actually also manages the mouse)
5
 * @defgroup    kbc kbc
6
 * @brief   KBC module.
7
 *
8
 * @{
4 9
 */
5 10

  
6
#ifndef KBC_H_INCLUDED
7
#define KBC_H_INCLUDED
8

  
9 11
/* KBC IRQ Line */
12
/** @brief KBC Controller IRQ Line */
13
#define KBC_IRQ     1
14
/** @brief Mouse IRQ Line */
15
#define MOUSE_IRQ   12
10 16

  
11
#define KBC_IRQ     1   /* @brief KBC Controller IRQ Line */
12
#define MOUSE_IRQ   12  /* @brief Mouse IRQ Line */
13

  
14 17
/* Delay for KBC */
15
#define DELAY           20000 /* @brief KBC Response Delay */
16
#define KBC_NUM_TRIES   20    /* @brief Number of tries to issue command before timeout */
18
/** @brief KBC Response Delay */
19
#define DELAY           20000
20
/** @brief Number of tries to issue command before timeout */
21
#define KBC_NUM_TRIES   20
17 22

  
18 23
/* I/O Ports Addresses */
24
/** @brief Address to send commands to KBC */
25
#define KBC_CMD     0x64
26
/** @brief Address to write KBC Command Arguments */
27
#define KBC_CMD_ARG 0x60
28
/** @brief KBC Status Register address */
29
#define STATUS_REG  0x64
30
/** @brief Address of Output Buffer of KBC */
31
#define OUTPUT_BUF  0x60
19 32

  
20
#define KBC_CMD     0x64 /* @brief Address to send commands to KBC */
21
#define KBC_CMD_ARG 0x60 /* @brief Address to write KBC Command Arguments */
22
#define STATUS_REG  0x64 /* @brief KBC Status Register address */
23

  
24
#define OUTPUT_BUF  0x60 /* @brief Address of Output Buffer of KBC */
25

  
26 33
/* KBC Commands */
27
#define READ_KBC_CMD    0x20 /* @brief Read KBC Command Byte */
28
#define WRITE_KBC_CMD   0x60 /* @brief Write KBC Command Byte */
29
#define KBC_SELF_TEST   0xAA /* @brief KBC Diagnostic Tests */
30
#define KBC_INT_TEST    0xAB /* @brief Tests Keyboard Clock and Data lines */
31
#define KBC_INT_DISABLE 0xAD /* @brief Disable KBC Interface */
32
#define KBC_INT_ENABLE  0xAE /* @brief Enable KBC Interface */
33
#define MOUSE_DISABLE   0xA7 /* @brief Disable Mouse */
34
#define MOUSE_ENABLE    0xA8 /* @brief Enable Mouse */
35
#define MOUSE_INT_TEST  0xA9 /* @brief Tests Mouse data line */
36
#define MOUSE_WRITE_B   0xD4 /* @brief Write a byte directly to the mouse */
34
/** @brief Read KBC Command Byte */
35
#define READ_KBC_CMD    0x20
36
/** @brief Write KBC Command Byte */
37
#define WRITE_KBC_CMD   0x60
38
/** @brief KBC Diagnostic Tests */
39
#define KBC_SELF_TEST   0xAA
40
/** @brief Tests Keyboard Clock and Data lines */
41
#define KBC_INT_TEST    0xAB
42
/** @brief Disable KBC Interface */
43
#define KBC_INT_DISABLE 0xAD
44
/** @brief Enable KBC Interface */
45
#define KBC_INT_ENABLE  0xAE
46
/** @brief Disable Mouse */
47
#define MOUSE_DISABLE   0xA7
48
/** @brief Enable Mouse */
49
#define MOUSE_ENABLE    0xA8
50
/** @brief Tests Mouse data line */
51
#define MOUSE_INT_TEST  0xA9
52
/** @brief Write a byte directly to the mouse */
53
#define MOUSE_WRITE_B   0xD4
37 54

  
38 55
/* Status Byte Masking */
56
/** @brief Output Buffer State */
57
#define OUT_BUF_FUL     BIT(0)
58
/** @brief Input Buffer State */
59
#define IN_BUF_FULL     BIT(1)
60
/** @brief System Flag */
61
#define SYS_FLAG        BIT(2)
62
/** @brief Identifier of type of byte in input buffer */
63
#define DATA_CMD_WRITE  BIT(3)
64
/** @brief Keyboard inihibited */
65
#define INH_FLAG        BIT(4)
66
/** @brief Mouse Data */
67
#define AUX_MOUSE       BIT(5)
68
/** @brief Time Out Error - Invalid Data */
69
#define TIME_OUT_REC    BIT(6)
70
/** @brief Parity Error - Invalid Data */
71
#define PARITY_ERROR    BIT(7)
39 72

  
40
#define OUT_BUF_FUL     BIT(0) /* @brief Output Buffer State */
41
#define IN_BUF_FULL     BIT(1) /* @brief Input Buffer State */
42
#define SYS_FLAG        BIT(2) /* @brief System Flag */
43
#define DATA_CMD_WRITE  BIT(3) /* @brief Identifier of type of byte in input buffer */
44
#define INH_FLAG        BIT(4) /* @brief Keyboard inihibited */
45
#define AUX_MOUSE       BIT(5) /* @brief Mouse Data */
46
#define TIME_OUT_REC    BIT(6) /* @brief Time Out Error - Invalid Data */
47
#define PARITY_ERROR    BIT(7) /* @brief Parity Error - Invalid Data */
48

  
49 73
/* Scancode Constants */
74
/** @brief ESC Break Code */
75
#define ESC_BREAK_CODE  0x81
76
/** @brief First byte of a two byte Scancode */
77
#define TWO_BYTE_CODE   0xE0
78
/** @brief Bit to distinguish between Make code and Break code */
79
#define BREAK_CODE_BIT  BIT(7)
50 80

  
51
#define ESC_BREAK_CODE  0x81    /* @brief ESC Break Code */
52
#define TWO_BYTE_CODE   0xE0    /* @brief First byte of a two byte Scancode */
53
#define BREAK_CODE_BIT  BIT(7)  /* @brief Bit to distinguish between Make code and Break code */
54

  
55 81
/* Command byte masks */
56
#define INT_KBD         BIT(0)  /* @brief Enable Keyboard Interrupts */
57
#define INT_MOU         BIT(1)  /* @brief Enable Mouse Interrupts */
58
#define DIS_KBD         BIT(4)  /* @brief Disable Keyboard */
59
#define DIS_MOU         BIT(5)  /* @brief Disable Mouse */
82
/** @brief Enable Keyboard Interrupts */
83
#define INT_KBD         BIT(0)
84
/** @brief Enable Mouse Interrupts */
85
#define INT_MOU         BIT(1)
86
/** @brief Disable Keyboard */
87
#define DIS_KBD         BIT(4)
88
/** @brief Disable Mouse */
89
#define DIS_MOU         BIT(5)
60 90

  
61 91
/**
62 92
 * @brief High-level function that reads the command byte of the KBC
......
74 104

  
75 105
/**
76 106
 * @brief High-level function that restores KBC to normal state
107
 *
77 108
 * High-level function that restores KBC to normal state, because lcf_start
78 109
 * changes the command byte of KBC. If this function is not used, there is a
79 110
 * chance that the keyboard and keyboard interrupts remain disabled.
......
97 128

  
98 129
/**
99 130
 * @brief Low-level function for reading byte from keyboard
131
 *
100 132
 * Low-level function for reading byte from keyboard. Waits until output buffer
101 133
 * is full
102 134
 * @param byte Pointer to variable where byte read from keyboard will be stored
......
104 136
 */
105 137
int (kbc_read_byte)(uint8_t *byte);
106 138

  
139
/**
140
 * @}
141
 */
142

  
107 143
#endif //KBC_H_INCLUDED
proj/libs/kbc/include/keyboard.h
1
#ifndef KEYBOARD_H_INCLUDED
2
#define KEYBOARD_H_INCLUDED
3

  
1 4
/**
2
 * This file concerns everything related to the keyboard
5
 * @defgroup    keyboard    keyboard
6
 * @ingroup kbc
7
 * @brief Keyboard module.
8
 *
9
 * @{
3 10
 */
4 11

  
5
#ifndef KEYBOARD_H_INCLUDED
6
#define KEYBOARD_H_INCLUDED
7

  
8 12
#include "kbc.h"
9 13

  
10
#define W_MAKE_CODE             0x11    /** @brief W Make Code */
11
#define W_BREAK_CODE            0x91    /** @brief W Break Code */
12
#define A_MAKE_CODE             0x1E    /** @brief A Make Code */
13
#define A_BREAK_CODE            0x9E    /** @brief A Break Code */
14
#define S_MAKE_CODE             0x1F    /** @brief S Make Code */
15
#define S_BREAK_CODE            0x9F    /** @brief S Break Code */
16
#define D_MAKE_CODE             0x20    /** @brief D Make Code */
17
#define D_BREAK_CODE            0xA0    /** @brief D Break Code */
18
#define CTRL_MAKE_CODE          0x1D    /** @brief CTRL Make Code */
19
#define CTRL_BREAK_CODE         0x9D    /** @brief CTRL Break Code */
20
#define PLUS_MAKE_CODE          0x1A    /** @brief Plus (+) Make Code */
21
#define PLUS_BREAK_CODE         0x9A    /** @brief Plus (+) Break Code */
22
#define MINUS_MAKE_CODE         0x35    /** @brief Minus (-) Make Code */
23
#define MINUS_BREAK_CODE        0xB5    /** @brief Minus (-) Break Code */
14
/** @brief W Make Code */
15
#define W_MAKE_CODE             0x11
16
/** @brief W Break Code */
17
#define W_BREAK_CODE            0x91
18
/** @brief A Make Code */
19
#define A_MAKE_CODE             0x1E
20
/** @brief A Break Code */
21
#define A_BREAK_CODE            0x9E
22
/** @brief S Make Code */
23
#define S_MAKE_CODE             0x1F
24
/** @brief S Break Code */
25
#define S_BREAK_CODE            0x9F
26
/** @brief D Make Code */
27
#define D_MAKE_CODE             0x20
28
/** @brief D Break Code */
29
#define D_BREAK_CODE            0xA0
30
/** @brief CTRL Make Code */
31
#define CTRL_MAKE_CODE          0x1D
32
/** @brief CTRL Break Code */
33
#define CTRL_BREAK_CODE         0x9D
34
/** @brief Plus (+) Make Code */
35
#define PLUS_MAKE_CODE          0x1A
36
/** @brief Plus (+) Break Code */
37
#define PLUS_BREAK_CODE         0x9A
38
/** @brief Minus (-) Make Code */
39
#define MINUS_MAKE_CODE         0x35
40
/** @brief Minus (-) Break Code */
41
#define MINUS_BREAK_CODE        0xB5
24 42
#define ENTER_MAKE_CODE         0x1C
25 43
#define ENTER_BREAK_CODE        0x9C
26 44
#define BACKSPACE_MAKE_CODE     0x0E
......
30 48
#define ESC_BREAK_CODE          0x81    /** @brief ESC Break Code */
31 49

  
32 50
/**
33
 * @brief Subscribes Keyboard Interrupts and disables Minix Default IH
51
 * @brief Subscribes Keyboard Interrupts and disables Minix Default IH.
34 52
 * @param interrupt_bit Bit of Interrupt Vector that will be set when Keyboard Interrupt is pending
35 53
 * @param interrupt_id Keyboard Interrupt ID to specify the Keyboard Interrupt in other calls
36 54
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
......
38 56
 */
39 57
int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
40 58

  
41

  
42 59
const uint8_t* keyboard_get_scancode(void);
43 60
int keyboard_get_done(void);
44 61
int keyboard_get_size(void);
......
48 65

  
49 66
int (keyboard_poll)(uint8_t bytes[], uint8_t *size);
50 67

  
68
/**
69
 * @}
70
 */
71

  
51 72
#endif //KEYBOARD_H_INCLUDED
proj/libs/kbc/include/mouse.h
2 2
#define MOUSE_H_INCLUDED
3 3

  
4 4
/**
5
 * @defgroup    mouse   mouse
6
 * @ingroup kbc
7
 * @brief   Mouse module.
8
 *
9
 * @{
10
 */
11

  
12
/**
5 13
 * @brief Subscribes Mouse Interrupts and disables Minix Default IH
6 14
 * @param interrupt_bit Bit of Interrupt Vector that will be set when Mouse Interrupt is pending
7 15
 * @param interrupt_id Mouse Interrupt ID to specify the Mouse Interrupt in other calls
......
87 95
 */
88 96
int16_t (sign_extend_byte)(uint8_t sign_bit, uint8_t byte);
89 97

  
98
/**
99
 * @}
100
 */
101

  
90 102
#endif //MOUSE_H_INCLUDED
proj/libs/rtc/include/rtc.h
1 1
#ifndef RTC_H_INCLUDED
2 2
#define RTC_H_INCLUDED
3 3

  
4
/**
5
 * @defgroup    rtc rtc
6
 * @brief RTC (Real-Time Clock) module.
7
 *
8
 * @{
9
 */
10

  
4 11
#include <stdint.h>
5 12

  
6 13
/**
......
43 50
 */
44 51
int (rtc_read_date)(uint8_t *date);
45 52

  
53
/**
54
 * @}
55
 */
56

  
46 57
#endif /* end of include guard: RTC_H_INCLUDED */
proj/libs/timer/include/timer.h
1
#ifndef TIMER_H_INCLUDED
2
#define TIMER_H_INCLUDED
3

  
1 4
/**
2
 * This file concerns everything related to the timer
5
 * @defgroup    timer   timer
6
 * @brief   Timer module.
7
 *
8
 * @{
3 9
 */
4 10

  
5
#ifndef TIMER_H_INCLUDED
6
#define TIMER_H_INCLUDED
11
/** @brief Timer 0 IRQ line */
12
#define TIMER0_IRQ     0
7 13

  
8
#define TIMER0_IRQ     0                                                                /**< @brief Timer 0 IRQ line */
9

  
10 14
int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
11 15

  
12 16
void (timer_int_handler)(void);
13 17

  
14 18
uint32_t (timer_get_no_interrupts)(void);
15 19

  
20
/**
21
 * @}
22
 */
23

  
16 24
#endif //TIMER_H_INCLUDED
proj/libs/uart/include/hltp.h
1 1
#ifndef HLTP_H_INCLUDED
2 2
#define HLTP_H_INCLUDED
3 3

  
4
/**
5
 * @defgroup    hltp    hltp
6
 * @ingroup nctp
7
 * @brief HLTP (High-Level Transfer Protocol) module.
8
 *
9
 * @{
10
 */
11

  
4 12
#include "uart.h"
5 13
#include "proj_structures.h"
6 14

  
......
12 20
    hltp_type_bullet  = 0x42
13 21
} hltp_type;
14 22

  
23
/**
24
 * @brief Send string.
25
 * @param   p   Pointer to string to be sent
26
 * @return  SUCCESS if operation was successful, other value otherwise
27
 */
15 28
int hltp_send_string(const char *p);
29
/**
30
 * @brief Send host_info.
31
 * @param   p   Pointer to host_info to be sent
32
 * @return  SUCCESS if operation was successful, other value otherwise
33
 */
16 34
int hltp_send_host_info(const host_info_t *p);
35
/**
36
 * @brief Send remote_info.
37
 * @param   p   Pointer to remote_info to be sent
38
 * @return  SUCCESS if operation was successful, other value otherwise
39
 */
17 40
int hltp_send_remote_info(const remote_info_t *p);
41
/**
42
 * @brief Send bullet_info.
43
 * @param   p   Pointer to bullet_info to be sent
44
 * @return  SUCCESS if operation was successful, other value otherwise
45
 */
18 46
int hltp_send_bullet_info(const bullet_info_t *p);
47
/**
48
 * @brief Interpret message received as one of the structs HLTP knows.
49
 * @param   p       Pointer to beginning of message
50
 * @param   sz      Size of message
51
 * @param   dest    Pointer to void*, to where the interpreted message will be saved
52
 * @return          Code of the interpreted message
53
 */
19 54
hltp_type hltp_interpret(const uint8_t *p, const size_t sz, void **dest);
55

  
56
/**
57
 * @}
58
 */
59

  
20 60
#endif //HLTP_H_INCLUDED
proj/libs/uart/include/uart.h
1 1
#ifndef UART_H_INCLUDED
2 2
#define UART_H_INCLUDED
3 3

  
4
/**
5
 * @defgroup uart uart
6
 * @brief UART module.
7
 *
8
 * @{
9
 */
10

  
4 11
#define COM1_ADDR           0x3F8
5 12
#define COM2_ADDR           0x2F8
6 13
#define COM1_IRQ            4
......
34 41
    uint8_t modem_stat_int        :1;
35 42
} uart_config;
36 43

  
44
/**
45
 * @brief Subscribes UART interrupts and disables Minix Default IH.
46
 * @param interrupt_bit Bit of interrupt vector that will be set when UART interrupt is pending
47
 * @param interrupt_id UART interrupt ID to specify the UART interrupt in other calls
48
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
49
 * @see {_ERRORS_H_::errors}
50
 */
37 51
int (subscribe_uart_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
38

  
52
/**
53
 * @brief Get UART configuration.
54
 * @param   base_addr   Base address of the serial port whose configuration we want
55
 * @param   config      Pointer to uart_config where the read configuration will be stored
56
 * @return SUCCESS if operation is successful, other value otherwise
57
 */
39 58
int uart_get_config(int base_addr, uart_config *config);
59
/**
60
 * @brief Print to stdout a UART configuration in a human-friendly way.
61
 * @param   config  UART configuration to be printed
62
 */
40 63
void uart_print_config(uart_config config);
41 64

  
65
/**
66
 * @brief Set number of bits per character.
67
 *
68
 * Valid numbers of bits per char go from 5 to 8.
69
 * @param   base_addr       Base address of serial port
70
 * @param   bits_per_char   Number of bits per char
71
 * @return                  SUCCESS if operation is successful, other value otherwise
72
 */
42 73
int uart_set_bits_per_character(int base_addr, uint8_t     bits_per_char);
74
/**
75
 * @brief Set number of stop bits.
76
 *
77
 * Valid numbers of stop bits are 1 and 2.
78
 * @param   base_addr   Base address of serial port
79
 * @param   stop        Number of stop bits
80
 * @return              SUCCESS if operation is successful, other value otherwise
81
 */
43 82
int uart_set_stop_bits         (int base_addr, uint8_t     stop         );
83
/**
84
 * @brief Set parity scheme to be used.
85
 * @param   base_addr   Base address of serial port
86
 * @param   par         Parity scheme
87
 * @return              SUCCESS if operation is successful, other value otherwise
88
 */
44 89
int uart_set_parity            (int base_addr, uart_parity par          );
90
/**
91
 * @brief Set bit rate.
92
 *
93
 * Valid numbers of bit rates go up to 115200 bps.
94
 * @param   base_addr       Base address of serial port
95
 * @param   bit_rate        Number of bits per second
96
 * @return                  SUCCESS if operation is successful, other value otherwise
97
 */
45 98
int uart_set_bit_rate          (int base_addr, uint32_t    bit_rate     );
46 99

  
100
/**
101
 * @brief Enable Receiver Register Ready interrupts
102
 * @param   base_addr   Base address of serial port
103
 * @return              SUCCESS if operation is successful, other value otherwise
104
 */
47 105
int uart_enable_int_rx (int base_addr);
106
/**
107
 * @brief Disable Receiver Register Ready interrupts
108
 * @param   base_addr   Base address of serial port
109
 * @return              SUCCESS if operation is successful, other value otherwise
110
 */
48 111
int uart_disable_int_rx(int base_addr);
112
/**
113
 * @brief Enable Transmitter Register Empty interrupts
114
 * @param   base_addr   Base address of serial port
115
 * @return              SUCCESS if operation is successful, other value otherwise
116
 */
49 117
int uart_enable_int_tx (int base_addr);
118
/**
119
 * @brief Disable Transmitter Register Empty interrupts
120
 * @param   base_addr   Base address of serial port
121
 * @return              SUCCESS if operation is successful, other value otherwise
122
 */
50 123
int uart_disable_int_tx(int base_addr);
51 124

  
52
/// NCTP - Non-critical transmission protocol
125
/**
126
 * @}
127
 */
128

  
129
/**
130
* @defgroup nctp    nctp
131
* @ingroup uart
132
* @brief NCTP (Non-Critical Transfer Protocol) module.
133
* @{
134
*/
135

  
136
/**
137
 * @brief Initialize NCTP structures.
138
 * @return SUCCESS if operation is successful, other value otherwise
139
 */
53 140
int nctp_init(void);
141
/**
142
 * @brief Dump all the content of the NCTP in/out queues.
143
 * @return SUCCESS if operation is successful, other value otherwise
144
 */
54 145
int nctp_dump(void);
146
/**
147
 * @brief Set function to be called when a full message is received.
148
 * @return SUCCESS if operation is successful, other value otherwise
149
 */
55 150
int nctp_set_processor(void (*proc_func)(const uint8_t*, const size_t));
151
/**
152
 * @brief Free resources taken on NCTP initialization.
153
 * @return SUCCESS if operation is successful, other value otherwise
154
 */
56 155
int nctp_free(void);
57 156

  
157
/**
158
 * @brief Send a message throught serial port COM1
159
 * @param   num     Number of different blocks to send in the message
160
 * @param   ptr     Array of length num, with pointers to blocks that should be sent
161
 * @param   sz      Size of each block that should be sent, in bytes
162
 * @return SUCCESS if operation is successful, other value otherwise
163
 */
58 164
int nctp_send(size_t num, const uint8_t *const *ptr, const size_t *const sz);
59

  
165
/**
166
 * @brief Get NCTP interrupt handler error code.
167
 * @return  SUCCESS if previous interrupt handler call was successful, other value otherwise
168
 */
60 169
int (nctp_get_ih_error)(void);
170
/**
171
 * @brief NCTP interrupt handler.
172
 *
173
 * @note Must be called on all interrupt cycles. Even if not necessary, it must be
174
 * called so the NCTP is allowed to dump any messages it might receive, even
175
 * if those messages are unexpected.
176
 */
61 177
void nctp_ih(void);
62 178

  
179
/**
180
 * @}
181
 */
182

  
63 183
#endif //UART_H_INCLUDED
proj/libs/utils/include/errors.h
1 1
#ifndef ERRORS_H_INCLUDED
2 2
#define ERRORS_H_INCLUDED
3 3

  
4
/**
5
 * @defgroup    errors  errors
6
 * @brief Error codes.
7
 *
8
 * @{
9
 */
10

  
4 11
/** @brief Error Codes */
5 12
enum errors {
6 13
    SUCCESS = 0,        /** @brief Sucessful */
......
24 31
    OTHER_ERROR         /** @brief Unspecified error */
25 32
};
26 33

  
34
/**
35
 * @}
36
 */
37

  
27 38
#endif //ERRORS_H_INCLUDED
proj/libs/utils/include/fast_math.h
1 1
#ifndef FAST_MATH_H_INCLUDED
2 2
#define FAST_MATH_H_INCLUDED
3 3

  
4
/**
5
 * @defgroup fast_math  fast_math
6
 * @ingroup utils
7
 * @brief   Fast math module.
8
 *
9
 * Essentially, this module provides almost-constant time for mathematical operations
10
 * that do not require extreme precision.
11
 *
12
 * @{
13
 */
14

  
15
/**
16
 * @brief Fast sine function.
17
 * @param   x   Argument
18
 * @return      Sine of x
19
 */
4 20
double fm_sin(double x);
21
/**
22
 * @brief Fast cosine function.
23
 * @param   x   Argument
24
 * @return      Cosine of x
25
 */
5 26
double fm_cos(double x);
6 27

  
28
/**
29
 * @}
30
 */
31

  
7 32
#endif //FAST_MATH_H_INCLUDED
proj/libs/utils/include/utils.h
1 1
#ifndef UTILS_H_INCLUDED
2 2
#define UTILS_H_INCLUDED
3 3

  
4
#define BCD_FIRST(n)     (n >> 4)       /** @brief Get first digit (leftmost digit) of 8-bit BCD */
5
#define BCD_SECOND(n)    (n & 0x0F)     /** @brief Get second digit (rightmost digit) of 8-bit BCD */
4
/**
5
 * @defgroup utils utils
6
 * @brief Utilities module.
7
 *
8
 * @{
9
 */
6 10

  
11
/** @brief Get first digit (leftmost digit) of 8-bit BCD */
12
#define BCD_FIRST(n)     (n >> 4)
13
/** @brief Get second digit (rightmost digit) of 8-bit BCD */
14
#define BCD_SECOND(n)    (n & 0x0F)
15

  
7 16
/**
8 17
 * @brief Gets the least significant byte of a 16-bit variable
9 18
 * @param val 16-bit variable
......
58 67
int32_t max32(int32_t a, int32_t b);
59 68
double  dmax (double  a, double  b);
60 69

  
70
/**
71
 * @brief Get the absolute value of a double.
72
 * @param   a   Argument
73
 * @return      Absolute value of a
74
 */
61 75
double dabs(double a);
62 76

  
77
/**
78
 * @brief Compare if two doubles are approximately equal (within 1e-10).
79
 * @param   a   First value
80
 * @param   b   Second value
81
 * @return      true if the two numbers are approximately equal, false otherwise
82
 */
63 83
int deq(double a, double b);
64 84

  
85
/**
86
 * @}
87
 */
88

  
65 89
#endif //UTILS_H_INCLUDED
proj/libs/utils/include/xpm_utils.h
1 1
#ifndef XMP_UTILS_H_INCLUDED
2 2
#define XMP_UTILS_H_INCLUDED
3 3

  
4
/**
5
 * @defgroup xpm_utils xpm_utils
6
 * @ingroup utils
7
 * @brief XPM utilities module.
8
 *
9
 * @{
10
 */
11

  
12
/**
13
 * @brief Save XPM array of strings as a XPM2 text file.
14
 * @param   p   XPM to be saved
15
 * @param   s   Path to save the XPM as XPM2 file
16
 */
4 17
void xpm_save_as_xpm2(const char* const* p, const char *s);
5

  
18
/**
19
 * @brief Load XPM2 file as a XPM array of strings.
20
 * @param   s   Path to XPM2 file to be loaded
21
 * @return      Array of strings representing the loaded XPM
22
 */
6 23
char** xpm_load_xpm2(const char *s);
7 24

  
25
/**
26
 * @}
27
 */
28

  
8 29
#endif //XMP_UTILS_H_INCLUDED

Also available in: Unified diff