Support for Freescale Kinetis MCUs, kinetis_common#2265
Support for Freescale Kinetis MCUs, kinetis_common#2265jnohlgard merged 1 commit intoRIOT-OS:masterfrom jfischer-no:pr@kinetis_common
Conversation
cpu/kinetis_common/timer.c
Outdated
There was a problem hiding this comment.
Why do we freeze the timer here? I can not find an instance below where the FRZ flag is turned off again.
There was a problem hiding this comment.
This allows the timers to be stopped when the device enters the Debug mode. (MKW2xD RM).
ups, PIT code is a little neglected. I wanted to remove it, because it does not fit in function to riot. Maybe I will find time to rewrite it on the weekend.
There was a problem hiding this comment.
Sorry, I mixed up the FRZ and MDIS flags.
|
I will do a more thorough review during the weekend or beginning of the next week. The code seems to work on my K60 board as well as @jfischer-phytec-iot 's KW22 board. |
|
During the porting to kw01z128 I had some problems with identifiers of IRQs (lptmr). It can be resolved if one uses the latest CMSIS compliant header filer. (Contact your FAE to get a newest 😄 ) I currently work at the UART code, there are 3 slightly different UARTs for kinetis MCUs. |
cpu/kinetis_common/uart.c
Outdated
There was a problem hiding this comment.
The logic seem wrong. TX interrupt is supposed to be disabled if return value is zero. dev->C2 &= ~(1 << UART_C2_TIE_SHIFT); (or shorter: dev->C2 &= ~(UART_C2_TIE_MASK);)
There was a problem hiding this comment.
You are right, corrected.
|
I have been working on this with my K60 port during the day, so far I have successfully used the following modules:
Still some more work to be done on my part for testing the rest of the stuff. |
|
@Farthen Regarding PIT timers: The timers are always running at the Bus clock frequency, in order to allow for variable frequency it is possible to use one timer as a divider/counter and chain two timers together. What the timer module does is that it counts |
|
@jfischer-phytec-iot Looking at the SPI driver. I think it can be merged as is, but I would like to suggest some changes to the configuration. I would like to use the two CTAR registers in a different way, in order to be able to communicate with multiple devices with different signal polarities or timings without having to reinitialize the driver over and over. I realize that currently there is no configuration at all, everything is hard coded. I will open a PR later if I find a way to provide a suitable API for the change... |
|
@Farthen Please write your comments in the "Files Changed" tab, that way the comments and a code snippet will be inlined in the discussion thread for the PR on #2265 |
There was a problem hiding this comment.
This should enable MCGIRCLK first, as this is not the default.
MCG->C1 |= MCG_C1_IRCLKEN_MASK;
// For fast internal clock
MCG->C2 |= MCG_C2_IRCS_MASK;
while(!(MCG->S & MCG_S_IRCST_MASK));
There was a problem hiding this comment.
But that is a option for MCG driver or your cpu_clock_init, not for LPTMR driver.
cpu/kinetis_common/adc.c
Outdated
There was a problem hiding this comment.
Change to @ingroup cpu_kinetis_common, put the textual description of the group in the @defgroup command, create a doc.txt similar to what some other CPU directories have.
This applies for all other uses of @addtogroup cpu_kinetis_common below as well. (I won't put a comment on every one, they are too many)
cpu/kinetis_common/adc.c
Outdated
There was a problem hiding this comment.
For each case, add:
adc_config[dev].max_value = (1 << numbits) - 1;|
I noticed some issues with the ADC driver when using it on the K60. Some of the analog pins on the K60 are not configurable through the pin mux and do not have a corresponding PORTx->PCR entry. I will add support for @jfischer-phytec-iot I will take care of the issues in the ADC driver and open a PR against your branch (this PR) when I have fixed it. See above for my other comments on the other |
|
@gebart ok |
|
@jfischer-phytec-iot |
cpu/kinetis_common/include/mcg.h
Outdated
There was a problem hiding this comment.
Replace by an extern declaration (if this is indeed used in any other files than mcg.c):
extern uint32_t cpufreq;There was a problem hiding this comment.
cpufreq is a zombie, it was planned that the mcg driver calculates current cpu frequency, but because of lack of time it has not been done. I will remove it for now.
|
@jfischer-phytec-iot |
cpu/kinetis_common/adc.c
Outdated
There was a problem hiding this comment.
I forgot to subtract 1 here.. Please change this to:
adc_config[dev].max_value = (1 << adc_config[dev].bits) - 1;|
I believe this is ready for merge after squashing and fixing the off by one error in adc.c (caused by me, oops!) |
add peripheral drivers for Freescale Kinetis MCUs:
adc driver
cpuid driver
gpio driver
hwtimer_arch driver (hwtimer used Low Power Timer)
i2c driver (master mode only)
mcg driver
pwm driver
random_rnga driver
random_rngb driver
rtc driver
spi driver
timer driver (timer used Periodic Interrupt Timer)
uart driver
add doc.txt (configuration examples)
random_rnga: Update RNGA driver in preparation for RNGB driver.
random_rngb: Add RNGB driver.
spi: refactor SPI to work for multiple CTARS, add spi_acquire, spi_release
gpio: Add gpio_irq_enable, gpio_irq_disable. Refactor GPIO.
gpio: Add gpio_irq_enable, gpio_irq_disable.
gpio: Refactor ISR functions to work with all GPIOs (0-31) and all ports (PORTA-PORTH)
adc: Refactor ADC, add calibration and scaling.
Added integer scaling of results in adc_map.
Handle precision setting in adc_init.
Set ADC clock divider depending on module clock.
Add ADC_1 as a possible device.
Add ADC calibration procedure according to K60 ref manual.
Handle ADC pins which are not part of the pin function mux.
Signed-off-by: Joakim Gebart <[email protected]>
|
ACK |
Support for Freescale Kinetis MCUs, kinetis_common
|
Great! Congrats and thanks for the effort. |
PRs/MCUs depend on kinetis_common: