Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f6571d

Browse files
committed
[TIM] Able to build without HAL module
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent2e79b83 commit9f6571d

File tree

7 files changed

+48
-6
lines changed

7 files changed

+48
-6
lines changed

‎cores/arduino/Tone.cpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include"Arduino.h"
2323

2424
PinName g_lastPin = NC;
25+
26+
#ifdef HAL_TIM_MODULE_ENABLED
2527
staticstimer_t _timer;
2628

2729
// frequency (in hertz) and duration (in milliseconds).
@@ -47,3 +49,16 @@ void noTone(uint8_t _pin)
4749
g_lastPin = NC;
4850
}
4951
}
52+
#else
53+
voidtone(uint8_t _pin,unsignedint frequency,unsignedlong duration)
54+
{
55+
UNUSED(_pin);
56+
UNUSED(frequency);
57+
UNUSED(duration);
58+
}
59+
60+
voidnoTone(uint8_t _pin)
61+
{
62+
UNUSED(_pin);
63+
}
64+
#endif/* HAL_TIM_MODULE_ENABLED*/

‎cores/arduino/stm32/analog.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ extern "C" {
4646

4747

4848
/* Private_Variables */
49+
#if defined(HAL_ADC_MODULE_ENABLED)|| defined(HAL_DAC_MODULE_ENABLED)||\
50+
defined(HAL_TIM_MODULE_ENABLED)
4951
staticPinNameg_current_pin=NC;
52+
#endif
5053

5154
/* Private_Defines */
5255
#ifdefHAL_ADC_MODULE_ENABLED
@@ -160,6 +163,7 @@ static uint32_t get_adc_channel(PinName pin)
160163
}
161164
#endif/* HAL_ADC_MODULE_ENABLED */
162165

166+
#ifdefHAL_TIM_MODULE_ENABLED
163167
staticuint32_tget_pwm_channel(PinNamepin)
164168
{
165169
uint32_tfunction=pinmap_function(pin,PinMap_PWM);
@@ -183,6 +187,7 @@ static uint32_t get_pwm_channel(PinName pin)
183187
}
184188
returnchannel;
185189
}
190+
#endif/* HAL_TIM_MODULE_ENABLED */
186191

187192
#ifdefHAL_DAC_MODULE_ENABLED
188193
staticuint32_tget_dac_channel(PinNamepin)
@@ -647,6 +652,7 @@ uint16_t adc_read_value(PinName pin)
647652
}
648653
#endif/* HAL_ADC_MODULE_ENABLED */
649654

655+
#ifdefHAL_TIM_MODULE_ENABLED
650656
////////////////////////// PWM INTERFACE FUNCTIONS /////////////////////////////
651657

652658

@@ -780,6 +786,7 @@ void pwm_stop(PinName pin)
780786

781787
HAL_TIM_PWM_DeInit(&timHandle);
782788
}
789+
#endif/* HAL_TIM_MODULE_ENABLED */
783790

784791
#ifdef__cplusplus
785792
}

‎cores/arduino/stm32/stm32yyxx_hal_conf.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#defineHAL_GPIO_MODULE_ENABLED
1212
#defineHAL_PWR_MODULE_ENABLED
1313
#defineHAL_RCC_MODULE_ENABLED
14-
#defineHAL_TIM_MODULE_ENABLED
1514

1615
/*
1716
* Optional HAL modules, can be enabled/disabled using
@@ -44,6 +43,12 @@
4443
#undef HAL_SPI_MODULE_ENABLED
4544
#endif
4645

46+
#if !defined(HAL_TIM_MODULE_DISABLED)
47+
#defineHAL_TIM_MODULE_ENABLED
48+
#else
49+
#undef HAL_TIM_MODULE_ENABLED
50+
#endif
51+
4752
/*
4853
* Not defined by default
4954
*/

‎cores/arduino/stm32/timer.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#ifdef__cplusplus
4343
extern"C" {
4444
#endif
45+
#ifdefHAL_TIM_MODULE_ENABLED
4546

4647
/* Private Variables */
4748
typedefenum {
@@ -1507,6 +1508,7 @@ void TIM22_IRQHandler(void)
15071508
}
15081509
}
15091510
#endif//TIM22_BASE
1511+
#endif/* HAL_TIM_MODULE_ENABLED */
15101512

15111513
#ifdef__cplusplus
15121514
}

‎cores/arduino/stm32/timer.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#ifdef__cplusplus
4747
extern"C" {
4848
#endif
49+
#ifdefHAL_TIM_MODULE_ENABLED
4950

5051
/* Exported types ------------------------------------------------------------*/
5152
#defineOFFSETOF(type,member) ((uint32_t) (&(((type *)(0))->member)))
@@ -233,6 +234,7 @@ uint32_t getTimerClkFreq(TIM_TypeDef *tim);
233234

234235
voidattachIntHandle(stimer_t*obj,void (*irqHandle)(stimer_t*));
235236
voidattachIntHandleOC(stimer_t*obj,void (*irqHandle)(void),uint16_ttimChannel,uint16_tpulseWidth);
237+
#endif/* HAL_TIM_MODULE_ENABLED */
236238

237239
#ifdef__cplusplus
238240
}

‎cores/arduino/wiring_analog.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
extern"C" {
2424
#endif
2525

26-
26+
#if defined(HAL_DAC_MODULE_ENABLED)|| defined(HAL_TIM_MODULE_ENABLED)
2727
//This is the list of the IOs configured
2828
uint32_tg_anOutputPinConfigured[MAX_NB_PORT]= {0};
29+
#endif
2930

3031
staticint_readResolution=10;
3132
staticint_writeResolution=8;
@@ -87,8 +88,9 @@ void analogOutputInit(void)
8788
// to digital output.
8889
voidanalogWrite(uint32_tulPin,uint32_tulValue)
8990
{
90-
91+
#if defined(HAL_DAC_MODULE_ENABLED)|| defined(HAL_TIM_MODULE_ENABLED)
9192
uint8_tdo_init=0;
93+
#endif
9294
PinNamep=digitalPinToPinName(ulPin);
9395
if (p!=NC) {
9496
#ifdefHAL_DAC_MODULE_ENABLED
@@ -101,6 +103,7 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue)
101103
dac_write_value(p,ulValue,do_init);
102104
}else
103105
#endif//HAL_DAC_MODULE_ENABLED
106+
#ifdefHAL_TIM_MODULE_ENABLED
104107
if (pin_in_pinmap(p,PinMap_PWM)) {
105108
if (is_pin_configured(p,g_anOutputPinConfigured)== false) {
106109
do_init=1;
@@ -110,7 +113,10 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue)
110113
pwm_start(p,_writeFreq*PWM_MAX_DUTY_CYCLE,
111114
PWM_MAX_DUTY_CYCLE,
112115
ulValue,do_init);
113-
}else {//DIGITAL PIN ONLY
116+
}else
117+
#endif/* HAL_TIM_MODULE_ENABLED */
118+
{
119+
//DIGITAL PIN ONLY
114120
// Defaults to digital write
115121
pinMode(ulPin,OUTPUT);
116122
ulValue=mapResolution(ulValue,_writeResolution,8);

‎cores/arduino/wiring_digital.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,23 @@ void pinMode(uint32_t ulPin, uint32_t ulMode)
3232

3333
if (p!=NC) {
3434
// If the pin that support PWM or DAC output, we need to turn it off
35+
#if defined(HAL_DAC_MODULE_ENABLED)|| defined(HAL_TIM_MODULE_ENABLED)
3536
if (is_pin_configured(p,g_anOutputPinConfigured)) {
3637
#ifdefHAL_DAC_MODULE_ENABLED
3738
if (pin_in_pinmap(p,PinMap_DAC)) {
3839
dac_stop(p);
3940
}else
4041
#endif//HAL_DAC_MODULE_ENABLED
42+
#ifdefHAL_TIM_MODULE_ENABLED
4143
if (pin_in_pinmap(p,PinMap_PWM)) {
4244
pwm_stop(p);
4345
}
44-
reset_pin_configured(p,g_anOutputPinConfigured);
46+
#endif//HAL_TIM_MODULE_ENABLED
47+
{
48+
reset_pin_configured(p,g_anOutputPinConfigured);
49+
}
4550
}
46-
51+
#endif
4752
switch (ulMode) {
4853
caseINPUT:/* INPUT_FLOATING */
4954
pin_function(p,STM_PIN_DATA(STM_MODE_INPUT,GPIO_NOPULL,0));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp