-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSoC.h
173 lines (132 loc) · 3.07 KB
/
SoC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*!
\file SoC.h
\brief SoC
\author Màrius Montón
\date Feb 2021
*/
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef GUI_SOC_H_
#define GUI_SOC_H_
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "stdbool.h"
#ifdef __cplusplus
extern "C" {
#endif
/** BUTTON 1 is connected to Port A */
#define BUTTON_1_PORT PORTA
/** BUTTON 1 is connected to Pin 11 */
#define BUTTON_1_PIN 11
/** BUTTON 2 is connected to Port B */
#define BUTTON_2_PORT PORTB
/** BUTTON 2 is connected to Pin 1 */
#define BUTTON_2_PIN 1
/** LED 1 is connected to Port C */
#define LED_1_PORT PORTC
/** LED 1 is connected to Pin 7 */
#define LED_1_PIN 7
/** LED 1 is connected to Port D */
#define LED_2_PORT PORTD
/** LED 2 is connected to Pin 12 */
#define LED_2_PIN 12
/** PORT A has IRQ #0 */
#define NVIC_PORTA_IRQ_NUM 0
/** PORT B has IRQ #1 */
#define NVIC_PORTB_IRQ_NUM 1
/** PORT C has IRQ #2 */
#define NVIC_PORTC_IRQ_NUM 2
/** PORT D has IRQ #3 */
#define NVIC_PORTD_IRQ_NUM 3
/** RTC has IRQ #14 */
#define NVIC_RTC_IRQ_NUM 14
/** DAC has IRQ #16 */
#define NVIC_DAC_IRQ_NUM 16
/** UART has irq #23 */
#define NVIC_UART_IRQ_NUM 23
/** Shift value to access PRESCALER value on TIMER_CTRL register */
#define TIMER_CTRL_PRESCALER_SHIFT (8)
/** Shift value to access PRESCALER value on WDOG_CTRL register */
#define WDT_CTRL_PRESCALER_SHIFT (8)
/**
* @brief Initializes SoC library
*/
void SoC_Init();
/********************************** GUI Side *********************************/
/**
* TBD
* @param dev
* @param val
*/
void I2CSlaveSet(int dev, int val);
/**
* @brief Button 1 is pressed. Updates all necessary GPIO registers
*/
void SoC_Button1Pressed();
/**
* @brief Button 1 is released. Updates all necessary GPIO registers
*/
void SoC_Button1Released();
/**
* @brief Button 2 is pressed. Updates all necessary GPIO registers
*/
void SoC_Button2Pressed();
/**
* @brief Button 2 is released. Updates all necessary GPIO registers
*/
void SoC_Button2Released();
/**
* @brief Checks if LED 1 should be on.
* @return true if LED should be on
*/
bool SoC_LED1On();
/**
* @brief Checks if LED 2 should be on
* @return true if LED should be on
*/
bool SoC_LED2On();
/**
* @brief Calculates duty cycle for TIMER
* @return PWM Duty cycle
*/
unsigned int PWMDutyGet();
/**
* @brief Calculates duty cycle frequency
* @return PWM frequency
*/
unsigned int PWMFreqGet();
/**
* @brief Calculates TIMER frequency
* @return TIMER frequency
*/
unsigned int TimerFreqGet();
/**
* DAC buffer size
*/
#define DAC_TOTAL_VALUES (50)
/**
* @brief accessor to DAC output buffer for GUI
* @param data unused
* @param idx buffer index
* @return dac sample
*/
float get_DACVal (void* data, int idx);
/**Anna Casacoberta
* @brief Returns current UART baud rate
* @return baud rate
*/
uint16_t UART_GetBaudRate();
/**
* @brief Notify new symbol received by UART
*/
void UART_NotifyRxData();
void ADCSetValue(int ch, uint16_t value);
#ifdef __cplusplus
}
#endif
/**
* @brief Get UART virtual device name
* @return Device name
*/
const char *getUART_Path();
#endif /* GUI_SOC_H_ */