diff options
Diffstat (limited to 'libmaple')
-rw-r--r-- | libmaple/dac.c | 16 | ||||
-rw-r--r-- | libmaple/dac.h | 2 | ||||
-rw-r--r-- | libmaple/rcc.c | 2 |
3 files changed, 10 insertions, 10 deletions
diff --git a/libmaple/dac.c b/libmaple/dac.c index 7f6101d..63a96ac 100644 --- a/libmaple/dac.c +++ b/libmaple/dac.c @@ -31,12 +31,11 @@ * @brief DAC peripheral routines. */ -/* Only one, so global to this file */ -DAC_Map *dac = (DAC_Map*)(DAC_BASE); - /* This numbering follows the registers (1-indexed) */ -#define DAC_CHA 1 -#define DAC_CHB 2 +#define DAC_CH1 1 +#define DAC_CH2 2 + +DAC_Map *dac = (DAC_Map*)(DAC_BASE); /* Sets up the DAC peripheral */ void dac_init(void) { @@ -49,16 +48,15 @@ void dac_init(void) { /* Then do register stuff. Default does no triggering, and * buffered output, so all good. */ - dac->CR |= DAC_CR_EN1; - dac->CR |= DAC_CR_EN2; + dac->CR = DAC_CR_EN1 | DAC_CR_EN2; } void dac_write(uint8 chan, uint16 val) { switch(chan) { - case DAC_CHA: + case DAC_CH1: dac->DHR12R1 = 0x0FFF & val; break; - case DAC_CHB: + case DAC_CH2: dac->DHR12R2 = 0x0FFF & val; break; default: diff --git a/libmaple/dac.h b/libmaple/dac.h index 9c84f2e..340a49a 100644 --- a/libmaple/dac.h +++ b/libmaple/dac.h @@ -55,6 +55,8 @@ typedef struct { volatile uint32 DOR2; } DAC_Map; +/* There's only one DAC, so expose it. */ +extern DAC_Map *dac; // And here are the register bit ranges #define DAC_CR_EN1 BIT(0) diff --git a/libmaple/rcc.c b/libmaple/rcc.c index 313eaf7..6905c22 100644 --- a/libmaple/rcc.c +++ b/libmaple/rcc.c @@ -70,7 +70,7 @@ static const struct rcc_dev_info rcc_dev_table[] = { [RCC_SPI1] = { .clk_domain = APB2, .line_num = 12 }, [RCC_SPI2] = { .clk_domain = APB1, .line_num = 14 }, [RCC_FSMC] = { .clk_domain = AHB, .line_num = 8 }, // High-density only - [RCC_DAC] = { .clk_domain = APB1, .line_num = 9 }, // High-density only + [RCC_DAC] = { .clk_domain = APB1, .line_num = 29 }, // High-density only [RCC_DMA1] = { .clk_domain = AHB, .line_num = 0 }, [RCC_DMA2] = { .clk_domain = AHB, .line_num = 1 }, // High-density only }; |