From da5a57e72d5c3147fbe402f9421cd8330b1fc8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Fri, 10 Aug 2018 15:23:59 +0200 Subject: [PATCH 1/3] frdm-k64f: Correct and format ADC pin configuration Only ADC1 has a connection with the configured pins, the chosen channels on ADC0 are connected to other pins. --- boards/frdm-k64f/include/periph_conf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/boards/frdm-k64f/include/periph_conf.h b/boards/frdm-k64f/include/periph_conf.h index f0f57c38c6..81d30aca0c 100644 --- a/boards/frdm-k64f/include/periph_conf.h +++ b/boards/frdm-k64f/include/periph_conf.h @@ -120,12 +120,12 @@ static const uart_conf_t uart_config[] = { * @{ */ static const adc_conf_t adc_config[] = { - { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 10), .chan = 14 }, - { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 11), .chan = 15 }, - { .dev = ADC0, .pin = GPIO_PIN(PORT_C, 11), .chan = 7 }, - { .dev = ADC0, .pin = GPIO_PIN(PORT_C, 10), .chan = 6 }, - { .dev = ADC0, .pin = GPIO_PIN(PORT_C, 8), .chan = 4 }, - { .dev = ADC0, .pin = GPIO_PIN(PORT_C, 9), .chan = 5 } + [ 0] = { .dev = ADC1, .pin = GPIO_PIN(PORT_B, 10), .chan = 14 }, /* PTB10 */ + [ 1] = { .dev = ADC1, .pin = GPIO_PIN(PORT_B, 11), .chan = 15 }, /* PTB11 */ + [ 2] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 11), .chan = 7 }, /* PTC11 */ + [ 3] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 10), .chan = 6 }, /* PTC10 */ + [ 4] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 8), .chan = 4 }, /* PTC8 */ + [ 5] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 9), .chan = 5 }, /* PTC9 */ }; #define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0])) From 9d720877d3bccb2ddf05649c766805e7e5efdf40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Fri, 10 Aug 2018 16:25:35 +0200 Subject: [PATCH 2/3] frdm-k64f: Change ADC config to use the Arduino compatible pins --- boards/frdm-k64f/include/periph_conf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/boards/frdm-k64f/include/periph_conf.h b/boards/frdm-k64f/include/periph_conf.h index 81d30aca0c..f44f36eff6 100644 --- a/boards/frdm-k64f/include/periph_conf.h +++ b/boards/frdm-k64f/include/periph_conf.h @@ -120,12 +120,12 @@ static const uart_conf_t uart_config[] = { * @{ */ static const adc_conf_t adc_config[] = { - [ 0] = { .dev = ADC1, .pin = GPIO_PIN(PORT_B, 10), .chan = 14 }, /* PTB10 */ - [ 1] = { .dev = ADC1, .pin = GPIO_PIN(PORT_B, 11), .chan = 15 }, /* PTB11 */ - [ 2] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 11), .chan = 7 }, /* PTC11 */ - [ 3] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 10), .chan = 6 }, /* PTC10 */ - [ 4] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 8), .chan = 4 }, /* PTC8 */ - [ 5] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 9), .chan = 5 }, /* PTC9 */ + [ 0] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 2), .chan = 12 }, /* PTB2 (Arduino A0) */ + [ 1] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 3), .chan = 13 }, /* PTB3 (Arduino A1) */ + [ 2] = { .dev = ADC1, .pin = GPIO_PIN(PORT_B, 10), .chan = 14 }, /* PTB10 (Arduino A2) */ + [ 3] = { .dev = ADC1, .pin = GPIO_PIN(PORT_B, 11), .chan = 15 }, /* PTB11 (Arduino A3) */ + [ 4] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 11), .chan = 7 }, /* PTC11 (Arduino A4) */ + [ 5] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 10), .chan = 6 }, /* PTC10 (Arduino A5) */ }; #define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0])) From 45edfa43bfbd0f410f0b6dcf741ff0506b847ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Fri, 10 Aug 2018 15:25:20 +0200 Subject: [PATCH 3/3] frdm-k64f: Add configuration for dedicated analog pins These pins have no alternate function in the pin mux so we might as well make them available to applications. These pins are the only pins which provide differential analog input pairs on this board. --- boards/frdm-k64f/include/periph_conf.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/boards/frdm-k64f/include/periph_conf.h b/boards/frdm-k64f/include/periph_conf.h index f44f36eff6..0985498588 100644 --- a/boards/frdm-k64f/include/periph_conf.h +++ b/boards/frdm-k64f/include/periph_conf.h @@ -126,6 +126,26 @@ static const adc_conf_t adc_config[] = { [ 3] = { .dev = ADC1, .pin = GPIO_PIN(PORT_B, 11), .chan = 15 }, /* PTB11 (Arduino A3) */ [ 4] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 11), .chan = 7 }, /* PTC11 (Arduino A4) */ [ 5] = { .dev = ADC1, .pin = GPIO_PIN(PORT_C, 10), .chan = 6 }, /* PTC10 (Arduino A5) */ + [ 6] = { .dev = ADC0, .pin = GPIO_UNDEF , .chan = 0 }, /* ADC0_DP0 */ + [ 7] = { .dev = ADC0, .pin = GPIO_UNDEF , .chan = 19 }, /* ADC0_DM0 */ + [ 8] = { .dev = ADC0, .pin = GPIO_UNDEF , .chan = (0 | ADC_SC1_DIFF_MASK) }, /* ADC0_DP0 - ADC0_DM0 */ + [ 9] = { .dev = ADC1, .pin = GPIO_UNDEF , .chan = 0 }, /* ADC1_DP0 */ + [10] = { .dev = ADC1, .pin = GPIO_UNDEF , .chan = 19 }, /* ADC1_DM0 */ + [11] = { .dev = ADC1, .pin = GPIO_UNDEF , .chan = (0 | ADC_SC1_DIFF_MASK) }, /* ADC1_DP0 - ADC1_DM0 */ + [12] = { .dev = ADC0, .pin = GPIO_UNDEF , .chan = 1 }, /* ADC0_DP1 */ + [13] = { .dev = ADC0, .pin = GPIO_UNDEF , .chan = 20 }, /* ADC0_DM1 */ + [14] = { .dev = ADC0, .pin = GPIO_UNDEF , .chan = (1 | ADC_SC1_DIFF_MASK) }, /* ADC0_DP1 - ADC0_DM1 */ + [15] = { .dev = ADC1, .pin = GPIO_UNDEF , .chan = 1 }, /* ADC1_DP1 */ + [16] = { .dev = ADC1, .pin = GPIO_UNDEF , .chan = 20 }, /* ADC1_DM1 */ + [17] = { .dev = ADC1, .pin = GPIO_UNDEF , .chan = (1 | ADC_SC1_DIFF_MASK) }, /* ADC1_DP1 - ADC1_DM1 */ + /* internal: temperature sensor */ + /* The temperature sensor has a very high output impedance, it must not be + * sampled using hardware averaging, or the sampled values will be garbage */ + [18] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 26 }, + /* internal: band gap */ + /* Note: the band gap buffer uses a bit of current and is turned off by default, + * Set PMC->REGSC |= PMC_REGSC_BGBE_MASK before reading or the input will be floating */ + [19] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 27 }, }; #define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))