Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 6100ef1

Browse files
committed
new pins info and new pwm pins management
1 parent 5a89429 commit 6100ef1

File tree

6 files changed

+198
-154
lines changed

6 files changed

+198
-154
lines changed

cores/arduino/boards.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void init(void) {
7878
systick_init(SYSTICK_RELOAD_VAL);
7979
gpio_init_all();
8080
rcc_clk_enable(RCC_SYSCFG);
81-
boardInit();
81+
//boardInit();
8282
startADC();
8383
setupTimers();
8484
HAL_Init();
@@ -178,6 +178,6 @@ static void timerDefaultConfig(timer_dev *dev) {
178178
case TIMER_BASIC:
179179
break;
180180
}
181-
181+
182182
timer_resume(dev);
183183
}

cores/arduino/boards.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void init(void);
113113
*
114114
* @see init()
115115
*/
116-
extern void boardInit(void);
116+
//extern void boardInit(void); // alfran: commented to new pin management
117117

118118
/**
119119
* @brief Test if a pin is used for a special purpose on your board.

cores/arduino/pwm.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ void analogWrite(uint8 pin, uint16 passed_val)
6969
{
7070
return;
7171
}
72-
72+
if (PIN_MAP[pin].alternate_function != AFx)
73+
{
74+
gpio_set_af_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, PIN_MAP[pin].alternate_function);
75+
}
7376
timer_set_compare(dev, PIN_MAP[pin].timer_channel, duty_cycle);
7477
timer_cc_enable(dev, PIN_MAP[pin].timer_channel);
7578
gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, GPIO_AF_OUTPUT_PP);

cores/arduino/wiring_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* @see stm32_pin_info
4848
*/
4949
#define ADCx 0xFF
50+
#define AFx 0xFF // alfran: added to improove the pwm management
5051

5152
/**
5253
* @brief Stores STM32-specific information related to a given pin.
@@ -57,6 +58,7 @@ typedef struct stm32_pin_info {
5758
uint8 gpio_bit; /**< GPIO port bit. */
5859
timer_dev *timer_device; /**< Pin's timer device, if any. */
5960
uint8 timer_channel; /**< Timer channel, or 0 if none. */
61+
uint8 alternate_function; /**< Alernate function for PWM. */ // alfran: added to improove the pwm management
6062
const adc_dev *adc_device; /**< ADC device, if any. */
6163
uint8 adc_channel; /**< Pin ADC channel, or ADCx if none. */
6264
uint8 filler;

0 commit comments

Comments
 (0)