forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
periph/spi: printing and testing SPI clock rates
tests/periph_spi: printing and testing SPI clock rates drivers/periph_spi: change API of spi_acquire (from RIOT-OS#15904) drivers/periph_spi: add the `bus` parameter to spi_get_*() This was necessary for implementations where multiple devices can have different clock sources. This broke the macros SPI_CLK_* that were reverted to an enum. periph/spi: adapted to the new API Arbitrary speed support was added to all implementations where it was missing.
- Loading branch information
1 parent
d4a8c14
commit 4465c29
Showing
54 changed files
with
1,278 additions
and
1,064 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2017 Eistec AB | ||
* 2021-2023 Hugues Larrive | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser General | ||
* Public License v2.1. See the file LICENSE in the top level directory for more | ||
|
@@ -14,6 +15,7 @@ | |
* @name Peripheral MCU configuration for the FRDM-K22F | ||
* | ||
* @author Joakim Nohlgård <[email protected]> | ||
* @author Hugues Larrive <[email protected]> | ||
*/ | ||
|
||
#ifndef PERIPH_CONF_H | ||
|
@@ -141,22 +143,54 @@ static const uart_conf_t uart_config[] = { | |
*/ | ||
static const adc_conf_t adc_config[] = { | ||
/* dev, pin, channel */ | ||
[ 0] = { .dev = ADC0, .pin = GPIO_UNDEF , .chan = 0, .avg = ADC_AVG_MAX }, /* ADC0_DP0 */ | ||
[ 1] = { .dev = ADC0, .pin = GPIO_UNDEF , .chan = 19, .avg = ADC_AVG_MAX }, /* ADC0_DM0 */ | ||
[ 2] = { .dev = ADC1, .pin = GPIO_UNDEF , .chan = 0, .avg = ADC_AVG_MAX }, /* ADC1_DP0 */ | ||
[ 3] = { .dev = ADC1, .pin = GPIO_UNDEF , .chan = 19, .avg = ADC_AVG_MAX }, /* ADC1_DM0 */ | ||
[ 4] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 0), .chan = 8, .avg = ADC_AVG_MAX }, /* PTB0 (Arduino A0) */ | ||
[ 5] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 1), .chan = 9, .avg = ADC_AVG_MAX }, /* PTB1 (Arduino A1) */ | ||
[ 6] = { .dev = ADC0, .pin = GPIO_PIN(PORT_C, 1), .chan = 15, .avg = ADC_AVG_MAX }, /* PTC1 (Arduino A2) */ | ||
[ 7] = { .dev = ADC0, .pin = GPIO_PIN(PORT_C, 2), .chan = 4, .avg = ADC_AVG_MAX }, /* PTC2 (Arduino A3) */ | ||
[0] = { /* ADC0_DP0 */ | ||
.dev = ADC0, .pin = GPIO_UNDEF, | ||
.chan = 0, .avg = ADC_AVG_MAX | ||
}, | ||
[1] = { /* ADC0_DM0 */ | ||
.dev = ADC0, .pin = GPIO_UNDEF, | ||
.chan = 19, .avg = ADC_AVG_MAX | ||
}, | ||
[2] = { /* ADC1_DP0 */ | ||
.dev = ADC1, .pin = GPIO_UNDEF, | ||
.chan = 0, .avg = ADC_AVG_MAX | ||
}, | ||
[3] = { /* ADC1_DM0 */ | ||
.dev = ADC1, .pin = GPIO_UNDEF, | ||
.chan = 19, .avg = ADC_AVG_MAX | ||
}, | ||
[4] = { /* PTB0 (Arduino A0) */ | ||
.dev = ADC0, .pin = GPIO_PIN(PORT_B, 0), | ||
.chan = 8, .avg = ADC_AVG_MAX | ||
}, | ||
[5] = { /* PTB1 (Arduino A1) */ | ||
.dev = ADC0, .pin = GPIO_PIN(PORT_B, 1), | ||
.chan = 9, .avg = ADC_AVG_MAX | ||
}, | ||
[6] = { /* PTC1 (Arduino A2) */ | ||
.dev = ADC0, .pin = GPIO_PIN(PORT_C, 1), | ||
.chan = 15, .avg = ADC_AVG_MAX | ||
}, | ||
[7] = { /* PTC2 (Arduino A3) */ | ||
.dev = ADC0, .pin = GPIO_PIN(PORT_C, 2), | ||
.chan = 4, .avg = ADC_AVG_MAX | ||
}, | ||
/* 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 */ | ||
[ 8] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 26, .avg = ADC_AVG_NONE }, | ||
/* The temperature sensor has a very high output impedance, it must | ||
* not be sampled using hardware averaging, or the sampled values | ||
* will be garbage */ | ||
[8] = { | ||
.dev = ADC0, .pin = GPIO_UNDEF, | ||
.chan = 26, .avg = ADC_AVG_NONE | ||
}, | ||
/* 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 */ | ||
[ 9] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 27, .avg = ADC_AVG_MAX }, | ||
/* 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 */ | ||
[9] = { | ||
.dev = ADC0, .pin = GPIO_UNDEF, | ||
.chan = 27, .avg = ADC_AVG_MAX | ||
}, | ||
}; | ||
|
||
#define ADC_NUMOF ARRAY_SIZE(adc_config) | ||
|
@@ -191,47 +225,8 @@ static const pwm_conf_t pwm_config[] = { | |
|
||
/** | ||
* @name SPI configuration | ||
* | ||
* Clock configuration values based on the configured 48Mhz module clock. | ||
* | ||
* Auto-generated by: | ||
* cpu/kinetis/dist/calc_spi_scalers/calc_spi_scalers.c | ||
* | ||
* @{ | ||
*/ | ||
static const uint32_t spi_clk_config[] = { | ||
( | ||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(8) | /* -> 93750Hz */ | ||
SPI_CTAR_PCSSCK(0) | SPI_CTAR_CSSCK(8) | | ||
SPI_CTAR_PASC(0) | SPI_CTAR_ASC(8) | | ||
SPI_CTAR_PDT(0) | SPI_CTAR_DT(8) | ||
), | ||
( | ||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(6) | /* -> 375000Hz */ | ||
SPI_CTAR_PCSSCK(0) | SPI_CTAR_CSSCK(6) | | ||
SPI_CTAR_PASC(0) | SPI_CTAR_ASC(6) | | ||
SPI_CTAR_PDT(0) | SPI_CTAR_DT(6) | ||
), | ||
( | ||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(4) | /* -> 1000000Hz */ | ||
SPI_CTAR_PCSSCK(1) | SPI_CTAR_CSSCK(3) | | ||
SPI_CTAR_PASC(1) | SPI_CTAR_ASC(3) | | ||
SPI_CTAR_PDT(1) | SPI_CTAR_DT(3) | ||
), | ||
( | ||
SPI_CTAR_PBR(2) | SPI_CTAR_BR(0) | /* -> 4800000Hz */ | ||
SPI_CTAR_PCSSCK(2) | SPI_CTAR_CSSCK(0) | | ||
SPI_CTAR_PASC(2) | SPI_CTAR_ASC(0) | | ||
SPI_CTAR_PDT(2) | SPI_CTAR_DT(0) | ||
), | ||
( | ||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(0) | /* -> 8000000Hz */ | ||
SPI_CTAR_PCSSCK(1) | SPI_CTAR_CSSCK(0) | | ||
SPI_CTAR_PASC(1) | SPI_CTAR_ASC(0) | | ||
SPI_CTAR_PDT(1) | SPI_CTAR_DT(0) | ||
) | ||
}; | ||
|
||
* @{ | ||
*/ | ||
static const spi_conf_t spi_config[] = { | ||
{ | ||
.dev = SPI0, | ||
|
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
Oops, something went wrong.