-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu+board frdm-k22f: Add NXP FRDM-K22F development board #6994
Conversation
98d195f
to
de76dac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codewise looks good. I only have a few nitpicks. Is there someone with the hardware that could test ?
This will be ok after usual rebase/squash and comments addressed.
Thanks for the hard work on supporting NXP @gebart :)
cpu/k22f/include/cpu_conf.h
Outdated
#endif | ||
|
||
/** | ||
* @brief ARM Cortex-M specific CPU configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be @name
?
cpu/k22f/include/cpu_conf.h
Outdated
/** | ||
* @name GPIO pin mux function numbers | ||
*/ | ||
/** @{ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be moved in the same doxygen block above
cpu/k22f/include/cpu_conf.h
Outdated
/** | ||
* @name GPIO interrupt flank settings | ||
*/ | ||
/** @{ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
cpu/k22f/include/cpu_conf.h
Outdated
/** | ||
* @name Timer hardware information | ||
*/ | ||
/** @{ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
* @brief UART module configuration options | ||
*/ | ||
typedef struct { | ||
UART_Type *dev; /**< Pointer to module hardware registers */ | ||
void *dev; /**< Pointer to module hardware registers */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for replacing by void *
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer moving the CPU_FAMILY
define into cpu/k22f/Makefile.include
, as it is tied to that CPU...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parens around the value?
}, \ | ||
} | ||
#define LPTMR_NUMOF (1U) | ||
#define LPTMR_CONFIG { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to name the parameters : { .dev = ADC0, .pin = ... },
boards/frdm-k64f/Makefile.include
Outdated
@@ -1,31 +1,7 @@ | |||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 */ | |||
uint8_t type; /**< Hardware module type (KINETIS_UART or KINETIS_LPUART)*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer to PR the 'UART extension' in a separate PR...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -105,6 +105,7 @@ WEAK_DEFAULT void isr_i2s0_rx(void); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is added to the common vectors file, but never used in this file, right?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be used in the periph UART driver, I'll look it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, never mind then.
cpu/kinetis_common/periph/uart.c
Outdated
@@ -23,13 +23,27 @@ | |||
* @} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Untested-ACK (to not block this PR)
Ok, turned out that I was not able to flash because I don't have a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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