Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adc-feature-for-stm32f429i-discovery #666

Merged
merged 1 commit into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion get-stm32-targets-to-build.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#build matrx with target names and build options
$BuildMatrix = ("MBN_QUAIL", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DUSE_FPU=TRUE -DNF_FEATURE_DEBUGGER=TRUE -DSWO_OUTPUT=OFF -DNF_FEATURE_RTC=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON", 'True'),
("ST_STM32F4_DISCOVERY", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DUSE_FPU=TRUE -DNF_FEATURE_DEBUGGER=TRUE -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON", 'False'),
("ST_STM32F429I_DISCOVERY", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DUSE_FPU=TRUE -DNF_FEATURE_DEBUGGER=TRUE -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON", 'False'),
("ST_STM32F429I_DISCOVERY", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DUSE_FPU=TRUE -DNF_FEATURE_DEBUGGER=TRUE -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON", 'False'),
("ST_NUCLEO64_F091RC", "-DTARGET_SERIES=STM32F0xx -DRTOS=CHIBIOS -DUSE_FPU=TRUE -DNF_FEATURE_DEBUGGER=TRUE -DSWO_OUTPUT=OFF -DNF_FEATURE_RTC=ON -DAPI_Windows.Devices.Gpio=OFF", 'False'),
("ST_NUCLEO144_F746ZG", "-DTARGET_SERIES=STM32F7xx -DRTOS=CHIBIOS -DUSE_FPU=TRUE -DNF_FEATURE_DEBUGGER=TRUE -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON", 'False'),
("ST_STM32F769I_DISCOVERY", "-DTARGET_SERIES=STM32F7xx -DRTOS=CHIBIOS -DUSE_FPU=TRUE -DNF_FEATURE_DEBUGGER=TRUE -DSWO_OUTPUT=ON -DNF_FEATURE_RTC=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON", 'False'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ if(API_Windows.Devices.SerialCommunication)
list(APPEND API_RELATED_TARGET_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/target_windows_devices_serialcommunication_config.cpp")
endif()

# Windows.Devices.Adc
if(API_Windows.Devices.Adc)
list(APPEND API_RELATED_TARGET_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/target_windows_devices_adc_config.cpp")
endif()

#######################################

add_subdirectory("common")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Managed code helpers

This folder contains helper classes to make developers life easier when coding for this target board.

* [Adc](STM32F429I_DISCOVERY.Adc.cs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// Copyright (c) 2018 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Targets.STM32F429I_DISCOVERY
{
/// <summary>
/// Enumeration of ADC channels available in STM32F429I_DISCOVERY
/// </summary>
public static class AdcChannels
{
/// <summary>
/// Channel 0, exposed on PA5, connected to PA5 (ADC1 - IN5)
/// </summary>
public const int Channel_0 = 0;

/// <summary>
/// Channel 1, exposed on PC3, connected to PC3 (ADC2 - IN13)
/// </summary>
public const int Channel_1 = 1;

/// <summary>
/// Channel 2, exposed on PF6, connected to PF6 (ADC3 - IN4)
/// </summary>
public const int Channel_2 = 2;

/// <summary>
/// Channel 3, internal temperature sensor, connected to ADC1
/// </summary>
public const int Channel_TemperatureSensor = 3;

/// <summary>
/// Channel 4, internal voltage reference, connected to ADC1
/// </summary>
public const int Channel_VrefIn = 4;

/// <summary>
/// Channel 5, connected to VBatt pin, ADC1
/// </summary>
public const int Channel_Vbatt = 5;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
* ADC driver system settings.
*/
#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
#define STM32_ADC_USE_ADC1 FALSE
#define STM32_ADC_USE_ADC2 FALSE
#define STM32_ADC_USE_ADC3 FALSE
#define STM32_ADC_USE_ADC1 TRUE
#define STM32_ADC_USE_ADC2 TRUE
#define STM32_ADC_USE_ADC3 TRUE
#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright (c) 2018 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

#include "win_dev_adc_native.h"


const NF_PAL_ADC_PORT_PIN_CHANNEL AdcPortPinConfig[] = {

// ADC1
{1, GPIOA, 5, ADC_CHANNEL_IN5},

// ADC2
{2, GPIOC, 3, ADC_CHANNEL_IN13},

// ADC3
{3, GPIOF, 6, ADC_CHANNEL_IN4},

// these are the internal sources, available only at ADC1
{1, NULL, NULL, ADC_CHANNEL_SENSOR},
{1, NULL, NULL, ADC_CHANNEL_VREFINT},
{1, NULL, NULL, ADC_CHANNEL_VBAT},
};

const int AdcChannelCount = ARRAYSIZE(AdcPortPinConfig);