cpu+board frdm-k22f: Add NXP FRDM-K22F development board#6994
cpu+board frdm-k22f: Add NXP FRDM-K22F development board#6994jnohlgard merged 6 commits intoRIOT-OS:masterfrom
Conversation
98d195f to
de76dac
Compare
cpu/k22f/include/cpu_conf.h
Outdated
| #endif | ||
|
|
||
| /** | ||
| * @brief ARM Cortex-M specific CPU configuration |
cpu/k22f/include/cpu_conf.h
Outdated
| /** | ||
| * @name GPIO pin mux function numbers | ||
| */ | ||
| /** @{ */ |
There was a problem hiding this comment.
This can be moved in the same doxygen block above
cpu/k22f/include/cpu_conf.h
Outdated
| /** | ||
| * @name GPIO interrupt flank settings | ||
| */ | ||
| /** @{ */ |
cpu/k22f/include/cpu_conf.h
Outdated
| /** | ||
| * @name Timer hardware information | ||
| */ | ||
| /** @{ */ |
| * @brief UART module configuration options | ||
| */ | ||
| typedef struct { | ||
| UART_Type *dev; /**< Pointer to module hardware registers */ |
There was a problem hiding this comment.
Any particular reason for replacing by void * ?
There was a problem hiding this comment.
Yes, this is part of the commit to support both UART and LPUART in the same driver, and there are other CPUs which only have one or the other, so I used a void pointer as the least common denominator.
There was a problem hiding this comment.
That's interesting. I'm wondering if the same strategy could also be applied to STM32. Some macros make the driver implementation harder to read/understand btw.
There was a problem hiding this comment.
The macros are used as a way to eliminate the dispatcher function if a board only supports one or the other type of hardware.
|
I will try to address all comments during this week |
haukepetersen
left a comment
There was a problem hiding this comment.
Nice one! My main issue is the added support for the lpuart which I think might be better PRed separately, but otherwise only minor things.
Did just try to flash the board with a newly pulled openOCD version (0.10.0+dev-00167-g29cfe9c (2017-07-13-18:35)), but without success -> using the jlink interface I get an Selected transport is not supported.... But then I did not try hard and did not try to update the firmware on the flash chip...
| # watchdog automatically. However, current stable releases of Ubuntu and Debian | ||
| # have only version 0.9.0 and older OpenOCD packages (Ubuntu 17.04, Debian Jessie) | ||
| # Set this to 0 to avoid the extra manual step of disabling the watchdog. | ||
| export USE_OLD_OPENOCD ?= 1 |
There was a problem hiding this comment.
I wonder: how about we make a recent version of OpenOCD mandatory if you want to use these boards? This would simplify the configuration quite a bit and I think it is completely ok to expect developers to have more or less recent tool versions... Maybe we can put something in place like OPENOCD_MIN_VER := 0.10.0 in the board's Makefile and add some code in dist/tools/openocd/openocd.sh to check that version and give some verbose error message telling the developter to update OpenOCD? This could also be useful for other boards...
Though this might as well be address in a follow-up PR...
There was a problem hiding this comment.
I don't like the idea of requiring a newer version than what is available in the distributions. For the newer CPUs (e.g. kw41z) there's no choice, but the older CPUs should be possible to use the distribution provided openocd.
There was a problem hiding this comment.
I'm fine with that, I just wanted to think that thought loud once :-)
boards/frdm-k22f/Makefile.include
Outdated
| # define the cpu used by the board | ||
| export CPU = k22f | ||
| export CPU_MODEL = mk22fn512vlh12 | ||
| export CPU_FAMILY = kx |
There was a problem hiding this comment.
I would prefer moving the CPU_FAMILY define into cpu/k22f/Makefile.include, as it is tied to that CPU...
| #define KINETIS_MCG_ERC_OSCILLATOR 1 | ||
| #define KINETIS_MCG_ERC_FRDIV 3 /* ERC divider = 256 */ | ||
| #define KINETIS_MCG_ERC_RANGE 1 | ||
| #define KINETIS_MCG_ERC_FREQ 40000000u |
There was a problem hiding this comment.
parens around the value?
| }, \ | ||
| } | ||
| #define LPTMR_NUMOF (1U) | ||
| #define LPTMR_CONFIG { \ |
There was a problem hiding this comment.
allignment of \ chars is somewhat inconsistent (sorry for being picky :-) )
| { ADC0, GPIO_PIN(PORT_B, 0), 8 }, | ||
| { ADC0, GPIO_PIN(PORT_B, 1), 9 }, | ||
| { ADC0, GPIO_PIN(PORT_C, 1), 15 }, | ||
| { ADC0, GPIO_PIN(PORT_C, 2), 4 }, |
There was a problem hiding this comment.
I'd prefer to name the parameters : { .dev = ADC0, .pin = ... },
boards/frdm-k64f/Makefile.include
Outdated
| # define the cpu used by the FRDM-K64F board | ||
| export CPU = k64f | ||
| export CPU_MODEL = mk64fn1m0vll12 | ||
| export CPU_FAMILY = kx |
There was a problem hiding this comment.
same here: move to CPUs Makefile.include
| @@ -322,6 +330,7 @@ typedef struct { | |||
| volatile uint32_t *scgc_addr; /**< Clock enable register, in SIM module */ | |||
| uint8_t scgc_bit; /**< Clock enable bit, within the register */ | |||
| uint8_t mode; /**< UART mode: data bits, parity, stop bits */ | |||
There was a problem hiding this comment.
I think I would prefer to PR the 'UART extension' in a separate PR...
There was a problem hiding this comment.
Is there any benefit in doing this in two steps, other than bureaucratic? This CPU supports both UART and LPUART, the KW41Z (other PR) supports only LPUART. The already supported kinetis CPUs support AFAIK, only UART. The LPUART should probably be the default when possible because it is working in STOP and VLPS modes (async operation), to allow lower power consumption.
| WEAK_DEFAULT void isr_i2s0_tx(void); | ||
| WEAK_DEFAULT void isr_llwu(void); | ||
| WEAK_DEFAULT void isr_lptmr0(void); | ||
| WEAK_DEFAULT void isr_lpuart0(void); |
There was a problem hiding this comment.
this is added to the common vectors file, but never used in this file, right?!
There was a problem hiding this comment.
Should be used in the periph UART driver, I'll look it up.
There was a problem hiding this comment.
This is the weak default for the function used in vectors.c (https://github.com/gebart/RIOT/blob/pr/frdm-k22f/cpu/k22f/vectors.c#L76) for when the LPUART module is not used by the UART driver.
There was a problem hiding this comment.
I see, never mind then.
| @@ -23,13 +23,27 @@ | |||
| * @} | |||
There was a problem hiding this comment.
as stated above, I think the support for the LPUART should be PRed separately...
|
@haukepetersen did you try flashing with the default setting for FRDM_IFACE? My frdm-k22f board came flashed with a DAP interface firmware. The frdm-kw41z, on the other hand, came with a jlink firmware. The default settings in the board Makefile.include reflect what my boards have had from the factory. |
|
addressed comments |
|
Split the LPUART change into a separate PR #7362 @haukepetersen @aabadie OK to squash? |
aabadie
left a comment
There was a problem hiding this comment.
Untested-ACK (to not block this PR)
|
Ok, turned out that I was not able to flash because I don't have a |
haukepetersen
left a comment
There was a problem hiding this comment.
untested ACK. But confirmed the frdm-k64f to be still working with this PR.
|
please squash and merge at will one Murdock is happy. |
Newer CPUs have alternate clock sources on ADICLK=1 instead of Bus/2
|
squashed, rebased |
|
Murdock is happy -> go |
This PR adds support for the NXP Kinetis K22F CPU and the FRDM-K22F development board.
Some common settings for FRDM development boards were moved to boards/frdm-common to reduce the maintenance effort. The existing FRDM-K64F board support has been updated to use the shared files.
Depends on
#6916#6993