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

Implement ADC feature for ST_NUCLEO_F746ZG board #667

Merged
merged 1 commit into from
Apr 17, 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ The above firmware builds include support for the class libraries and features m
| ST_STM32F4_DISCOVERY | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| ST_STM32F429I_DISCOVERY | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: |
| ST_NUCLEO64_F091RC | | | | :heavy_check_mark: | | | | :heavy_check_mark: | | |
| ST_NUCLEO144_F746ZG | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| ST_NUCLEO144_F746ZG | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| ST_STM32F769I_DISCOVERY | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: |
| MBN_QUAIL | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | | | | |
| NETDUINO3_WIFI | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | | |
Expand Down
2 changes: 1 addition & 1 deletion get-stm32-targets-to-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $BuildMatrix = ("MBN_QUAIL", "-DTARGET_SERIES=STM32F4xx -DRTOS=CHIBIOS -DUSE_FPU
("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 -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_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 -DAPI_Windows.Devices.Adc=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'),
("NETDUINO3_WIFI", "-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 -DAPI_Windows.Devices.Adc=ON", 'True')

Expand Down
5 changes: 5 additions & 0 deletions targets/CMSIS-OS/ChibiOS/ST_NUCLEO144_F746ZG/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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,73 @@
//
// Copyright (c) 2018 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Targets.ST_NUCLEO144_F746ZG
{
/// <summary>
/// Enumeration of ADC channels available on ST_NUCLEO144_F746ZG
/// </summary>
public static class AdcChannels
{
/// <summary>
/// Channel 0, exposed as A0, connected to pin 1 on CN9 = PA3 (ADC1 - IN3)
/// </summary>
public const int Channel_0 = 0;

/// <summary>
/// Channel 1, exposed as A1, connected to pin 3 on CN9 = PC0 (ADC1 - IN10)
/// </summary>
public const int Channel_1 = 1;

/// <summary>
/// Channel 2, exposed as A2, connected to pin 5 on CN9 = PC3 (ADC1 - IN13)
/// </summary>
public const int Channel_2 = 2;

/// <summary>
/// Channel 3, exposed as A3, connected to pin 7 on CN9 = PF3 (ADC3 - IN9)
/// </summary>
public const int Channel_3 = 3;

/// <summary>
/// Channel 4, exposed as A4, connected to pin 9 on CN9 = PF5 (ADC3 - IN15)
/// </summary>
public const int Channel_4 = 4;

/// <summary>
/// Channel 5, exposed on A5, connected to pin 11 on CN9 = PF10 (ADC3 - IN8)
/// </summary>
public const int Channel_5 = 5;

/// <summary>
/// Channel 6, exposed on PB1, connected to CN10 Pin 7 (ADC2 - IN9)
/// </summary>
public const int Channel_6 = 6;

/// <summary>
/// Channel 7, exposed on PC2, connected to CN10 Pin 9 (ADC2 - IN12)
/// </summary>
public const int Channel_7 = 7;

/// <summary>
/// Channel 8, exposed on PF4, connected to CN10 Pin 11 (ADC3 - IN14)
/// </summary>
public const int Channel_8 = 8;

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

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

/// <summary>
/// Channel 11, connected to VBatt pin, ADC1
/// </summary>
public const int Channel_Vbatt = 11;
}
}
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](Adc.cs)
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,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,32 @@
//
// 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, 3, ADC_CHANNEL_IN3},
{1, GPIOC, 0, ADC_CHANNEL_IN10},
{1, GPIOC, 3, ADC_CHANNEL_IN13},

// ADC3
{3, GPIOF, 3, ADC_CHANNEL_IN9},
{3, GPIOF, 5, ADC_CHANNEL_IN15},
{3, GPIOF, 10, ADC_CHANNEL_IN8},

// ADC2/ADC3
// Fill up with rest of set ADC pins
{2, GPIOB, 1, ADC_CHANNEL_IN9},
{2, GPIOC, 2, ADC_CHANNEL_IN12},
{3, GPIOF, 4, ADC_CHANNEL_IN14},

// 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);