forked from apache/nuttx
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boards/nucleo-l432kc: Add internal DAC code.
* Nucleo-L432KC board was missing internal MCU DAC code. * DAC is now available on PA4/A3 and /dev/dac0 when enabled. * Updated info on ADC inputs (PA6/A5,PA7/A6) depending on configuration. Signed-off-by: Tomasz 'CeDeROM' CEDRO <[email protected]>
- Loading branch information
1 parent
444ba4c
commit 2ed9bd5
Showing
5 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/**************************************************************************** | ||
* boards/arm/stm32l4/nucleo-l432kc/src/stm32_dac.c | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. The | ||
* ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Included Files | ||
****************************************************************************/ | ||
|
||
#include <nuttx/config.h> | ||
#include <errno.h> | ||
#include <debug.h> | ||
|
||
#include <nuttx/board.h> | ||
#include <nuttx/analog/dac.h> | ||
|
||
#include "stm32l4_gpio.h" | ||
#include "stm32l4_dac.h" | ||
#include "nucleo-l432kc.h" | ||
|
||
#include <arch/board/board.h> | ||
|
||
/**************************************************************************** | ||
* Private Data | ||
****************************************************************************/ | ||
|
||
#ifdef CONFIG_STM32L4_DAC1 | ||
static struct dac_dev_s *g_dac; | ||
#endif | ||
|
||
/**************************************************************************** | ||
* Public Functions | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Name: stm32l4_dac_setup | ||
****************************************************************************/ | ||
|
||
int stm32l4_dac_setup(void) | ||
{ | ||
static bool initialized = false; | ||
|
||
if (!initialized) | ||
{ | ||
#ifdef CONFIG_STM32L4_DAC1 | ||
int ret; | ||
|
||
g_dac = stm32l4_dacinitialize(0); | ||
if (g_dac == NULL) | ||
{ | ||
aerr("ERROR: Failed to get DAC1 interface\n"); | ||
return -ENODEV; | ||
} | ||
|
||
/* Register the DAC driver at "/dev/dac0" */ | ||
|
||
ret = dac_register("/dev/dac0", g_dac); | ||
if (ret < 0) | ||
{ | ||
aerr("ERROR: dac_register failed: %d\n", ret); | ||
return ret; | ||
} | ||
#endif | ||
|
||
initialized = true; | ||
} | ||
|
||
return OK; | ||
} |