mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 22:20:01 +08:00
Merge remote-tracking branch 'origin/master' into timekeeping
This commit is contained in:
+1
-12
@@ -280,16 +280,6 @@ tools/cnvwindeps$(HOSTEXEEXT):
|
||||
# setting up symbolic links with 'generic' directory names to specific,
|
||||
# configured directories.
|
||||
#
|
||||
# Link the apps/include directory to include/apps
|
||||
|
||||
include/apps: Make.defs
|
||||
ifneq ($(APPDIR),)
|
||||
@echo "LN: include/apps to $(APPDIR)/include"
|
||||
$(Q) if [ -d $(TOPDIR)/$(APPDIR)/include ]; then \
|
||||
$(DIRLINK) $(TOPDIR)/$(APPDIR)/include include/apps; \
|
||||
fi
|
||||
endif
|
||||
|
||||
# Link the arch/<arch-name>/include directory to include/arch
|
||||
|
||||
include/arch: Make.defs
|
||||
@@ -324,7 +314,7 @@ ifneq ($(CONFIG_ARCH_CHIP),)
|
||||
$(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip
|
||||
endif
|
||||
|
||||
dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip include/apps
|
||||
dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip
|
||||
|
||||
# context
|
||||
#
|
||||
@@ -354,7 +344,6 @@ clean_context:
|
||||
$(Q) $(DIRUNLINK) include/arch
|
||||
$(Q) $(DIRUNLINK) $(ARCH_SRC)/board
|
||||
$(Q) $(DIRUNLINK) $(ARCH_SRC)/chip
|
||||
$(Q) $(DIRUNLINK) include/apps
|
||||
|
||||
# check_context
|
||||
#
|
||||
|
||||
+1
-15
@@ -275,19 +275,6 @@ tools\mkdeps$(HOSTEXEEXT):
|
||||
# setting up symbolic links with 'generic' directory names to specific,
|
||||
# configured directories.
|
||||
#
|
||||
# Link the apps\include directory to include\apps
|
||||
|
||||
include\apps: Make.defs
|
||||
ifneq ($(APPDIR),)
|
||||
@echo LN: include\apps $(APPDIR)\include
|
||||
ifeq ($(CONFIG_WINDOWS_MKLINK),y)
|
||||
$(Q) /user:administrator mklink /d include\apps $(APPDIR)\include
|
||||
else
|
||||
$(Q) xcopy $(APPDIR)\include include\apps /c /q /s /e /y /i
|
||||
$(Q) echo FAKELNK > include\apps\.fakelnk
|
||||
endif
|
||||
endif
|
||||
|
||||
# Link the arch\<arch-name>\include directory to include\arch
|
||||
|
||||
include\arch: Make.defs
|
||||
@@ -347,7 +334,7 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $(ARCH_SRC)\chip include\apps
|
||||
dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $(ARCH_SRC)\chip
|
||||
|
||||
# context
|
||||
#
|
||||
@@ -374,7 +361,6 @@ clean_context:
|
||||
$(call DELDIR, include\arch)
|
||||
$(call DELDIR, $(ARCH_SRC)\board)
|
||||
$(call DELDIR, $(ARCH_SRC)\chip)
|
||||
$(call DELDIR, include\apps)
|
||||
|
||||
# check_context
|
||||
#
|
||||
|
||||
@@ -937,6 +937,7 @@ o Network (net/, drivers/net)
|
||||
LM3S NO NO
|
||||
TM4C YES YES
|
||||
eZ80 NO NO
|
||||
Kinetis YES YES (not tested)
|
||||
LPC17xx YES YES (not tested)
|
||||
LPC43xx YES YES (not tested)
|
||||
DMxxx NIC NO NO
|
||||
|
||||
@@ -205,19 +205,22 @@ config KINETIS_UART5
|
||||
config KINETIS_ENET
|
||||
bool "Ethernet"
|
||||
default n
|
||||
depends on ARCH_FAMILY_K60
|
||||
select NET
|
||||
depends on ARCH_FAMILY_K60 || ARCH_FAMILY_K64
|
||||
select ARCH_HAVE_PHY
|
||||
select ARCH_HAVE_NETDEV_STATISTICS
|
||||
select NET
|
||||
select NETDEVICES
|
||||
select NET_MULTIBUFFER
|
||||
---help---
|
||||
Support Ethernet (K60 only)
|
||||
Support Ethernet (K6x only)
|
||||
|
||||
config KINETIS_RNGB
|
||||
bool "Random number generator"
|
||||
default n
|
||||
depends on ARCH_FAMILY_K60
|
||||
depends on ARCH_FAMILY_K60 || ARCH_FAMILY_K64
|
||||
select ARCH_HAVE_RNG
|
||||
---help---
|
||||
Support the random number generator(K60 only)
|
||||
Support the random number generator(K6x only)
|
||||
|
||||
config KINETIS_FLEXCAN0
|
||||
bool "FlexCAN0"
|
||||
@@ -478,7 +481,7 @@ config KINETIS_FTM2_CHANNEL
|
||||
If FTM2 is enabled for PWM usage, you also need specifies the timer output
|
||||
channel {0,..,1}
|
||||
|
||||
comment "Kinetis GPIO Interrupt Configuration"
|
||||
menu "Kinetis GPIO Interrupt Configuration"
|
||||
|
||||
config GPIO_IRQ
|
||||
bool "GPIO pin interrupts"
|
||||
@@ -513,55 +516,63 @@ config KINETIS_PORTEINTS
|
||||
Enable support for 32 interrupts from GPIO port E pins
|
||||
|
||||
endif
|
||||
endmenu # Kinetis GPIO Interrupt Configuration
|
||||
|
||||
if KINETIS_ENET
|
||||
menu "Kinetis Ethernet Configuration"
|
||||
depends on KINETIS_ENET
|
||||
|
||||
comment "Kinetis Ethernet Configuration"
|
||||
|
||||
config ENET_ENHANCEDBD
|
||||
config KINETIS_ENETENHANCEDBD
|
||||
bool "Use enhanced buffer descriptors"
|
||||
default n
|
||||
---help---
|
||||
Use enhanced, 32-byte buffer descriptors
|
||||
|
||||
config ENET_NETHIFS
|
||||
config KINETIS_ENETNETHIFS
|
||||
int "Number of Ethernet interfaces"
|
||||
default 1
|
||||
---help---
|
||||
Number of Ethernet interfaces supported by the hardware. Must be
|
||||
one for now.
|
||||
|
||||
config ENET_NRXBUFFERS
|
||||
config KINETIS_ENETNRXBUFFERS
|
||||
int "Number of Ethernet Rx buffers"
|
||||
default 6
|
||||
---help---
|
||||
Number of Ethernet Rx buffers to use. The size of one buffer is
|
||||
determined by NET_BUFSIZE
|
||||
|
||||
config ENET_NTXBUFFERS
|
||||
config KINETIS_ENETNTXBUFFERS
|
||||
int "Number of Ethernet Tx buffers"
|
||||
default 2
|
||||
---help---
|
||||
Number of Ethernet Tx buffers to use. The size of one buffer is
|
||||
determined by NET_BUFSIZE
|
||||
|
||||
config ENET_PHYADDR
|
||||
int "PHY address"
|
||||
default 1
|
||||
---help---
|
||||
MII/RMII address of the PHY
|
||||
|
||||
config ENET_USEMII
|
||||
config KINETIS_ENETUSEMII
|
||||
bool "Use MII interface"
|
||||
default n
|
||||
---help---
|
||||
The the MII PHY interface. Default: Use RMII interface
|
||||
|
||||
endif
|
||||
config KINETIS_ENET_MDIOPULLUP
|
||||
bool "MDIO pull-up"
|
||||
default n
|
||||
---help---
|
||||
If there is no on-board pull-up resister on the MII/RMII MDIO line,
|
||||
then this option may be selected in order to configure an internal
|
||||
pull-up on MDIO.
|
||||
|
||||
if KINETIS_SDHC
|
||||
config KINETIS_ENET_NORXER
|
||||
bool "Suppress RXER"
|
||||
default n
|
||||
---help---
|
||||
If selected, then the MII/RMII RXER output will be configured as a
|
||||
GPIO and pulled low.
|
||||
|
||||
comment "Kinetis SDHC Configuration"
|
||||
endmenu # Kinetis Ethernet Configuration
|
||||
|
||||
menu "Kinetis SDHC Configuration"
|
||||
depends on KINETIS_SDHC
|
||||
|
||||
config KINETIS_SDHC_ABSFREQ
|
||||
bool "Custom transfer frequencies"
|
||||
@@ -604,18 +615,13 @@ config KINETIS_SD4BIT_FREQ
|
||||
Frequency to use for transferring data to/from an SD card using all four data lines.
|
||||
|
||||
endif
|
||||
endmenu # Kinetis SDHC Configuration
|
||||
|
||||
config KINETIS_SDHC_DMAPRIO
|
||||
int "SDHC DMA priority"
|
||||
depends on SDIO_DMA
|
||||
---help---
|
||||
SDHC DMA priority
|
||||
|
||||
endif
|
||||
|
||||
comment "Kinetis UART Configuration"
|
||||
menu "Kinetis UART Configuration"
|
||||
|
||||
config KINETIS_UARTFIFOS
|
||||
bool "Enable UART0 FIFO"
|
||||
default n
|
||||
depends on KINETIS_UART0
|
||||
|
||||
endmenu # Kinetis UART Configuration
|
||||
|
||||
@@ -83,12 +83,12 @@
|
||||
#define PIN_FTM0_CH1_1 (PIN_ALT3 | PIN_PORTA | PIN4)
|
||||
#define PIN_NMI (PIN_ALT7 | PIN_PORTA | PIN4)
|
||||
#define PIN_FTM0_CH2_1 (PIN_ALT3 | PIN_PORTA | PIN5)
|
||||
#if 0
|
||||
#ifdef CONFIG_KINETIS_ENET_NORXER
|
||||
# define PIN_RMII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
# define PIN_MII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
#else
|
||||
# define PIN_RMII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
# define PIN_MII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#else
|
||||
# define PIN_RMII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
# define PIN_MII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
#endif
|
||||
#define PIN_CMP2_OUT_1 (PIN_ALT5 | PIN_PORTA | PIN5)
|
||||
#define PIN_I2S0_RX_BCLK_1 (PIN_ALT6 | PIN_PORTA | PIN5)
|
||||
@@ -174,7 +174,11 @@
|
||||
#define PIN_TSI0_CH0 (PIN_ANALOG | PIN_PORTB | PIN0)
|
||||
#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0)
|
||||
#define PIN_FTM1_CH0_3 (PIN_ALT3 | PIN_PORTB | PIN0)
|
||||
#define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP
|
||||
# define PIN_RMII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0)
|
||||
#else
|
||||
# define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#endif
|
||||
#define PIN_MII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#define PIN_FTM1_QD_PHA_3 (PIN_ALT6 | PIN_PORTB | PIN0)
|
||||
#define PIN_ADC0_SE9 (PIN_ANALOG | PIN_PORTB | PIN1)
|
||||
|
||||
@@ -398,14 +398,22 @@
|
||||
#define PIN_MII0_COL (PIN_ALT4 | PIN_PORTA | PIN29)
|
||||
#define PIN_MII0_CRS (PIN_ALT4 | PIN_PORTA | PIN27)
|
||||
#define PIN_MII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1)
|
||||
#define PIN_MII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP
|
||||
# define PIN_MII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0)
|
||||
#else
|
||||
# define PIN_MII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#endif
|
||||
#define PIN_MII0_RXCLK (PIN_ALT4 | PIN_PORTA | PIN11)
|
||||
#define PIN_MII0_RXD0 (PIN_ALT4 | PIN_PORTA | PIN13)
|
||||
#define PIN_MII0_RXD1 (PIN_ALT4 | PIN_PORTA | PIN12)
|
||||
#define PIN_MII0_RXD2 (PIN_ALT4 | PIN_PORTA | PIN10)
|
||||
#define PIN_MII0_RXD3 (PIN_ALT4 | PIN_PORTA | PIN9)
|
||||
#define PIN_MII0_RXDV (PIN_ALT4 | PIN_PORTA | PIN14)
|
||||
#define PIN_MII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#ifdef CONFIG_KINETIS_ENET_NORXER
|
||||
# define PIN_MII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
#else
|
||||
# define PIN_MII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#endif
|
||||
#define PIN_MII0_TXCLK (PIN_ALT4 | PIN_PORTA | PIN25)
|
||||
#define PIN_MII0_TXD0 (PIN_ALT4 | PIN_PORTA | PIN16)
|
||||
#define PIN_MII0_TXD1 (PIN_ALT4 | PIN_PORTA | PIN17)
|
||||
@@ -427,10 +435,18 @@
|
||||
|
||||
#define PIN_RMII0_CRS_DV (PIN_ALT4 | PIN_PORTA | PIN14)
|
||||
#define PIN_RMII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1)
|
||||
#define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP
|
||||
# define PIN_RMII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0)
|
||||
#else
|
||||
# define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#endif
|
||||
#define PIN_RMII0_RXD0 (PIN_ALT4 | PIN_PORTA | PIN13)
|
||||
#define PIN_RMII0_RXD1 (PIN_ALT4 | PIN_PORTA | PIN12)
|
||||
#define PIN_RMII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#ifdef CONFIG_KINETIS_ENET_NORXER
|
||||
# define PIN_RMII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
#else
|
||||
# define PIN_RMII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#endif
|
||||
#define PIN_RMII0_TXD0 (PIN_ALT4 | PIN_PORTA | PIN16)
|
||||
#define PIN_RMII0_TXD1 (PIN_ALT4 | PIN_PORTA | PIN17)
|
||||
#define PIN_RMII0_TXEN (PIN_ALT4 | PIN_PORTA | PIN15)
|
||||
|
||||
+601
-100
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/kinetis/kinetis_sdhc.c
|
||||
*
|
||||
* Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -85,10 +85,6 @@
|
||||
# define CONFIG_KINETIS_SDHC_PRIO NVIC_SYSH_PRIORITY_DEFAULT
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_KINETIS_SDHC_DMAPRIO
|
||||
# define CONFIG_KINETIS_SDHC_DMAPRIO DMA_CCR_PRIMED
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DEBUG_MEMCARD_INFO
|
||||
# undef CONFIG_SDIO_XFRDEBUG
|
||||
#endif
|
||||
|
||||
@@ -301,6 +301,7 @@ enum sam_epstate_e
|
||||
USBHS_EPSTATE_STALLED, /* Endpoint is stalled */
|
||||
USBHS_EPSTATE_IDLE, /* Endpoint is idle (i.e. ready for transmission) */
|
||||
USBHS_EPSTATE_SENDING, /* Endpoint is sending data */
|
||||
USBHS_EPSTATE_SENDING_DMA, /* Endpoint is sending data via DMA */
|
||||
USBHS_EPSTATE_NBUSYBK, /* Endpoint DMA complete, waiting for NBUSYBK==0 */
|
||||
USBHS_EPSTATE_RECEIVING, /* Endpoint is receiving data */
|
||||
/* --- Endpoint 0 Only --- */
|
||||
@@ -1006,7 +1007,7 @@ static void sam_dma_wrsetup(struct sam_usbdev_s *priv, struct sam_ep_s *privep,
|
||||
|
||||
/* Switch to the sending state */
|
||||
|
||||
privep->epstate = USBHS_EPSTATE_SENDING;
|
||||
privep->epstate = USBHS_EPSTATE_SENDING_DMA;
|
||||
privreq->inflight = 0;
|
||||
|
||||
/* Get the endpoint number */
|
||||
@@ -1211,16 +1212,23 @@ static void sam_req_complete(struct sam_ep_s *privep, int16_t result)
|
||||
|
||||
privreq->req.result = result;
|
||||
|
||||
/* Callback to the request completion handler */
|
||||
|
||||
privreq->flink = NULL;
|
||||
privreq->req.callback(&privep->ep, &privreq->req);
|
||||
|
||||
/* Reset the endpoint state and restore the stalled indication */
|
||||
/* Reset the endpoint state and restore the stalled indication.
|
||||
*
|
||||
* At least the USB class CDC/ACM calls the function sam_ep_submit within
|
||||
* the callback. This function uses sam_req_write or sam_req_read to process
|
||||
* the request, both functions can change the state. Therefore it is verry
|
||||
* important to set the state to USBHS_EPSTATE_IDLE before the callback is
|
||||
* called.
|
||||
*/
|
||||
|
||||
privep->epstate = USBHS_EPSTATE_IDLE;
|
||||
privep->zlpneeded = false;
|
||||
privep->zlpsent = false;
|
||||
|
||||
/* Callback to the request completion handler */
|
||||
|
||||
privreq->flink = NULL;
|
||||
privreq->req.callback(&privep->ep, &privreq->req);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2497,7 +2505,8 @@ static void sam_dma_interrupt(struct sam_usbdev_s *priv, int epno)
|
||||
|
||||
/* Were we sending? Or receiving? */
|
||||
|
||||
if (privep->epstate == USBHS_EPSTATE_SENDING)
|
||||
if (privep->epstate == USBHS_EPSTATE_SENDING ||
|
||||
privep->epstate == USBHS_EPSTATE_SENDING_DMA)
|
||||
{
|
||||
uint32_t nbusybk;
|
||||
uint32_t byct;
|
||||
@@ -2923,7 +2932,8 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno)
|
||||
*/
|
||||
|
||||
if (privep->epstate == USBHS_EPSTATE_RECEIVING ||
|
||||
privep->epstate == USBHS_EPSTATE_SENDING)
|
||||
privep->epstate == USBHS_EPSTATE_SENDING ||
|
||||
privep->epstate == USBHS_EPSTATE_SENDING_DMA)
|
||||
{
|
||||
sam_req_complete(privep, -EPROTO);
|
||||
}
|
||||
|
||||
@@ -95,9 +95,10 @@ static int stm32_oneshot_handler(int irq, void *context)
|
||||
* Disable the TC now and disable any further interrupts.
|
||||
*/
|
||||
|
||||
STM32_TIM_SETISR(oneshot->tch, NULL, 0);
|
||||
STM32_TIM_DISABLEINT(oneshot->tch, 0);
|
||||
STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
|
||||
STM32_TIM_ACKINT(oneshot->tch, 0);
|
||||
STM32_TIM_DISABLEINT(oneshot->tch, 0);
|
||||
|
||||
/* The timer is no longer running */
|
||||
|
||||
@@ -351,6 +352,7 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
|
||||
/* Now we can disable the interrupt and stop the timer. */
|
||||
|
||||
STM32_TIM_DISABLEINT(oneshot->tch, 0);
|
||||
STM32_TIM_SETISR(oneshot->tch, NULL, 0);
|
||||
STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
|
||||
|
||||
oneshot->running = false;
|
||||
|
||||
@@ -158,9 +158,12 @@
|
||||
# undef CONFIG_STM32_TIM17
|
||||
#endif
|
||||
|
||||
#undef HAVE_TIM_GPIOCONFIG
|
||||
#if defined(CONFIG_STM32_TIM1)
|
||||
# if defined(GPIO_TIM1_CH1OUT) ||defined(GPIO_TIM1_CH2OUT)||\
|
||||
defined(GPIO_TIM1_CH3OUT) ||defined(GPIO_TIM1_CH4OUT)
|
||||
# undef HAVE_TIM_GPIOCONFIG
|
||||
# define HAVE_TIM_GPIOCONFIG 1
|
||||
# define HAVE_TIM1_GPIOCONFIG 1
|
||||
#endif
|
||||
#endif
|
||||
@@ -168,6 +171,8 @@
|
||||
#if defined(CONFIG_STM32_TIM2)
|
||||
# if defined(GPIO_TIM2_CH1OUT) ||defined(GPIO_TIM2_CH2OUT)||\
|
||||
defined(GPIO_TIM2_CH3OUT) ||defined(GPIO_TIM2_CH4OUT)
|
||||
# undef HAVE_TIM_GPIOCONFIG
|
||||
# define HAVE_TIM_GPIOCONFIG 1
|
||||
# define HAVE_TIM2_GPIOCONFIG 1
|
||||
#endif
|
||||
#endif
|
||||
@@ -175,6 +180,8 @@
|
||||
#if defined(CONFIG_STM32_TIM3)
|
||||
# if defined(GPIO_TIM3_CH1OUT) ||defined(GPIO_TIM3_CH2OUT)||\
|
||||
defined(GPIO_TIM3_CH3OUT) ||defined(GPIO_TIM3_CH4OUT)
|
||||
# undef HAVE_TIM_GPIOCONFIG
|
||||
# define HAVE_TIM_GPIOCONFIG 1
|
||||
# define HAVE_TIM3_GPIOCONFIG 1
|
||||
#endif
|
||||
#endif
|
||||
@@ -182,6 +189,8 @@
|
||||
#if defined(CONFIG_STM32_TIM4)
|
||||
# if defined(GPIO_TIM4_CH1OUT) ||defined(GPIO_TIM4_CH2OUT)||\
|
||||
defined(GPIO_TIM4_CH3OUT) ||defined(GPIO_TIM4_CH4OUT)
|
||||
# undef HAVE_TIM_GPIOCONFIG
|
||||
# define HAVE_TIM_GPIOCONFIG 1
|
||||
# define HAVE_TIM4_GPIOCONFIG 1
|
||||
#endif
|
||||
#endif
|
||||
@@ -189,6 +198,8 @@
|
||||
#if defined(CONFIG_STM32_TIM5)
|
||||
# if defined(GPIO_TIM5_CH1OUT) ||defined(GPIO_TIM5_CH2OUT)||\
|
||||
defined(GPIO_TIM5_CH3OUT) ||defined(GPIO_TIM5_CH4OUT)
|
||||
# undef HAVE_TIM_GPIOCONFIG
|
||||
# define HAVE_TIM_GPIOCONFIG 1
|
||||
# define HAVE_TIM5_GPIOCONFIG 1
|
||||
#endif
|
||||
#endif
|
||||
@@ -196,6 +207,8 @@
|
||||
#if defined(CONFIG_STM32_TIM8)
|
||||
# if defined(GPIO_TIM8_CH1OUT) ||defined(GPIO_TIM8_CH2OUT)||\
|
||||
defined(GPIO_TIM8_CH3OUT) ||defined(GPIO_TIM8_CH4OUT)
|
||||
# undef HAVE_TIM_GPIOCONFIG
|
||||
# define HAVE_TIM_GPIOCONFIG 1
|
||||
# define HAVE_TIM8_GPIOCONFIG 1
|
||||
#endif
|
||||
#endif
|
||||
@@ -314,7 +327,10 @@ static void stm32_tim_reload_counter(FAR struct stm32_tim_dev_s *dev);
|
||||
static void stm32_tim_enable(FAR struct stm32_tim_dev_s *dev);
|
||||
static void stm32_tim_disable(FAR struct stm32_tim_dev_s *dev);
|
||||
static void stm32_tim_reset(FAR struct stm32_tim_dev_s *dev);
|
||||
|
||||
#ifdef HAVE_TIM_GPIOCONFIG
|
||||
static void stm32_tim_gpioconfig(uint32_t cfg, stm32_tim_channel_t mode);
|
||||
#endif
|
||||
|
||||
/* Timer methods */
|
||||
|
||||
@@ -637,9 +653,7 @@ static void stm32_tim_reset(FAR struct stm32_tim_dev_s *dev)
|
||||
* Name: stm32_tim_gpioconfig
|
||||
************************************************************************************/
|
||||
|
||||
#if defined(HAVE_TIM1_GPIOCONFIG)||defined(HAVE_TIM2_GPIOCONFIG)||\
|
||||
defined(HAVE_TIM3_GPIOCONFIG)||defined(HAVE_TIM4_GPIOCONFIG)||\
|
||||
defined(HAVE_TIM5_GPIOCONFIG)||defined(HAVE_TIM8_GPIOCONFIG)
|
||||
#ifdef HAVE_TIM_GPIOCONFIG
|
||||
static void stm32_tim_gpioconfig(uint32_t cfg, stm32_tim_channel_t mode)
|
||||
{
|
||||
/* TODO: Add support for input capture and bipolar dual outputs for TIM8 */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/************************************************************************************
|
||||
* arch/arm/src/stm32l4/chip/stm32_pinmap.h
|
||||
* arch/arm/src/stm32l4/chip/stm32l4_pinmap.h
|
||||
*
|
||||
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "chip.h"
|
||||
#include "stm32l4_adc.h"
|
||||
//#include "stm32_bkp.h"
|
||||
//#include "stm32l4_bkp.h"
|
||||
#include "stm32l4_can.h"
|
||||
#include "stm32l4_dbgmcu.h"
|
||||
#include "stm32l4_dma.h"
|
||||
|
||||
@@ -57,14 +57,14 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static struct stm32l4_freerun_s *g_freerun;
|
||||
FAR static struct stm32l4_freerun_s *g_freerun;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_freerun_handler
|
||||
* Name: stm32l4_freerun_handler
|
||||
*
|
||||
* Description:
|
||||
* Timer interrupt callback. When the freerun timer counter overflows,
|
||||
@@ -81,9 +81,9 @@ static struct stm32l4_freerun_s *g_freerun;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32_freerun_handler(int irq, void *context)
|
||||
static int stm32l4_freerun_handler(int irq, FAR void *context)
|
||||
{
|
||||
struct stm32l4_freerun_s *freerun = g_freerun;
|
||||
FAR struct stm32l4_freerun_s *freerun = g_freerun;
|
||||
|
||||
DEBUGASSERT(freerun != NULL && freerun->overflow < UINT32_MAX);
|
||||
freerun->overflow++;
|
||||
@@ -115,8 +115,8 @@ static int stm32_freerun_handler(int irq, void *context)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_freerun_initialize(struct stm32l4_freerun_s *freerun, int chan,
|
||||
uint16_t resolution)
|
||||
int stm32l4_freerun_initialize(FAR struct stm32l4_freerun_s *freerun, int chan,
|
||||
uint16_t resolution)
|
||||
{
|
||||
uint32_t frequency;
|
||||
|
||||
@@ -149,7 +149,7 @@ int stm32l4_freerun_initialize(struct stm32l4_freerun_s *freerun, int chan,
|
||||
|
||||
/* Set up to receive the callback when the counter overflow occurs */
|
||||
|
||||
STM32L4_TIM_SETISR(freerun->tch, stm32_freerun_handler, 0);
|
||||
STM32L4_TIM_SETISR(freerun->tch, stm32l4_freerun_handler, 0);
|
||||
|
||||
/* Set timer period */
|
||||
|
||||
@@ -173,7 +173,7 @@ int stm32l4_freerun_initialize(struct stm32l4_freerun_s *freerun, int chan,
|
||||
* Input Parameters:
|
||||
* freerun Caller allocated instance of the freerun state structure. This
|
||||
* structure must have been previously initialized via a call to
|
||||
* stm32_freerun_initialize();
|
||||
* stm32l4_freerun_initialize();
|
||||
* ts The location in which to return the time from the free-running
|
||||
* timer.
|
||||
*
|
||||
@@ -183,8 +183,8 @@ int stm32l4_freerun_initialize(struct stm32l4_freerun_s *freerun, int chan,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_freerun_counter(struct stm32l4_freerun_s *freerun,
|
||||
struct timespec *ts)
|
||||
int stm32l4_freerun_counter(FAR struct stm32l4_freerun_s *freerun,
|
||||
FAR struct timespec *ts)
|
||||
{
|
||||
uint64_t usec;
|
||||
uint32_t counter;
|
||||
@@ -197,7 +197,7 @@ int stm32l4_freerun_counter(struct stm32l4_freerun_s *freerun,
|
||||
DEBUGASSERT(freerun && freerun->tch && ts);
|
||||
|
||||
/* Temporarily disable the overflow counter. NOTE that we have to be
|
||||
* careful here because stm32_tc_getpending() will reset the pending
|
||||
* careful here because stm32l4_tc_getpending() will reset the pending
|
||||
* interrupt status. If we do not handle the overflow here then, it will
|
||||
* be lost.
|
||||
*/
|
||||
@@ -267,7 +267,7 @@ int stm32l4_freerun_counter(struct stm32l4_freerun_s *freerun,
|
||||
* Input Parameters:
|
||||
* freerun Caller allocated instance of the freerun state structure. This
|
||||
* structure must have been previously initialized via a call to
|
||||
* stm32_freerun_initialize();
|
||||
* stm32l4_freerun_initialize();
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned
|
||||
@@ -275,7 +275,7 @@ int stm32l4_freerun_counter(struct stm32l4_freerun_s *freerun,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_freerun_uninitialize(struct stm32l4_freerun_s *freerun)
|
||||
int stm32l4_freerun_uninitialize(FAR struct stm32l4_freerun_s *freerun)
|
||||
{
|
||||
DEBUGASSERT(freerun && freerun->tch);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/* The freerun client must allocate an instance of this structure and called
|
||||
* stm32_freerun_initialize() before using the freerun facilities. The client
|
||||
* stm32l4_freerun_initialize() before using the freerun facilities. The client
|
||||
* should not access the contents of this structure directly since the
|
||||
* contents are subject to change.
|
||||
*/
|
||||
@@ -118,7 +118,7 @@ int stm32l4_freerun_initialize(struct stm32l4_freerun_s *freerun, int chan,
|
||||
* Input Parameters:
|
||||
* freerun Caller allocated instance of the freerun state structure. This
|
||||
* structure must have been previously initialized via a call to
|
||||
* stm32_freerun_initialize();
|
||||
* stm32l4_freerun_initialize();
|
||||
* ts The location in which to return the time remaining on the
|
||||
* oneshot timer.
|
||||
*
|
||||
@@ -140,7 +140,7 @@ int stm32l4_freerun_counter(struct stm32l4_freerun_s *freerun,
|
||||
* Input Parameters:
|
||||
* freerun Caller allocated instance of the freerun state structure. This
|
||||
* structure must have been previously initialized via a call to
|
||||
* stm32_freerun_initialize();
|
||||
* stm32l4_freerun_initialize();
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned
|
||||
|
||||
@@ -268,7 +268,7 @@ EXTERN const uint32_t g_gpiobase[STM32L4_NPORTS];
|
||||
* Description:
|
||||
* Configure a GPIO pin based on bit-encoded description of the pin.
|
||||
* Once it is configured as Alternative (GPIO_ALT|GPIO_CNF_AFPP|...)
|
||||
* function, it must be unconfigured with stm32_unconfiggpio() with
|
||||
* function, it must be unconfigured with stm32l4_unconfiggpio() with
|
||||
* the same cfgset first before it can be set to non-alternative function.
|
||||
*
|
||||
* Returns:
|
||||
|
||||
@@ -65,7 +65,7 @@ static struct stm32l4_oneshot_s *g_oneshot;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_oneshot_handler
|
||||
* Name: stm32l4_oneshot_handler
|
||||
*
|
||||
* Description:
|
||||
* Timer interrupt callback. When the oneshot timer interrupt expires,
|
||||
@@ -83,11 +83,11 @@ static struct stm32l4_oneshot_s *g_oneshot;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32_oneshot_handler(int irq, void *context)
|
||||
static int stm32l4_oneshot_handler(int irq, FAR void *context)
|
||||
{
|
||||
struct stm32l4_oneshot_s *oneshot = g_oneshot;
|
||||
FAR struct stm32l4_oneshot_s *oneshot = g_oneshot;
|
||||
oneshot_handler_t oneshot_handler;
|
||||
void *oneshot_arg;
|
||||
FAR void *oneshot_arg;
|
||||
|
||||
tmrinfo("Expired...\n");
|
||||
DEBUGASSERT(oneshot != NULL && oneshot->handler);
|
||||
@@ -138,8 +138,8 @@ static int stm32_oneshot_handler(int irq, void *context)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_oneshot_initialize(struct stm32l4_oneshot_s *oneshot, int chan,
|
||||
uint16_t resolution)
|
||||
int stm32l4_oneshot_initialize(FAR struct stm32l4_oneshot_s *oneshot, int chan,
|
||||
uint16_t resolution)
|
||||
{
|
||||
uint32_t frequency;
|
||||
|
||||
@@ -174,14 +174,15 @@ int stm32l4_oneshot_initialize(struct stm32l4_oneshot_s *oneshot, int chan,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_oneshot_max_delay
|
||||
* Name: stm32l4_oneshot_max_delay
|
||||
*
|
||||
* Description:
|
||||
* Determine the maximum delay of the one-shot timer (in microseconds)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_oneshot_max_delay(struct stm32l4_oneshot_s *oneshot, uint64_t *usec)
|
||||
int stm32l4_oneshot_max_delay(FAR struct stm32l4_oneshot_s *oneshot,
|
||||
FAR uint64_t *usec)
|
||||
{
|
||||
DEBUGASSERT(oneshot != NULL && usec != NULL);
|
||||
|
||||
@@ -199,7 +200,7 @@ int stm32l4_oneshot_max_delay(struct stm32l4_oneshot_s *oneshot, uint64_t *usec)
|
||||
* Input Parameters:
|
||||
* oneshot Caller allocated instance of the oneshot state structure. This
|
||||
* structure must have been previously initialized via a call to
|
||||
* stm32_oneshot_initialize();
|
||||
* stm32l4_oneshot_initialize();
|
||||
* handler The function to call when when the oneshot timer expires.
|
||||
* arg An opaque argument that will accompany the callback.
|
||||
* ts Provides the duration of the one shot timer.
|
||||
@@ -210,9 +211,9 @@ int stm32l4_oneshot_max_delay(struct stm32l4_oneshot_s *oneshot, uint64_t *usec)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_oneshot_start(struct stm32l4_oneshot_s *oneshot,
|
||||
oneshot_handler_t handler, void *arg,
|
||||
const struct timespec *ts)
|
||||
int stm32l4_oneshot_start(FAR struct stm32l4_oneshot_s *oneshot,
|
||||
oneshot_handler_t handler, FAR void *arg,
|
||||
FAR const struct timespec *ts)
|
||||
{
|
||||
uint64_t usec;
|
||||
uint64_t period;
|
||||
@@ -259,7 +260,7 @@ int stm32l4_oneshot_start(struct stm32l4_oneshot_s *oneshot,
|
||||
|
||||
/* Set up to receive the callback when the interrupt occurs */
|
||||
|
||||
STM32L4_TIM_SETISR(oneshot->tch, stm32_oneshot_handler, 0);
|
||||
STM32L4_TIM_SETISR(oneshot->tch, stm32l4_oneshot_handler, 0);
|
||||
|
||||
/* Set timer period */
|
||||
|
||||
@@ -294,7 +295,7 @@ int stm32l4_oneshot_start(struct stm32l4_oneshot_s *oneshot,
|
||||
* Input Parameters:
|
||||
* oneshot Caller allocated instance of the oneshot state structure. This
|
||||
* structure must have been previously initialized via a call to
|
||||
* stm32_oneshot_initialize();
|
||||
* stm32l4_oneshot_initialize();
|
||||
* ts The location in which to return the time remaining on the
|
||||
* oneshot timer. A time of zero is returned if the timer is
|
||||
* not running. ts may be zero in which case the time remaining
|
||||
@@ -307,8 +308,8 @@ int stm32l4_oneshot_start(struct stm32l4_oneshot_s *oneshot,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_oneshot_cancel(struct stm32l4_oneshot_s *oneshot,
|
||||
struct timespec *ts)
|
||||
int stm32l4_oneshot_cancel(FAR struct stm32l4_oneshot_s *oneshot,
|
||||
FAR struct timespec *ts)
|
||||
{
|
||||
irqstate_t flags;
|
||||
uint64_t usec;
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
typedef void (*oneshot_handler_t)(void *arg);
|
||||
|
||||
/* The oneshot client must allocate an instance of this structure and called
|
||||
* stm32_oneshot_initialize() before using the oneshot facilities. The client
|
||||
* stm32l4_oneshot_initialize() before using the oneshot facilities. The client
|
||||
* should not access the contents of this structure directly since the
|
||||
* contents are subject to change.
|
||||
*/
|
||||
@@ -139,7 +139,7 @@ int stm32l4_oneshot_max_delay(struct stm32l4_oneshot_s *oneshot, uint64_t *usec)
|
||||
* Input Parameters:
|
||||
* oneshot Caller allocated instance of the oneshot state structure. This
|
||||
* structure must have been previously initialized via a call to
|
||||
* stm32_oneshot_initialize();
|
||||
* stm32l4_oneshot_initialize();
|
||||
* handler The function to call when when the oneshot timer expires.
|
||||
* arg An opaque argument that will accompany the callback.
|
||||
* ts Provides the duration of the one shot timer.
|
||||
@@ -166,7 +166,7 @@ int stm32l4_oneshot_start(struct stm32l4_oneshot_s *oneshot,
|
||||
* Input Parameters:
|
||||
* oneshot Caller allocated instance of the oneshot state structure. This
|
||||
* structure must have been previously initialized via a call to
|
||||
* stm32_oneshot_initialize();
|
||||
* stm32l4_oneshot_initialize();
|
||||
* ts The location in which to return the time remaining on the
|
||||
* oneshot timer. A time of zero is returned if the timer is
|
||||
* not running.
|
||||
|
||||
+1057
-1040
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+195
-192
File diff suppressed because it is too large
Load Diff
@@ -140,7 +140,7 @@ static inline void rcc_resetbkp(void)
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_clockconfig
|
||||
* Name: stm32l4_clockconfig
|
||||
*
|
||||
* Description:
|
||||
* Called to establish the clock settings based on the values in board.h.
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define STM32_NALARMS 2
|
||||
#define STM32L4_NALARMS 2
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@@ -93,7 +93,7 @@ struct stm32l4_lowerhalf_s
|
||||
#ifdef CONFIG_RTC_ALARM
|
||||
/* Alarm callback information */
|
||||
|
||||
struct stm32l4_cbinfo_s cbinfo[STM32_NALARMS];
|
||||
struct stm32l4_cbinfo_s cbinfo[STM32L4_NALARMS];
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -200,7 +200,7 @@ static void stm32l4_alarm_callback(FAR void *arg, unsigned int alarmid)
|
||||
#endif /* CONFIG_RTC_ALARM */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_rdtime
|
||||
* Name: stm32l4_rdtime
|
||||
*
|
||||
* Description:
|
||||
* Implements the rdtime() method of the RTC driver interface
|
||||
|
||||
@@ -535,7 +535,7 @@ static void rtc_resume(void)
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_RTC_ALARM
|
||||
static int stm32l4_rtc_alarm_handler(int irq, void *context)
|
||||
static int stm32l4_rtc_alarm_handler(int irq, FAR void *context)
|
||||
{
|
||||
FAR struct alm_cbinfo_s *cbinfo;
|
||||
alm_callback_t cb;
|
||||
@@ -685,7 +685,7 @@ static int rtchw_check_alrbwf(void)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_rtchw_set_alrmXr X is a or b
|
||||
* Name: stm32l4_rtchw_set_alrmXr X is a or b
|
||||
*
|
||||
* Description:
|
||||
* Set the alarm (A or B) hardware registers, using the required hardware access
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -118,7 +118,7 @@
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct stm32_tickless_s
|
||||
struct stm32l4_tickless_s
|
||||
{
|
||||
struct stm32l4_oneshot_s oneshot;
|
||||
struct stm32l4_freerun_s freerun;
|
||||
@@ -128,14 +128,14 @@ struct stm32_tickless_s
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct stm32_tickless_s g_tickless;
|
||||
static struct stm32l4_tickless_s g_tickless;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_oneshot_handler
|
||||
* Name: stm32l4_oneshot_handler
|
||||
*
|
||||
* Description:
|
||||
* Called when the one shot timer expires
|
||||
@@ -152,7 +152,7 @@ static struct stm32_tickless_s g_tickless;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void stm32_oneshot_handler(void *arg)
|
||||
static void stm32l4_oneshot_handler(FAR void *arg)
|
||||
{
|
||||
tmrinfo("Expired...\n");
|
||||
sched_timer_expiration();
|
||||
@@ -201,7 +201,7 @@ void up_timer_initialize(void)
|
||||
CONFIG_USEC_PER_TICK);
|
||||
if (ret < 0)
|
||||
{
|
||||
tmrerr("ERROR: stm32_oneshot_initialize failed\n");
|
||||
tmrerr("ERROR: stm32l4_oneshot_initialize failed\n");
|
||||
PANIC();
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ void up_timer_initialize(void)
|
||||
ret = stm32l4_oneshot_max_delay(&g_tickless.oneshot, &max_delay);
|
||||
if (ret < 0)
|
||||
{
|
||||
tmrerr("ERROR: stm32_oneshot_max_delay failed\n");
|
||||
tmrerr("ERROR: stm32l4_oneshot_max_delay failed\n");
|
||||
PANIC();
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ void up_timer_initialize(void)
|
||||
CONFIG_USEC_PER_TICK);
|
||||
if (ret < 0)
|
||||
{
|
||||
tmrerr("ERROR: stm32_freerun_initialize failed\n");
|
||||
tmrerr("ERROR: stm32l4_freerun_initialize failed\n");
|
||||
PANIC();
|
||||
}
|
||||
}
|
||||
@@ -346,6 +346,6 @@ int up_timer_cancel(FAR struct timespec *ts)
|
||||
|
||||
int up_timer_start(FAR const struct timespec *ts)
|
||||
{
|
||||
return stm32l4_oneshot_start(&g_tickless.oneshot, stm32_oneshot_handler, NULL, ts);
|
||||
return stm32l4_oneshot_start(&g_tickless.oneshot, stm32l4_oneshot_handler, NULL, ts);
|
||||
}
|
||||
#endif /* CONFIG_SCHED_TICKLESS */
|
||||
|
||||
+236
-226
File diff suppressed because it is too large
Load Diff
@@ -87,7 +87,7 @@
|
||||
* timer_lowerhalf_s structure.
|
||||
*/
|
||||
|
||||
struct stm32_lowerhalf_s
|
||||
struct stm32l4_lowerhalf_s
|
||||
{
|
||||
FAR const struct timer_ops_s *ops; /* Lower half operations */
|
||||
FAR struct stm32l4_tim_dev_s *tim; /* stm32 timer driver */
|
||||
@@ -104,49 +104,49 @@ struct stm32_lowerhalf_s
|
||||
/* Interrupt handling *******************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM1
|
||||
static int stm32_tim1_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim1_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM2
|
||||
static int stm32_tim2_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim2_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM3
|
||||
static int stm32_tim3_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim3_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM4
|
||||
static int stm32_tim4_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim4_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM5
|
||||
static int stm32_tim5_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim5_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM6
|
||||
static int stm32_tim6_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim6_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM7
|
||||
static int stm32_tim7_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim7_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM8
|
||||
static int stm32_tim8_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim8_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM15
|
||||
static int stm32_tim15_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim15_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM16
|
||||
static int stm32_tim16_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim16_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32L4_TIM17
|
||||
static int stm32_tim17_interrupt(int irq, FAR void *context);
|
||||
static int stm32l4_tim17_interrupt(int irq, FAR void *context);
|
||||
#endif
|
||||
|
||||
static int stm32_timer_handler(FAR struct stm32_lowerhalf_s *lower);
|
||||
static int stm32l4_timer_handler(FAR struct stm32l4_lowerhalf_s *lower);
|
||||
|
||||
/* "Lower half" driver methods **********************************************/
|
||||
|
||||
static int stm32_start(FAR struct timer_lowerhalf_s *lower);
|
||||
static int stm32_stop(FAR struct timer_lowerhalf_s *lower);
|
||||
static int stm32_settimeout(FAR struct timer_lowerhalf_s *lower,
|
||||
uint32_t timeout);
|
||||
static tccb_t stm32_sethandler(FAR struct timer_lowerhalf_s *lower,
|
||||
tccb_t handler);
|
||||
static int stm32l4_start(FAR struct timer_lowerhalf_s *lower);
|
||||
static int stm32l4_stop(FAR struct timer_lowerhalf_s *lower);
|
||||
static int stm32l4_settimeout(FAR struct timer_lowerhalf_s *lower,
|
||||
uint32_t timeout);
|
||||
static tccb_t stm32l4_sethandler(FAR struct timer_lowerhalf_s *lower,
|
||||
tccb_t handler);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@@ -155,109 +155,109 @@ static tccb_t stm32_sethandler(FAR struct timer_lowerhalf_s *lower,
|
||||
|
||||
static const struct timer_ops_s g_timer_ops =
|
||||
{
|
||||
.start = stm32_start,
|
||||
.stop = stm32_stop,
|
||||
.start = stm32l4_start,
|
||||
.stop = stm32l4_stop,
|
||||
.getstatus = NULL,
|
||||
.settimeout = stm32_settimeout,
|
||||
.sethandler = stm32_sethandler,
|
||||
.settimeout = stm32l4_settimeout,
|
||||
.sethandler = stm32l4_sethandler,
|
||||
.ioctl = NULL,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM1
|
||||
static struct stm32_lowerhalf_s g_tim1_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim1_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim1_interrupt,
|
||||
.timhandler = stm32l4_tim1_interrupt,
|
||||
.resolution = STM32L4_TIM1_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM2
|
||||
static struct stm32_lowerhalf_s g_tim2_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim2_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim2_interrupt,
|
||||
.timhandler = stm32l4_tim2_interrupt,
|
||||
.resolution = STM32L4_TIM2_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM3
|
||||
static struct stm32_lowerhalf_s g_tim3_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim3_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim3_interrupt,
|
||||
.timhandler = stm32l4_tim3_interrupt,
|
||||
.resolution = STM32L4_TIM3_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM4
|
||||
static struct stm32_lowerhalf_s g_tim4_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim4_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim4_interrupt,
|
||||
.timhandler = stm32l4_tim4_interrupt,
|
||||
.resolution = STM32L4_TIM4_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM5
|
||||
static struct stm32_lowerhalf_s g_tim5_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim5_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim5_interrupt,
|
||||
.timhandler = stm32l4_tim5_interrupt,
|
||||
.resolution = STM32L4_TIM5_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM6
|
||||
static struct stm32_lowerhalf_s g_tim6_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim6_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim6_interrupt,
|
||||
.timhandler = stm32l4_tim6_interrupt,
|
||||
.resolution = STM32L4_TIM6_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM7
|
||||
static struct stm32_lowerhalf_s g_tim7_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim7_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim7_interrupt,
|
||||
.timhandler = stm32l4_tim7_interrupt,
|
||||
.resolution = STM32L4_TIM7_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM8
|
||||
static struct stm32_lowerhalf_s g_tim8_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim8_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim8_interrupt,
|
||||
.timhandler = stm32l4_tim8_interrupt,
|
||||
.resolution = STM32L4_TIM8_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM15
|
||||
static struct stm32_lowerhalf_s g_tim15_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim15_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim15_interrupt,
|
||||
.timhandler = stm32l4_tim15_interrupt,
|
||||
.resolution = STM32L4_TIM15_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM16
|
||||
static struct stm32_lowerhalf_s g_tim16_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim16_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim16_interrupt,
|
||||
.timhandler = stm32l4_tim16_interrupt,
|
||||
.resolution = STM32L4_TIM16_RES,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM17
|
||||
static struct stm32_lowerhalf_s g_tim17_lowerhalf =
|
||||
static struct stm32l4_lowerhalf_s g_tim17_lowerhalf =
|
||||
{
|
||||
.ops = &g_timer_ops,
|
||||
.timhandler = stm32_tim17_interrupt,
|
||||
.timhandler = stm32l4_tim17_interrupt,
|
||||
.resolution = STM32L4_TIM17_RES,
|
||||
};
|
||||
#endif
|
||||
@@ -267,7 +267,7 @@ static struct stm32_lowerhalf_s g_tim17_lowerhalf =
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_timN_interrupt, N=1..14
|
||||
* Name: stm32l4_timN_interrupt, N=1..14
|
||||
*
|
||||
* Description:
|
||||
* Individual interrupt handlers for each timer
|
||||
@@ -275,84 +275,84 @@ static struct stm32_lowerhalf_s g_tim17_lowerhalf =
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM1
|
||||
static int stm32_tim1_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim1_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim1_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim1_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM2
|
||||
static int stm32_tim2_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim2_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim2_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim2_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM3
|
||||
static int stm32_tim3_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim3_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim3_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim3_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM4
|
||||
static int stm32_tim4_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim4_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim4_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim4_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM5
|
||||
static int stm32_tim5_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim5_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim5_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim5_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM6
|
||||
static int stm32_tim6_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim6_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim6_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim6_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM7
|
||||
static int stm32_tim7_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim7_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim7_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim7_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM8
|
||||
static int stm32_tim8_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim8_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim8_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim8_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM15
|
||||
static int stm32_tim15_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim15_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim15_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim15_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM16
|
||||
static int stm32_tim16_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim16_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim16_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim16_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_TIM17
|
||||
static int stm32_tim17_interrupt(int irq, FAR void *context)
|
||||
static int stm32l4_tim17_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
return stm32_timer_handler(&g_tim17_lowerhalf);
|
||||
return stm32l4_timer_handler(&g_tim17_lowerhalf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_timer_handler
|
||||
* Name: stm32l4_timer_handler
|
||||
*
|
||||
* Description:
|
||||
* timer interrupt handler
|
||||
@@ -363,7 +363,7 @@ static int stm32_tim17_interrupt(int irq, FAR void *context)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32_timer_handler(FAR struct stm32_lowerhalf_s *lower)
|
||||
static int stm32l4_timer_handler(FAR struct stm32l4_lowerhalf_s *lower)
|
||||
{
|
||||
uint32_t next_interval_us = 0;
|
||||
|
||||
@@ -378,14 +378,14 @@ static int stm32_timer_handler(FAR struct stm32_lowerhalf_s *lower)
|
||||
}
|
||||
else
|
||||
{
|
||||
stm32_stop((struct timer_lowerhalf_s *)lower);
|
||||
stm32l4_stop((struct timer_lowerhalf_s *)lower);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_start
|
||||
* Name: stm32l4_start
|
||||
*
|
||||
* Description:
|
||||
* Start the timer, resetting the time to the current timeout,
|
||||
@@ -399,9 +399,9 @@ static int stm32_timer_handler(FAR struct stm32_lowerhalf_s *lower)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32_start(FAR struct timer_lowerhalf_s *lower)
|
||||
static int stm32l4_start(FAR struct timer_lowerhalf_s *lower)
|
||||
{
|
||||
FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)lower;
|
||||
FAR struct stm32l4_lowerhalf_s *priv = (FAR struct stm32l4_lowerhalf_s *)lower;
|
||||
|
||||
if (!priv->started)
|
||||
{
|
||||
@@ -423,7 +423,7 @@ static int stm32_start(FAR struct timer_lowerhalf_s *lower)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_stop
|
||||
* Name: stm32l4_stop
|
||||
*
|
||||
* Description:
|
||||
* Stop the timer
|
||||
@@ -437,9 +437,9 @@ static int stm32_start(FAR struct timer_lowerhalf_s *lower)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32_stop(struct timer_lowerhalf_s *lower)
|
||||
static int stm32l4_stop(FAR struct timer_lowerhalf_s *lower)
|
||||
{
|
||||
struct stm32_lowerhalf_s *priv = (struct stm32_lowerhalf_s *)lower;
|
||||
FAR struct stm32l4_lowerhalf_s *priv = (FAR struct stm32l4_lowerhalf_s *)lower;
|
||||
|
||||
if (priv->started)
|
||||
{
|
||||
@@ -456,7 +456,7 @@ static int stm32_stop(struct timer_lowerhalf_s *lower)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_settimeout
|
||||
* Name: stm32l4_settimeout
|
||||
*
|
||||
* Description:
|
||||
* Set a new timeout value (and reset the timer)
|
||||
@@ -471,9 +471,10 @@ static int stm32_stop(struct timer_lowerhalf_s *lower)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32_settimeout(FAR struct timer_lowerhalf_s *lower, uint32_t timeout)
|
||||
static int stm32l4_settimeout(FAR struct timer_lowerhalf_s *lower,
|
||||
uint32_t timeout)
|
||||
{
|
||||
FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)lower;
|
||||
FAR struct stm32l4_lowerhalf_s *priv = (FAR struct stm32l4_lowerhalf_s *)lower;
|
||||
uint64_t maxtimeout;
|
||||
|
||||
if (priv->started)
|
||||
@@ -498,7 +499,7 @@ static int stm32_settimeout(FAR struct timer_lowerhalf_s *lower, uint32_t timeou
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_sethandler
|
||||
* Name: stm32l4_sethandler
|
||||
*
|
||||
* Description:
|
||||
* Call this user provided timeout handler.
|
||||
@@ -516,10 +517,10 @@ static int stm32_settimeout(FAR struct timer_lowerhalf_s *lower, uint32_t timeou
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static tccb_t stm32_sethandler(FAR struct timer_lowerhalf_s *lower,
|
||||
tccb_t newhandler)
|
||||
static tccb_t stm32l4_sethandler(FAR struct timer_lowerhalf_s *lower,
|
||||
tccb_t newhandler)
|
||||
{
|
||||
FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)lower;
|
||||
FAR struct stm32l4_lowerhalf_s *priv = (FAR struct stm32l4_lowerhalf_s *)lower;
|
||||
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
@@ -570,7 +571,7 @@ static tccb_t stm32_sethandler(FAR struct timer_lowerhalf_s *lower,
|
||||
|
||||
int stm32l4_timer_initialize(FAR const char *devpath, int timer)
|
||||
{
|
||||
FAR struct stm32_lowerhalf_s *lower;
|
||||
FAR struct stm32l4_lowerhalf_s *lower;
|
||||
|
||||
switch (timer)
|
||||
{
|
||||
|
||||
@@ -4,4 +4,34 @@
|
||||
#
|
||||
|
||||
if ARCH_BOARD_FREEDOM_K64F
|
||||
|
||||
config FRDMK64F_SDHC_AUTOMOUNT
|
||||
bool "SDHC automounter"
|
||||
default n
|
||||
depends on FS_AUTOMOUNTER && SAMA5_SDHC
|
||||
|
||||
if FRDMK64F_SDHC_AUTOMOUNT
|
||||
|
||||
config FRDMK64F_SDHC_AUTOMOUNT_FSTYPE
|
||||
string "SDHC file system type"
|
||||
default "vfat"
|
||||
|
||||
config FRDMK64F_SDHC_AUTOMOUNT_BLKDEV
|
||||
string "SDHC block device"
|
||||
default "/dev/mmcsd0"
|
||||
|
||||
config FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT
|
||||
string "SDHC mount point"
|
||||
default "/mnt/sdcard0"
|
||||
|
||||
config FRDMK64F_SDHC_AUTOMOUNT_DDELAY
|
||||
int "SDHC debounce delay (milliseconds)"
|
||||
default 1000
|
||||
|
||||
config FRDMK64F_SDHC_AUTOMOUNT_UDELAY
|
||||
int "SDHC unmount retry delay (milliseconds)"
|
||||
default 2000
|
||||
|
||||
endif # FRDMK64F_SDHC_AUTOMOUNT
|
||||
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,8 +41,9 @@
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
@@ -68,7 +69,7 @@
|
||||
*
|
||||
* PLL Input frequency: PLLIN = REFCLK / PRDIV = 50 Mhz / 20 = 2.5 MHz
|
||||
* PLL Output frequency: PLLOUT = PLLIN * VDIV = 2.5 Mhz * 48 = 120 MHz
|
||||
* MCG Frequency: PLLOUT = 96MHz
|
||||
* MCG Frequency: PLLOUT = 120 MHz
|
||||
*
|
||||
* PRDIV register value is the divider minus one. So 20 -> 19
|
||||
* VDIV regiser value is offset by 24. So 28 -> 24
|
||||
@@ -100,36 +101,37 @@
|
||||
* SDCLK frequency = (base clock) / (prescaler * divisor)
|
||||
*
|
||||
* The SDHC module is always configure configured so that the core clock is the base
|
||||
* clock.
|
||||
* clock. Possible values for presscaler and divisor are:
|
||||
*
|
||||
* SDCLKFS: {2, 4, 8, 16, 32, 63, 128, 256}
|
||||
* DVS: {1..16}
|
||||
*/
|
||||
|
||||
/* Identification mode: 400KHz = 96MHz / ( 16 * 15) */
|
||||
/* Identification mode: Optimal 400KHz, Actual 120MHz / (32 * 10) = 375 Khz */
|
||||
|
||||
#define BOARD_SDHC_IDMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
|
||||
#define BOARD_SDHC_IDMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
|
||||
#define BOARD_SDHC_IDMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV32
|
||||
#define BOARD_SDHC_IDMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(10)
|
||||
|
||||
/* MMC normal mode: 16MHz = 96MHz / (2 * 3) */
|
||||
/* MMC normal mode: Optimal 20MHz, Actual 120MHz / (2 * 3) = 20 MHz */
|
||||
|
||||
#define BOARD_SDHC_MMCMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
#define BOARD_SDHC_MMCMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
|
||||
/* SD normal mode (1-bit): 16MHz = 96MHz / (2 * 3) */
|
||||
/* SD normal mode (1-bit): Optimal 20MHz, Actual 120MHz / (2 * 3) = 20 MHz */
|
||||
|
||||
#define BOARD_SDHC_SD1MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
#define BOARD_SDHC_SD1MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
|
||||
/* SD normal mode (4-bit): 24MHz = 96MHz / (2 * 2) (with DMA)
|
||||
* SD normal mode (4-bit): 16MHz = 96MHz / (2 * 3) (no DMA)
|
||||
/* SD normal mode (4-bit): Optimal 25MHz, Actual 120MHz / (2 * 3) = 20 MHz (with DMA)
|
||||
* SD normal mode (4-bit): Optimal 20MHz, Actual 120MHz / (2 * 3) = 20 MHz (no DMA)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SDIO_DMA
|
||||
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(2)
|
||||
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
#else
|
||||
//# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
//# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
|
||||
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
|
||||
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
#endif
|
||||
|
||||
/* LED definitions ******************************************************************/
|
||||
@@ -162,18 +164,18 @@
|
||||
* the Freedom K64F. The following definitions describe how NuttX controls
|
||||
* the LEDs:
|
||||
*
|
||||
* SYMBOL Meaning LED state
|
||||
* RED GREEN BLUE
|
||||
* ------------------- ----------------------- ----------------- */
|
||||
#define LED_STARTED 1 /* NuttX has been started OFF OFF OFF */
|
||||
#define LED_HEAPALLOCATE 2 /* Heap has been allocated OFF OFF ON */
|
||||
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF ON */
|
||||
#define LED_STACKCREATED 3 /* Idle stack created OFF ON OFF */
|
||||
#define LED_INIRQ 0 /* In an interrupt (no change) */
|
||||
#define LED_SIGNAL 0 /* In a signal handler (no change) */
|
||||
#define LED_ASSERTION 0 /* An assertion failed (no change) */
|
||||
#define LED_PANIC 4 /* The system has crashed FLASH OFF OFF */
|
||||
#undef LED_IDLE /* K64 is in sleep mode (Not used) */
|
||||
* SYMBOL Meaning LED state
|
||||
* RED GREEN BLUE
|
||||
* ------------------- ---------------------------- ----------------- */
|
||||
#define LED_STARTED 1 /* NuttX has been started OFF OFF OFF */
|
||||
#define LED_HEAPALLOCATE 2 /* Heap has been allocated OFF OFF ON */
|
||||
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF ON */
|
||||
#define LED_STACKCREATED 3 /* Idle stack created OFF ON OFF */
|
||||
#define LED_INIRQ 0 /* In an interrupt (no change) */
|
||||
#define LED_SIGNAL 0 /* In a signal handler (no change) */
|
||||
#define LED_ASSERTION 0 /* An assertion failed (no change) */
|
||||
#define LED_PANIC 4 /* The system has crashed FLASH OFF OFF */
|
||||
#undef LED_IDLE /* K64 is in sleep mode (Not used) */
|
||||
|
||||
/* Button definitions ***************************************************************/
|
||||
/* Two push buttons, SW2 and SW3, are available on FRDM-K64F board, where SW2 is
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
############################################################################
|
||||
# configs/freedom-k64f/netnsh/Make.defs
|
||||
#
|
||||
# Copyright (C) 2016 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
|
||||
|
||||
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/flash.ld}"
|
||||
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/flash.ld
|
||||
endif
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
CPP = $(CROSSDEV)gcc -E
|
||||
LD = $(CROSSDEV)ld
|
||||
AR = $(CROSSDEV)ar rcs
|
||||
NM = $(CROSSDEV)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
|
||||
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 =
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
# configs/freedom-k64f/netnsh/setenv.sh
|
||||
#
|
||||
# Copyright (C) 2016 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.
|
||||
#
|
||||
|
||||
if [ "$_" = "$0" ] ; then
|
||||
echo "You must source this script, not run it!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WD=`pwd`
|
||||
if [ ! -x "setenv.sh" ]; then
|
||||
echo "This script must be executed from the top-level NuttX build directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${PATH_ORIG}" ]; then
|
||||
export PATH_ORIG="${PATH}"
|
||||
fi
|
||||
|
||||
# This is the Cygwin path to the location where I installed the Atmel GCC
|
||||
# toolchain under Windows. You will also have to edit this if you install
|
||||
# this toolchain in any other location
|
||||
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/Atmel/Atmel Toolchain/ARM GCC/Native/4.7.3.99/arm-gnu-toolchain/bin"
|
||||
|
||||
# This is the Cygwin path to the location where I installed the CodeSourcery
|
||||
# toolchain under windows. You will also have to edit this if you install
|
||||
# the CodeSourcery toolchain in any other location
|
||||
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin"
|
||||
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
|
||||
# export TOOLCHAIN_BIN="/cygdrive/c/Users/MyName/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
|
||||
|
||||
# This is the location where I installed the ARM "GNU Tools for ARM Embedded Processors"
|
||||
# You can this free toolchain here https://launchpad.net/gcc-arm-embedded
|
||||
export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin"
|
||||
|
||||
# This is the path to the location where I installed the devkitARM toolchain
|
||||
# You can get this free toolchain from http://devkitpro.org/ or http://sourceforge.net/projects/devkitpro/
|
||||
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/devkitARM/bin"
|
||||
|
||||
# This is the Cygwin path to the location where I build the buildroot
|
||||
# toolchain.
|
||||
#export TOOLCHAIN_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin"
|
||||
|
||||
# Add the path to the toolchain to the PATH varialble
|
||||
export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
|
||||
|
||||
echo "PATH : ${PATH}"
|
||||
@@ -8,10 +8,14 @@
|
||||
#
|
||||
# CONFIG_EXPERIMENTAL is not set
|
||||
# CONFIG_DEFAULT_SMALL is not set
|
||||
CONFIG_HOST_LINUX=y
|
||||
# CONFIG_HOST_LINUX is not set
|
||||
# CONFIG_HOST_OSX is not set
|
||||
# CONFIG_HOST_WINDOWS is not set
|
||||
CONFIG_HOST_WINDOWS=y
|
||||
# CONFIG_HOST_OTHER is not set
|
||||
# CONFIG_WINDOWS_NATIVE is not set
|
||||
CONFIG_WINDOWS_CYGWIN=y
|
||||
# CONFIG_WINDOWS_MSYS is not set
|
||||
# CONFIG_WINDOWS_OTHER is not set
|
||||
|
||||
#
|
||||
# Build Configuration
|
||||
@@ -135,12 +139,15 @@ CONFIG_ARM_HAVE_MPU_UNIFIED=y
|
||||
# CONFIG_ARMV7M_HAVE_DCACHE is not set
|
||||
# CONFIG_ARMV7M_HAVE_ITCM is not set
|
||||
# CONFIG_ARMV7M_HAVE_DTCM is not set
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_IARL is not set
|
||||
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_IARW is not set
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC is not set
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_CODEREDW is not set
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW is not set
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM is not set
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set
|
||||
CONFIG_ARMV7M_OABI_TOOLCHAIN=y
|
||||
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y
|
||||
# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set
|
||||
# CONFIG_ARMV7M_HAVE_STACKCHECK is not set
|
||||
# CONFIG_ARMV7M_ITMSYSLOG is not set
|
||||
|
||||
@@ -192,6 +199,8 @@ CONFIG_ARCH_FAMILY_K64=y
|
||||
CONFIG_KINETIS_UART3=y
|
||||
# CONFIG_KINETIS_UART4 is not set
|
||||
# CONFIG_KINETIS_UART5 is not set
|
||||
# CONFIG_KINETIS_ENET is not set
|
||||
# CONFIG_KINETIS_RNGB is not set
|
||||
# CONFIG_KINETIS_FLEXCAN0 is not set
|
||||
# CONFIG_KINETIS_FLEXCAN1 is not set
|
||||
# CONFIG_KINETIS_SPI0 is not set
|
||||
@@ -206,7 +215,7 @@ CONFIG_KINETIS_UART3=y
|
||||
# CONFIG_KINETIS_ADC1 is not set
|
||||
# CONFIG_KINETIS_CMP is not set
|
||||
# CONFIG_KINETIS_VREF is not set
|
||||
# CONFIG_KINETIS_SDHC is not set
|
||||
CONFIG_KINETIS_SDHC=y
|
||||
# CONFIG_KINETIS_FTM0 is not set
|
||||
# CONFIG_KINETIS_FTM1 is not set
|
||||
# CONFIG_KINETIS_FTM2 is not set
|
||||
@@ -227,11 +236,23 @@ CONFIG_KINETIS_UART3=y
|
||||
#
|
||||
# Kinetis GPIO Interrupt Configuration
|
||||
#
|
||||
# CONFIG_GPIO_IRQ is not set
|
||||
CONFIG_GPIO_IRQ=y
|
||||
# CONFIG_KINETIS_PORTAINTS is not set
|
||||
# CONFIG_KINETIS_PORTBINTS is not set
|
||||
# CONFIG_KINETIS_PORTCINTS is not set
|
||||
# CONFIG_KINETIS_PORTDINTS is not set
|
||||
CONFIG_KINETIS_PORTEINTS=y
|
||||
|
||||
#
|
||||
# Kinetis SDHC Configuration
|
||||
#
|
||||
# CONFIG_KINETIS_SDHC_ABSFREQ is not set
|
||||
|
||||
#
|
||||
# Kinetis UART Configuration
|
||||
#
|
||||
CONFIG_SDIO_DMA=y
|
||||
# CONFIG_SDIO_WIDTH_D1_ONLY is not set
|
||||
|
||||
#
|
||||
# Architecture Options
|
||||
@@ -312,7 +333,14 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y
|
||||
# Board-Specific Options
|
||||
#
|
||||
# CONFIG_BOARD_CRASHDUMP is not set
|
||||
# CONFIG_LIB_BOARDCTL is not set
|
||||
CONFIG_LIB_BOARDCTL=y
|
||||
# CONFIG_BOARDCTL_RESET is not set
|
||||
# CONFIG_BOARDCTL_UNIQUEID is not set
|
||||
# CONFIG_BOARDCTL_TSCTEST is not set
|
||||
# CONFIG_BOARDCTL_ADCTEST is not set
|
||||
# CONFIG_BOARDCTL_PWMTEST is not set
|
||||
# CONFIG_BOARDCTL_GRAPHICS is not set
|
||||
# CONFIG_BOARDCTL_IOCTL is not set
|
||||
|
||||
#
|
||||
# RTOS Features
|
||||
@@ -384,6 +412,7 @@ CONFIG_NAME_MAX=32
|
||||
# CONFIG_SCHED_STARTHOOK is not set
|
||||
# CONFIG_SCHED_ATEXIT is not set
|
||||
# CONFIG_SCHED_ONEXIT is not set
|
||||
# CONFIG_SIG_EVTHREAD is not set
|
||||
|
||||
#
|
||||
# Signal Numbers
|
||||
@@ -392,6 +421,7 @@ CONFIG_SIG_SIGUSR1=1
|
||||
CONFIG_SIG_SIGUSR2=2
|
||||
CONFIG_SIG_SIGALARM=3
|
||||
CONFIG_SIG_SIGCONDTIMEDOUT=16
|
||||
CONFIG_SIG_SIGWORK=17
|
||||
|
||||
#
|
||||
# POSIX Message Queue Options
|
||||
@@ -403,8 +433,11 @@ CONFIG_MQ_MAXMSGSIZE=32
|
||||
#
|
||||
# Work queue support
|
||||
#
|
||||
# CONFIG_SCHED_WORKQUEUE is not set
|
||||
# CONFIG_SCHED_HPWORK is not set
|
||||
CONFIG_SCHED_WORKQUEUE=y
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_HPWORKPRIORITY=224
|
||||
CONFIG_SCHED_HPWORKPERIOD=50000
|
||||
CONFIG_SCHED_HPWORKSTACKSIZE=2048
|
||||
# CONFIG_SCHED_LPWORK is not set
|
||||
|
||||
#
|
||||
@@ -470,7 +503,18 @@ CONFIG_DEV_NULL=y
|
||||
# CONFIG_RGBLED is not set
|
||||
# CONFIG_PCA9635PW is not set
|
||||
# CONFIG_NCP5623C is not set
|
||||
# CONFIG_MMCSD is not set
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_MMCSD_NSLOTS=1
|
||||
# CONFIG_MMCSD_READONLY is not set
|
||||
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
|
||||
# CONFIG_MMCSD_MMCSUPPORT is not set
|
||||
CONFIG_MMCSD_HAVECARDDETECT=y
|
||||
CONFIG_ARCH_HAVE_SDIO=y
|
||||
# CONFIG_ARCH_HAVE_SDIOWAIT_WRCOMPLETE is not set
|
||||
CONFIG_MMCSD_SDIO=y
|
||||
# CONFIG_SDIO_PREFLIGHT is not set
|
||||
# CONFIG_SDIO_MUXBUS is not set
|
||||
CONFIG_SDIO_BLOCKSETUP=y
|
||||
# CONFIG_MODEM is not set
|
||||
# CONFIG_MTD is not set
|
||||
# CONFIG_EEPROM is not set
|
||||
@@ -545,6 +589,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y
|
||||
CONFIG_SYSLOG_CONSOLE=y
|
||||
# CONFIG_SYSLOG_NONE is not set
|
||||
# CONFIG_SYSLOG_FILE is not set
|
||||
# CONFIG_SYSLOG_CHARDEV is not set
|
||||
|
||||
#
|
||||
# Networking Support
|
||||
@@ -574,8 +619,9 @@ CONFIG_FS_WRITABLE=y
|
||||
CONFIG_FS_MQUEUE_MPATH="/var/mqueue"
|
||||
# CONFIG_FS_RAMMAP is not set
|
||||
CONFIG_FS_FAT=y
|
||||
# CONFIG_FAT_LCNAMES is not set
|
||||
# CONFIG_FAT_LFN is not set
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FAT_MAXFNAME=32
|
||||
# CONFIG_FS_FATTIME is not set
|
||||
# CONFIG_FAT_FORCE_INDIRECT is not set
|
||||
# CONFIG_FAT_DMAMEMORY is not set
|
||||
@@ -584,7 +630,15 @@ CONFIG_FS_FAT=y
|
||||
# CONFIG_FS_ROMFS is not set
|
||||
# CONFIG_FS_TMPFS is not set
|
||||
# CONFIG_FS_SMARTFS is not set
|
||||
# CONFIG_FS_PROCFS is not set
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_PROCFS_REGISTER=y
|
||||
|
||||
#
|
||||
# Exclude individual procfs entries
|
||||
#
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set
|
||||
# CONFIG_FS_UNIONFS is not set
|
||||
|
||||
#
|
||||
@@ -730,6 +784,7 @@ CONFIG_EXAMPLES_NSH=y
|
||||
# CONFIG_EXAMPLES_TELNETD is not set
|
||||
# CONFIG_EXAMPLES_TIFF is not set
|
||||
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
|
||||
# CONFIG_EXAMPLES_USBSERIAL is not set
|
||||
# CONFIG_EXAMPLES_USBTERM is not set
|
||||
# CONFIG_EXAMPLES_WATCHDOG is not set
|
||||
# CONFIG_EXAMPLES_WEBSERVER is not set
|
||||
@@ -829,7 +884,6 @@ CONFIG_NSH_DISABLE_LOSMART=y
|
||||
# CONFIG_NSH_DISABLE_MV is not set
|
||||
# CONFIG_NSH_DISABLE_MW is not set
|
||||
# CONFIG_NSH_DISABLE_PS is not set
|
||||
# CONFIG_NSH_DISABLE_PSSTACKUSAGE is not set
|
||||
# CONFIG_NSH_DISABLE_PUT is not set
|
||||
# CONFIG_NSH_DISABLE_PWD is not set
|
||||
# CONFIG_NSH_DISABLE_RM is not set
|
||||
@@ -846,6 +900,7 @@ CONFIG_NSH_DISABLE_LOSMART=y
|
||||
# CONFIG_NSH_DISABLE_WGET is not set
|
||||
# CONFIG_NSH_DISABLE_XD is not set
|
||||
CONFIG_NSH_MMCSDMINOR=0
|
||||
CONFIG_NSH_MMCSDSLOTNO=0
|
||||
|
||||
#
|
||||
# Configure Command Options
|
||||
@@ -853,6 +908,7 @@ CONFIG_NSH_MMCSDMINOR=0
|
||||
CONFIG_NSH_CMDOPT_DF_H=y
|
||||
CONFIG_NSH_CODECS_BUFSIZE=128
|
||||
CONFIG_NSH_CMDOPT_HEXDUMP=y
|
||||
CONFIG_NSH_PROC_MOUNTPOINT="/proc"
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
|
||||
#
|
||||
@@ -867,7 +923,7 @@ CONFIG_NSH_FILEIOSIZE=512
|
||||
#
|
||||
CONFIG_NSH_CONSOLE=y
|
||||
# CONFIG_NSH_ALTCONDEV is not set
|
||||
# CONFIG_NSH_ARCHINIT is not set
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
# CONFIG_NSH_LOGIN is not set
|
||||
# CONFIG_NSH_CONSOLE_LOGIN is not set
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ fi
|
||||
|
||||
# This is the location where I installed the ARM "GNU Tools for ARM Embedded Processors"
|
||||
# You can this free toolchain here https://launchpad.net/gcc-arm-embedded
|
||||
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin"
|
||||
export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin"
|
||||
|
||||
# This is the path to the location where I installed the devkitARM toolchain
|
||||
# You can get this free toolchain from http://devkitpro.org/ or http://sourceforge.net/projects/devkitpro/
|
||||
@@ -69,7 +69,7 @@ fi
|
||||
|
||||
# This is the Cygwin path to the location where I build the buildroot
|
||||
# toolchain.
|
||||
export TOOLCHAIN_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin"
|
||||
# export TOOLCHAIN_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin"
|
||||
|
||||
# Add the path to the toolchain to the PATH varialble
|
||||
export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
|
||||
|
||||
@@ -54,6 +54,13 @@ else ifeq ($(CONFIG_BOARD_INITIALIZE),y)
|
||||
CSRCS += k64_bringup.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_KINETIS_SDHC),y)
|
||||
CSRCS += k64_sdhc.c
|
||||
ifeq ($(CONFIG_FS_AUTOMOUNTER),y)
|
||||
CSRCS += k64_automount.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USBDEV),y)
|
||||
CSRCS += k64_usbdev.c
|
||||
endif
|
||||
|
||||
@@ -49,6 +49,109 @@
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Application Configuration ********************************************************/
|
||||
|
||||
/* Assume we have everything */
|
||||
|
||||
#define HAVE_PROC 1
|
||||
#define HAVE_MMCSD 1
|
||||
#define HAVE_AUTOMOUNTER 1
|
||||
#define HAVE_USBDEV 1
|
||||
|
||||
/* Automount procfs */
|
||||
|
||||
#if !defined(CONFIG_FS_PROCFS)
|
||||
# undef HAVE_PROC
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PROC) && defined(CONFIG_DISABLE_MOUNTPOINT)
|
||||
# warning Mountpoints disabled. No procfs support
|
||||
# undef HAVE_PROC
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NSH_PROC_MOUNTPOINT)
|
||||
# define PROCFS_MOUNTPOUNT CONFIG_NSH_PROC_MOUNTPOINT
|
||||
#else
|
||||
# define PROCFS_MOUNTPOUNT "/proc"
|
||||
#endif
|
||||
|
||||
/* SD card support */
|
||||
|
||||
#define MMCSD_SLOTNO 0
|
||||
|
||||
/* Can't support MMC/SD features if mountpoints are disabled or if SDHC support
|
||||
* is not enabled.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_KINETIS_SDHC)
|
||||
# undef HAVE_MMCSD
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMCSD
|
||||
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0
|
||||
# error Only one MMC/SD slot, slot 0
|
||||
# endif
|
||||
|
||||
# ifdef CONFIG_NSH_MMCSDMINOR
|
||||
# define MMSCD_MINOR CONFIG_NSH_MMCSDMINOR
|
||||
# else
|
||||
# define MMSCD_MINOR 0
|
||||
# endif
|
||||
|
||||
/* We expect to receive GPIO interrupts for card insertion events */
|
||||
|
||||
# ifndef CONFIG_GPIO_IRQ
|
||||
# error "CONFIG_GPIO_IRQ required for card detect interrupt"
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_KINETIS_PORTEINTS
|
||||
# error "CONFIG_KINETIS_PORTEINTS required for card detect interrupt"
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Automounter */
|
||||
|
||||
#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_MMCSD)
|
||||
# undef HAVE_AUTOMOUNTER
|
||||
# undef CONFIG_FRDMK64F_SDHC_AUTOMOUNT
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT
|
||||
# undef HAVE_AUTOMOUNTER
|
||||
#endif
|
||||
|
||||
/* Automounter defaults */
|
||||
|
||||
#ifdef HAVE_AUTOMOUNTER
|
||||
|
||||
# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_FSTYPE
|
||||
# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_FSTYPE "vfat"
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_BLKDEV
|
||||
# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_BLKDEV "/dev/mmcds0"
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT
|
||||
# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0"
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY
|
||||
# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY 1000
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_FRDMK64F_SDHC_AUTOMOUNT_UDELAY
|
||||
# define CONFIG_FRDMK64F_SDHC_AUTOMOUNT_UDELAY 2000
|
||||
# endif
|
||||
#endif /* HAVE_AUTOMOUNTER */
|
||||
|
||||
/* Can't support USB features if USB is not enabled */
|
||||
|
||||
#ifndef CONFIG_USBDEV
|
||||
# undef HAVE_USBDEV
|
||||
#endif
|
||||
|
||||
/* How many SPI modules does this chip support? The LM3S6918 supports 2 SPI
|
||||
* modules (others may support more -- in such case, the following must be
|
||||
* expanded).
|
||||
@@ -67,6 +170,18 @@
|
||||
* format SD memory cards. The SD card detect pin (PTE6) is an open switch that
|
||||
* shorts with VDD when card is inserted.
|
||||
*
|
||||
* ------------ ------------- --------
|
||||
* SD Card Slot Board Signal K64F Pin
|
||||
* ------------ ------------- --------
|
||||
* DAT0 SDHC0_D0 PTE0
|
||||
* DAT1 SDHC0_D1 PTE1
|
||||
* DAT2 SDHC0_D2 PTE5
|
||||
* CD/DAT3 SDHC0_D3 PTE4
|
||||
* CMD SDHC0_CMD PTE3
|
||||
* CLK SDHC0_DCLK PTE2
|
||||
* SWITCH D_CARD_DETECT PTE6
|
||||
* ------------ ------------- --------
|
||||
*
|
||||
* There is no Write Protect pin available to the K64F.
|
||||
*/
|
||||
|
||||
@@ -91,13 +206,13 @@
|
||||
* LED K64
|
||||
* ------ -------------------------------------------------------
|
||||
* RED PTB22/SPI2_SOUT/FB_AD29/CMP2_OUT
|
||||
* BLUE PTB21/SPI2_SCK/FB_AD30/CMP1_OUT
|
||||
* GREEN PTE26/ENET_1588_CLKIN/UART4_CTS_b/RTC_CLKOUT/USB0_CLKIN
|
||||
* BLUE PTB21/SPI2_SCK/FB_AD30/CMP1_OUT
|
||||
*/
|
||||
|
||||
#define GPIO_LED_R (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTB | PIN22)
|
||||
#define GPIO_LED_G (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTB | PIN21)
|
||||
#define GPIO_LED_B (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTE | PIN26)
|
||||
#define GPIO_LED_G (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTE | PIN26)
|
||||
#define GPIO_LED_B (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTB | PIN21)
|
||||
|
||||
/************************************************************************************
|
||||
* Public data
|
||||
@@ -141,5 +256,89 @@ void weak_function k64_usbinitialize(void);
|
||||
int k64_bringup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k64_sdhc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Inititialize the SDHC SD card slot
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_MMCSD
|
||||
int k64_sdhc_initialize(void);
|
||||
#else
|
||||
# define k64_sdhc_initialize() (OK)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: k64_cardinserted
|
||||
*
|
||||
* Description:
|
||||
* Check if a card is inserted into the SDHC slot
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef HAVE_AUTOMOUNTER
|
||||
bool k64_cardinserted(void);
|
||||
#else
|
||||
# define k64_cardinserted() (false)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: k64_writeprotected
|
||||
*
|
||||
* Description:
|
||||
* Check if the card in the MMC/SD slot is write protected
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef HAVE_AUTOMOUNTER
|
||||
bool k64_writeprotected(void);
|
||||
#else
|
||||
# define k64_writeprotected() (false)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: k64_automount_initialize
|
||||
*
|
||||
* Description:
|
||||
* Configure auto-mounter for the configured SDHC slot
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef HAVE_AUTOMOUNTER
|
||||
void k64_automount_initialize(void);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: k64_automount_event
|
||||
*
|
||||
* Description:
|
||||
* The SDHC card detection logic has detected an insertion or removal event. It
|
||||
* has already scheduled the MMC/SD block driver operations. Now we need to
|
||||
* schedule the auto-mount event which will occur with a substantial delay to make
|
||||
* sure that everything has settle down.
|
||||
*
|
||||
* Input Parameters:
|
||||
* inserted - True if the card is inserted in the slot. False otherwise.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Interrupts are disabled.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef HAVE_AUTOMOUNTER
|
||||
void k64_automount_event(bool inserted);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_FREEDOM_K64F_SRC_FREEDOM_K64F_H */
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
/************************************************************************************
|
||||
* configs/freedom-k64f/src/k64_automount.c
|
||||
*
|
||||
* Copyright (C) 2016 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>
|
||||
|
||||
#if defined(CONFIG_FS_AUTOMOUNTER_DEBUG) && !defined(CONFIG_DEBUG_FS)
|
||||
# define CONFIG_DEBUG_FS 1
|
||||
#endif
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/fs/automount.h>
|
||||
|
||||
#include "freedom-k64f.h"
|
||||
|
||||
#ifdef HAVE_AUTOMOUNTER
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL (FAR void *)0
|
||||
#endif
|
||||
|
||||
#ifndef OK
|
||||
# define OK 0
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Types
|
||||
************************************************************************************/
|
||||
/* This structure represents the changeable state of the automounter */
|
||||
|
||||
struct k64_automount_state_s
|
||||
{
|
||||
volatile automount_handler_t handler; /* Upper half handler */
|
||||
FAR void *arg; /* Handler argument */
|
||||
bool enable; /* Fake interrupt enable */
|
||||
bool pending; /* Set if there an event while disabled */
|
||||
};
|
||||
|
||||
/* This structure represents the static configuration of an automounter */
|
||||
|
||||
struct k64_automount_config_s
|
||||
{
|
||||
/* This must be first thing in structure so that we can simply cast from struct
|
||||
* automount_lower_s to struct k64_automount_config_s
|
||||
*/
|
||||
|
||||
struct automount_lower_s lower; /* Publicly visible part */
|
||||
FAR struct k64_automount_state_s *state; /* Changeable state */
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
* Private Function Prototypes
|
||||
************************************************************************************/
|
||||
|
||||
static int k64_attach(FAR const struct automount_lower_s *lower,
|
||||
automount_handler_t isr, FAR void *arg);
|
||||
static void k64_enable(FAR const struct automount_lower_s *lower, bool enable);
|
||||
static bool k64_inserted(FAR const struct automount_lower_s *lower);
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
static struct k64_automount_state_s g_sdhc_state;
|
||||
static const struct k64_automount_config_s g_sdhc_config =
|
||||
{
|
||||
.lower =
|
||||
{
|
||||
.fstype = CONFIG_FRDMK64F_SDHC_AUTOMOUNT_FSTYPE,
|
||||
.blockdev = CONFIG_FRDMK64F_SDHC_AUTOMOUNT_BLKDEV,
|
||||
.mountpoint = CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT,
|
||||
.ddelay = MSEC2TICK(CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY),
|
||||
.udelay = MSEC2TICK(CONFIG_FRDMK64F_SDHC_AUTOMOUNT_UDELAY),
|
||||
.attach = k64_attach,
|
||||
.enable = k64_enable,
|
||||
.inserted = k64_inserted
|
||||
},
|
||||
.state = &g_sdhc_state
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: k64_attach
|
||||
*
|
||||
* Description:
|
||||
* Attach a new SDHC event handler
|
||||
*
|
||||
* Input Parameters:
|
||||
* lower - An instance of the auto-mounter lower half state structure
|
||||
* isr - The new event handler to be attach
|
||||
* arg - Client data to be provided when the event handler is invoked.
|
||||
*
|
||||
* Returned Value:
|
||||
* Always returns OK
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
static int k64_attach(FAR const struct automount_lower_s *lower,
|
||||
automount_handler_t isr, FAR void *arg)
|
||||
{
|
||||
FAR const struct k64_automount_config_s *config;
|
||||
FAR struct k64_automount_state_s *state;
|
||||
|
||||
/* Recover references to our structure */
|
||||
|
||||
config = (FAR struct k64_automount_config_s *)lower;
|
||||
DEBUGASSERT(config && config->state);
|
||||
|
||||
state = config->state;
|
||||
|
||||
/* Save the new handler info (clearing the handler first to eliminate race
|
||||
* conditions).
|
||||
*/
|
||||
|
||||
state->handler = NULL;
|
||||
state->pending = false;
|
||||
state->arg = arg;
|
||||
state->handler = isr;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: k64_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable card insertion/removal event detection
|
||||
*
|
||||
* Input Parameters:
|
||||
* lower - An instance of the auto-mounter lower half state structure
|
||||
* enable - True: enable event detection; False: disable
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
static void k64_enable(FAR const struct automount_lower_s *lower, bool enable)
|
||||
{
|
||||
FAR const struct k64_automount_config_s *config;
|
||||
FAR struct k64_automount_state_s *state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Recover references to our structure */
|
||||
|
||||
config = (FAR struct k64_automount_config_s *)lower;
|
||||
DEBUGASSERT(config && config->state);
|
||||
|
||||
state = config->state;
|
||||
|
||||
/* Save the fake enable setting */
|
||||
|
||||
flags = enter_critical_section();
|
||||
state->enable = enable;
|
||||
|
||||
/* Did an interrupt occur while interrupts were disabled? */
|
||||
|
||||
if (enable && state->pending)
|
||||
{
|
||||
/* Yes.. perform the fake interrupt if the interrutp is attached */
|
||||
|
||||
if (state->handler)
|
||||
{
|
||||
bool inserted = k64_cardinserted();
|
||||
(void)state->handler(&config->lower, state->arg, inserted);
|
||||
}
|
||||
|
||||
state->pending = false;
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: k64_inserted
|
||||
*
|
||||
* Description:
|
||||
* Check if a card is inserted into the slot.
|
||||
*
|
||||
* Input Parameters:
|
||||
* lower - An instance of the auto-mounter lower half state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* True if the card is inserted; False otherwise
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
static bool k64_inserted(FAR const struct automount_lower_s *lower)
|
||||
{
|
||||
FAR const struct k64_automount_config_s *config;
|
||||
|
||||
config = (FAR struct k64_automount_config_s *)lower;
|
||||
DEBUGASSERT(config && config->state);
|
||||
|
||||
return k64_cardinserted();
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: k64_automount_initialize
|
||||
*
|
||||
* Description:
|
||||
* Configure auto-mounters for each enable and so configured SDHC
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void k64_automount_initialize(void)
|
||||
{
|
||||
FAR void *handle;
|
||||
|
||||
finfo("Initializing automounter(s)\n");
|
||||
|
||||
/* Initialize the SDHC0 auto-mounter */
|
||||
|
||||
handle = automount_initialize(&g_sdhc_config.lower);
|
||||
if (!handle)
|
||||
{
|
||||
ferr("ERROR: Failed to initialize auto-mounter for SDHC0\n");
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: k64_automount_event
|
||||
*
|
||||
* Description:
|
||||
* The SDHC card detection logic has detected an insertion or removal event. It
|
||||
* has already scheduled the MMC/SD block driver operations. Now we need to
|
||||
* schedule the auto-mount event which will occur with a substantial delay to make
|
||||
* sure that everything has settle down.
|
||||
*
|
||||
* Input Parameters:
|
||||
* slotno - Identifies the SDHC0 slot: SDHC0_SLOTNO or SDHC1_SLOTNO. There is a
|
||||
* terminology problem here: Each SDHC supports two slots, slot A and slot B.
|
||||
* Only slot A is used. So this is not a really a slot, but an HSCMI peripheral
|
||||
* number.
|
||||
* inserted - True if the card is inserted in the slot. False otherwise.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Interrupts are disabled.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void k64_automount_event(bool inserted)
|
||||
{
|
||||
FAR const struct k64_automount_config_s *config = &g_sdhc_config;
|
||||
FAR struct k64_automount_state_s *state = &g_sdhc_state;
|
||||
|
||||
/* Is the auto-mounter interrupt attached? */
|
||||
|
||||
if (state->handler)
|
||||
{
|
||||
/* Yes.. Have we been asked to hold off interrupts? */
|
||||
|
||||
if (!state->enable)
|
||||
{
|
||||
/* Yes.. just remember the there is a pending interrupt. We will
|
||||
* deliver the interrupt when interrupts are "re-enabled."
|
||||
*/
|
||||
|
||||
state->pending = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No.. forward the event to the handler */
|
||||
|
||||
(void)state->handler(&config->lower, state->arg, inserted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HAVE_AUTOMOUNTER */
|
||||
@@ -39,216 +39,84 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#ifdef CONFIG_KINETIS_SDHC
|
||||
# include <nuttx/sdio.h>
|
||||
# include <nuttx/mmcsd.h>
|
||||
#endif
|
||||
|
||||
#include "kinetis.h"
|
||||
#include "freedom-k64f.h"
|
||||
|
||||
#if defined(CONFIG_LIB_BOARDCTL) || defined(CONFIG_BOARD_INITIALIZE)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* PORT and SLOT number probably depend on the board configuration */
|
||||
|
||||
#ifdef CONFIG_ARCH_BOARD_FREEDOM_K64F
|
||||
# define NSH_HAVEUSBDEV 1
|
||||
# define NSH_HAVEMMCSD 1
|
||||
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0
|
||||
# error "Only one MMC/SD slot, slot 0"
|
||||
# undef CONFIG_NSH_MMCSDSLOTNO
|
||||
# endif
|
||||
# ifndef CONFIG_NSH_MMCSDSLOTNO
|
||||
# define CONFIG_NSH_MMCSDSLOTNO 0
|
||||
# endif
|
||||
#else
|
||||
/* Add configuration for new Kinetis boards here */
|
||||
# error "Unrecognized Kinetis board"
|
||||
# undef NSH_HAVEUSBDEV
|
||||
# undef NSH_HAVEMMCSD
|
||||
#endif
|
||||
|
||||
/* Can't support USB features if USB is not enabled */
|
||||
|
||||
#ifndef CONFIG_USBDEV
|
||||
# undef NSH_HAVEUSBDEV
|
||||
#endif
|
||||
|
||||
/* Can't support MMC/SD features if mountpoints are disabled or if SDHC support
|
||||
* is not enabled.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_KINETIS_SDHC)
|
||||
# undef NSH_HAVEMMCSD
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_MMCSDMINOR
|
||||
# define CONFIG_NSH_MMCSDMINOR 0
|
||||
#endif
|
||||
|
||||
/* We expect to receive GPIO interrupts for card insertion events */
|
||||
|
||||
#ifndef CONFIG_GPIO_IRQ
|
||||
# error "CONFIG_GPIO_IRQ required for card detect interrupt"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_KINETIS_PORTEINTS
|
||||
# error "CONFIG_KINETIS_PORTEINTS required for card detect interrupt"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure encapsulates the global variable used in this file and
|
||||
* reduces the probability of name collistions.
|
||||
*/
|
||||
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
struct k64_nsh_s
|
||||
{
|
||||
FAR struct sdio_dev_s *sdhc; /* SDIO driver handle */
|
||||
bool inserted; /* True: card is inserted */
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
static struct k64_nsh_s g_nsh;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k64_mediachange
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
static void k64_mediachange(void)
|
||||
{
|
||||
bool inserted;
|
||||
|
||||
/* Get the current value of the card detect pin. This pin is pulled up on
|
||||
* board. So low means that a card is present.
|
||||
*/
|
||||
|
||||
inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT);
|
||||
|
||||
/* Has the pin changed state? */
|
||||
|
||||
if (inserted != g_nsh.inserted)
|
||||
{
|
||||
/* Yes.. perform the appropriate action (this might need some debounce). */
|
||||
|
||||
g_nsh.inserted = inserted;
|
||||
sdhc_mediachange(g_nsh.sdhc, inserted);
|
||||
|
||||
/* If the card has been inserted, then check if it is write protected
|
||||
* as well. The pin is pulled up, but apparently logic high means
|
||||
* write protected.
|
||||
*/
|
||||
|
||||
if (inserted)
|
||||
{
|
||||
sdhc_wrprotect(g_nsh.sdhc, kinetis_gpioread(GPIO_SD_WRPROTECT));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k64_cdinterrupt
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
static int k64_cdinterrupt(int irq, FAR void *context)
|
||||
{
|
||||
/* All of the work is done by k64_mediachange() */
|
||||
|
||||
k64_mediachange();
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: k64_bringup
|
||||
*
|
||||
* Description:
|
||||
* Bring up board features
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
int k64_bringup(void)
|
||||
{
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
int ret;
|
||||
|
||||
/* Configure GPIO pins */
|
||||
#ifdef HAVE_PROC
|
||||
/* Mount the proc filesystem */
|
||||
|
||||
/* Attached the card detect interrupt (but don't enable it yet) */
|
||||
syslog(LOG_INFO, "Mounting procfs to /proc\n");
|
||||
|
||||
kinetis_pinconfig(GPIO_SD_CARDDETECT);
|
||||
kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt);
|
||||
|
||||
/* Configure the write protect GPIO */
|
||||
|
||||
kinetis_pinconfig(GPIO_SD_WRPROTECT);
|
||||
|
||||
/* Mount the SDHC-based MMC/SD block driver */
|
||||
/* First, get an instance of the SDHC interface */
|
||||
|
||||
syslog(LOG_INFO, "Initializing SDHC slot %d\n",
|
||||
CONFIG_NSH_MMCSDSLOTNO);
|
||||
|
||||
g_nsh.sdhc = sdhc_initialize(CONFIG_NSH_MMCSDSLOTNO);
|
||||
if (!g_nsh.sdhc)
|
||||
ret = mount(NULL, PROCFS_MOUNTPOUNT, "procfs", 0, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize SDHC slot %d\n",
|
||||
CONFIG_NSH_MMCSDSLOTNO);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Now bind the SDHC interface to the MMC/SD driver */
|
||||
|
||||
syslog(LOG_INFO, "Bind SDHC to the MMC/SD driver, minor=%d\n",
|
||||
CONFIG_NSH_MMCSDMINOR);
|
||||
|
||||
ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, g_nsh.sdhc);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to bind SDHC to the MMC/SD driver: %d\n", ret);
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
|
||||
ret, errno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "Successfully bound SDHC to the MMC/SD driver\n");
|
||||
|
||||
/* Handle the initial card state */
|
||||
|
||||
k64_mediachange();
|
||||
|
||||
/* Enable CD interrupts to handle subsequent media changes */
|
||||
|
||||
kinetis_pinirqenable(GPIO_SD_CARDDETECT);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMCSD
|
||||
/* Initialize the SDHC driver */
|
||||
|
||||
ret = k64_sdhc_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
mcerr("ERROR: k64_sdhc_initialize() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FRDMK64F_SDHC_MOUNT
|
||||
else
|
||||
{
|
||||
/* REVISIT: A delay seems to be required here or the mount will fail. */
|
||||
/* Mount the volume on HSMCI0 */
|
||||
|
||||
ret = mount(CONFIG_FRDMK64F_SDHC_MOUNT_BLKDEV,
|
||||
CONFIG_FRDMK64F_SDHC_MOUNT_MOUNTPOINT,
|
||||
CONFIG_FRDMK64F_SDHC_MOUNT_FSTYPE,
|
||||
0, NULL);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
mcerr("ERROR: Failed to mount %s: %d\n",
|
||||
CONFIG_FRDMK64F_SDHC_MOUNT_MOUNTPOINT, errno);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FRDMK64F_SDHC_MOUNT */
|
||||
#endif /* HAVE_MMCSD */
|
||||
|
||||
#ifdef HAVE_AUTOMOUNTER
|
||||
/* Initialize the auto-mounter */
|
||||
|
||||
k64_automount_initialize();
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
/****************************************************************************
|
||||
* config/freedom-k64f/src/k64_sdhc.c
|
||||
*
|
||||
* Copyright (C) 2016 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* A micro Secure Digital (SD) card slot is available on the FRDM-K64F connected to
|
||||
* the SD Host Controller (SDHC) signals of the MCU. This slot will accept micro
|
||||
* format SD memory cards. The SD card detect pin (PTE6) is an open switch that
|
||||
* shorts with VDD when card is inserted.
|
||||
*
|
||||
* ------------ ------------- --------
|
||||
* SD Card Slot Board Signal K64F Pin
|
||||
* ------------ ------------- --------
|
||||
* DAT0 SDHC0_D0 PTE0
|
||||
* DAT1 SDHC0_D1 PTE1
|
||||
* DAT2 SDHC0_D2 PTE5
|
||||
* CD/DAT3 SDHC0_D3 PTE4
|
||||
* CMD SDHC0_CMD PTE3
|
||||
* CLK SDHC0_DCLK PTE2
|
||||
* SWITCH D_CARD_DETECT PTE6
|
||||
* ------------ ------------- --------
|
||||
*
|
||||
* There is no Write Protect pin available to the K64F.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/sdio.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
|
||||
#include "kinetis.h"
|
||||
|
||||
#include "freedom-k64f.h"
|
||||
|
||||
#ifdef HAVE_MMCSD
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
/* This structure holds static information unique to one SDHC peripheral */
|
||||
|
||||
struct k64_sdhc_state_s
|
||||
{
|
||||
struct sdio_dev_s *sdhc; /* R/W device handle */
|
||||
bool inserted; /* TRUE: card is inserted */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* HSCMI device state */
|
||||
|
||||
static struct k64_sdhc_state_s g_sdhc;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k64_mediachange
|
||||
****************************************************************************/
|
||||
|
||||
static void k64_mediachange(void)
|
||||
{
|
||||
bool inserted;
|
||||
|
||||
/* Get the current value of the card detect pin. This pin is pulled up on
|
||||
* board. So low means that a card is present.
|
||||
*/
|
||||
|
||||
inserted = !kinetis_gpioread(GPIO_SD_CARDDETECT);
|
||||
|
||||
/* Has the pin changed state? */
|
||||
|
||||
if (inserted != g_sdhc.inserted)
|
||||
{
|
||||
/* Yes.. perform the appropriate action (this might need some debounce). */
|
||||
|
||||
g_sdhc.inserted = inserted;
|
||||
sdhc_mediachange(g_sdhc.sdhc, inserted);
|
||||
|
||||
#ifdef CONFIG_FRDMK64F_SDHC_AUTOMOUNT
|
||||
/* Let the automounter know about the insertion event */
|
||||
|
||||
k64_automount_event(SDHC0_SLOTNO, k64_cardinserted());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k64_cdinterrupt
|
||||
****************************************************************************/
|
||||
|
||||
static int k64_cdinterrupt(int irq, FAR void *context)
|
||||
{
|
||||
/* All of the work is done by k64_mediachange() */
|
||||
|
||||
k64_mediachange();
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k64_sdhc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Inititialize the SDHC SD card slot
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int k64_sdhc_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Configure GPIO pins */
|
||||
|
||||
/* Attached the card detect interrupt (but don't enable it yet) */
|
||||
|
||||
kinetis_pinconfig(GPIO_SD_CARDDETECT);
|
||||
kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt);
|
||||
|
||||
/* Configure the write protect GPIO -- None */
|
||||
|
||||
/* Mount the SDHC-based MMC/SD block driver */
|
||||
/* First, get an instance of the SDHC interface */
|
||||
|
||||
mcinfo("Initializing SDHC slot %d\n", MMCSD_SLOTNO);
|
||||
|
||||
g_sdhc.sdhc = sdhc_initialize(MMCSD_SLOTNO);
|
||||
if (!g_sdhc.sdhc)
|
||||
{
|
||||
mcerr("ERROR: Failed to initialize SDHC slot %d\n", MMCSD_SLOTNO);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Now bind the SDHC interface to the MMC/SD driver */
|
||||
|
||||
mcinfo("Bind SDHC to the MMC/SD driver, minor=%d\n", MMSCD_MINOR);
|
||||
|
||||
ret = mmcsd_slotinitialize(MMSCD_MINOR, g_sdhc.sdhc);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to bind SDHC to the MMC/SD driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "Successfully bound SDHC to the MMC/SD driver\n");
|
||||
|
||||
/* Handle the initial card state */
|
||||
|
||||
k64_mediachange();
|
||||
|
||||
/* Enable CD interrupts to handle subsequent media changes */
|
||||
|
||||
kinetis_pinirqenable(GPIO_SD_CARDDETECT);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k64_cardinserted
|
||||
*
|
||||
* Description:
|
||||
* Check if a card is inserted into the SDHC slot
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_AUTOMOUNTER
|
||||
bool k64_cardinserted(void)
|
||||
{
|
||||
return !kinetis_gpioread(GPIO_SD_CARDDETECT);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k64_writeprotected
|
||||
*
|
||||
* Description:
|
||||
* Check if a card is inserted into the SDHC slot
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_AUTOMOUNTER
|
||||
bool k64_writeprotected(void)
|
||||
{
|
||||
/* There are no write protect pins */
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_MMCSD */
|
||||
@@ -71,7 +71,7 @@ ARCHDEFINES =
|
||||
|
||||
# Check if building a 32-bit target with a 64-bit toolchain
|
||||
|
||||
ifeq ($(ARCH_X86_M32),y)
|
||||
ifeq ($(CONFIG_ARCH_X86_M32),y)
|
||||
ARCHCPUFLAGS += -m32
|
||||
endif
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ ARCHDEFINES =
|
||||
|
||||
# Check if building a 32-bit target with a 64-bit toolchain
|
||||
|
||||
ifeq ($(ARCH_X86_M32),y)
|
||||
ifeq ($(CONFIG_ARCH_X86_M32),y)
|
||||
ARCHCPUFLAGS += -m32
|
||||
endif
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ bool sam_cardinserted_internal(struct sam_hsmci_state_s *state)
|
||||
/* Get the state of the PIO pin */
|
||||
|
||||
inserted = sam_gpioread(state->cdcfg);
|
||||
finfo("Slot %d inserted: %s\n", state->slotno, inserted ? "NO" : "YES");
|
||||
mcinfo("Slot %d inserted: %s\n", state->slotno, inserted ? "NO" : "YES");
|
||||
return !inserted;
|
||||
}
|
||||
|
||||
@@ -221,12 +221,12 @@ int sam_hsmci_initialize(int slotno, int minor)
|
||||
struct sam_hsmci_state_s *state;
|
||||
int ret;
|
||||
|
||||
/* Get the static HSMI description */
|
||||
/* Get the static HSMCI description */
|
||||
|
||||
state = sam_hsmci_state(slotno);
|
||||
if (!state)
|
||||
{
|
||||
ferr("ERROR: No state for slotno %d\n", slotno);
|
||||
mcerr("ERROR: No state for slotno %d\n", slotno);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ int sam_hsmci_initialize(int slotno, int minor)
|
||||
state->hsmci = sdio_initialize(slotno);
|
||||
if (!state->hsmci)
|
||||
{
|
||||
ferr("ERROR: Failed to initialize SDIO slot %d\n", slotno);
|
||||
mcerr("ERROR: Failed to initialize SDIO slot %d\n", slotno);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ int sam_hsmci_initialize(int slotno, int minor)
|
||||
ret = mmcsd_slotinitialize(minor, state->hsmci);
|
||||
if (ret != OK)
|
||||
{
|
||||
ferr("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
|
||||
mcerr("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ bool sam_cardinserted(int slotno)
|
||||
state = sam_hsmci_state(slotno);
|
||||
if (!state)
|
||||
{
|
||||
ferr("ERROR: No state for slotno %d\n", slotno);
|
||||
mcerr("ERROR: No state for slotno %d\n", slotno);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,10 @@ ifeq ($(CONFIG_LCD_UG2864HSWEG01),y)
|
||||
CSRCS += stm32_ug2864hsweg01.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_OSTEST),y)
|
||||
CSRCS += stm32_ostest.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TIMER),y)
|
||||
CSRCS += stm32_timer.c
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/************************************************************************************
|
||||
* configs/stm32f4discovery/src/stm32_ostest.c
|
||||
*
|
||||
* Copyright (C) 2016 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 <string.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "stm32f4discovery.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Configuration ********************************************************************/
|
||||
|
||||
#undef HAVE_FPU
|
||||
#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_EXAMPLES_OSTEST_FPUTESTDISABLE) && \
|
||||
defined(CONFIG_EXAMPLES_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) && \
|
||||
!defined(CONFIG_DISABLE_SIGNALS)
|
||||
# define HAVE_FPU 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FPU
|
||||
|
||||
#if CONFIG_EXAMPLES_OSTEST_FPUSIZE != (4*SW_FPU_REGS)
|
||||
# error "CONFIG_EXAMPLES_OSTEST_FPUSIZE has the wrong size"
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
static uint32_t g_saveregs[XCPTCONTEXT_REGS];
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/* Given an array of size CONFIG_EXAMPLES_OSTEST_FPUSIZE, this function will return
|
||||
* the current FPU registers.
|
||||
*/
|
||||
|
||||
void arch_getfpu(FAR uint32_t *fpusave)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
/* Take a snapshot of the thread context right now */
|
||||
|
||||
flags = enter_critical_section();
|
||||
up_saveusercontext(g_saveregs);
|
||||
|
||||
/* Return only the floating register values */
|
||||
|
||||
memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS));
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Given two arrays of size CONFIG_EXAMPLES_OSTEST_FPUSIZE this function
|
||||
* will compare them and return true if they are identical.
|
||||
*/
|
||||
|
||||
bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2)
|
||||
{
|
||||
return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_FPU */
|
||||
@@ -210,22 +210,60 @@ FAR struct mtd_dev_s *mtd_temp;
|
||||
g_mtd_fs = mtd_temp;
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITION
|
||||
/* Setup a partition of 256KiB for our file system. */
|
||||
{
|
||||
FAR struct mtd_geometry_s geo;
|
||||
off_t nblocks;
|
||||
|
||||
#if defined(CONFIG_N25QXXX_SECTOR512)
|
||||
mtd_temp = mtd_partition(g_mtd_fs, 0, 512);
|
||||
#else
|
||||
mtd_temp = mtd_partition(g_mtd_fs, 0, 64);
|
||||
/* Setup a partition of 256KiB for our file system. */
|
||||
|
||||
ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY, (unsigned long)(uintptr_t)&geo);
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("ERROR: MTDIOC_GEOMETRY failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
nblocks = (256*1024) / geo.blocksize;
|
||||
|
||||
mtd_temp = mtd_partition(g_mtd_fs, 0, nblocks);
|
||||
if (!mtd_temp)
|
||||
{
|
||||
_err("ERROR: mtd_partition failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
g_mtd_fs = mtd_temp;
|
||||
}
|
||||
#endif
|
||||
if (!g_mtd_fs)
|
||||
|
||||
#ifdef HAVE_N25QXXX_SMARTFS
|
||||
/* Configure the device with no partition support */
|
||||
|
||||
ret = smart_initialize(N25QXXX_SMART_MINOR, g_mtd_fs, NULL);
|
||||
if (ret != OK)
|
||||
{
|
||||
_err("ERROR: mtd_partition failed\n");
|
||||
_err("ERROR: Failed to initialize SmartFS: %d\n", ret);
|
||||
}
|
||||
|
||||
#elif defined(HAVE_N25QXXX_NXFFS)
|
||||
/* Initialize to provide NXFFS on the N25QXXX MTD interface */
|
||||
|
||||
ret = nxffs_initialize(g_mtd_fs);
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("ERROR: NXFFS initialization failed: %d\n", ret);
|
||||
}
|
||||
|
||||
/* Mount the file system at /mnt/nxffs */
|
||||
|
||||
ret = mount(NULL, "/mnt/nxffs", "nxffs", 0, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
g_mtd_fs = mtd_temp;
|
||||
#endif
|
||||
|
||||
#else /* if defined(HAVE_N25QXXX_CHARDEV) */
|
||||
/* Use the FTL layer to wrap the MTD driver as a block driver */
|
||||
|
||||
ret = ftl_initialize(N25QXXX_MTD_MINOR, g_mtd_fs);
|
||||
@@ -256,6 +294,7 @@ FAR struct mtd_dev_s *mtd_temp;
|
||||
_err("ERROR: bchdev_register %s failed: %d\n", chardev, ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "up_arch.h"
|
||||
#include "kinetis.h"
|
||||
#include "kinetis_usbotg.h"
|
||||
#include "kinetis_sim.h"
|
||||
#include "chip/kinetis_sim.h"
|
||||
#include "teensy-3x.h"
|
||||
|
||||
/************************************************************************************
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user