mirror of https://github.com/ARMmbed/mbed-os.git
STM32F4 Analogout driver: Add explicit pinmap support
parent
4a79e59ef6
commit
eab08d7047
|
@ -35,14 +35,20 @@
|
|||
#include "stm32f4xx_hal.h"
|
||||
#include "PeripheralPins.h"
|
||||
|
||||
void analogout_init(dac_t *obj, PinName pin)
|
||||
#if EXPLICIT_PINMAP_READY
|
||||
#define ANALOGOUT_INIT_DIRECT analogout_init_direct
|
||||
void analogout_init_direct(dac_t* obj, const PinMap *pinmap)
|
||||
#else
|
||||
#define ANALOGOUT_INIT_DIRECT _analogout_init_direct
|
||||
static void _analogout_init_direct(dac_t* obj, const PinMap *pinmap)
|
||||
#endif
|
||||
{
|
||||
DAC_ChannelConfTypeDef sConfig = {0};
|
||||
|
||||
// Get the peripheral name (DAC_1, ...) from the pin and assign it to the object
|
||||
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
|
||||
obj->dac = (DACName)pinmap->peripheral;
|
||||
// Get the functions (dac channel) from the pin and assign it to the object
|
||||
uint32_t function = pinmap_function(pin, PinMap_DAC);
|
||||
uint32_t function = (uint32_t)pinmap->function;
|
||||
MBED_ASSERT(function != (uint32_t)NC);
|
||||
|
||||
// Save the channel for the write and read functions
|
||||
|
@ -65,7 +71,8 @@ void analogout_init(dac_t *obj, PinName pin)
|
|||
}
|
||||
|
||||
// Configure GPIO
|
||||
pinmap_pinout(pin, PinMap_DAC);
|
||||
pin_function(pinmap->pin, pinmap->function);
|
||||
pin_mode(pinmap->pin, PullNone);
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
|
||||
|
@ -88,6 +95,16 @@ void analogout_init(dac_t *obj, PinName pin)
|
|||
analogout_write_u16(obj, 0);
|
||||
}
|
||||
|
||||
void analogout_init(dac_t *obj, PinName pin)
|
||||
{
|
||||
int peripheral = (int)pinmap_peripheral(pin, PinMap_DAC);
|
||||
int function = (int)pinmap_find_function(pin, PinMap_DAC);
|
||||
|
||||
const PinMap explicit_pinmap = {pin, peripheral, function};
|
||||
|
||||
ANALOGOUT_INIT_DIRECT(obj, &explicit_pinmap);
|
||||
}
|
||||
|
||||
void analogout_free(dac_t *obj)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue