mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Add circular DMA support to STM32 and STM32 serial driver; Add initial configuration for the Mikroelektronika PIC32MX7 MMB board
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4640 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -2673,4 +2673,10 @@
|
|||||||
* drivers/serial/serial.c: Do not disable Rx interrupts on each byte.
|
* drivers/serial/serial.c: Do not disable Rx interrupts on each byte.
|
||||||
Rather, only disable Rx interrupts when the Rx ring buffer may be empty.
|
Rather, only disable Rx interrupts when the Rx ring buffer may be empty.
|
||||||
* include/nuttx/usb/audio.h: USB Audio 1.0 definitions (in progress).
|
* include/nuttx/usb/audio.h: USB Audio 1.0 definitions (in progress).
|
||||||
|
* arch/arm/src/stm32/stm32fxx_dma.c: STM32 F4 DMA now supports circular
|
||||||
|
buffer mode (contributed by Mike Smith)
|
||||||
|
* arch/arm/src/stm32/stm32_serial.c: The serial driver can now support
|
||||||
|
Rx DMA into a circular buffer (contributed by Mike Smith)
|
||||||
|
* configs/pic32mx7mmb: Beginning of a configuration for the Mikroelektronka
|
||||||
|
PIC32MX7 Multimedia Board (MMB).
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* arch/arm/src/stm32/chip/stm32_uart.h
|
* arch/arm/src/stm32/chip/stm32_uart.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2011-2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/stm32/stm32_dma.c
|
* arch/arm/src/stm32/stm32_dma.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2011-2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
@@ -251,6 +251,19 @@ EXTERN void stm32_dmastart(DMA_HANDLE handle, dma_callback_t callback,
|
|||||||
|
|
||||||
EXTERN void stm32_dmastop(DMA_HANDLE handle);
|
EXTERN void stm32_dmastop(DMA_HANDLE handle);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32_dmaresidual
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Returns the number of bytes remaining to be transferred
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* - DMA handle allocated by stm32_dmachannel()
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
EXTERN size_t stm32_dmaresidual(DMA_HANDLE handle);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_dmasample
|
* Name: stm32_dmasample
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -56,89 +56,6 @@
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Private Definitions
|
* Private Definitions
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
/* Configuration **********************************************************/
|
|
||||||
/* Make sure that we have not enabled more U[S]ARTs than are support by
|
|
||||||
* the device.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if STM32_NUSART < 6
|
|
||||||
# undef CONFIG_STM32_USART6
|
|
||||||
#endif
|
|
||||||
#if STM32_NUSART < 5
|
|
||||||
# undef CONFIG_STM32_UART5
|
|
||||||
#endif
|
|
||||||
#if STM32_NUSART < 4
|
|
||||||
# undef CONFIG_STM32_UART4
|
|
||||||
#endif
|
|
||||||
#if STM32_NUSART < 3
|
|
||||||
# undef CONFIG_STM32_USART3
|
|
||||||
#endif
|
|
||||||
#if STM32_NUSART < 2
|
|
||||||
# undef CONFIG_STM32_USART2
|
|
||||||
#endif
|
|
||||||
#if STM32_NUSART < 1
|
|
||||||
# undef CONFIG_STM32_USART1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_STM32_USART1) || defined (CONFIG_STM32_USART2) || defined(CONFIG_STM32_USART3) || \
|
|
||||||
defined(CONFIG_STM32_UART4) || defined (CONFIG_STM32_UART5) || defined(CONFIG_STM32_USART6)
|
|
||||||
# define HAVE_UART
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Is there a serial console? */
|
|
||||||
|
|
||||||
#if defined(CONFIG_USART1_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART1)
|
|
||||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART3_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART4_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART5_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART6_SERIAL_CONSOLE
|
|
||||||
# define HAVE_CONSOLE 1
|
|
||||||
#elif defined(CONFIG_USART2_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART2)
|
|
||||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART3_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART4_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART5_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART6_SERIAL_CONSOLE
|
|
||||||
# define HAVE_CONSOLE 1
|
|
||||||
#elif defined(CONFIG_USART3_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART3)
|
|
||||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART4_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART5_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART6_SERIAL_CONSOLE
|
|
||||||
# define HAVE_CONSOLE 1
|
|
||||||
#elif defined(CONFIG_UART4_SERIAL_CONSOLE) && defined(CONFIG_STM32_UART4)
|
|
||||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART3_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART5_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART6_SERIAL_CONSOLE
|
|
||||||
# define HAVE_CONSOLE 1
|
|
||||||
#elif defined(CONFIG_UART5_SERIAL_CONSOLE) && defined(CONFIG_STM32_UART5)
|
|
||||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART3_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART4_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART6_SERIAL_CONSOLE
|
|
||||||
# define HAVE_CONSOLE 1
|
|
||||||
#elif defined(CONFIG_USART6_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART6)
|
|
||||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART3_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART4_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART5_SERIAL_CONSOLE
|
|
||||||
# define HAVE_CONSOLE 1
|
|
||||||
#else
|
|
||||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART3_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART4_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_UART5_SERIAL_CONSOLE
|
|
||||||
# undef CONFIG_USART6_SERIAL_CONSOLE
|
|
||||||
# undef HAVE_CONSOLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Select USART parameters for the selected console */
|
/* Select USART parameters for the selected console */
|
||||||
|
|
||||||
#if defined(CONFIG_USART1_SERIAL_CONSOLE)
|
#if defined(CONFIG_USART1_SERIAL_CONSOLE)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -532,6 +532,9 @@ static inline void spi_dmarxwakeup(FAR struct stm32_spidev_s *priv)
|
|||||||
static void spi_dmarxcallback(DMA_HANDLE handle, uint8_t isr, void *arg)
|
static void spi_dmarxcallback(DMA_HANDLE handle, uint8_t isr, void *arg)
|
||||||
{
|
{
|
||||||
FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)arg;
|
FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)arg;
|
||||||
|
|
||||||
|
/* Wake-up the SPI driver */
|
||||||
|
|
||||||
priv->rxresult = isr | 0x080; /* OR'ed with 0x80 to assure non-zero */
|
priv->rxresult = isr | 0x080; /* OR'ed with 0x80 to assure non-zero */
|
||||||
spi_dmarxwakeup(priv);
|
spi_dmarxwakeup(priv);
|
||||||
}
|
}
|
||||||
@@ -549,6 +552,9 @@ static void spi_dmarxcallback(DMA_HANDLE handle, uint8_t isr, void *arg)
|
|||||||
static void spi_dmatxcallback(DMA_HANDLE handle, uint8_t isr, void *arg)
|
static void spi_dmatxcallback(DMA_HANDLE handle, uint8_t isr, void *arg)
|
||||||
{
|
{
|
||||||
FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)arg;
|
FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)arg;
|
||||||
|
|
||||||
|
/* Wake-up the SPI driver */
|
||||||
|
|
||||||
priv->txresult = isr | 0x080; /* OR'ed with 0x80 to assure non-zero */
|
priv->txresult = isr | 0x080; /* OR'ed with 0x80 to assure non-zero */
|
||||||
spi_dmatxwakeup(priv);
|
spi_dmatxwakeup(priv);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* arch/arm/src/stm32/stm32_uart.h
|
* arch/arm/src/stm32/stm32_uart.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -48,6 +48,163 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
/* Make sure that we have not enabled more U[S]ARTs than are support by
|
||||||
|
* the device.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if STM32_NUSART < 6
|
||||||
|
# undef CONFIG_STM32_USART6
|
||||||
|
#endif
|
||||||
|
#if STM32_NUSART < 5
|
||||||
|
# undef CONFIG_STM32_UART5
|
||||||
|
#endif
|
||||||
|
#if STM32_NUSART < 4
|
||||||
|
# undef CONFIG_STM32_UART4
|
||||||
|
#endif
|
||||||
|
#if STM32_NUSART < 3
|
||||||
|
# undef CONFIG_STM32_USART3
|
||||||
|
#endif
|
||||||
|
#if STM32_NUSART < 2
|
||||||
|
# undef CONFIG_STM32_USART2
|
||||||
|
#endif
|
||||||
|
#if STM32_NUSART < 1
|
||||||
|
# undef CONFIG_STM32_USART1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Is there a USART enabled? */
|
||||||
|
|
||||||
|
#if defined(CONFIG_STM32_USART1) || defined(CONFIG_STM32_USART2) || \
|
||||||
|
defined(CONFIG_STM32_USART3) || defined(CONFIG_STM32_UART4) || \
|
||||||
|
defined(CONFIG_STM32_UART5) || defined(CONFIG_STM32_USART6)
|
||||||
|
# define HAVE_UART 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Is there a serial console? */
|
||||||
|
|
||||||
|
#if defined(CONFIG_USART1_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART1)
|
||||||
|
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART3_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART4_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART5_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART6_SERIAL_CONSOLE
|
||||||
|
# define CONSOLE_UART 1
|
||||||
|
# define HAVE_CONSOLE 1
|
||||||
|
#elif defined(CONFIG_USART2_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART2)
|
||||||
|
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART3_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART4_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART5_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART6_SERIAL_CONSOLE
|
||||||
|
# define CONSOLE_UART 2
|
||||||
|
# define HAVE_CONSOLE 1
|
||||||
|
#elif defined(CONFIG_USART3_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART3)
|
||||||
|
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART4_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART5_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART6_SERIAL_CONSOLE
|
||||||
|
# define CONSOLE_UART 3
|
||||||
|
# define HAVE_CONSOLE 1
|
||||||
|
#elif defined(CONFIG_USART4_SERIAL_CONSOLE) && defined(CONFIG_STM32_UART4)
|
||||||
|
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART3_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART5_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART6_SERIAL_CONSOLE
|
||||||
|
# define CONSOLE_UART 4
|
||||||
|
# define HAVE_CONSOLE 1
|
||||||
|
#elif defined(CONFIG_USART5_SERIAL_CONSOLE) && defined(CONFIG_STM32_UART5)
|
||||||
|
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART3_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART4_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART6_SERIAL_CONSOLE
|
||||||
|
# define CONSOLE_UART 5
|
||||||
|
# define HAVE_CONSOLE 1
|
||||||
|
#elif defined(CONFIG_USART6_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART6)
|
||||||
|
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART3_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART4_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART5_SERIAL_CONSOLE
|
||||||
|
# define CONSOLE_UART 6
|
||||||
|
# define HAVE_CONSOLE 1
|
||||||
|
#else
|
||||||
|
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART3_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART4_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_UART5_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_USART6_SERIAL_CONSOLE
|
||||||
|
# define CONSOLE_UART 0
|
||||||
|
# undef HAVE_CONSOLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* DMA support is only provided if CONFIG_ARCH_DMA is in the NuttX configuration.
|
||||||
|
* Furthermore, DMA support is currently only implemented for the F4 (but could be
|
||||||
|
* extended to the F1 and F2 with a little effort in the DMA code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(HAVE_UART) || !defined(CONFIG_ARCH_DMA) || !defined(CONFIG_STM32_STM32F40XX)
|
||||||
|
# undef CONFIG_USART1_RXDMA
|
||||||
|
# undef CONFIG_USART2_RXDMA
|
||||||
|
# undef CONFIG_USART3_RXDMA
|
||||||
|
# undef CONFIG_USART4_RXDMA
|
||||||
|
# undef CONFIG_USART5_RXDMA
|
||||||
|
# undef CONFIG_USART6_RXDMA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Disable the DMA configuration on all unused USARTs */
|
||||||
|
|
||||||
|
#ifndef CONFIG_STM32_USART1
|
||||||
|
# undef CONFIG_USART1_RXDMA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_STM32_USART2
|
||||||
|
# undef CONFIG_USART2_RXDMA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_STM32_USART3
|
||||||
|
# undef CONFIG_USART3_RXDMA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_STM32_USART4
|
||||||
|
# undef CONFIG_USART4_RXDMA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_STM32_USART5
|
||||||
|
# undef CONFIG_USART5_RXDMA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_STM32_USART6
|
||||||
|
# undef CONFIG_USART6_RXDMA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Is DMA available on any (enabled) USART? */
|
||||||
|
|
||||||
|
#undef SERIAL_HAVE_DMA
|
||||||
|
#if defined(CONFIG_USART1_RXDMA) || defined(CONFIG_USART2_RXDMA) || \
|
||||||
|
defined(CONFIG_USART3_RXDMA) || defined(CONFIG_USART4_RXDMA) || \
|
||||||
|
defined(CONFIG_USART5_RXDMA) || defined(CONFIG_USART6_RXDMA)
|
||||||
|
# define SERIAL_HAVE_DMA 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Is DMA used on all (enabled) USARTs */
|
||||||
|
|
||||||
|
#define SERIAL_HAVE_ONLY_DMA 1
|
||||||
|
#if defined(CONFIG_STM32_USART1) && !defined(CONFIG_USART1_RXDMA)
|
||||||
|
# undef SERIAL_HAVE_ONLY_DMA
|
||||||
|
#elif defined(CONFIG_STM32_USART2) && !defined(CONFIG_USART2_RXDMA)
|
||||||
|
# undef SERIAL_HAVE_ONLY_DMA
|
||||||
|
#elif defined(CONFIG_STM32_USART3) && !defined(CONFIG_USART3_RXDMA)
|
||||||
|
# undef SERIAL_HAVE_ONLY_DMA
|
||||||
|
#elif defined(CONFIG_STM32_UART4) && !defined(CONFIG_USART4_RXDMA)
|
||||||
|
# undef SERIAL_HAVE_ONLY_DMA
|
||||||
|
#elif defined(CONFIG_STM32_UART5) && !defined(CONFIG_USART5_RXDMA)
|
||||||
|
# undef SERIAL_HAVE_ONLY_DMA
|
||||||
|
#elif defined(CONFIG_STM32_USART6) && !defined(CONFIG_USART6_RXDMA)
|
||||||
|
# undef SERIAL_HAVE_ONLY_DMA
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
@@ -57,8 +214,41 @@
|
|||||||
* Public Data
|
* Public Data
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C" {
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32_serial_dma_poll
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Must be called periodically if any STM32 UART is configured for DMA.
|
||||||
|
* The DMA callback is triggered for each fifo size/2 bytes, but this can
|
||||||
|
* result in some bytes being transferred but not collected if the incoming
|
||||||
|
* data is not a whole multiple of half the FIFO size.
|
||||||
|
*
|
||||||
|
* May be safely called from either interrupt or thread context.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef SERIAL_HAVE_DMA
|
||||||
|
EXTERN void stm32_serial_dma_poll(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __ARCH_ARM_STC_STM32_STM32_UART_H */
|
#endif /* __ARCH_ARM_STC_STM32_STM32_UART_H */
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ struct stm32_dma_s
|
|||||||
uint8_t irq; /* DMA stream IRQ number */
|
uint8_t irq; /* DMA stream IRQ number */
|
||||||
uint8_t shift; /* ISR/IFCR bit shift value */
|
uint8_t shift; /* ISR/IFCR bit shift value */
|
||||||
uint8_t channel; /* DMA channel number (0-7) */
|
uint8_t channel; /* DMA channel number (0-7) */
|
||||||
|
bool nonstop; /* Stream is configured in a non-stopping mode. */
|
||||||
sem_t sem; /* Used to wait for DMA channel to become available */
|
sem_t sem; /* Used to wait for DMA channel to become available */
|
||||||
uint32_t base; /* DMA register channel base address */
|
uint32_t base; /* DMA register channel base address */
|
||||||
dma_callback_t callback; /* Callback invoked when the DMA completes */
|
dma_callback_t callback; /* Callback invoked when the DMA completes */
|
||||||
@@ -429,9 +430,20 @@ static int stm32_dmainterrupt(int irq, void *context)
|
|||||||
|
|
||||||
status = (dmabase_getreg(dmast, regoffset) >> dmast->shift) & DMA_STREAM_MASK;
|
status = (dmabase_getreg(dmast, regoffset) >> dmast->shift) & DMA_STREAM_MASK;
|
||||||
|
|
||||||
/* Disable the DMA stream */
|
/* Clear fetched stream interrupts by setting bits in the upper or lower IFCR
|
||||||
|
* register
|
||||||
|
*/
|
||||||
|
|
||||||
stm32_dmastreamdisable(dmast);
|
if (stream < 4)
|
||||||
|
{
|
||||||
|
regoffset = STM32_DMA_LIFCR_OFFSET;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
regoffset = STM32_DMA_HIFCR_OFFSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
dmabase_putreg(dmast, regoffset, (status << dmast->shift));
|
||||||
|
|
||||||
/* Invoke the callback */
|
/* Invoke the callback */
|
||||||
|
|
||||||
@@ -636,11 +648,15 @@ void stm32_dmasetup(DMA_HANDLE handle, uint32_t paddr, uint32_t maddr,
|
|||||||
/* "Set the memory address in the DMA_SM0ARx ... register. The data will be
|
/* "Set the memory address in the DMA_SM0ARx ... register. The data will be
|
||||||
* written to or read from this memory after the peripheral event."
|
* written to or read from this memory after the peripheral event."
|
||||||
*
|
*
|
||||||
* Note that only single-buffer mode is currently supported so SM1ARx
|
* Note that in double-buffered mode it is explicitly assumed that the second
|
||||||
* is not used."
|
* buffer immediately follows the first.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dmast_putreg(dmast, STM32_DMA_SM0AR_OFFSET, maddr);
|
dmast_putreg(dmast, STM32_DMA_SM0AR_OFFSET, maddr);
|
||||||
|
if (scr & DMA_SCR_DBM)
|
||||||
|
{
|
||||||
|
dmast_putreg(dmast, STM32_DMA_SM1AR_OFFSET, maddr + ntransfers);
|
||||||
|
}
|
||||||
|
|
||||||
/* "Configure the total number of data items to be transferred in the
|
/* "Configure the total number of data items to be transferred in the
|
||||||
* DMA_SNDTRx register. After each peripheral event, this value will be
|
* DMA_SNDTRx register. After each peripheral event, this value will be
|
||||||
@@ -677,28 +693,42 @@ void stm32_dmasetup(DMA_HANDLE handle, uint32_t paddr, uint32_t maddr,
|
|||||||
* generated when the stream is enabled, then the stream will be automatically
|
* generated when the stream is enabled, then the stream will be automatically
|
||||||
* disabled."
|
* disabled."
|
||||||
*
|
*
|
||||||
|
* The FIFO is disabled in circular mode when transferring data from a
|
||||||
|
* peripheral to memory, as in this case it is usually desirable to know that
|
||||||
|
* every byte from the peripheral is transferred immediately to memory. It is
|
||||||
|
* not practical to flush the DMA FIFO, as this requires disabling the channel
|
||||||
|
* which triggers the transfer-complete interrupt.
|
||||||
|
*
|
||||||
* NOTE: The FEIFx error interrupt is not enabled because the FEIFx seems to
|
* NOTE: The FEIFx error interrupt is not enabled because the FEIFx seems to
|
||||||
* be reported spuriously causing good transfers to be marked as failures.
|
* be reported spuriously causing good transfers to be marked as failures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
regval = dmast_getreg(dmast, STM32_DMA_SFCR_OFFSET);
|
regval = dmast_getreg(dmast, STM32_DMA_SFCR_OFFSET);
|
||||||
regval &= ~(DMA_SFCR_FTH_MASK | DMA_SFCR_FS_MASK | DMA_SFCR_FEIE);
|
regval &= ~(DMA_SFCR_FTH_MASK | DMA_SFCR_FS_MASK | DMA_SFCR_FEIE);
|
||||||
|
if (!((scr & (DMA_SCR_CIRC | DMA_SCR_DIR_MASK)) == (DMA_SCR_CIRC | DMA_SCR_DIR_P2M)))
|
||||||
|
{
|
||||||
regval |= (DMA_SFCR_FTH_FULL | DMA_SFCR_DMDIS);
|
regval |= (DMA_SFCR_FTH_FULL | DMA_SFCR_DMDIS);
|
||||||
|
}
|
||||||
dmast_putreg(dmast, STM32_DMA_SFCR_OFFSET, regval);
|
dmast_putreg(dmast, STM32_DMA_SFCR_OFFSET, regval);
|
||||||
|
|
||||||
/* "Configure data transfer direction, circular mode, peripheral & memory
|
/* "Configure data transfer direction, circular mode, peripheral & memory
|
||||||
* incremented mode, peripheral & memory data size, and interrupt after
|
* incremented mode, peripheral & memory data size, and interrupt after
|
||||||
* half and/or full transfer in the DMA_CCRx register."
|
* half and/or full transfer in the DMA_CCRx register."
|
||||||
|
*
|
||||||
|
* Note: The CT bit is always reset.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
regval = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET);
|
regval = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET);
|
||||||
regval &= ~(DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC|
|
regval &= ~(DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC|
|
||||||
DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS|
|
DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS|
|
||||||
|
DMA_SCR_CIRC|DMA_SCR_DBM|DMA_SCR_CT|
|
||||||
DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK);
|
DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK);
|
||||||
scr &= (DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC|
|
scr &= (DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC|
|
||||||
DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS|
|
DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS|
|
||||||
|
DMA_SCR_DBM|DMA_SCR_CIRC|
|
||||||
DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK);
|
DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK);
|
||||||
regval |= scr;
|
regval |= scr;
|
||||||
|
dmast->nonstop = (scr & (DMA_SCR_DBM|DMA_SCR_CIRC)) != 0;
|
||||||
dmast_putreg(dmast, STM32_DMA_SCR_OFFSET, regval);
|
dmast_putreg(dmast, STM32_DMA_SCR_OFFSET, regval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -734,6 +764,8 @@ void stm32_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg, bool
|
|||||||
scr = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET);
|
scr = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET);
|
||||||
scr |= DMA_SCR_EN;
|
scr |= DMA_SCR_EN;
|
||||||
|
|
||||||
|
if (!dmast->nonstop)
|
||||||
|
{
|
||||||
/* Once half of the bytes are transferred, the half-transfer flag (HTIF) is
|
/* Once half of the bytes are transferred, the half-transfer flag (HTIF) is
|
||||||
* set and an interrupt is generated if the Half-Transfer Interrupt Enable
|
* set and an interrupt is generated if the Half-Transfer Interrupt Enable
|
||||||
* bit (HTIE) is set. At the end of the transfer, the Transfer Complete Flag
|
* bit (HTIE) is set. At the end of the transfer, the Transfer Complete Flag
|
||||||
@@ -742,6 +774,18 @@ void stm32_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg, bool
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
scr |= (half ? (DMA_SCR_HTIE|DMA_SCR_TEIE) : (DMA_SCR_TCIE|DMA_SCR_TEIE));
|
scr |= (half ? (DMA_SCR_HTIE|DMA_SCR_TEIE) : (DMA_SCR_TCIE|DMA_SCR_TEIE));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* In nonstop mode, when the transfer completes it immediately resets
|
||||||
|
* and starts again. The transfer-complete interrupt is thus always
|
||||||
|
* enabled, and the half-complete interrupt can be used in circular
|
||||||
|
* mode to determine when the buffer is half-full, or in double-buffered
|
||||||
|
* mode to determine when one of the two buffers is full.
|
||||||
|
*/
|
||||||
|
scr |= (half ? DMA_SCR_HTIE : 0) | DMA_SCR_TCIE | DMA_SCR_TEIE;
|
||||||
|
}
|
||||||
|
|
||||||
dmast_putreg(dmast, STM32_DMA_SCR_OFFSET, scr);
|
dmast_putreg(dmast, STM32_DMA_SCR_OFFSET, scr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,6 +808,38 @@ void stm32_dmastop(DMA_HANDLE handle)
|
|||||||
stm32_dmastreamdisable(dmast);
|
stm32_dmastreamdisable(dmast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32_dmaresidual
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Read the DMA bytes-remaining register.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* - DMA handle allocated by stm32_dmachannel()
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
size_t stm32_dmaresidual(DMA_HANDLE handle)
|
||||||
|
{
|
||||||
|
struct stm32_dma_s *dmast = (struct stm32_dma_s *)handle;
|
||||||
|
uint32_t residual;
|
||||||
|
|
||||||
|
/* Fetch the count of bytes remaining to be transferred.
|
||||||
|
*
|
||||||
|
* If the FIFO is enabled, this count may be inaccurate. ST don't
|
||||||
|
* appear to document whether this counts the peripheral or the memory
|
||||||
|
* side of the channel, and they don't make the memory pointer
|
||||||
|
* available either.
|
||||||
|
*
|
||||||
|
* For reception in circular mode the FIFO is disabled in order that
|
||||||
|
* this value can be useful.
|
||||||
|
*/
|
||||||
|
|
||||||
|
residual = dmast_getreg(dmast, STM32_DMA_SNDTR_OFFSET);
|
||||||
|
|
||||||
|
return (size_t)residual;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_dmasample
|
* Name: stm32_dmasample
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -660,7 +660,7 @@ config PIC32MX_UART2PRIO
|
|||||||
---help---
|
---help---
|
||||||
UART 2. Range 4-31, Default 16.
|
UART 2. Range 4-31, Default 16.
|
||||||
|
|
||||||
config PIC32MX_CN
|
config PIC32MX_CNPRIO
|
||||||
int "CN"
|
int "CN"
|
||||||
default 16
|
default 16
|
||||||
depends on PIC32MX_CN
|
depends on PIC32MX_CN
|
||||||
|
|||||||
+11
-3
@@ -266,9 +266,16 @@ config ARCH_BOARD_PIC32_STARTERKIT
|
|||||||
bool "Microchip PIC32 Ethernet Starter Kit (DM320004)"
|
bool "Microchip PIC32 Ethernet Starter Kit (DM320004)"
|
||||||
depends on ARCH_CHIP_PIC32MX795F512L
|
depends on ARCH_CHIP_PIC32MX795F512L
|
||||||
---help---
|
---help---
|
||||||
This README file discusses the port of NuttX to the Microchip PIC32 Ethernet
|
This is the port of NuttX to the Microchip PIC32 Ethernet Starter Kit
|
||||||
Starter Kit (DM320004) with the Multimedia Expansion Board (MEB, DM320005).
|
(DM320004) with the Multimedia Expansion Board (MEB, DM320005).
|
||||||
Advanced USB Storage. See www.microchip.com for further information.
|
See www.microchip.com for further information.
|
||||||
|
|
||||||
|
config ARCH_BOARD_PIC32_PIC32MXMMB
|
||||||
|
bool "Mikroelektronika PIC32MX7 MMB"
|
||||||
|
depends on ARCH_CHIP_PIC32MX795F512L
|
||||||
|
---help---
|
||||||
|
This is the port NuttX to the Mikroelektronika PIC32MX7 Multimedia Board
|
||||||
|
(MMB). See http://www.mikroe.com/ for further information.
|
||||||
|
|
||||||
config ARCH_BOARD_PJRC_87C52
|
config ARCH_BOARD_PJRC_87C52
|
||||||
bool "PJRC 87C52 development system"
|
bool "PJRC 87C52 development system"
|
||||||
@@ -524,6 +531,7 @@ source "configs/olimex-lpc2378/Kconfig"
|
|||||||
source "configs/olimex-strp711/Kconfig"
|
source "configs/olimex-strp711/Kconfig"
|
||||||
source "configs/pcblogic-pic32mx/Kconfig"
|
source "configs/pcblogic-pic32mx/Kconfig"
|
||||||
source "configs/pic32-starterkit/Kconfig"
|
source "configs/pic32-starterkit/Kconfig"
|
||||||
|
source "configs/pic32mx7mmb/Kconfig"
|
||||||
source "configs/pjrc-8051/Kconfig"
|
source "configs/pjrc-8051/Kconfig"
|
||||||
source "configs/qemu-i486/Kconfig"
|
source "configs/qemu-i486/Kconfig"
|
||||||
source "configs/rgmp/Kconfig"
|
source "configs/rgmp/Kconfig"
|
||||||
|
|||||||
+11
-2
@@ -1486,9 +1486,18 @@ configs/pcblogic-pic32mx
|
|||||||
|
|
||||||
configs/pic32-starterkit
|
configs/pic32-starterkit
|
||||||
|
|
||||||
This README file discusses the port of NuttX to the Microchip PIC32 Ethernet
|
This directory contains the port of NuttX to the Microchip PIC32 Ethernet
|
||||||
Starter Kit (DM320004) with the Multimedia Expansion Board (MEB, DM320005).
|
Starter Kit (DM320004) with the Multimedia Expansion Board (MEB, DM320005).
|
||||||
Advanced USB Storage. See www.microchip.com for further information.
|
See www.microchip.com for further information.
|
||||||
|
|
||||||
|
configs/pic32mx7mmb
|
||||||
|
|
||||||
|
This directory will (eventually) contain the port of NuttX to the
|
||||||
|
Mikroelektronika PIC32MX7 Multimedia Board (MMB). See
|
||||||
|
http://www.mikroe.com/ for further information.
|
||||||
|
|
||||||
|
On initial check-in, this directory is just a clone of the PIC32 starter
|
||||||
|
kit port with the appropriate naming changes. More to come.
|
||||||
|
|
||||||
configs/pjrc-8051
|
configs/pjrc-8051
|
||||||
8051 Microcontroller. This port uses the PJRC 87C52 development system
|
8051 Microcontroller. This port uses the PJRC 87C52 development system
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#
|
||||||
|
# For a description of the syntax of this configuration file,
|
||||||
|
# see misc/tools/kconfig-language.txt.
|
||||||
|
#
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,221 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/pic32mx7mmb/include/board.h
|
||||||
|
* include/arch/board/board.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __CONFIGS_MIKROELEKTRONIKA_PIC32MX7MMB_INCLUDE_BOARD_H
|
||||||
|
#define __CONFIGS_MIKROELEKTRONIKA_PIC32MX7MMB_INCLUDE_BOARD_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
# include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-Processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
/* Configuration ************************************************************/
|
||||||
|
|
||||||
|
/* Clocking *****************************************************************/
|
||||||
|
/* Crystal frequencies */
|
||||||
|
|
||||||
|
#define BOARD_POSC_FREQ 8000000 /* Primary OSC XTAL frequency (8MHz) */
|
||||||
|
#define BOARD_SOSC_FREQ 32768 /* Secondary OSC XTAL frequency (32.768KHz) */
|
||||||
|
|
||||||
|
/* PLL configuration and resulting CPU clock.
|
||||||
|
* CPU_CLOCK = ((POSC_FREQ / IDIV) * MULT) / ODIV
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BOARD_PLL_IDIV 2 /* PLL input divider */
|
||||||
|
#define BOARD_PLL_MULT 20 /* PLL multiplier */
|
||||||
|
#define BOARD_PLL_ODIV 1 /* PLL output divider */
|
||||||
|
|
||||||
|
#define BOARD_CPU_CLOCK 80000000 /* CPU clock (80MHz = 8MHz * 20 / 2) */
|
||||||
|
|
||||||
|
/* USB PLL configuration.
|
||||||
|
* USB_CLOCK = ((POSC_XTAL / IDIV) * 24) / 2
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BOARD_UPLL_IDIV 2 /* USB PLL divider (revisit) */
|
||||||
|
#define BOARD_USB_CLOCK 48000000 /* USB clock (8MHz / 2) * 24 / 2) */
|
||||||
|
|
||||||
|
/* Peripheral clock is divided down from CPU clock.
|
||||||
|
* PBCLOCK = CPU_CLOCK / PBDIV
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BOARD_PBDIV 2 /* Peripheral clock divisor (PBDIV) */
|
||||||
|
#define BOARD_PBCLOCK 40000000 /* Peripheral clock (PBCLK = 80MHz/2) */
|
||||||
|
|
||||||
|
/* Watchdog pre-scaler (re-visit) */
|
||||||
|
|
||||||
|
#define BOARD_WD_ENABLE 0 /* Watchdog is disabled */
|
||||||
|
#define BOARD_WD_PRESCALER 8 /* Watchdog pre-scaler */
|
||||||
|
|
||||||
|
/* Ethernet MII clocking.
|
||||||
|
*
|
||||||
|
* The clock divider used to create the MII Management Clock (MDC). The MIIM
|
||||||
|
* module uses the SYSCLK as an input clock. According to the IEEE 802.3
|
||||||
|
* Specification this should be no faster than 2.5 MHz. However, some PHYs
|
||||||
|
* support clock rates up to 12.5 MHz.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BOARD_EMAC_MIIM_DIV 32 /* Ideal: 80MHz/32 = 2.5MHz */
|
||||||
|
|
||||||
|
/* LED definitions **********************************************************/
|
||||||
|
/* LED Configuration ********************************************************/
|
||||||
|
/* The Mikroelektronika PIC32MX7 MMB has 3 user LEDs labeled LED1-3 on the
|
||||||
|
* board graphics (but referred to as LED4-6 in the schematic):
|
||||||
|
*
|
||||||
|
* PIN User's Guide Board Stencil Notes
|
||||||
|
* --- ------------- -------------- -------------------------
|
||||||
|
* RD0 "User LED D4" "LED1 (RD0") High illuminates (RED)
|
||||||
|
* RD2 "User LED D5" "LED3 (RD2)" High illuminates (YELLOW)
|
||||||
|
* RD1 "User LED D6" "LED2 (RD1)" High illuminates (GREEN)
|
||||||
|
*
|
||||||
|
* We will use the labels on the board to identify LEDs
|
||||||
|
*
|
||||||
|
* There are 5 additional LEDs available on the MEB (but not used by NuttX):
|
||||||
|
*
|
||||||
|
* RD1 LED1
|
||||||
|
* RD2 LED2
|
||||||
|
* RD3 LED3
|
||||||
|
* RC1 LED4
|
||||||
|
* RC2 LED5
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* LED index values for use with pic32mx_setled() */
|
||||||
|
|
||||||
|
#define PIC32MX_PIC32MX7MMB_LED1 0
|
||||||
|
#define PIC32MX_PIC32MX7MMB_LED2 1
|
||||||
|
#define PIC32MX_PIC32MX7MMB_LED3 2
|
||||||
|
#define PIC32MX_PIC32MX7MMB_NLEDS 3
|
||||||
|
|
||||||
|
/* LED bits for use with pic32mx_setleds() */
|
||||||
|
|
||||||
|
#define PIC32MX_PIC32MX7MMB_LED1_BIT (1 << PIC32MX_PIC32MX7MMB_LED1)
|
||||||
|
#define PIC32MX_PIC32MX7MMB_LED2_BIT (1 << PIC32MX_PIC32MX7MMB_LED2)
|
||||||
|
#define PIC32MX_PIC32MX7MMB_LED3_BIT (1 << PIC32MX_PIC32MX7MMB_LED3)
|
||||||
|
|
||||||
|
/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 3 LEDs
|
||||||
|
* on board the Mikroelektronika PIC32MX7 MMB. The following definitions
|
||||||
|
* describe how NuttX controls the LEDs:
|
||||||
|
*
|
||||||
|
* ON OFF
|
||||||
|
* ------------------------- ---- ---- ---- ---- ---- ----
|
||||||
|
* LED1 LED2 LED3 LED1 LED2 LED3
|
||||||
|
* ------------------------- ---- ---- ---- ---- ---- ----
|
||||||
|
* LED_STARTED 0 OFF OFF OFF --- --- ---
|
||||||
|
* LED_HEAPALLOCATE 1 ON OFF N/C --- --- ---
|
||||||
|
* LED_IRQSENABLED 2 OFF ON N/C --- --- ---
|
||||||
|
* LED_STACKCREATED 3 ON ON N/C --- --- ---
|
||||||
|
* LED_INIRQ 4 N/C N/C ON N/C N/C OFF
|
||||||
|
* LED_SIGNAL 4 N/C N/C ON N/C N/C OFF
|
||||||
|
* LED_ASSERTION 4 N/C N/C ON N/C N/C OFF
|
||||||
|
* LED_PANIC 5 ON N/C N/C OFF N/C N/C
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LED_STARTED 0
|
||||||
|
#define LED_HEAPALLOCATE 1
|
||||||
|
#define LED_IRQSENABLED 2
|
||||||
|
#define LED_STACKCREATED 3
|
||||||
|
#define LED_INIRQ 4
|
||||||
|
#define LED_SIGNAL 4
|
||||||
|
#define LED_ASSERTION 4
|
||||||
|
#define LED_PANIC 5
|
||||||
|
|
||||||
|
#define LED_NVALUES 6
|
||||||
|
|
||||||
|
/* Switch definitions *******************************************************/
|
||||||
|
/* The PIC32 start kit has 3 switches:
|
||||||
|
*
|
||||||
|
* RD7 Switch SW2 (low when closed)
|
||||||
|
* RD6 Switch SW1 (low when closed)
|
||||||
|
* RD13 Switch SW3 (low when closed)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Inline Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C" {
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pic32mx_ledinit and pic32mx_setled
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
|
||||||
|
* LEDs. If CONFIG_ARCH_LEDS is not defined, then the following interfaces
|
||||||
|
* are available to control the LEDs from user applicaitons.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_ARCH_LEDS
|
||||||
|
EXTERN void pic32mx_ledinit(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_ARCH_LEDS
|
||||||
|
EXTERN void pic32mx_setled(int led, bool ledon);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_ARCH_LEDS
|
||||||
|
EXTERN void pic32mx_setleds(uint8_t ledset);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
|
#endif /* __CONFIGS_MIKROELEKTRONIKA_PIC32MX7MMB_INCLUDE_BOARD_H */
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
############################################################################
|
||||||
|
# configs/pic32mx7mmb/ostest/Make.defs
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 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
|
||||||
|
|
||||||
|
# Setup for the selected toolchain
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_PIC32MX_MICROCHIPW),y)
|
||||||
|
# Microchip toolchain under Windows
|
||||||
|
CROSSDEV = pic32-
|
||||||
|
WINTOOL = y
|
||||||
|
MAXOPTIMIZATION = -O2
|
||||||
|
ARCHCPUFLAGS = -mprocessor=elf32pic32mx -mno-float -mlong32 -membedded-data
|
||||||
|
ARCHPICFLAGS = -fpic -membedded-pic
|
||||||
|
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_PIC32MX_MICROCHIPW_LITE),y)
|
||||||
|
# Microchip toolchain under Windows
|
||||||
|
CROSSDEV = pic32-
|
||||||
|
WINTOOL = y
|
||||||
|
# MAXOPTIMIZATION = -O2
|
||||||
|
ARCHCPUFLAGS = -mprocessor=elf32pic32mx -mno-float -mlong32 -membedded-data
|
||||||
|
ARCHPICFLAGS = -fpic -membedded-pic
|
||||||
|
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_PIC32MX_MICROCHIPL),y)
|
||||||
|
# Microchip toolchain under Linux
|
||||||
|
CROSSDEV = pic32-
|
||||||
|
MAXOPTIMIZATION = -O2
|
||||||
|
ARCHCPUFLAGS = -mprocessor=elf32pic32mx -mno-float -mlong32 -membedded-data
|
||||||
|
ARCHPICFLAGS = -fpic -membedded-pic
|
||||||
|
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_PIC32MX_MICROCHIPL_LITE),y)
|
||||||
|
# Microchip toolchain under Linux
|
||||||
|
CROSSDEV = pic32-
|
||||||
|
# MAXOPTIMIZATION = -O2
|
||||||
|
ARCHCPUFLAGS = -mprocessor=elf32pic32mx -mno-float -mlong32 -membedded-data
|
||||||
|
ARCHPICFLAGS = -fpic -membedded-pic
|
||||||
|
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(WINTOOL),y)
|
||||||
|
# Windows-native toolchains
|
||||||
|
DIRLINK = $(TOPDIR)/tools/winlink.sh
|
||||||
|
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
|
||||||
|
MKDEP = $(TOPDIR)/tools/mknulldeps.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)/ostest/ld.script}"
|
||||||
|
else
|
||||||
|
# Linux/Cygwin-native toolchain
|
||||||
|
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||||
|
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||||
|
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||||
|
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ostest/ld.script
|
||||||
|
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
|
||||||
|
|
||||||
|
ifeq ("${CONFIG_DEBUG_SYMBOLS}","y")
|
||||||
|
ARCHOPTIMIZATION = -g
|
||||||
|
else
|
||||||
|
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
|
||||||
|
ARCHWARNINGSXX = -Wall -Wshadow
|
||||||
|
ARCHDEFINES =
|
||||||
|
|
||||||
|
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.ld -no-check-sections
|
||||||
|
LDNXFLATFLAGS = -e main -s 2048
|
||||||
|
|
||||||
|
OBJEXT = .o
|
||||||
|
LIBEXT = .a
|
||||||
|
EXEEXT =
|
||||||
|
|
||||||
|
define PREPROCESS
|
||||||
|
@echo "CPP: $1->$2"
|
||||||
|
@$(CPP) $(CPPFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define COMPILE
|
||||||
|
@echo "CC: $1"
|
||||||
|
@$(CC) -c $(CFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define COMPILEXX
|
||||||
|
@echo "CXX: $1"
|
||||||
|
@$(CXX) -c $(CXXFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define ASSEMBLE
|
||||||
|
@echo "AS: $1"
|
||||||
|
@$(CC) -c $(AFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define ARCHIVE
|
||||||
|
echo "AR: $2"; \
|
||||||
|
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
|
||||||
|
endef
|
||||||
|
|
||||||
|
define CLEAN
|
||||||
|
@rm -f *.o *.a
|
||||||
|
endef
|
||||||
|
|
||||||
|
HOSTCC = gcc
|
||||||
|
HOSTINCLUDES = -I.
|
||||||
|
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
|
||||||
|
HOSTLDFLAGS =
|
||||||
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
############################################################################
|
||||||
|
# configs/pic32mx7mmb/ostest/appconfig
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 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.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Path to example in apps/examples containing the user_start entry point
|
||||||
|
|
||||||
|
CONFIGURED_APPS += examples/ostest
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,317 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/pic32mx7mmb/ostest/ld.script
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
/* Memory Regions ***********************************************************/
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
/* The PIC32MX795F512L has 512Kb of program FLASH at physical address
|
||||||
|
* 0x1d000000 but is always accessed at KSEG0 address 0x9d00:0000
|
||||||
|
*/
|
||||||
|
|
||||||
|
kseg0_progmem (rx) : ORIGIN = 0x9d000000, LENGTH = 512K
|
||||||
|
|
||||||
|
/* The PIC32MX795F512L has 12Kb of boot FLASH at physical address
|
||||||
|
* 0x1fc00000. The initial reset vector is in KSEG1, but all other
|
||||||
|
* accesses are in KSEG0.
|
||||||
|
*
|
||||||
|
* REGION PHYSICAL KSEG SIZE
|
||||||
|
* DESCRIPTION START ADDR (BYTES)
|
||||||
|
* ------------- ---------- ------ ----------------------
|
||||||
|
* Exceptions:*
|
||||||
|
* Reset 0x1fc00000 KSEG1 512 512
|
||||||
|
* TLB Refill 0x1fc00200 KSEG1 256 768
|
||||||
|
* Cache Error 0x1fc00300 KSEG1 128 896
|
||||||
|
* Others 0x1fc00380 KSEG1 128 1024 (1Kb)
|
||||||
|
* Interrupt 0x1fc00400 KSEG1 128 1152
|
||||||
|
* JTAG 0x1fc00480 KSEG1 16 1168
|
||||||
|
* Exceptions 0x1fc00490 KSEG0 8192-1168 8192 (4Kb)
|
||||||
|
* Debug code 0x1fc02000 KSEG1 4096-16 12272
|
||||||
|
* DEVCFG3-0 0x1fc02ff0 KSEG1 16 12288 (12Kb)
|
||||||
|
*
|
||||||
|
* Exceptions assume:
|
||||||
|
*
|
||||||
|
* STATUS: BEV=0/1 and EXL=0
|
||||||
|
* CAUSE: IV=1
|
||||||
|
* JTAG: ProbEn=0
|
||||||
|
* And multi-vector support disabled
|
||||||
|
*/
|
||||||
|
|
||||||
|
kseg1_reset (rx) : ORIGIN = 0xbfc00000, LENGTH = 384
|
||||||
|
kseg1_genexcpt (rx) : ORIGIN = 0xbfc00180, LENGTH = 128
|
||||||
|
kseg1_ebexcpt (rx) : ORIGIN = 0xbfc00200, LENGTH = 128
|
||||||
|
kseg1_bevexcpt (rx) : ORIGIN = 0xbfc00380, LENGTH = 128
|
||||||
|
kseg1_intexcpt (rx) : ORIGIN = 0xbfc00400, LENGTH = 128
|
||||||
|
kseg1_dbgexcpt (rx) : ORIGIN = 0xbfc00480, LENGTH = 16
|
||||||
|
kseg0_bootmem (rx) : ORIGIN = 0x9fc00490, LENGTH = 8192-1168
|
||||||
|
kseg1_dbgcode (rx) : ORIGIN = 0xbfc02000, LENGTH = 4096-16
|
||||||
|
kseg1_devcfg (r) : ORIGIN = 0xbfc02ff0, LENGTH = 16
|
||||||
|
|
||||||
|
/* The PIC32MX795F512L has 128Kb of data memory at physical address
|
||||||
|
* 0x00000000. Since the PIC32MX has no data cache, this memory is
|
||||||
|
* always accessed through KSEG1.
|
||||||
|
*
|
||||||
|
* When used with MPLAB, we need to set aside 512 bytes of memory
|
||||||
|
* for use by MPLAB.
|
||||||
|
*/
|
||||||
|
|
||||||
|
kseg1_datamem (w!x) : ORIGIN = 0xa0000200, LENGTH = 128K - 512
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT_FORMAT("elf32-tradlittlemips")
|
||||||
|
OUTPUT_ARCH(pic32mx)
|
||||||
|
ENTRY(__start)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
/* Boot FLASH sections */
|
||||||
|
|
||||||
|
.reset :
|
||||||
|
{
|
||||||
|
KEEP (*(.reset))
|
||||||
|
} > kseg1_reset
|
||||||
|
|
||||||
|
/* Exception handlers. The following is assumed:
|
||||||
|
*
|
||||||
|
* STATUS: BEV=1 and EXL=0
|
||||||
|
* CAUSE: IV=1
|
||||||
|
* JTAG: ProbEn=0
|
||||||
|
* And multi-vector support disabled
|
||||||
|
*
|
||||||
|
* In that configuration, the vector locations become:
|
||||||
|
*
|
||||||
|
* Reset, Soft Reset bfc0:0000
|
||||||
|
* TLB Refill bfc0:0200
|
||||||
|
* Cache Error bfc0:0300
|
||||||
|
* All others bfc0:0380
|
||||||
|
* Interrupt bfc0:0400
|
||||||
|
* EJTAG Debug bfc0:0480
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* KSEG1 exception handler "trampolines" */
|
||||||
|
|
||||||
|
.gen_excpt :
|
||||||
|
{
|
||||||
|
KEEP (*(.gen_excpt))
|
||||||
|
} > kseg1_genexcpt
|
||||||
|
|
||||||
|
.ebase_excpt :
|
||||||
|
{
|
||||||
|
KEEP (*(.ebase_excpt))
|
||||||
|
} > kseg1_ebexcpt
|
||||||
|
|
||||||
|
.bev_excpt :
|
||||||
|
{
|
||||||
|
KEEP (*(.bev_excpt))
|
||||||
|
} > kseg1_bevexcpt
|
||||||
|
|
||||||
|
.int_excpt :
|
||||||
|
{
|
||||||
|
KEEP (*(.int_excpt))
|
||||||
|
} > kseg1_intexcpt
|
||||||
|
|
||||||
|
.dbg_excpt = ORIGIN(kseg1_dbgexcpt);
|
||||||
|
|
||||||
|
.start :
|
||||||
|
{
|
||||||
|
/* KSEG0 Reset startup logic */
|
||||||
|
|
||||||
|
*(.start)
|
||||||
|
|
||||||
|
/* KSEG0 exception handlers */
|
||||||
|
|
||||||
|
*(.nmi_handler)
|
||||||
|
*(.bev_handler)
|
||||||
|
*(.int_handler)
|
||||||
|
} > kseg0_bootmem
|
||||||
|
|
||||||
|
.dbg_code = ORIGIN(kseg1_dbgcode);
|
||||||
|
|
||||||
|
.devcfg :
|
||||||
|
{
|
||||||
|
KEEP (*(.devcfg))
|
||||||
|
} > kseg1_devcfg
|
||||||
|
|
||||||
|
/* Program FLASH sections */
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
_stext = ABSOLUTE(.);
|
||||||
|
*(.text .text.*)
|
||||||
|
*(.stub)
|
||||||
|
KEEP (*(.text.*personality*))
|
||||||
|
*(.gnu.linkonce.t.*)
|
||||||
|
*(.gnu.warning)
|
||||||
|
*(.mips16.fn.*)
|
||||||
|
*(.mips16.call.*)
|
||||||
|
|
||||||
|
/* Read-only data is included in the text section */
|
||||||
|
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
*(.rodata1)
|
||||||
|
*(.gnu.linkonce.r.*)
|
||||||
|
|
||||||
|
/* Small initialized constant global and static data */
|
||||||
|
|
||||||
|
*(.sdata2 .sdata2.*)
|
||||||
|
*(.gnu.linkonce.s2.*)
|
||||||
|
|
||||||
|
/* Uninitialized constant global and static data */
|
||||||
|
|
||||||
|
*(.sbss2 .sbss2.*)
|
||||||
|
*(.gnu.linkonce.sb2.*)
|
||||||
|
_etext = ABSOLUTE(.);
|
||||||
|
} > kseg0_progmem
|
||||||
|
|
||||||
|
/* Initialization data begins here in progmem */
|
||||||
|
|
||||||
|
_data_loaddr = LOADADDR(.data);
|
||||||
|
|
||||||
|
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||||
|
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
|
||||||
|
|
||||||
|
/* RAM functions are positioned at the beginning of RAM so that
|
||||||
|
* they can be guaranteed to satisfy the 2Kb alignment requirement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This causes failures if there are no RAM functions
|
||||||
|
.ramfunc ALIGN(2K) :
|
||||||
|
{
|
||||||
|
_sramfunc = ABSOLUTE(.);
|
||||||
|
*(.ramfunc .ramfunc.*)
|
||||||
|
_eramfunc = ABSOLUTE(.);
|
||||||
|
} > kseg1_datamem AT > kseg0_progmem
|
||||||
|
|
||||||
|
_ramfunc_loadaddr = LOADADDR(.ramfunc);
|
||||||
|
_ramfunc_sizeof = SIZEOF(.ramfunc);
|
||||||
|
_bmxdkpba_address = _sramfunc - ORIGIN(kseg1_datamem) ;
|
||||||
|
_bmxdudba_address = LENGTH(kseg1_datamem) ;
|
||||||
|
_bmxdupba_address = LENGTH(kseg1_datamem) ;
|
||||||
|
*/
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
_sdata = ABSOLUTE(.);
|
||||||
|
*(.data .data.*)
|
||||||
|
*(.gnu.linkonce.d.*)
|
||||||
|
KEEP (*(.gnu.linkonce.d.*personality*))
|
||||||
|
*(.data1)
|
||||||
|
} > kseg1_datamem AT > kseg0_progmem
|
||||||
|
|
||||||
|
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
|
||||||
|
_gp = ALIGN(16) + 0x7FF0 ;
|
||||||
|
|
||||||
|
.got :
|
||||||
|
{
|
||||||
|
*(.got.plt) *(.got)
|
||||||
|
} > kseg1_datamem AT > kseg0_progmem
|
||||||
|
|
||||||
|
.sdata :
|
||||||
|
{
|
||||||
|
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
||||||
|
} > kseg1_datamem AT > kseg0_progmem
|
||||||
|
|
||||||
|
.lit8 :
|
||||||
|
{
|
||||||
|
*(.lit8)
|
||||||
|
} > kseg1_datamem AT > kseg0_progmem
|
||||||
|
|
||||||
|
.lit4 :
|
||||||
|
{
|
||||||
|
*(.lit4)
|
||||||
|
_edata = ABSOLUTE(.);
|
||||||
|
} >kseg1_datamem AT>kseg0_progmem
|
||||||
|
|
||||||
|
.sbss :
|
||||||
|
{
|
||||||
|
_sbss = ABSOLUTE(.);
|
||||||
|
*(.dynsbss)
|
||||||
|
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||||
|
*(.scommon)
|
||||||
|
} >kseg1_datamem
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
*(.dynbss)
|
||||||
|
*(.bss .bss.*)
|
||||||
|
*(.gnu.linkonce.b.*)
|
||||||
|
*(COMMON)
|
||||||
|
_ebss = ABSOLUTE(.);
|
||||||
|
} > kseg1_datamem
|
||||||
|
|
||||||
|
/* Stabs debugging sections */
|
||||||
|
|
||||||
|
.stab 0 : { *(.stab) }
|
||||||
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||||
|
.stab.index 0 : { *(.stab.index) }
|
||||||
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||||
|
.comment 0 : { *(.comment) }
|
||||||
|
|
||||||
|
/* DWARF debug sections */
|
||||||
|
/* DWARF 1 */
|
||||||
|
|
||||||
|
.debug 0 : { *(.debug) }
|
||||||
|
.line 0 : { *(.line) }
|
||||||
|
|
||||||
|
/* GNU DWARF 1 extensions */
|
||||||
|
|
||||||
|
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||||
|
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||||
|
|
||||||
|
/* DWARF 1.1 and DWARF 2 */
|
||||||
|
|
||||||
|
.debug_aranges 0 : { *(.debug_aranges) }
|
||||||
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||||
|
|
||||||
|
/* DWARF 2 */
|
||||||
|
|
||||||
|
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||||
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||||
|
.debug_line 0 : { *(.debug_line) }
|
||||||
|
.debug_frame 0 : { *(.debug_frame) }
|
||||||
|
.debug_str 0 : { *(.debug_str) }
|
||||||
|
.debug_loc 0 : { *(.debug_loc) }
|
||||||
|
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||||
|
|
||||||
|
/* SGI/MIPS DWARF 2 extensions */
|
||||||
|
|
||||||
|
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||||
|
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||||
|
.debug_typenames 0 : { *(.debug_typenames) }
|
||||||
|
.debug_varnames 0 : { *(.debug_varnames) }
|
||||||
|
|
||||||
|
/DISCARD/ : { *(.note.GNU-stack) }
|
||||||
|
}
|
||||||
Executable
+61
@@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# configs/pic32mx7mmb/ostest/setenv.sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 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
|
||||||
|
|
||||||
|
if [ -z "${PATH_ORIG}" ]; then export PATH_ORIG="${PATH}"; fi
|
||||||
|
|
||||||
|
WD=`pwd`
|
||||||
|
if [ ! -x "setenv.sh" ]; then
|
||||||
|
echo "This script must be executed from the top-level NuttX build directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This the Cygwin path to the location where I installed the MicroChip
|
||||||
|
# PIC32MX toolchain under windows. This is *not* the default install
|
||||||
|
# location so you will probably have to edit this. You will also have
|
||||||
|
# to edit this if you install a different version of if you install
|
||||||
|
# the Linux PIC32MX toolchain as well
|
||||||
|
export TOOLCHAIN_BIN="/cygdrive/c/MicroChip/mplabc32/v1.12/bin"
|
||||||
|
|
||||||
|
# This is the path to the toosl subdirectory
|
||||||
|
export PIC32TOOL_DIR="${WD}/configs/pic32mx7mmb/tools"
|
||||||
|
|
||||||
|
# Add the path to the toolchain to the PATH varialble
|
||||||
|
export PATH="${TOOLCHAIN_BIN}:${PIC32TOOL_DIR}:/sbin:/usr/sbin:${PATH_ORIG}"
|
||||||
|
|
||||||
|
echo "PATH : ${PATH}"
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
############################################################################
|
||||||
|
# configs/pic32mx7mmb/src/Makefile
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
-include $(TOPDIR)/Make.defs
|
||||||
|
|
||||||
|
CFLAGS += -I$(TOPDIR)/sched
|
||||||
|
|
||||||
|
ASRCS =
|
||||||
|
CSRCS = up_boot.c up_leds.c up_spi.c
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_PIC32MX_USBDEV),y)
|
||||||
|
CSRCS += up_usbdev.c
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_USBTERM_DEVINIT),y)
|
||||||
|
CSRCS += up_usbterm.c
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NSH_ARCHINIT),y)
|
||||||
|
CSRCS += up_nsh.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_USBMSC),y)
|
||||||
|
CSRCS += up_usbmsc.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||||
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||||
|
|
||||||
|
SRCS = $(ASRCS) $(CSRCS)
|
||||||
|
OBJS = $(AOBJS) $(COBJS)
|
||||||
|
|
||||||
|
ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src
|
||||||
|
ifeq ($(WINTOOL),y)
|
||||||
|
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \
|
||||||
|
-I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \
|
||||||
|
-I "${shell cygpath -w $(ARCH_SRCDIR)/mips32}"
|
||||||
|
else
|
||||||
|
CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/mips32
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: libboard$(LIBEXT)
|
||||||
|
|
||||||
|
$(AOBJS): %$(OBJEXT): %.S
|
||||||
|
$(call ASSEMBLE, $<, $@)
|
||||||
|
|
||||||
|
$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
|
||||||
|
$(call COMPILE, $<, $@)
|
||||||
|
|
||||||
|
libboard$(LIBEXT): $(OBJS)
|
||||||
|
@( for obj in $(OBJS) ; do \
|
||||||
|
$(call ARCHIVE, $@, $${obj}); \
|
||||||
|
done ; )
|
||||||
|
|
||||||
|
.depend: Makefile $(SRCS)
|
||||||
|
@$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
depend: .depend
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm -f libboard$(LIBEXT) *~ .*.swp
|
||||||
|
$(call CLEAN)
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
@rm -f Make.dep .depend
|
||||||
|
|
||||||
|
-include Make.dep
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/pic32mx7mmb/src/pic32mx7mmb_internal.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __CONFIGS_MIKROELEKTRONIKA_PIC32MX7MMB_SRC_PIC32MX7MMB_INTERNAL_H
|
||||||
|
#define __CONFIGS_MIKROELEKTRONIKA_PIC32MX7MMB_SRC_PIC32MX7MMB_INTERNAL_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-Processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
/* Configuration ************************************************************/
|
||||||
|
/* The Mikroelektronika PIC32MX7 MMB has 3 user LEDs
|
||||||
|
*
|
||||||
|
* RD0 User LED D4 (high illuminates)
|
||||||
|
* RD2 User LED D5 (high illuminates)
|
||||||
|
* RD1 User LED D6 (high illuminates)
|
||||||
|
*
|
||||||
|
* There are 5 LEDs available on the MEB:
|
||||||
|
*
|
||||||
|
* RD1 LED1
|
||||||
|
* RD2 LED2
|
||||||
|
* RD3 LED3
|
||||||
|
* RC1 LED4
|
||||||
|
* RC2 LED5
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The PIC32 start kit has 3 switches:
|
||||||
|
*
|
||||||
|
* RD7 Switch SW2 (low when closed)
|
||||||
|
* RD6 Switch SW1 (low when closed)
|
||||||
|
* RD13 Switch SW3 (low when closed)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Inline Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C" {
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: pic32mx_spiinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called to configure SPI chip select GPIO pins for the PCB Logic board.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_PIC32MX_SPI2)
|
||||||
|
EXTERN void weak_function pic32mx_spiinitialize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: pic32mx_ledinit
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Configure on-board LEDs if LED support has been selected.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_LEDS
|
||||||
|
EXTERN void pic32mx_ledinit(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
|
#endif /* __CONFIGS_MIKROELEKTRONIKA_PIC32MX7MMB_SRC_PIC32MX7MMB_INTERNAL_H */
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
/************************************************************************************
|
||||||
|
* configs/pic32mx7mmb/src/up_boot.c
|
||||||
|
* arch/mips/src/board/up_boot.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Included Files
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "up_arch.h"
|
||||||
|
#include "up_internal.h"
|
||||||
|
|
||||||
|
#include "pic32mx-internal.h"
|
||||||
|
#include "pic32mx7mmb_internal.h"
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Definitions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: pic32mx_boardinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* All PIC32MX architectures must provide the following entry point. This entry
|
||||||
|
* point is called early in the intitialization -- after all memory has been
|
||||||
|
* configured and mapped but before any devices have been initialized.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
void pic32mx_boardinitialize(void)
|
||||||
|
{
|
||||||
|
/* Configure SPI chip selects if 1) at least one SPI is enabled, and 2) the weak
|
||||||
|
* function pic32mx_spiinitialize() has been brought into the link.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_PIC32MX_SPI1) || defined(CONFIG_PIC32MX_SPI2) || \
|
||||||
|
defined(CONFIG_PIC32MX_SPI3) || defined(CONFIG_PIC32MX_SPI4)
|
||||||
|
if (pic32mx_spiinitialize)
|
||||||
|
{
|
||||||
|
pic32mx_spiinitialize();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configure on-board LEDs if LED support has been selected. */
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_LEDS
|
||||||
|
pic32mx_ledinit();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -0,0 +1,266 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/pic32mx7mmb/src/up_leds.c
|
||||||
|
* arch/arm/src/board/up_leds.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "chip.h"
|
||||||
|
#include "up_arch.h"
|
||||||
|
#include "up_internal.h"
|
||||||
|
|
||||||
|
#include "pic32mx-internal.h"
|
||||||
|
#include "pic32mx-ioport.h"
|
||||||
|
#include "pic32mx7mmb_internal.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
/* LED Configuration ********************************************************/
|
||||||
|
/* The Mikroelektronika PIC32MX7 MMB has 3 user LEDs labeled LED1-3 on the
|
||||||
|
* board graphics (but referred to as LED4-6 in the schematic):
|
||||||
|
*
|
||||||
|
* PIN User's Guide Board Stencil Notes
|
||||||
|
* --- ------------- -------------- -------------------------
|
||||||
|
* RD0 "User LED D4" "LED1 (RD0") High illuminates (RED)
|
||||||
|
* RD2 "User LED D5" "LED3 (RD2)" High illuminates (YELLOW)
|
||||||
|
* RD1 "User LED D6" "LED2 (RD1)" High illuminates (GREEN)
|
||||||
|
*
|
||||||
|
* We will use the labels on the board to identify LEDs
|
||||||
|
*
|
||||||
|
* ON OFF
|
||||||
|
* ------------------------- ---- ---- ---- ---- ---- ----
|
||||||
|
* LED1 LED2 LED3 LED1 LED2 LED3
|
||||||
|
* ------------------------- ---- ---- ---- ---- ---- ----
|
||||||
|
* LED_STARTED 0 OFF OFF OFF --- --- ---
|
||||||
|
* LED_HEAPALLOCATE 1 ON OFF N/C --- --- ---
|
||||||
|
* LED_IRQSENABLED 2 OFF ON N/C --- --- ---
|
||||||
|
* LED_STACKCREATED 3 ON ON N/C --- --- ---
|
||||||
|
* LED_INIRQ 4 N/C N/C ON N/C N/C OFF
|
||||||
|
* LED_SIGNAL 4 N/C N/C ON N/C N/C OFF
|
||||||
|
* LED_ASSERTION 4 N/C N/C ON N/C N/C OFF
|
||||||
|
* LED_PANIC 5 ON N/C N/C OFF N/C N/C
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define GPIO_LED_1 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTD|GPIO_PIN0)
|
||||||
|
#define GPIO_LED_2 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTD|GPIO_PIN1)
|
||||||
|
#define GPIO_LED_3 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTD|GPIO_PIN2)
|
||||||
|
|
||||||
|
/* LED Management Definitions ***********************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_LEDS
|
||||||
|
# define LED_OFF 0
|
||||||
|
# define LED_ON 1
|
||||||
|
# define LED_NC 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Debug ********************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_LEDS)
|
||||||
|
# define leddbg lldbg
|
||||||
|
# ifdef CONFIG_DEBUG_VERBOSE
|
||||||
|
# define ledvdbg lldbg
|
||||||
|
# else
|
||||||
|
# define ledvdbg(x...)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# undef CONFIG_DEBUG_LEDS
|
||||||
|
# undef CONFIG_DEBUG_VERBOSE
|
||||||
|
# define leddbg(x...)
|
||||||
|
# define ledvdbg(x...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_LEDS
|
||||||
|
struct led_setting_s
|
||||||
|
{
|
||||||
|
uint8_t led1 : 2;
|
||||||
|
uint8_t led2 : 2;
|
||||||
|
uint8_t led3 : 2;
|
||||||
|
uint8_t unused : 2;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
/* If CONFIG_ARCH_LEDS is defined then NuttX will control the LEDs. The
|
||||||
|
* following structures identified the LED settings for each NuttX LED state.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_LEDS
|
||||||
|
static const struct led_setting_s g_ledonvalues[LED_NVALUES] =
|
||||||
|
{
|
||||||
|
{LED_OFF, LED_OFF, LED_OFF, LED_OFF},
|
||||||
|
{LED_ON, LED_OFF, LED_NC, LED_OFF},
|
||||||
|
{LED_OFF, LED_ON, LED_NC, LED_OFF},
|
||||||
|
{LED_ON, LED_ON, LED_NC, LED_OFF},
|
||||||
|
{LED_NC, LED_NC, LED_ON, LED_OFF},
|
||||||
|
{LED_ON, LED_NC, LED_NC, LED_OFF},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct led_setting_s g_ledoffvalues[LED_NVALUES] =
|
||||||
|
{
|
||||||
|
{LED_NC, LED_NC, LED_NC, LED_OFF},
|
||||||
|
{LED_NC, LED_NC, LED_NC, LED_OFF},
|
||||||
|
{LED_NC, LED_NC, LED_NC, LED_OFF},
|
||||||
|
{LED_NC, LED_NC, LED_NC, LED_OFF},
|
||||||
|
{LED_NC, LED_NC, LED_OFF, LED_OFF},
|
||||||
|
{LED_OFF, LED_NC, LED_NC, LED_OFF},
|
||||||
|
};
|
||||||
|
|
||||||
|
/* If CONFIG_ARCH_LEDS is not defined, the the user can control the LEDs in
|
||||||
|
* any way. The following array simply maps the PIC32MX_PIC32MX7MMB_LEDn
|
||||||
|
* index values to the correct LED pin configuration.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#else
|
||||||
|
static const uint16_t g_ledpincfg[PIC32MX_PIC32MX7MMB_NLEDS] =
|
||||||
|
{
|
||||||
|
GPIO_LED_1, GPIO_LED_2, GPIO_LED_3
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_setleds
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_LEDS
|
||||||
|
void up_setleds(FAR const struct led_setting_s *setting)
|
||||||
|
{
|
||||||
|
if (setting->led1 != LED_NC)
|
||||||
|
{
|
||||||
|
pic32mx_gpiowrite(GPIO_LED_1, setting->led1 == LED_ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setting->led2 != LED_NC)
|
||||||
|
{
|
||||||
|
pic32mx_gpiowrite(GPIO_LED_2, setting->led2 == LED_ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setting->led3 != LED_NC)
|
||||||
|
{
|
||||||
|
pic32mx_gpiowrite(GPIO_LED_3, setting->led3 == LED_ON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pic32mx_ledinit
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void pic32mx_ledinit(void)
|
||||||
|
{
|
||||||
|
/* Configure output pins */
|
||||||
|
|
||||||
|
pic32mx_configgpio(GPIO_LED_1);
|
||||||
|
pic32mx_configgpio(GPIO_LED_2);
|
||||||
|
pic32mx_configgpio(GPIO_LED_3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pic32mx_setled
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_ARCH_LEDS
|
||||||
|
void pic32mx_setled(int led, bool ledon)
|
||||||
|
{
|
||||||
|
if ((unsigned)led < PIC32MX_PIC32MX7MMB_NLEDS)
|
||||||
|
{
|
||||||
|
pic32mx_gpiowrite(g_ledpincfg[led], ledon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pic32mx_setleds
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_ARCH_LEDS
|
||||||
|
void pic32mx_setleds(uint8_t ledset)
|
||||||
|
{
|
||||||
|
pic32mx_setled(PIC32MX_PIC32MX7MMB_LED1, (ledset & PIC32MX_PIC32MX7MMB_LED1_BIT) != 0);
|
||||||
|
pic32mx_setled(PIC32MX_PIC32MX7MMB_LED2, (ledset & PIC32MX_PIC32MX7MMB_LED2_BIT) != 0);
|
||||||
|
pic32mx_setled(PIC32MX_PIC32MX7MMB_LED3, (ledset & PIC32MX_PIC32MX7MMB_LED3_BIT) != 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_ledon
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_LEDS
|
||||||
|
void up_ledon(int led)
|
||||||
|
{
|
||||||
|
if ((unsigned)led < LED_NVALUES)
|
||||||
|
{
|
||||||
|
up_setleds(&g_ledonvalues[led]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_ledoff
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_LEDS
|
||||||
|
void up_ledoff(int led)
|
||||||
|
{
|
||||||
|
if ((unsigned)led < LED_NVALUES)
|
||||||
|
{
|
||||||
|
up_setleds(&g_ledoffvalues[led]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,382 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* config/pic32mx7mmb/src/up_nsh.c
|
||||||
|
* arch/arm/src/board/up_nsh.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 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 <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/spi.h>
|
||||||
|
#include <nuttx/mmcsd.h>
|
||||||
|
#include <nuttx/usb/usbhost.h>
|
||||||
|
|
||||||
|
#include "pic32mx-internal.h"
|
||||||
|
#include "pic32mx7mmb_internal.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-Processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
/* Configuration ************************************************************/
|
||||||
|
/* Assume that we have MMC/SD, USB host (and USB device) */
|
||||||
|
|
||||||
|
#define CONFIG_NSH_HAVEMMCSD 1
|
||||||
|
#define CONFIG_NSH_HAVEUSBHOST 1
|
||||||
|
|
||||||
|
/* TheMikroelektronika PIC32MX7 MMB does not have an SD slot on board. If one
|
||||||
|
* is added, then it must be specified by defining which SPI bus that it
|
||||||
|
* is connected on.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_PIC32MX_MMCSDSPIPORTNO
|
||||||
|
# undef CONFIG_NSH_HAVEMMCSD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Make sure that the configuration will support the SD card */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_HAVEMMCSD
|
||||||
|
|
||||||
|
/* Make sure that the NSH configuration uses the correct SPI */
|
||||||
|
|
||||||
|
# if !defined(CONFIG_NSH_MMCSDSPIPORTNO)
|
||||||
|
# define CONFIG_NSH_MMCSDSPIPORTNO CONFIG_PIC32MX_MMCSDSPIPORTNO
|
||||||
|
# elif CONFIG_NSH_MMCSDSPIPORTNO != CONFIG_PIC32MX_MMCSDSPIPORTNO
|
||||||
|
# warning "CONFIG_PIC32MX_MMCSDSPIPORTNO does not match CONFIG_NSH_MMCSDSPIPORTNO"
|
||||||
|
# undef CONFIG_NSH_MMCSDSPIPORTNO
|
||||||
|
# define CONFIG_NSH_MMCSDSPIPORTNO CONFIG_PIC32MX_MMCSDSPIPORTNO
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Make sure that the NSH configuration uses the slot */
|
||||||
|
|
||||||
|
# if !defined(CONFIG_NSH_MMCSDSLOTNO) || CONFIG_NSH_MMCSDSLOTNO != 0
|
||||||
|
# warning "The Mikroelektronika PIC32MX7 MMB has only one slot (0)"
|
||||||
|
# undef CONFIG_NSH_MMCSDSLOTNO
|
||||||
|
# define CONFIG_NSH_MMCSDSLOTNO 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Make sure that the correct SPI is enabled in the configuration */
|
||||||
|
|
||||||
|
# if CONFIG_PIC32MX_MMCSDSPIPORTNO == 1 && !defined(CONFIG_PIC32MX_SPI1)
|
||||||
|
# warning "CONFIG_PIC32MX_SPI1 is not enabled"
|
||||||
|
# undef CONFIG_NSH_HAVEMMCSD
|
||||||
|
# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 2 && !defined(CONFIG_PIC32MX_SPI2)
|
||||||
|
# warning "CONFIG_PIC32MX_SPI2 is not enabled"
|
||||||
|
# undef CONFIG_NSH_HAVEMMCSD
|
||||||
|
# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 3 && !defined(CONFIG_PIC32MX_SPI3)
|
||||||
|
# warning "CONFIG_PIC32MX_SPI3 is not enabled"
|
||||||
|
# undef CONFIG_NSH_HAVEMMCSD
|
||||||
|
# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 4 && !defined(CONFIG_PIC32MX_SPI4)
|
||||||
|
# warning "CONFIG_PIC32MX_SPI4 is not enabled"
|
||||||
|
# undef CONFIG_NSH_HAVEMMCSD
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Can't support MMC/SD features if mountpoints are disabled */
|
||||||
|
|
||||||
|
#if defined(CONFIG_DISABLE_MOUNTPOINT)
|
||||||
|
# undef CONFIG_NSH_HAVEMMCSD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Select /dev/mmcsd0 if no other minor number is provided */
|
||||||
|
|
||||||
|
#ifndef CONFIG_NSH_MMCSDMINOR
|
||||||
|
# define CONFIG_NSH_MMCSDMINOR 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* USB Host */
|
||||||
|
|
||||||
|
#ifdef CONFIG_USBHOST
|
||||||
|
# ifndef CONFIG_PIC32MX_USBHOST
|
||||||
|
# error "CONFIG_PIC32MX_USBHOST is not selected"
|
||||||
|
# undef CONFIG_NSH_HAVEUSBHOST
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_PIC32MX_USBHOST
|
||||||
|
# ifndef CONFIG_USBHOST
|
||||||
|
# warning "CONFIG_USBHOST is not selected"
|
||||||
|
# undef CONFIG_NSH_HAVEUSBHOST
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CONFIG_USBHOST) || !defined(CONFIG_PIC32MX_USBHOST)
|
||||||
|
# undef CONFIG_NSH_HAVEUSBHOST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_HAVEUSBHOST
|
||||||
|
# ifndef CONFIG_USBHOST_DEFPRIO
|
||||||
|
# define CONFIG_USBHOST_DEFPRIO 50
|
||||||
|
# endif
|
||||||
|
# ifndef CONFIG_USBHOST_STACKSIZE
|
||||||
|
# define CONFIG_USBHOST_STACKSIZE 1024
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Debug ********************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||||
|
# ifdef CONFIG_DEBUG
|
||||||
|
# define message(...) lib_lowprintf(__VA_ARGS__)
|
||||||
|
# else
|
||||||
|
# define message(...) printf(__VA_ARGS__)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# ifdef CONFIG_DEBUG
|
||||||
|
# define message lib_lowprintf
|
||||||
|
# else
|
||||||
|
# define message printf
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_HAVEUSBHOST
|
||||||
|
static struct usbhost_driver_s *g_drvr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nsh_waiter
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Wait for USB devices to be connected.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_HAVEUSBHOST
|
||||||
|
static int nsh_waiter(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
bool connected = false;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
message("nsh_waiter: Running\n");
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
|
ret = DRVR_WAIT(g_drvr, connected);
|
||||||
|
DEBUGASSERT(ret == OK);
|
||||||
|
|
||||||
|
connected = !connected;
|
||||||
|
message("nsh_waiter: %s\n", connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
|
/* Did we just become connected? */
|
||||||
|
|
||||||
|
if (connected)
|
||||||
|
{
|
||||||
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
|
(void)DRVR_ENUMERATE(g_drvr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Keep the compiler from complaining */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nsh_sdinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize SPI-based microSD.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_HAVEMMCSD
|
||||||
|
static int nsh_sdinitialize(void)
|
||||||
|
{
|
||||||
|
FAR struct spi_dev_s *ssp;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Get the SPI port */
|
||||||
|
|
||||||
|
ssp = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO);
|
||||||
|
if (!ssp)
|
||||||
|
{
|
||||||
|
message("nsh_archinitialize: Failed to initialize SPI port %d\n",
|
||||||
|
CONFIG_NSH_MMCSDSPIPORTNO);
|
||||||
|
ret = -ENODEV;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
|
message("Successfully initialized SPI port %d\n",
|
||||||
|
CONFIG_NSH_MMCSDSPIPORTNO);
|
||||||
|
|
||||||
|
/* Bind the SPI port to the slot */
|
||||||
|
|
||||||
|
ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR,
|
||||||
|
CONFIG_NSH_MMCSDSLOTNO, ssp);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
message("nsh_sdinitialize: "
|
||||||
|
"Failed to bind SPI port %d to MMC/SD slot %d: %d\n",
|
||||||
|
CONFIG_NSH_MMCSDSPIPORTNO,
|
||||||
|
CONFIG_NSH_MMCSDSLOTNO, ret);
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
|
message("Successfuly bound SPI port %d to MMC/SD slot %d\n",
|
||||||
|
CONFIG_NSH_MMCSDSPIPORTNO,
|
||||||
|
CONFIG_NSH_MMCSDSLOTNO);
|
||||||
|
return OK;
|
||||||
|
|
||||||
|
errout:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define nsh_sdinitialize() (OK)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nsh_usbhostinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize SPI-based microSD.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_HAVEUSBHOST
|
||||||
|
static int nsh_usbhostinitialize(void)
|
||||||
|
{
|
||||||
|
int pid;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* First, register all of the class drivers needed to support the drivers
|
||||||
|
* that we care about:
|
||||||
|
*/
|
||||||
|
|
||||||
|
message("nsh_usbhostinitialize: Register class drivers\n");
|
||||||
|
ret = usbhost_storageinit();
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
message("nsh_usbhostinitialize: Failed to register the mass storage class\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Then get an instance of the USB host interface */
|
||||||
|
|
||||||
|
message("nsh_usbhostinitialize: Initialize USB host\n");
|
||||||
|
g_drvr = usbhost_initialize(0);
|
||||||
|
if (g_drvr)
|
||||||
|
{
|
||||||
|
/* Start a thread to handle device connection. */
|
||||||
|
|
||||||
|
message("nsh_usbhostinitialize: Start nsh_waiter\n");
|
||||||
|
|
||||||
|
#ifndef CONFIG_CUSTOM_STACK
|
||||||
|
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||||
|
CONFIG_USBHOST_STACKSIZE,
|
||||||
|
(main_t)nsh_waiter, (const char **)NULL);
|
||||||
|
#else
|
||||||
|
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||||
|
(main_t)nsh_waiter, (const char **)NULL);
|
||||||
|
#endif
|
||||||
|
return pid < 0 ? -ENOEXEC : OK;
|
||||||
|
}
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define nsh_usbhostinitialize() (OK)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nsh_usbdevinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize SPI-based microSD.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_USBDEV
|
||||||
|
static int nsh_usbdevinitialize(void)
|
||||||
|
{
|
||||||
|
/* The Mikroelektronika PIC32MX7 MMB has no way to know when the USB is
|
||||||
|
* connected. So we will fake it and tell the USB driver that the USB is
|
||||||
|
* connected now.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pic32mx_usbattach();
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define nsh_usbdevinitialize() (OK)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nsh_archinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Perform architecture specific initialization
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int nsh_archinitialize(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Initialize SPI-based microSD */
|
||||||
|
|
||||||
|
ret = nsh_sdinitialize();
|
||||||
|
if (ret == OK)
|
||||||
|
{
|
||||||
|
/* Initialize USB host */
|
||||||
|
|
||||||
|
ret = nsh_usbhostinitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == OK)
|
||||||
|
{
|
||||||
|
/* Initialize USB device */
|
||||||
|
|
||||||
|
ret = nsh_usbdevinitialize();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
/************************************************************************************
|
||||||
|
* configs/pic32mx7mmb/src/up_ssp.c
|
||||||
|
* arch/arm/src/board/up_ssp.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Included Files
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/spi.h>
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "up_arch.h"
|
||||||
|
#include "chip.h"
|
||||||
|
#include "pic32mx-internal.h"
|
||||||
|
#include "pic32mx7mmb_internal.h"
|
||||||
|
|
||||||
|
#if defined(CONFIG_PIC32MX_SPI1) || defined(CONFIG_PIC32MX_SPI2) || \
|
||||||
|
defined(CONFIG_PIC32MX_SPI3) || defined(CONFIG_PIC32MX_SPI4)
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Definitions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/* The following enable debug output from this file (needs CONFIG_DEBUG too).
|
||||||
|
*
|
||||||
|
* CONFIG_SPI_DEBUG - Define to enable basic SPI debug
|
||||||
|
* CONFIG_SPI_VERBOSE - Define to enable verbose SPI debug
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPI_DEBUG
|
||||||
|
# define sspdbg lldbg
|
||||||
|
# ifdef CONFIG_SPI_VERBOSE
|
||||||
|
# define sspvdbg lldbg
|
||||||
|
# else
|
||||||
|
# define sspvdbg(x...)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# undef CONFIG_SPI_VERBOSE
|
||||||
|
# define sspdbg(x...)
|
||||||
|
# define sspvdbg(x...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: pic32mx_sspinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called to configure SPI chip select GPIO pins for the Sure PIC32MX board.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
void weak_function pic32mx_sspinitialize(void)
|
||||||
|
{
|
||||||
|
/* Configure the SPI chip select GPIOs */
|
||||||
|
|
||||||
|
#warning "Missing logic"
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: pic32mx_spiNselect, pic32mx_spiNstatus, and pic32mx_spiNcmddata
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* These external functions must be provided by board-specific logic. They are
|
||||||
|
* implementations of the select, status, and cmddata methods of the SPI interface
|
||||||
|
* defined by struct spi_ops_s (see include/nuttx/spi.h). All other methods
|
||||||
|
* including up_spiinitialize()) are provided by common PIC32MX logic. To use
|
||||||
|
* this common SPI logic on your board:
|
||||||
|
*
|
||||||
|
* 1. Provide logic in pic32mx_boardinitialize() to configure SPI/SSP chip select
|
||||||
|
* pins.
|
||||||
|
* 2. Provide pic32mx_spiNselect() and pic32mx_spiNstatus() functions
|
||||||
|
* in your board-specific logic. These functions will perform chip selection
|
||||||
|
* and status operations using GPIOs in the way your board is configured.
|
||||||
|
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
|
||||||
|
* pic32mx_spiNcmddata() functions in your board-specific logic. These
|
||||||
|
* functions will perform cmd/data selection operations using GPIOs in the way
|
||||||
|
* your board is configured.
|
||||||
|
* 3. Add a call to up_spiinitialize() in your low level application
|
||||||
|
* initialization logic
|
||||||
|
* 4. The handle returned by up_spiinitialize() may then be used to bind the
|
||||||
|
* SPI driver to higher level logic (e.g., calling
|
||||||
|
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
||||||
|
* the SPI MMC/SD driver).
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
struct spi_dev_s;
|
||||||
|
enum spi_dev_e;
|
||||||
|
|
||||||
|
#ifdef CONFIG_PIC32MX_SPI1
|
||||||
|
void pic32mx_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||||
|
{
|
||||||
|
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||||
|
#warning "Missing logic"
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||||
|
{
|
||||||
|
sspdbg("Returning nothing\n");
|
||||||
|
#warning "Missing logic"
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_SPI_CMDDATA
|
||||||
|
int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||||
|
{
|
||||||
|
#warning "Missing logic"
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_PIC31MX_SPI1
|
||||||
|
void pic31mx_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||||
|
{
|
||||||
|
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||||
|
#warning "Missing logic"
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t pic31mx_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||||
|
{
|
||||||
|
sspdbg("Returning nothing\n");
|
||||||
|
#warning "Missing logic"
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_SPI_CMDDATA
|
||||||
|
int pic31mx_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||||
|
{
|
||||||
|
#warning "Missing logic"
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_PIC31MX_SPI3
|
||||||
|
void pic32mx_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||||
|
{
|
||||||
|
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||||
|
#warning "Missing logic"
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t pic32mx_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||||
|
{
|
||||||
|
sspdbg("Returning nothing\n");
|
||||||
|
#warning "Missing logic"
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_SPI_CMDDATA
|
||||||
|
int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||||
|
{
|
||||||
|
#warning "Missing logic"
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_PIC32MX_SPI4
|
||||||
|
void pic32mx_spi4select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||||
|
{
|
||||||
|
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||||
|
#warning "Missing logic"
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t pic32mx_spi4status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||||
|
{
|
||||||
|
sspdbg("Returning nothing\n");
|
||||||
|
#warning "Missing logic"
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_SPI_CMDDATA
|
||||||
|
int pic32mx_spi4cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||||
|
{
|
||||||
|
#warning "Missing logic"
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_PIC32MX_SPI1..4 */
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
/************************************************************************************
|
||||||
|
* configs/pic32mx7mmb/src/up_usbdev.c
|
||||||
|
* arch/arm/src/board/up_usbdev.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Included Files
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/usb/usbdev.h>
|
||||||
|
|
||||||
|
#include "pic32mx-internal.h"
|
||||||
|
#include "pic32mx7mmb_internal.h"
|
||||||
|
|
||||||
|
#if defined(CONFIG_PIC32MX_USBDEV)
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Definitions
|
||||||
|
************************************************************************************/
|
||||||
|
/*
|
||||||
|
* PIN NAME SIGNAL NOTES
|
||||||
|
* ---- ------------------------------- -------------- ------------------------------
|
||||||
|
* 20 VBUSON/C1IN+/AN5/CN7/RB5 VBUSON To USB VBUS circuitry
|
||||||
|
* 43 C2IN+/AN3/CN5/RB3 USB_PGOOD Power good (low if bad)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define GPIO_USB_VBUSON (GPIO_INPUT|GPIO_PORTB|GPIO_PIN5)
|
||||||
|
#define GPIO_USB_PGOOD (GPIO_INPUT|GPIO_PORTB|GPIO_PIN3)
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: pic32mx_usbdevinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called to configure the mini-A/B J5 on the Mikroelektronika PIC32MX7 MMB for the
|
||||||
|
* USB device
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
void weak_function pic32mx_usbdevinitialize(void)
|
||||||
|
{
|
||||||
|
/* Connect the PHY to the USB mini-B port. Order and timing matter! */
|
||||||
|
|
||||||
|
pic32mx_configgpio(GPIO_USB_PGOOD);
|
||||||
|
|
||||||
|
/* Notes from the Sure Electronics sample code:
|
||||||
|
*
|
||||||
|
* "The USB specifications require that USB peripheral devices must never source
|
||||||
|
* current onto the Vbus pin. Additionally, USB peripherals should not source
|
||||||
|
* current on D+ or D- when the host/hub is not actively powering the Vbus line.
|
||||||
|
* When designing a self powered (as opposed to bus powered) USB peripheral
|
||||||
|
* device, the firmware should make sure not to turn on the USB module and D+
|
||||||
|
* or D- pull up resistor unless Vbus is actively powered. Therefore, the
|
||||||
|
* firmware needs some means to detect when Vbus is being powered by the host.
|
||||||
|
* A 5V tolerant I/O pin can be connected to Vbus (through a resistor), and
|
||||||
|
* can be used to detect when Vbus is high (host actively powering), or low
|
||||||
|
* (host is shut down or otherwise not supplying power). The USB firmware
|
||||||
|
* can then periodically poll this I/O pin to know when it is okay to turn on
|
||||||
|
* the USB module/D+/D- pull up resistor. When designing a purely bus powered
|
||||||
|
* peripheral device, it is not possible to source current on D+ or D- when the
|
||||||
|
* host is not actively providing power on Vbus. Therefore, implementing this
|
||||||
|
* bus sense feature is optional. ..."
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_USBHOST
|
||||||
|
// pic32mx_configgpio(GPIO_USB_VBUSON);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* "If the host PC sends a GetStatus (device) request, the firmware must respond
|
||||||
|
* and let the host know if the USB peripheral device is currently bus powered
|
||||||
|
* or self powered. See chapter 9 in the official USB specifications for details
|
||||||
|
* regarding this request. If the peripheral device is capable of being both
|
||||||
|
* self and bus powered, it should not return a hard coded value for this request.
|
||||||
|
* Instead, firmware should check if it is currently self or bus powered, and
|
||||||
|
* respond accordingly. If the hardware has been configured like demonstrated
|
||||||
|
* on the PICDEM FS USB Demo Board, an I/O pin can be polled to determine the
|
||||||
|
* currently selected power source. ..."
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_USB_PWRSENSE
|
||||||
|
// pic32mx_configgpio(GPIO_USB_PWRSENSE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: pic32mx_usbpullup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* If USB is supported and the board supports a pullup via GPIO (for USB
|
||||||
|
* software connect and disconnect), then the board software must provide
|
||||||
|
* stm32_pullup. See include/nuttx/usb/usbdev.h for additional description
|
||||||
|
* of this method. Alternatively, if no pull-up GPIO the following EXTERN
|
||||||
|
* can be redefined to be NULL.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable)
|
||||||
|
{
|
||||||
|
/* The Mikroelektronika PIC32MX7 MMB does not have a USB pull-up */
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: pic32mx_usbsuspend
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Board logic must provide the stm32_usbsuspend logic if the USBDEV driver
|
||||||
|
* is used. This function is called whenever the USB enters or leaves
|
||||||
|
* suspend mode. This is an opportunity for the board logic to shutdown
|
||||||
|
* clocks, power, etc. while the USB is suspended.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume)
|
||||||
|
{
|
||||||
|
/* Do nothing */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_PIC32MX_USBDEV */
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/pic32mx7mmb/src/up_usbmsc.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 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 "pic32mx7mmb_internal.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-Processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
/* Configuration ************************************************************/
|
||||||
|
|
||||||
|
/* Debug ********************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||||
|
# ifdef CONFIG_DEBUG
|
||||||
|
# define message(...) lib_lowprintf(__VA_ARGS__)
|
||||||
|
# define msgflush()
|
||||||
|
# else
|
||||||
|
# define message(...) printf(__VA_ARGS__)
|
||||||
|
# define msgflush() fflush(stdout)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# ifdef CONFIG_DEBUG
|
||||||
|
# define message lib_lowprintf
|
||||||
|
# define msgflush()
|
||||||
|
# else
|
||||||
|
# define message printf
|
||||||
|
# define msgflush() fflush(stdout)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: usbmsc_archinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Perform architecture specific initialization as needed to establish
|
||||||
|
* the mass storage device that will be exported by the USB MSC device.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int usbmsc_archinitialize(void)
|
||||||
|
{
|
||||||
|
/* If examples/usbmsc is built as an NSH command, then SD slot should
|
||||||
|
* already have been initized in nsh_archinitialize() (see up_nsh.c). In
|
||||||
|
* this case, there is nothing further to be done here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_EXAMPLES_USBMSC_BUILTIN
|
||||||
|
# warning "Missing Logic"
|
||||||
|
#endif /* CONFIG_EXAMPLES_USBMSC_BUILTIN */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/************************************************************************************
|
||||||
|
* configs/pic32mx7mmb/src/up_usbterm.c
|
||||||
|
* arch/arm/src/board/up_usbterm.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Included Files
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/usb/usbdev.h>
|
||||||
|
|
||||||
|
#include "pic32mx-internal.h"
|
||||||
|
#include "pic32mx7mmb_internal.h"
|
||||||
|
|
||||||
|
#if defined(CONFIG_PIC32MX_USBDEV) && defined(CONFIG_EXAMPLES_USBTERM_DEVINIT)
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Definitions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name:
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will
|
||||||
|
* call this user provided function as part of its initialization.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int usbterm_devinit(void)
|
||||||
|
{
|
||||||
|
/* The Mikroelektronika PIC32MX7 MMB has no way to know when the USB is
|
||||||
|
* connected. So we will fake it and tell the USB driver that the USB is
|
||||||
|
* connected now.
|
||||||
|
*
|
||||||
|
* If examples/usbterm is built as an NSH built-in application, then
|
||||||
|
* pic32mx_usbattach() will be called in nsh_archinitialize().
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_EXAMPLES_USBTERM_BUILTIN
|
||||||
|
pic32mx_usbattach();
|
||||||
|
#endif
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name:
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will
|
||||||
|
* call this user provided function as part of its termination sequence.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void usbterm_devuninit(void)
|
||||||
|
{
|
||||||
|
/* Tell the USB driver that the USB is no longer connected */
|
||||||
|
|
||||||
|
pic32mx_usbdetach();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_PIC32MX_USBDEV && CONFIG_EXAMPLES_USBTERM_DEVINIT */
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
############################################################################
|
||||||
|
# configs/pic32mx7mmb/tools/Makefile
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011-2012 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.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
all: mkpichex
|
||||||
|
default: mkpichex
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
# Add CFLAGS=-g on the make command line to build debug versions
|
||||||
|
|
||||||
|
CFLAGS = -O2 -Wall -I.
|
||||||
|
|
||||||
|
# mkpichex - Convert virtual addresses in nuttx.hex to physical addresses
|
||||||
|
|
||||||
|
mkconfig: mkpichex.c mkpichex.c
|
||||||
|
@gcc $(CFLAGS) -o mkpichex mkpichex.c
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm -f *.o *.a *~ .*.swp
|
||||||
|
@rm -f mkpichex mkpichex.exe
|
||||||
@@ -0,0 +1,315 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/pic32mx7mmb/tools/mkpichex.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-2012 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 <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define MAX_LINE 1024
|
||||||
|
|
||||||
|
/* Line offsets */
|
||||||
|
|
||||||
|
#define START_OFFSET 0
|
||||||
|
#define LEN_OFFSET 1
|
||||||
|
#define ADDR_OFFSET (LEN_OFFSET + 2)
|
||||||
|
#define TYPE_OFFSET (ADDR_OFFSET + 4)
|
||||||
|
#define PAYLOAD_OFFSET (TYPE_OFFSET + 2)
|
||||||
|
#define CHKSUM_OFFSET(n) (PAYLOAD_OFFSET+2*(n))
|
||||||
|
|
||||||
|
/* Record types:
|
||||||
|
*
|
||||||
|
* 00, data record, contains data and 16-bit address. The format described
|
||||||
|
* above.
|
||||||
|
* 01, End Of File record, a file termination record. No data. Has to be
|
||||||
|
* the last line of the file, only one per file permitted. Usually
|
||||||
|
* ':00000001FF'. Originally the End Of File record could contain a
|
||||||
|
* start address for the program being loaded, e.g. :00AB2F0125
|
||||||
|
* would make a jump to address AB2F. This was convenient when programs
|
||||||
|
* were loaded from punched paper tape.
|
||||||
|
* 02, Extended Segment Address Record, segment-base address. Used when 16
|
||||||
|
* bits are not enough, identical to 80x86 real mode addressing. The
|
||||||
|
* address specified by the 02 record is multiplied by 16 (shifted 4
|
||||||
|
* bits left) and added to the subsequent 00 record addresses. This
|
||||||
|
* allows addressing of up to a megabyte of address space. The address
|
||||||
|
* field of this record has to be 0000, the byte count is 02 (the segment
|
||||||
|
* is 16-bit). The least significant hex digit of the segment address is
|
||||||
|
* always 0.
|
||||||
|
* 03, Start Segment Address Record. For 80x86 processors, it specifies the
|
||||||
|
* initial content of the CS:IP registers. The address field is 0000, the
|
||||||
|
* byte count is 04, the first two bytes are the CS value, the latter two
|
||||||
|
* are the IP value.
|
||||||
|
* 04, Extended Linear Address Record, allowing for fully 32 bit addressing.
|
||||||
|
* The address field is 0000, the byte count is 02. The two data bytes
|
||||||
|
* represent the upper 16 bits of the 32 bit address, when combined with
|
||||||
|
* the address of the 00 type record.
|
||||||
|
* 05, Start Linear Address Record. The address field is 0000, the byte
|
||||||
|
* count is 04. The 4 data bytes represent the 32-bit value loaded into
|
||||||
|
* the EIP register of the 80386 and higher CPU.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define TYPE_DATA 0
|
||||||
|
#define TYPE_EOF 1
|
||||||
|
#define TYPE_EXTSEG 2
|
||||||
|
#define TYPE_STARTSEG 3
|
||||||
|
#define TYPE_EXTLIN 4
|
||||||
|
#define TYPE_STARTLIN 5
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct hex_s
|
||||||
|
{
|
||||||
|
unsigned char len; /* Length of the data payload */
|
||||||
|
unsigned char type; /* Record type */
|
||||||
|
unsigned short addr; /* Lower 16-bit address */
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static char line[MAX_LINE+1];
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static inline char *getfilepath(const char *path, const char *name, const char *extension)
|
||||||
|
{
|
||||||
|
snprintf(line, MAX_LINE, "%s/%s.%s", path, name, extension);
|
||||||
|
line[MAX_LINE] = '\0';
|
||||||
|
return strdup(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void show_usage(const char *progname)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "USAGE: %s <abs path to nuttx.hex>\n", progname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned char get4(char hex)
|
||||||
|
{
|
||||||
|
if (hex >= '0' && hex <= '9')
|
||||||
|
{
|
||||||
|
return hex - '0';
|
||||||
|
}
|
||||||
|
else if (hex >= 'a' && hex <= 'f')
|
||||||
|
{
|
||||||
|
return hex - 'a' + 10;
|
||||||
|
}
|
||||||
|
else if (hex >= 'A' && hex <= 'F')
|
||||||
|
{
|
||||||
|
return hex - 'A' + 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Bad hex character code: %s\n", line);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned char get8(const char *ptr)
|
||||||
|
{
|
||||||
|
return get4(ptr[0]) << 4 | get4(ptr[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned short get16(const char *ptr)
|
||||||
|
{
|
||||||
|
return (unsigned short)get8(&ptr[0]) << 8 | (unsigned short)get8(&ptr[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_line(struct hex_s *hexline)
|
||||||
|
{
|
||||||
|
/* :LLAAAATT... */
|
||||||
|
|
||||||
|
if (line[START_OFFSET] != ':')
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Bad start code: %s\n", line);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hexline->len = get8(&line[LEN_OFFSET]);
|
||||||
|
hexline->addr = get16(&line[ADDR_OFFSET]);
|
||||||
|
hexline->type = get8(&line[TYPE_OFFSET]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static unsigned char checksum(chksum_ndx)
|
||||||
|
{
|
||||||
|
int chksum = 0;
|
||||||
|
int ndx;
|
||||||
|
|
||||||
|
for (ndx = 1; ndx < chksum_ndx; ndx += 2)
|
||||||
|
{
|
||||||
|
chksum += (int)get8(&line[ndx]);
|
||||||
|
}
|
||||||
|
return (unsigned char)((-chksum) & 0xff);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void adjust_extlin(struct hex_s *hexline)
|
||||||
|
{
|
||||||
|
unsigned short segment;
|
||||||
|
int chksum;
|
||||||
|
|
||||||
|
/* Make sure that the payload is exactly 2 bytes */
|
||||||
|
|
||||||
|
if (hexline->len != 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Bad length on extended segment address record\n");
|
||||||
|
fprintf(stderr, " %s", line);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* And the address field is supposed to be zero */
|
||||||
|
|
||||||
|
if (hexline->addr != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Bad address on extended segment address record\n");
|
||||||
|
fprintf(stderr, " %s", line);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Decode the 2 byte payload */
|
||||||
|
|
||||||
|
segment = get16(&line[PAYLOAD_OFFSET]);
|
||||||
|
|
||||||
|
/* Convert the address to a 29-bit physical address */
|
||||||
|
|
||||||
|
segment &= 0x1fff;
|
||||||
|
|
||||||
|
/* Recalculate the checksum and make sure that there is a null terminator
|
||||||
|
* Since len=2, addr=0, type=4, the is a trivial calculation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
chksum = (-(segment + (segment >> 8) + 6)) & 0xff;
|
||||||
|
|
||||||
|
/* Then create the new output record */
|
||||||
|
|
||||||
|
snprintf(line, MAX_LINE-PAYLOAD_OFFSET, ":02000004%04X%02X\n", segment, chksum);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int main(int argc, char **argv, char **envp)
|
||||||
|
{
|
||||||
|
struct hex_s hexline;
|
||||||
|
char *srcfile;
|
||||||
|
char *destfile;
|
||||||
|
FILE *src;
|
||||||
|
FILE *dest;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unexpected number of arguments\n");
|
||||||
|
show_usage(argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
srcfile = getfilepath(argv[1], "nuttx", "hex");
|
||||||
|
if (!srcfile)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "getfilepath failed\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
destfile = getfilepath(argv[1], "nuttx", "tmp");
|
||||||
|
if (!destfile)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "getfilepath failed\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
src = fopen(srcfile, "r");
|
||||||
|
if (!src)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "open %s failed: %s\n", srcfile, strerror(errno));
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
dest = fopen(destfile, "w");
|
||||||
|
if (!dest)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "open %s failed: %s\n", destfile, strerror(errno));
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read each line from the source file */
|
||||||
|
|
||||||
|
while (fgets(line, MAX_LINE, src) != NULL)
|
||||||
|
{
|
||||||
|
if (parse_line(&hexline))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to parse line\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Adjust 'Extended Segment Address Records'. */
|
||||||
|
|
||||||
|
if (hexline.type == TYPE_EXTLIN)
|
||||||
|
{
|
||||||
|
adjust_extlin(&hexline);
|
||||||
|
}
|
||||||
|
fputs(line, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(src);
|
||||||
|
fclose(dest);
|
||||||
|
|
||||||
|
/* Remove the original nuttx.hex file */
|
||||||
|
|
||||||
|
if (remove(srcfile) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to remove the old '%s'\n", srcfile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rename the new nuttx.tmp file to nuttx.hex */
|
||||||
|
|
||||||
|
if (rename(destfile, srcfile) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to rename '%s' to '%s'\n", destfile, srcfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user