This commits adds initial support for the Kinetis Freedom-K28F board. Not you ready for prime time.

Squashed commit of the following:

    arch/arm/src/kinetis:  A fixes from first (unsuccessful) attempt to build the Freedom-K28F configuration.
    configs/freedom-k28f:  Add basic board support for Freedom-K28F.  Initial commit is basically just the Teensy-3.x brought up to date and with name changes.
This commit is contained in:
Gregory Nutt 2018-05-02 13:14:32 -06:00
parent 4261249fb6
commit d2def725d9
25 changed files with 1953 additions and 5 deletions

View file

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX README Files</i></font></big></h1>
<p>Last Updated: April 21, 2018</p>
<p>Last Updated: May 1, 2018</p>
</td>
</tr>
</table>
@ -105,6 +105,8 @@ nuttx/
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/flipnclick-pic32mz/README.txt" target="_blank"><b><i>README.txt</i></b></a>
| |- flipnclick-sam3x/
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/flipnclick-sam3x/README.txt" target="_blank"><b><i>README.txt</i></b></a>
| |- freedom-k28f/
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/freedom-k28f/README.txt" target="_blank"><b><i>README.txt</i></b></a>
| |- freedom-k64f/
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/freedom-k64f/README.txt" target="_blank"><b><i>README.txt</i></b></a>
| |- freedom-k66f/

View file

@ -1682,6 +1682,8 @@ nuttx/
| | `- README.txt
| |- flipnclick-sam3x/
| | `- README.txt
| |- freedom-k28f/
| | `- README.txt
| |- freedom-k64f/
| | `- README.txt
| |- freedom-k66f/

View file

@ -7,7 +7,7 @@ if ARCH_ARM
comment "ARM Options"
choice
prompt "ARM chip selection"
prompt "ARM MCU selection"
default ARCH_CHIP_STM32
config ARCH_CHIP_A1X

View file

@ -174,7 +174,7 @@
# define KINETIS_TPM2_BASE 0x400ca000 /* TPM2 */
# define KINETIS_DAC0_ALT_BASE 0x400cc000 /* Alternate address 12-bit digital-to-analog
* converter (DAC) 0 */
# define KINETIS_LPUART3_BASE 0x400d6000 /* LPUART3 */
# define KINETIS_LPUART4_BASE 0x400d6000 /* LPUART4 */
# define KINETIS_QSPI0C_BASE 0x400da000 /* QSPI0 controller */
# define KINETIS_FLEXIO0_BASE 0x400df000 /* FlexIO0 */
# define KINETIS_I2C2_BASE 0x400e6000 /* I2C 2 */

View file

@ -57,7 +57,7 @@
# else
VECTOR(kinetis_dmach0, KINETIS_IRQ_DMACH0 /* 0: DMA channel 0, 16 transfer complete */
VECTOR(kinetis_dmach0, KINETIS_IRQ_DMACH0) /* 0: DMA channel 0, 16 transfer complete */
VECTOR(kinetis_dmach1, KINETIS_IRQ_DMACH1) /* 1: DMA channel 1, 17 transfer complete */
VECTOR(kinetis_dmach2, KINETIS_IRQ_DMACH2) /* 2: DMA channel 2, 18 transfer complete */
VECTOR(kinetis_dmach3, KINETIS_IRQ_DMACH3) /* 3: DMA channel 3, 19 transfer complete */

View file

@ -220,6 +220,17 @@ config ARCH_BOARD_FLIPNCLICK_SAM3X
Like the Arduino DUE, this board features the Atmel ATSAM3X8E MCU
running at 84 MHz.
config ARCH_BOARD_FREEDOM_K28F
bool "NXP Freedom-k28f development board"
depends on ARCH_CHIP_MK28FN2M0VMI15
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
select ARCH_HAVE_IRQBUTTONS
---help---
development board.
This port uses the NXP/FreeScale FREEDOM-K28F development board. This
board uses the Kinetis K28F MK28FN2M0VMI15 Cortex-M4 MCU.
config ARCH_BOARD_FREEDOM_K64F
bool "NXP Freedom-k64f development board"
depends on ARCH_CHIP_MK64FN1M0VLL12
@ -1649,6 +1660,7 @@ config ARCH_BOARD
default "fire-stm32v2" if ARCH_BOARD_FIRE_STM32
default "flipnclick-pic32mz" if ARCH_BOARD_FLIPNCLICK_PIC32MZ
default "flipnclick-sam3x" if ARCH_BOARD_FLIPNCLICK_SAM3X
default "freedom-k28f" if ARCH_BOARD_FREEDOM_K28F
default "freedom-k64f" if ARCH_BOARD_FREEDOM_K64F
default "freedom-k66f" if ARCH_BOARD_FREEDOM_K66F
default "freedom-kl25z" if ARCH_BOARD_FREEDOM_KL25Z
@ -1881,6 +1893,9 @@ endif
if ARCH_BOARD_FLIPNCLICK_SAM3X
source "configs/flipnclick-sam3x/Kconfig"
endif
if ARCH_BOARD_FREEDOM_K28F
source "configs/freedom-k28f/Kconfig"
endif
if ARCH_BOARD_FREEDOM_K64F
source "configs/freedom-k64f/Kconfig"
endif

View file

@ -273,6 +273,10 @@ configs/flipnclick-sam3x
Arduino DUE, this board features the Atmel ATSAM3X8E MCU running at 84
MHz.
configs/freedom-k28f
This port uses the NXP/FreeScale FREEDOM-K28F development board. This
board uses the Kinetis K28F MK28FN2M0VMI15 Cortex-M4 MCU.
configs/freedom-k64f
This port uses the NXP/FreeScale FREEDOM-K64F development board. This board
uses the Kinetis K64 MK64FN1M0VLL12 Cortex-M4 MCU.

View file

@ -0,0 +1,8 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_BOARD_FREEDOM_K28F
endif

View file

@ -27,4 +27,118 @@ README
- CMSIS-DAP debug interface over a driverless USB HID connection providing
run-control debugging and compatibility with the IDE tools.
- Virtual serial port interface.
- Open-source CMSIS-DAP software project.
- Open-source CMSIS-DAP software project.
Serial Console
==============
----- --------------- -------------------------------
GPIO LPUART FUNCTION BOARD CONFIGURATION
----- --------------- -------------------------------
PTA1 LPUART0_RX PTA1 GPIO0
PTA15 LPUART0_RX PTA15 FXIO0_D21
PTB14 LPUART0_RX PTB14
PTB16 LPUART0_RX PTB16 SDRAM_D17
PTC25 LPUART0_RX PTC25 LPUART0_RX_TGTMCU
PTD6 LPUART0_RX PTD6 Arduino_D17_ADC0_SE7b
PTA2 LPUART0_TX PTA2 INT
PTA14 LPUART0_TX PTA14 FXIO0_D20
PTB15 LPUART0_TX N/C
PTB17 LPUART0_TX PTB17 SDRAM_D16
PTC24 LPUART0_TX PTC24 LPUART0_TX_TGTMCU
PTD7 LPUART0_TX PTD7 SDRAM_CKE
PTA3 LPUART0_RTS PTA3
PTA17 LPUART0_RTS PTA17 FXIO0_D23
PTB2 LPUART0_RTS PTB2 Arduino_D19_ADC0_SE12/I2C0_SCL/SDRAM_WE
PTB12 LPUART0_RTS PTB12 Arduino_D5_FTM1_CH0/FTM0_CH4
PTC27 LPUART0_RTS PTC27 FXOS8700CQ_RESET
PTD4 LPUART0_RTS PTD4 SDRAM_A10
PTA0 LPUART0_CTS PTA0 K28F_SWD_CLK
PTA16 LPUART0_CTS PTA16 FXIO0_D22
PTB3 LPUART0_CTS PTB3 Arduino_D18_ADC0_SE13/I2C0_SDA/SDRAM_CS0
PTB13 LPUART0_CTS PTB13 Arduino_D6_FTM1_CH1/FTM0_CH5
PTC26 LPUART0_CTS PTC26 FXOS8700CQ_INT
PTD5 LPUART0_CTS PTD5 SDRAM_A9
----- --------------- -------------------------------
PTD8 LPUART1_RX PTD8 FXIO0_D24
PTC3 LPUART1_RX PTC3 CLKOUT
PTE1 LPUART1_RX PTE1 QSPIA0_SCLK
PTC4 LPUART1_TX PTC4 SDRAM_A19
PTD9 LPUART1_TX PTD9 FXIO0_D25
PTE0 LPUART1_TX PTE0 QSPIA0_DATA3
PTD10 LPUART1_RTS PTD10 FXIO0_D26
PTC1 LPUART1_RTS PTC1 SDRAM_A21
PTE3 LPUART1_RTS PTE3 QSPIA0_DATA2
PTC2 LPUART1_CTS PTC1 SDRAM_A21
PTD11 LPUART1_CTS PTD11 FXIO0_D27
PTE2 LPUART1_CTS PTE2 QSPIA0_DATA0
----- --------------- -------------------------------
PTA25 LPUART2_RX PTA25 SDHC0_D0/Arduino_D0_LPUART2_RX
PTD2 LPUART2_RX PTD2 SDRAM_A12
PTE13 LPUART2_RX N/C
PTE17 LPUART2_RX N/C
PTA24 LPUART2_TX PTA24 SDHC0_D1/Arduino_D1_LPUART2_TX
PTD3 LPUART2_TX PTD3 SDRAM_A11
PTE12 LPUART2_TX PTE12 I2S0_TX_BCLK
PTE16 LPUART2_TX N/C
PTD0 LPUART2_RTS PTD0 Button_LLWU_P12
PTA27 LPUART2_RTS PTA27 SDHC0_CMD
PTE19 LPUART2_RTS N/C
PTA26 LPUART2_CTS PTA26 SDHC0_DCLK
PTD1 LPUART2_CTS PTD1 Arduino_D16_ADC0_SE5b
PTE18 LPUART2_CTS N/C
----- --------------- -------------------------------
PTA29 LPUART3_RX PTA29 SDHC0_D2
PTB10 LPUART3_RX PTB10 SDRAM_D19
PTC16 LPUART3_RX PTC16 SDRAM_DQM2
PTE5 LPUART3_RX PTE5 QSPIA0_SS0/USB0_SOF_OUT
PTA28 LPUART3_TX PTA28 SDHC0_D3
PTB11 LPUART3_TX PTB11 SDRAM_D18
PTC17 LPUART3_TX PTC17 SDRAM_DQM3
PTE4 LPUART3_TX PTE4 QSPIA0_DATA1
PTB8 LPUART3_RTS PTB8 SDRAM_D21
PTA31 LPUART3_RTS PTA31
PTC18 LPUART3_RTS PTC18 Arduino_D7
PTE7 LPUART3_RTS PTE7 I2S0_RXD0/LEDRGB_GREEN
PTA30 LPUART3_CTS PTA30
PTB9 LPUART3_CTS PTB9 SDRAM_D20
PTC19 LPUART3_CTS PTC19 Arduino_D8
PTE6 LPUART3_CTS PTE6 I2S0_MCK/LEDRGB_RED
----- --------------- -------------------------------
PTA21 LPUART4_RX PTA21 TE/FXIO0_D9
PTC14 LPUART4_RX PTC14 SDRAM_D25
PTE21 LPUART4_RX N/C
PTA20 LPUART4_TX PTA20 RD/FXIO0_D8
PTC15 LPUART4_TX PTC15 SDRAM_D24
PTE20 LPUART4_TX N/C
PTA23 LPUART4_RTS PTA23 WR/FXIO0_D7
PTC12 LPUART4_RTS PTC12 SDRAM_D27
PTE23 LPUART4_RTS N/C
PTA22 LPUART4_CTS PTA22 CS/FXIO0_D6
PTC13 LPUART4_CTS PTC13 SDRAM_D26
PTE22 LPUART4_CTS N/C
----- --------------- -------------------------------
Arduino RS-232 Shield
---------------------
----- --------------- -------------------------------
GPIO LPUART FUNCTION BOARD CONFIGURATION
----- --------------- -------------------------------
PTA25 LPUART2_RX PTA25 SDHC0_D0/Arduino_D0_LPUART2_RX
PTA24 LPUART2_TX PTA24 SDHC0_D1/Arduino_D1_LPUART2_TX
----- --------------- -------------------------------
Note: PTA24 and PTA25 are shared between Micro SD Card circuit and
Arduino connectors. Remove R106 and R107 or R94 and R11 as necessary to
prevent contention.
TGTMCU
------
----- --------------- -------------------------------
GPIO LPUART FUNCTION BOARD CONFIGURATION
----- --------------- -------------------------------
PTC25 LPUART0_RX PTC25 LPUART0_RX_TGTMCU
PTC24 LPUART0_TX PTC24 LPUART0_TX_TGTMCU
----- --------------- -------------------------------

View file

@ -0,0 +1,263 @@
/************************************************************************************
* configs/freedom-k28f/include/board.h
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
#ifndef __CONFIGS_FREEDOM_K28F_INCLUDE_BOARD_H
#define __CONFIGS_FREEDOM_K28F_INCLUDE_BOARD_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
# include <stdbool.h>
#endif
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Clocking *************************************************************************/
/* The freedom-k28f has a 12MHz crystal on board */
#undef BOARD_EXTCLOCK /* Crystal */
#define BOARD_EXTAL_LP /* Low Power, as opposed to Hi Gain */
/* BOARD_FRDIV is MCG_C1_FRDIV_DIV512 from kinetis_mcg.h. According to the k20
* reference manual, when transitioning MCG clock modes to FLL Bypassed External
* the C1 divider must be set so that the FLL clock is between 31.25 and 39.0625 khz.
* For freedom-k28f that works out to a divider of 512.
*/
#define BOARD_FRDIV MCG_C1_FRDIV_DIV512
#define BOARD_EXTAL_FREQ 12000000 /* 12MHz crystal frequency (REFCLK, Y2) */
#define BOARD_XTAL32_FREQ 32768 /* 32KHz RTC Oscillator (Y1) */
/* PLL Configuration. NOTE: Only even frequency crystals are supported that will
* produce a 2MHz reference clock to the PLL. The rated speed for the MK20DX256VLH7
* is 72MHz and 50MHz for the MK20DX128VLH5.
*
* MK20DX128VLH5 Rated Frequency 50MHz (selecting 48Mhz to use USB)
*
* PLL Input frequency: PLLIN = REFCLK/PRDIV = 16MHz/8 = 2MHz
* PLL Output frequency: PLLOUT = PLLIN*VDIV = 2Mhz*24 = 48MHz
* MCG Frequency: PLLOUT = 48MHz
*
* MK20DX256VLH7 Rated Frequency 72MHz
*
* PLL Input frequency: PLLIN = REFCLK/PRDIV = 16MHz/8 = 2MHz
* PLL Output frequency: PLLOUT = PLLIN*VDIV = 2Mhz*36 = 72MHz
* MCG Frequency: PLLOUT = 72MHz
*/
/* PLL Configuration */
#define BOARD_PRDIV 8 /* PLL External Reference Divider */
#define BOARD_VDIV 24 /* PLL VCO Divider (frequency multiplier) */
/* SIM CLKDIV1 dividers */
#define BOARD_OUTDIV1 1 /* Core = MCG, 48MHz */
#define BOARD_OUTDIV2 1 /* Bus = MCG/1, 48MHz */
#define BOARD_OUTDIV3 0 /* N/A = No OUTDIV3 */
#define BOARD_OUTDIV4 2 /* Flash clock = MCG/2, 24MHz */
#define BOARD_PLLIN_FREQ (BOARD_EXTAL_FREQ / BOARD_PRDIV)
#define BOARD_PLLOUT_FREQ (BOARD_PLLIN_FREQ * BOARD_VDIV)
#define BOARD_MCG_FREQ BOARD_PLLOUT_FREQ
#define BOARD_CORECLK_FREQ (BOARD_MCG_FREQ / BOARD_OUTDIV1)
#define BOARD_BUS_FREQ (BOARD_MCG_FREQ / BOARD_OUTDIV2)
#define BOARD_FLEXBUS_FREQ (BOARD_MCG_FREQ / BOARD_OUTDIV3)
#define BOARD_FLASHCLK_FREQ (BOARD_MCG_FREQ / BOARD_OUTDIV4)
/* Use MCGPLLCLK as the output SIM_SOPT2 MUX selected by
* SIM_SOPT2[PLLFLLSEL]
*/
#define BOARD_SOPT2_PLLFLLSEL SIM_SOPT2_PLLFLLSEL_MCGPLLCLK
#define BOARD_SOPT2_FREQ BOARD_MCG_FREQ
/* Divider output clock = Divider input clock × [ (USBFRAC+1) / (USBDIV+1) ]
* SIM_CLKDIV2_FREQ = BOARD_SOPT2_FREQ × [ (USBFRAC+1) / (USBDIV+1) ]
*/
#if BOARD_SOPT2_FREQ == 96000000
/* USBFRAC/USBDIV = 1/2 of 96Mhz clock = 48MHz */
# define BOARD_SIM_CLKDIV2_USBFRAC 1
# define BOARD_SIM_CLKDIV2_USBDIV 2
#elif BOARD_SOPT2_FREQ == 72000000
/* USBFRAC/USBDIV = 2/3 of 72Mhz clock = 48MHz */
# define BOARD_SIM_CLKDIV2_USBFRAC 2
# define BOARD_SIM_CLKDIV2_USBDIV 3
#elif BOARD_SOPT2_FREQ == 48000000
/* USBFRAC/USBDIV = 1/1 of 48Mhz clock = 48MHz */
# define BOARD_SIM_CLKDIV2_USBFRAC 1
# define BOARD_SIM_CLKDIV2_USBDIV 1
#endif
#define BOARD_SIM_CLKDIV2_FREQ (BOARD_SOPT2_FREQ / \
BOARD_SIM_CLKDIV2_USBDIV * \
BOARD_SIM_CLKDIV2_USBFRAC)
/* Use the output of SIM_SOPT2[PLLFLLSEL] as the USB clock source */
#define BOARD_USB_CLKSRC SIM_SOPT2_USBSRC
#define BOARD_USB_FREQ BOARD_SIM_CLKDIV2_FREQ
/* Allow USBOTG-FS Controller to Read from FLASH */
#define BOARD_USB_FLASHACCESS
/* PWM Configuration */
/* FTM0 Channels */
#define GPIO_FTM0_CH0OUT PIN_FTM0_CH0_2 /* Pin 22: PTC1 */
#define GPIO_FTM0_CH1OUT PIN_FTM0_CH1_2 /* Pin 23: PTC2 */
#define GPIO_FTM0_CH2OUT PIN_FTM0_CH2_2 /* Pin 9: PTC3 */
#define GPIO_FTM0_CH3OUT PIN_FTM0_CH3 /* Pin 10: PTC4 */
#define GPIO_FTM0_CH4OUT PIN_FTM0_CH4 /* Pin 6: PTD4 */
#define GPIO_FTM0_CH5OUT PIN_FTM0_CH5_2 /* Pin 20: PTD5 */
#define GPIO_FTM0_CH6OUT PIN_FTM0_CH6_2 /* Pin 21: PTD6 */
#define GPIO_FTM0_CH7OUT PIN_FTM0_CH7_2 /* Pin 5: PTD7 */
/* FTM1 Channels */
#define GPIO_FTM1_CH0OUT PIN_FTM1_CH0_1 /* Pin 3: PTA12 */
#define GPIO_FTM1_CH1OUT PIN_FTM1_CH1_1 /* Pin 4: PTA13 */
/* FTM2 Channels */
#define GPIO_FTM2_CH0OUT PIN_FTM2_CH0 /* Pin 25: PTB18 */
#define GPIO_FTM2_CH1OUT PIN_FTM2_CH1 /* Pin 32: PTB19 */
/* LED definitions ******************************************************************/
/* A single LED is available driven by PTC5. The LED is grounded so bringing PTC5
* high will illuminate the LED.
*/
/* LED index values for use with board_userled() */
#define BOARD_LED 0
#define BOARD_NLEDS 1
/* LED bits for use with board_userled_all() */
#define BOARD_LED_BIT (1 << BOARD_LED)
/* When CONFIG_ARCH_LEDS is defined in the NuttX configuration, NuttX will
* control the LED as defined below. Thus if the LED is statically on, NuttX has
* successfully booted and is, apparently, running normally. If the LED is
* flashing at approximately 2Hz, then a fatal error has been detected and the
* system has halted.
*/
#define LED_STARTED 0 /* STATUS LED=OFF */
#define LED_HEAPALLOCATE 0 /* STATUS LED=OFF */
#define LED_IRQSENABLED 0 /* STATUS LED=OFF */
#define LED_STACKCREATED 1 /* STATUS LED=ON */
#define LED_INIRQ 2 /* STATUS LED=no change */
#define LED_SIGNAL 2 /* STATUS LED=no change */
#define LED_ASSERTION 3 /* STATUS LED=no change */
#define LED_PANIC 3 /* STATUS LED=flashing */
/* Button definitions ***************************************************************/
/* The freedom-k28f board has no standard GPIO contact buttons */
/* Alternative pin resolution *******************************************************/
/* The K20 has three UARTs with pin availability as follows:
*
* --------- ------ ----------- -------------------------
* UART PORT BOARD PJRC PINOUT DESCRIPTION
* FUNCTION LABEL
* --------- ------ ----------- -------------------------
* UART0_RX PTA1 (See above) MINI54TAN / Bootloader
* PTB16 Pin 0 RX1 / Touch
* PTD6 Pin 21 / A7 RX1 / CS / PWM
* UART0_TX PTA2 (See above) MINI54TAN / Bootloader
* PTB17 Pin 1 TX1 / Touch
* PTD7 Pin 5 TX1 / PWM
* --------- ------ ----------- -------------------------
* UART1_RX PTC3 Pin 9 RX2 / CS / PWM
* PTE1 Pad 26 (Pad on back of board)
* UART1_TX PTC4 Pin 10 TX2 / CS / PWM
* PTE0 Pad 31 (Pad on back of board)
* --------- ------ ----------- -------------------------
* UART2_RX PTD2 Pin 7 RX3 / DOUT
* UART2_TX PTD3 Pin 8 TX3 / DIN
* --------- ------ ----------- -------------------------
*
* The default serial console is UART0 on pins 0 (RX) and 1 (TX).
*/
#ifdef CONFIG_KINETIS_UART0
# define PIN_UART0_RX PIN_UART0_RX_2
# define PIN_UART0_TX PIN_UART0_TX_2
#endif
#ifdef CONFIG_KINETIS_UART1
# define PIN_UART0_RX PIN_UART1_RX_1
# define PIN_UART0_TX PIN_UART1_TX_1
#endif
#ifdef CONFIG_KINETIS_I2C0
#ifdef CONFIG_FREEDOM_K28F_I2C_ALT_PINS
# define PIN_I2C0_SCL (PIN_I2C0_SCL_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW)
# define PIN_I2C0_SDA (PIN_I2C0_SDA_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW)
#else
# define PIN_I2C0_SCL (PIN_I2C0_SCL_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW)
# define PIN_I2C0_SDA (PIN_I2C0_SDA_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW)
#endif
#endif
/* REVISIT: Added only for clean compilation with I2C1 enabled. */
#ifdef CONFIG_KINETIS_I2C1
#ifdef CONFIG_FREEDOM_K28F_I2C_ALT_PINS
# define PIN_I2C1_SCL (PIN_I2C1_SCL_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW)
# define PIN_I2C1_SDA (PIN_I2C1_SDA_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW)
#else
# define PIN_I2C1_SCL (PIN_I2C1_SCL_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW)
# define PIN_I2C1_SDA (PIN_I2C1_SDA_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW)
#endif
#endif
#endif /* __CONFIGS_FREEDOM_K28F_INCLUDE_BOARD_H */

View file

@ -0,0 +1,49 @@
# CONFIG_ARCH_FPU is not set
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
# CONFIG_NSH_CMDPARMS is not set
# CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_PS is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="freedom-k28f"
CONFIG_ARCH_BOARD_FREEDOM_K28F=y
CONFIG_ARCH_CHIP_KINETIS=y
CONFIG_ARCH_CHIP_MK28FN2M0VMI15=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y
CONFIG_BOARD_LOOPSPERMSEC=6024
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_HOST_WINDOWS=y
CONFIG_INTELHEX_BINARY=y
CONFIG_KINETIS_SERIALBRK_BSDCOMPAT=y
CONFIG_KINETIS_UART0=y
CONFIG_KINETIS_UARTFIFOS=y
CONFIG_KINETIS_UART_BREAKS=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=16
CONFIG_RAM_SIZE=65536
CONFIG_RAM_START=0x1fff8000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_SERIAL_TERMIOS=y
CONFIG_SPI=y
CONFIG_START_DAY=2
CONFIG_START_MONTH=5
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"

View file

@ -0,0 +1,114 @@
############################################################################
# configs/freedom-k28f/scripts/Make.defs
#
# Copyright (C) 2018 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
LDSCRIPT = flash.ld
ifeq ($(WINTOOL),y)
# Windows-native toolchains
DIRLINK = $(TOPDIR)/tools/copydir.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mkwindeps.sh
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
else
# Linux/Cygwin-native toolchain
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
endif
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
STRIP = $(CROSSDEV)strip --strip-unneeded
AR = $(ARCROSSDEV)ar rcs
NM = $(ARCROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHDEFINES =
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
ASMEXT = .S
OBJEXT = .o
LIBEXT = .a
EXEEXT =
ifneq ($(CROSSDEV),arm-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
HOSTLDFLAGS =

View file

@ -0,0 +1,160 @@
/****************************************************************************
* configs/freedom-k28f/scripts/flash.ld
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/* The MK28FN2M0VMI15 has 2Mb of FLASH beginning at address 0x0000:0000 and
* 1024Kb of SRAM as follows.
* This device contains TCRAM that is tightly coupled to the ARM Cortex-M4
* core as well as OCRAM that is not tightly coupled to ARM Cortex-M4 core.
* The TCRAM is split into SRAM_L and SRAM_U regions where the SRAM_L and
* SRAM_U ranges form a contiguous block in the memory map anchored at
* address 0x20000000. As such:
*
* - SRAM_L is anchored at address 0x20000000 and occupies the space below
* this address, that is, addresses less than 0x20000000.
* - SRAM_U is anchored at address 0x2000_0000 and occupies the space at and
* above this beginning address, that is, addresses greater than or equal
* to 0x20000000.
*
* FLASH is arranged as 4 blocks of 512 kB of program flash each block
* consisting of 4Kb sectors. The first part of the K28F FLASH region is
* reserved for interrupt vectflash.
*/
MEMORY
{
vectflash (rx) : ORIGIN = 0x00000000, LENGTH = 1K
cfmprotect (rx) : ORIGIN = 0x00000400, LENGTH = 16
progflash (rx) : ORIGIN = 0x00000800, LENGTH = 1M - 2K
tcm (rwx) : ORIGIN = 0x1ffc0000, LENGTH = 512K
ocram (rwx) : ORIGIN = 0x34000000, LENGTH = 512K
}
OUTPUT_ARCH(arm)
ENTRY(_stext)
EXTERN(__flashconfigbytes)
SECTIONS
{
.vectors :
{
_svectors = ABSOLUTE(.);
*(.vectors)
_evectors = ABSOLUTE(.);
} > vectflash
.cfmprotect :
{
KEEP(*(.cfmconfig))
} > cfmprotect
.text :
{
_stext = ABSOLUTE(.);
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > progflash
.init_section :
{
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > progflash
.ARM.extab :
{
*(.ARM.extab*)
} > progflash
__exidx_start = ABSOLUTE(.);
.ARM.exidx :
{
*(.ARM.exidx*)
} > progflash
__exidx_end = ABSOLUTE(.);
.data :
{
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
_edata = ABSOLUTE(.);
} > ocram AT > progflash
_eronly = LOADADDR(.data);
.ramfunc ALIGN(4):
{
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > ocram AT > progflash
_framfuncs = LOADADDR(.ramfunc);
.bss :
{
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
_ebss = ABSOLUTE(.);
} > ocram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

2
configs/freedom-k28f/src/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/.depend
/Make.dep

View file

@ -0,0 +1,58 @@
############################################################################
# configs/freedom-k28f/src/Makefile
#
# Copyright (C) 2018 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
-include $(TOPDIR)/Make.defs
ASRCS =
CSRCS = k28_boot.c k28_bringup.c k28_spi.c k28_i2c.c
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += k28_autoleds.c
else
CSRCS += k28_userleds.c
endif
ifeq ($(CONFIG_KINETIS_USBOTG),y)
CSRCS += k28_usbdev.c
endif
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += k28_appinit.c
endif
ifeq ($(CONFIG_PWM),y)
CSRCS += k28_pwm.c
endif
include $(TOPDIR)/configs/Board.mk

View file

@ -0,0 +1,135 @@
/****************************************************************************
* configs/freedom-k28f/src/freedom-k28f.h
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __CONFIGS_FREEDOM_K28F_SRC_FREEDOM_K28F_H
#define __CONFIGS_FREEDOM_K28F_SRC_FREEDOM_K28F_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Freedom-K28F GPIOs *******************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public data
****************************************************************************/
#ifndef __ASSEMBLY__
struct i2c_master_s; /* Forward reference */
#ifdef CONFIG_KINETIS_I2C0
extern FAR struct i2c_master_s* g_i2c0_dev;
#endif
#ifdef CONFIG_KINETIS_I2C1
extern FAR struct i2c_master_s* g_i2c1_dev;
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: k28_bringup
*
* Description:
* Perform architecture-specific initialization
*
* CONFIG_BOARD_INITIALIZE=y :
* Called from board_initialize().
*
* CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y :
* Called from the NSH library
*
****************************************************************************/
int k28_bringup(void);
/****************************************************************************
* Name: k28_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the KwikStik-K40
* board.
*
****************************************************************************/
void weak_function k28_spidev_initialize(void);
/****************************************************************************
* Name: k28_i2cdev_initialize
*
* Description:
* Called to configure I2C
*
*****************************************************************************/
void k28_i2cdev_initialize(void);
/****************************************************************************
* Name: k28_usbdev_initialize
*
* Description:
* Called to setup USB-related GPIO pins for the Freedom K28F board.
*
****************************************************************************/
extern void weak_function k28_usbdev_initialize(void);
/****************************************************************************
* Name: k28_pwm_setup
*
* Description:
* Initialize PWM and register the PWM device.
*
****************************************************************************/
#ifdef CONFIG_PWM
int k28_pwm_setup(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_FREEDOM_K28F_SRC_FREEDOM_K28F_H */

View file

@ -0,0 +1,102 @@
/****************************************************************************
* config/freedom-k28f/src/k28_appinit.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <syslog.h>
#include <nuttx/board.h>
#include "kinetis_usbotg.h"
#include "freedom-k28f.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef OK
# define OK 0
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform application specific initialization. This function is never
* called directly from application code, but only indirectly via the
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initialization logic and the
* matching application logic. The value cold be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
int board_app_initialize(uintptr_t arg)
{
#ifdef CONFIG_BOARD_INITIALIZE
/* Board initialization already performed by board_initialize() */
return OK;
#else
/* Perform board-specific initialization */
return k28_bringup();
#endif
}

View file

@ -0,0 +1,92 @@
/****************************************************************************
* configs/freedom-k28f/src/k28_autoleds.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include "kinetis.h"
#include "freedom-k28f.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_autoled_initialize
*
* Description:
* Initialize LED GPIOs so that LEDs can be controlled.
*
****************************************************************************/
void board_autoled_initialize(void)
{
kinetis_pinconfig(GPIO_LED);
}
/****************************************************************************
* Name: board_autoled_on
****************************************************************************/
void board_autoled_on(int led)
{
if (led != 2)
{
kinetis_gpiowrite(GPIO_LED, (led != 0));
}
}
/****************************************************************************
* Name: board_autoled_off
****************************************************************************/
void board_autoled_off(int led)
{
if (led != 2)
{
kinetis_gpiowrite(GPIO_LED, false);
}
}
#endif /* CONFIG_ARCH_LEDS */

View file

@ -0,0 +1,103 @@
/************************************************************************************
* configs/freedom-k28f/src/k28_boot.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "freedom-k28f.h"
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: kinetis_boardinitialize
*
* Description:
* All Kinetis architectures must provide the following entry point. This entry
* point is called early in the initialization -- after all memory has been
* configured and mapped but before any devices have been initialized.
*
************************************************************************************/
void kinetis_boardinitialize(void)
{
#if defined(CONFIG_KINETIS_SPI1) || defined(CONFIG_KINETIS_SPI2)
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
* k28_spidev_initialize() has been brought into the link.
*/
if (k28_spidev_initialize)
{
k28_spidev_initialize();
}
#endif
#ifdef CONFIG_ARCH_LEDS
/* Configure on-board LEDs if LED support has been selected. */
board_autoled_initialize();
#endif
}
/****************************************************************************
* Name: board_initialize
*
* Description:
* If CONFIG_BOARD_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_initialize(). board_initialize() will be
* called immediately after up_initialize() is called and just before the
* initial application is started. This additional initialization phase
* may be used, for example, to initialize board-specific device drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_INITIALIZE
void board_initialize(void)
{
/* Perform board-specific initialization */
(void)k28_bringup();
}
#endif

View file

@ -0,0 +1,98 @@
/****************************************************************************
* config/freedom-k28f/src/k28_bringup.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/mount.h>
#include <stdbool.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: k28_bringup
*
* Description:
* Perform architecture-specific initialization
*
* CONFIG_BOARD_INITIALIZE=y :
* Called from board_initialize().
*
* CONFIG_BOARD_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y :
* Called from the NSH library
*
****************************************************************************/
int k28_bringup(void)
{
int ret;
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
ret = mount(NULL, "/proc", "procfs", 0, NULL);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
}
#endif
#ifdef CONFIG_PWM
/* Initialize PWM and register the PWM device. */
ret = k28_pwm_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: k28_pwm_setup() failed: %d\n", ret);
}
#endif
#if defined(CONFIG_KINETIS_I2C0) || defined(CONFIG_KINETIS_I2C1)
/* Initialize I2C busses */
k28_i2cdev_initialize();
#endif
UNUSED(ret);
return OK;
}

View file

@ -0,0 +1,118 @@
/****************************************************************************
* configs/freedom-k28f/src/k28_i2c.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/i2c/i2c_master.h>
#include "up_arch.h"
#include "chip.h"
#include "kinetis.h"
#include "kinetis_i2c.h"
#include "freedom-k28f.h"
#include <arch/board/board.h>
#if defined(CONFIG_KINETIS_I2C0) || defined(CONFIG_KINETIS_I2C1)
/************************************************************************************
* Public Data
************************************************************************************/
#ifdef CONFIG_KINETIS_I2C0
FAR struct i2c_master_s* g_i2c0_dev;
#endif
#ifdef CONFIG_KINETIS_I2C1
FAR struct i2c_master_s* g_i2c1_dev;
#endif
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: k28_i2cdev_initialize
*
* Description:
* Called to configure I2C
*
************************************************************************************/
void k28_i2cdev_initialize(void)
{
int ret = OK;
#ifdef CONFIG_KINETIS_I2C0
g_i2c0_dev = kinetis_i2cbus_initialize(0);
if (g_i2c0_dev == NULL)
{
syslog(LOG_ERR, "ERROR: kinetis_i2cbus_initialize(0) failed: %d\n", ret);
ret = -ENODEV;
}
else
{
#ifdef CONFIG_I2C_DRIVER
ret = i2c_register(g_i2c0_dev, 0);
#endif
}
#endif
#ifdef CONFIG_KINETIS_I2C1
g_i2c1_dev = kinetis_i2cbus_initialize(1);
if (g_i2c1_dev == NULL)
{
syslog(LOG_ERR, "ERROR: kinetis_i2cbus_initialize(1) failed: %d\n", ret);
ret = -ENODEV;
}
else
{
#ifdef CONFIG_I2C_DRIVER
ret = i2c_register(g_i2c1_dev, 1);
#endif
}
#endif
return ret;
}
#endif /* CONFIG_KINETIS_I2C0 || CONFIG_KINETIS_I2C1 */

View file

@ -0,0 +1,143 @@
/************************************************************************************
* configs/freedom-k28f/src/k28_pwm.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/drivers/pwm.h>
#include "chip.h"
#include "up_arch.h"
#include "kinetis_pwm.h"
#include <arch/board/board.h>
#ifdef CONFIG_PWM
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: k28_pwm_setup
*
* Description:
* Initialize PWM and register the PWM device.
*
************************************************************************************/
int k28_pwm_setup(void)
{
static bool initialized = false;
struct pwm_lowerhalf_s *pwm;
int ret;
/* Have we already initialized? */
if (!initialized)
{
#ifdef CONFIG_KINETIS_FTM0_PWM
/* Call kinetis_pwminitialize() to get an instance of the PWM interface */
pwm = kinetis_pwminitialize(0);
if (!pwm)
{
aerr("ERROR: Failed to get the KL20 PWM lower half\n");
return -ENODEV;
}
/* Register the PWM driver at "/dev/pwm0" */
ret = pwm_register("/dev/pwm0", pwm);
if (ret < 0)
{
aerr("ERROR: pwm_register failed: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_KINETIS_FTM1_PWM
pwm = kinetis_pwminitialize(1);
if (!pwm)
{
aerr("ERROR: Failed to get the KL20 PWM lower half\n");
return -ENODEV;
}
/* Register the PWM driver at "/dev/pwm1" */
ret = pwm_register("/dev/pwm1", pwm);
if (ret < 0)
{
aerr("ERROR: pwm_register failed: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_KINETIS_FTM2_PWM
pwm = kinetis_pwminitialize(2);
if (!pwm)
{
aerr("ERROR: Failed to get the KL20 PWM lower half\n");
return -ENODEV;
}
/* Register the PWM driver at "/dev/pwm2" */
ret = pwm_register("/dev/pwm2", pwm);
if (ret < 0)
{
aerr("ERROR: pwm_register failed: %d\n", ret);
return ret;
}
#endif
/* Now we are initialized */
initialized = true;
}
return OK;
}
#endif /* CONFIG_PWM */

View file

@ -0,0 +1,142 @@
/************************************************************************************
* configs/freedom-k28f/src/k28_spi.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/spi/spi.h>
#include "up_arch.h"
#include "chip.h"
#include "kinetis.h"
#include "freedom-k28f.h"
#include <arch/board/board.h>
#if defined(CONFIG_KINETIS_SPI0) || defined(CONFIG_KINETIS_SPI1) || \
defined(CONFIG_KINETIS_SPI2)
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: k28_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the KwikStik-K40 board.
*
************************************************************************************/
void weak_function k28_spidev_initialize(void)
{
# warning "Missing logic"
}
/************************************************************************************
* Name: kinetis_spi0/1/2select and kinetis_spi0/1/2status
*
* Description:
* The external functions, kinetis_spi0/1/2select and kinetis_spi0/1/2status must be
* provided by board-specific logic. They are implementations of the select
* and status methods of the SPI interface defined by struct spi_ops_s (see
* include/nuttx/spi/spi.h). All other methods (including kinetis_spibus_initialize())
* are provided by common Kinetis logic. To use this common SPI logic on your
* board:
*
* 1. Provide logic in kinetis_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide kinetis_spi0/1/2select() and kinetis_spi0/1/2status() functions in your
* board-specific logic. These functions will perform chip selection and
* status operations using GPIOs in the way your board is configured.
* 3. Add a calls to kinetis_spibus_initialize() in your low level application
* initialization logic
* 4. The handle returned by kinetis_spibus_initialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
************************************************************************************/
#ifdef CONFIG_KINETIS_SPI0
void kinetis_spi0select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
# warning "Missing logic"
}
uint8_t kinetis_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
{
# warning "Missing logic"
return SPI_STATUS_PRESENT;
}
#endif
#ifdef CONFIG_KINETIS_SPI1
void kinetis_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
# warning "Missing logic"
}
uint8_t kinetis_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
{
# warning "Missing logic"
return SPI_STATUS_PRESENT;
}
#endif
#ifdef CONFIG_KINETIS_SPI2
void kinetis_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
# warning "Missing logic"
}
uint8_t kinetis_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
{
# warning "Missing logic"
return SPI_STATUS_PRESENT;
}
#endif
#endif /* CONFIG_KINETIS_SPI0 || CONFIG_KINETIS_SPI1 || CONFIG_KINETIS_SPI2 */

View file

@ -0,0 +1,140 @@
/************************************************************************************
* configs/freedom-k28f/src/k28_usbdev.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
#include <nuttx/usb/usbdev_trace.h>
#include "up_arch.h"
#include "kinetis.h"
#include "kinetis_usbotg.h"
#include "chip/kinetis_sim.h"
#include "freedom-k28f.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
#define khci_getreg(addr) getreg8(addr)
#define khci_putreg(val,addr) putreg8(val,addr)
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: k28_usbdev_initialize
*
* Description:
* Called to setup USB-related GPIO pins for the KwikStik-K40 board.
*
************************************************************************************/
void k28_usbdev_initialize(void)
{
}
/************************************************************************************
* Name: kinetis_usbpullup
*
* Description:
* If USB is supported and the board supports a pullup via GPIO (for USB software
* connect and disconnect), then the board software must provide kinetis_pullup.
* See include/nuttx/usb/usbdev.h for additional description of this method.
* Alternatively, if no pull-up GPIO the following EXTERN can be redefined to be
* NULL.
*
************************************************************************************/
int kinetis_usbpullup(FAR struct usbdev_s *dev, bool enable)
{
usbtrace(TRACE_DEVPULLUP, (uint16_t)enable);
#if 0
uint32_t regval;
#endif
if (enable)
{
khci_putreg(USB_CONTROL_DPPULLUPNONOTG, KINETIS_USB0_CONTROL);
}
else
{
khci_putreg(0,KINETIS_USB0_CONTROL);
}
#if 0
regval = khci_getreg(KINETIS_USB0_OTGCTL);
if (enable)
{
regval |= (1 << 2);
}
else
{
regval &= ~(1 << 2);
}
khci_putreg(regval,KINETIS_USB0_OTGCTL);
#endif
return OK;
}
/************************************************************************************
* Name: kinetis_usbsuspend
*
* Description:
* Board logic must provide the kinetis_usbsuspend logic if the USBDEV driver is
* used. This function is called whenever the USB enters or leaves suspend mode.
* This is an opportunity for the board logic to shutdown clocks, power, etc.
* while the USB is suspended.
*
************************************************************************************/
void kinetis_usbsuspend(FAR struct usbdev_s *dev, bool resume)
{
uinfo("resume: %d\n", resume);
#warning "Missing logic"
}

View file

@ -0,0 +1,84 @@
/****************************************************************************
* configs/freedom-k28f/src/kinetis_userleds.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <debug.h>
#include "kinetis.h"
#include "freedom-k28f.h"
#ifndef CONFIG_ARCH_LEDS
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_userled_initialize
****************************************************************************/
void board_userled_initialize(void)
{
kinetis_pinconfig(GPIO_LED);
}
/****************************************************************************
* Name: board_userled
****************************************************************************/
void board_userled(int led, bool ledon)
{
if (led == BOARD_LED)
{
kinetis_gpiowrite(GPIO_LED, ledon);
}
}
/****************************************************************************
* Name: board_userled_all
****************************************************************************/
void board_userled_all(uint8_t ledset)
{
kinetis_gpiowrite(GPIO_LED, (ledset & BOARD_LED_BIT) != 0);
}
#endif /* !CONFIG_ARCH_LEDS */