Skip to content

Commit 9c87b50

Browse files
FoniksFoxCantonplasjorgesg82
authored
Delete EXTI and Timer things from Runes, it.c and hal_msp.c (#74)
* feat(EXTI): Remove EXTI from Runes and *it.c * feat(EXTI): Add EXTI example * feat(Timer): Remove time things from Runes and hal_msp.c * style: Run pre-commit * applied formatter --------- Co-authored-by: Daniel Cantó Catalán <144663567+Cantonplas@users.noreply.github.com> Co-authored-by: Jorge Sáez <125664643+jorgesg82@users.noreply.github.com> Co-authored-by: Jorge Sáez <jorgeesg82@gmail.com>
1 parent fff660e commit 9c87b50

6 files changed

Lines changed: 41 additions & 735 deletions

File tree

Core/Src/Examples/ExampleEXTI.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifdef EXAMPLE_EXTI
2+
3+
#include "main.h"
4+
#include "ST-LIB.hpp"
5+
6+
#ifdef TEST_0
7+
// Press the nucleo user button (PC13) to toggle the LED (PB0)
8+
9+
using namespace ST_LIB;
10+
constexpr auto led = ST_LIB::DigitalOutputDomain::DigitalOutput(ST_LIB::PB0);
11+
ST_LIB::DigitalOutputDomain::Instance* g_led;
12+
13+
void toggle_led() { g_led->toggle(); }
14+
15+
constexpr auto exti_req =
16+
ST_LIB::EXTIDomain::Device(ST_LIB::PC13, ST_LIB::EXTIDomain::Trigger::BOTH_EDGES, toggle_led);
17+
using MainBoard = ST_LIB::Board<led, exti_req>;
18+
19+
int main(void) {
20+
MainBoard::init();
21+
22+
static auto& led_instance = MainBoard::instance_of<led>();
23+
g_led = &led_instance;
24+
25+
while (1) {
26+
// led_instance.toggle();
27+
// HAL_Delay(200);
28+
}
29+
}
30+
#endif
31+
32+
#endif

Core/Src/Runes/Runes.cpp

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@ ADC_HandleTypeDef hadc3;
1515
LPTIM_HandleTypeDef hlptim1;
1616
LPTIM_HandleTypeDef hlptim2;
1717
LPTIM_HandleTypeDef hlptim3;
18-
extern TIM_HandleTypeDef htim1;
19-
extern TIM_HandleTypeDef htim2;
20-
extern TIM_HandleTypeDef htim3;
21-
extern TIM_HandleTypeDef htim4;
22-
extern TIM_HandleTypeDef htim5;
23-
extern TIM_HandleTypeDef htim7;
24-
extern TIM_HandleTypeDef htim8;
25-
extern TIM_HandleTypeDef htim12;
26-
extern TIM_HandleTypeDef htim16;
27-
extern TIM_HandleTypeDef htim17;
28-
extern TIM_HandleTypeDef htim15;
29-
extern TIM_HandleTypeDef htim23;
30-
extern TIM_HandleTypeDef htim24;
3118
UART_HandleTypeDef huart1;
3219
UART_HandleTypeDef huart2;
3320
UART_HandleTypeDef huart3;
@@ -98,91 +85,6 @@ unordered_map<UART::Peripheral, UART::Instance*> UART::available_uarts = {
9885
uint8_t UART::printf_uart = 0;
9986
bool UART::printf_ready = false;
10087

101-
#endif
102-
/************************************************
103-
* Encoder
104-
***********************************************/
105-
#ifdef HAL_TIM_MODULE_ENABLED
106-
#define BASE TimerPeripheral::TIM_TYPE::BASE
107-
108-
TimerPeripheral encoder_timer(&htim8, {BASE, 0, 65535}, "TIM 8");
109-
110-
map<pair<Pin, Pin>, TimerPeripheral*> Encoder::pin_timer_map = {{{PC6, PC7}, &encoder_timer}};
111-
112-
#endif
113-
/************************************************
114-
* Timer
115-
***********************************************/
116-
#ifdef HAL_TIM_MODULE_ENABLED
117-
118-
#define BASE TimerPeripheral::TIM_TYPE::BASE
119-
#define ADVANCED TimerPeripheral::TIM_TYPE::ADVANCED
120-
121-
TIM_HandleTypeDef* Time::global_timer = &htim2;
122-
set<TIM_HandleTypeDef*> Time::high_precision_timers = {&htim5, &htim24};
123-
TIM_HandleTypeDef* Time::mid_precision_timer = &htim23;
124-
125-
TimerPeripheral timer1(&htim1, {ADVANCED}, "TIM 1");
126-
TimerPeripheral timer2(&htim2, {BASE}, "TIM 2");
127-
TimerPeripheral timer3(&htim3, {ADVANCED}, "TIM 3");
128-
TimerPeripheral timer4(&htim4, {ADVANCED}, "TIM 4");
129-
TimerPeripheral timer12(&htim12, {ADVANCED}, "TIM 12");
130-
TimerPeripheral timer16(&htim16, {BASE}, "TIM 16");
131-
TimerPeripheral timer17(&htim17, {BASE}, "TIM 17");
132-
TimerPeripheral timer15(&htim15, {ADVANCED}, "TIM 15");
133-
TimerPeripheral timer23(&htim23, {BASE, 275, UINT32_MAX - 1}, "TIM 23");
134-
135-
vector<reference_wrapper<TimerPeripheral>> TimerPeripheral::timers =
136-
{timer1, timer2, timer3, timer4, timer12, timer15, timer16, timer17, timer23};
137-
138-
#endif
139-
140-
/************************************************
141-
* PWM
142-
***********************************************/
143-
#ifdef HAL_TIM_MODULE_ENABLED
144-
145-
#define NORMAL TimerPeripheral::PWM_MODE::NORMAL
146-
#define PHASED TimerPeripheral::PWM_MODE::PHASED
147-
148-
PWMmap TimerPeripheral::available_pwm = {
149-
{PB14, {timer12, {TIM_CHANNEL_1, NORMAL}}},
150-
{PB15, {timer12, {TIM_CHANNEL_2, NORMAL}}},
151-
{PB4, {timer3, {TIM_CHANNEL_1, PHASED}}},
152-
{PB5, {timer3, {TIM_CHANNEL_2, NORMAL}}},
153-
{PC8, {timer3, {TIM_CHANNEL_3, NORMAL}}},
154-
{PD12, {timer4, {TIM_CHANNEL_1, NORMAL}}},
155-
{PD13, {timer4, {TIM_CHANNEL_2, NORMAL}}},
156-
{PD15, {timer4, {TIM_CHANNEL_4, NORMAL}}},
157-
{PE14, {timer1, {TIM_CHANNEL_4, PHASED}}},
158-
{PE6, {timer15, {TIM_CHANNEL_2, NORMAL}}},
159-
{PF1, {timer23, {TIM_CHANNEL_2, NORMAL}}},
160-
{PF2, {timer23, {TIM_CHANNEL_3, NORMAL}}},
161-
{PF3, {timer23, {TIM_CHANNEL_4, NORMAL}}},
162-
{PE5, {timer15, {TIM_CHANNEL_1, NORMAL}}},
163-
{PE11, {timer1, {TIM_CHANNEL_2, NORMAL}}},
164-
};
165-
166-
DualPWMmap TimerPeripheral::available_dual_pwms = {
167-
{{PB8, PB6}, {timer16, {TIM_CHANNEL_1, NORMAL}}},
168-
{{PB9, PB7}, {timer17, {TIM_CHANNEL_1, PHASED}}},
169-
{{PE11, PE10}, {timer1, {TIM_CHANNEL_2, PHASED}}},
170-
{{PE13, PE12}, {timer1, {TIM_CHANNEL_3, PHASED}}},
171-
{{PE5, PE4}, {timer15, {TIM_CHANNEL_1, NORMAL}}},
172-
{{PE9, PE8}, {timer1, {TIM_CHANNEL_1, NORMAL}}},
173-
};
174-
175-
#endif
176-
177-
/************************************************
178-
* Input Capture
179-
***********************************************/
180-
#ifdef HAL_TIM_MODULE_ENABLED
181-
182-
map<Pin, InputCapture::Instance> InputCapture::available_instances = {
183-
{PF0, InputCapture::Instance(PF0, &timer23, TIM_CHANNEL_1, TIM_CHANNEL_2)}
184-
};
185-
18688
#endif
18789

18890
/************************************************
@@ -262,18 +164,6 @@ uint32_t ADC::ranks[16] = {
262164
#endif
263165
#endif
264166

265-
/************************************************
266-
* EXTI
267-
***********************************************/
268-
#ifdef HAL_EXTI_MODULE_ENABLED
269-
270-
map<uint16_t, ExternalInterrupt::Instance> ExternalInterrupt::instances = {
271-
{PE0.gpio_pin, Instance(EXTI0_IRQn)},
272-
{PE1.gpio_pin, Instance(EXTI1_IRQn)}
273-
};
274-
275-
#endif
276-
277167
/************************************************
278168
* I2C
279169
***********************************************/

Core/Src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ constexpr auto led = ST_LIB::DigitalOutputDomain::DigitalOutput(ST_LIB::PF13);
99
using MainBoard = ST_LIB::Board<led>;
1010

1111
#if !defined(EXAMPLE_ADC) && !defined(EXAMPLE_ETHERNET) && !defined(EXAMPLE_MPU) && \
12-
!defined(EXAMPLE_HARDFAULT)
12+
!defined(EXAMPLE_HARDFAULT) && !defined(EXAMPLE_EXTI)
1313
int main(void) {
1414
MainBoard::init();
1515

0 commit comments

Comments
 (0)