Adds support for the U-Blox C027 board with the lower-half U-Blox modem driver.

This commit is contained in:
Vladimir Komendantskiy
2016-01-31 08:49:30 -06:00
committed by Gregory Nutt
parent cd1a7e5744
commit 01f95a4c52
21 changed files with 3745 additions and 0 deletions
+13
View File
@@ -1070,6 +1070,15 @@ config ARCH_BOARD_TWR_K60N512
Kinetis K60 Cortex-M4 MCU. This port uses the FreeScale TWR-K60N512
development board.
config ARCH_BOARD_U_BLOX_C027
bool "u-blox C027"
depends on ARCH_CHIP_LPC1768
select ARCH_HAVE_LEDS
---help---
u-blox GSM and GPS module evaluation board with NXP LPCExpresso
LPC1768. The GSM module is one of LISA-C200, LISA-U200 or SARA-G350.
The GPS module is one of MAX-M7 or MAX-M8.
config ARCH_BOARD_UBW32
bool "UBW32 v2.4 board from Sparkfun"
depends on ARCH_CHIP_PIC32MX460F512L
@@ -1386,6 +1395,7 @@ config ARCH_BOARD
default "tm4c1294-launchpad" if ARCH_BOARD_TM4C1294_LAUNCHPAD
default "cc3200-launchpad" if ARCH_BOARD_CC3200_LAUNCHPAD
default "twr-k60n512" if ARCH_BOARD_TWR_K60N512
default "u-blox-c027" if ARCH_BOARD_U_BLOX_C027
default "ubw32" if ARCH_BOARD_UBW32
default "us7032evb1" if ARCH_BOARD_US7032EVB1
default "viewtool-stm32f107" if ARCH_BOARD_VIEWTOOL_STM32F107
@@ -1766,6 +1776,9 @@ endif
if ARCH_BOARD_TWR_K60N512
source "configs/twr-k60n512/Kconfig"
endif
if ARCH_BOARD_U_BLOX_C027
source "configs/u-blox-c027/Kconfig"
endif
if ARCH_BOARD_UBW32
source "configs/ubw32/Kconfig"
endif
+7
View File
@@ -0,0 +1,7 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_BOARD_U_BLOX_C027
endif
+144
View File
@@ -0,0 +1,144 @@
README
^^^^^^
README for NuttX port to the u-blox C027 dev board.
The board is intended for prototyping software for u-blox cellular modems (SARA
or LISA families) and the u-blox GPS receiver (MAX-7Q, MAX-M8Q, or other,
depending on board revision).
This board features the LPC1768 MCU and is related to the Embedded Artists' base
board with the NXP the LPCXpresso daughter board, see
configs/lpcxpresso-lpc1768/README.txt.
The board also features an embedded USB debugger.
Contents
^^^^^^^^
u-blox C027 Board
Configurations
u-blox C027 Board
^^^^^^^^^^^^^^^^^
Pin Description Connector On Board
-------------------------------- --------- --------------
P0[0]/RD1/TXD3/SDA1 D14 TXD3/SDA1
P0[1]/TD1/RXD3/SCL1 D15 RXD3/SCL1
P0[2]/TXD0/AD0[7] USBTXD
P0[3]/RXD0/AD0[6] USBRXD
P0[4]/I2SRX-CLK/RD2/CAP2.0 CANRD CAN_RX2
P0[5]/I2SRX-WS/TD2/CAP2.1 CANTD CAN_TX2
P0[6]/I2SRX_SDA/SSEL1/MAT2[0] CANS SSEL1
P0[7]/I2STX_CLK/SCK1/MAT2[1] MDMUSBDET
P0[8]/I2STX_WS/MISO1/MAT2[2] MDMLVLOE
P0[9]/I2STX_SDA/MOSI1/MAT2[3] MDMILVLOE
P0[10]/TXD2/SDA2 GPSTXD
P0[11]/RXD2/SCL2 GPSRXD
P0[15]/TXD1/SCK0/SCK MDMTXD
P0[16]/RXD1/SSEL0/SSEL MDMRXD
P0[17]/CTS1/MISO0/MISO MDMCTS
P0[18]/DCD1/MOSI0/MOSI MDMDCD
P0[19]/DSR1/SDA1 MDMDCR
P0[20]/DTR1/SCL1 MDMDTR
P0[21]/RI1/MCIPWR/RD1 MDMRI
P0[22]/RTS1/TD1 MDMRTS
P0[23]/AD0[0]/I2SRX_CLK/CAP3[0] A0 I2S_CLK
P0[24]/AD0[1]/I2SRX_WS/CAP3[1] A1 I2S_WS
P0[25]/AD0[2]/I2SRX_SDA/TXD3 A2 I2S_SDA
P0[26]/AD0[3]/AOUT/RXD3 A3 AD0.3/AOUT
P0[27]/SDA0/USB_SDA GPSSDA
P0[28]/SCL0 GPSSCL
P0[29]/USB_D+ MDMUSBDP
P0[30]/USB_D- MDMUSBDM
P1[0]/ENET_TXD0 ENET_TXD0
P1[1]/ENET_TXD1 ENET_TXD1
P1[4]/ENET_TX_EN ENET_TX_EN
P1[8]/ENET_CRS ENET_CRS
P1[9]/ENET_RXD0 ENET_RXD0
P1[10]/ENET_RXD1 ENET_RXD1
P1[14]/ENET_RX_ER ENET_RX_ER
P1[15]/ENET_REF_CLK ENET_REF_CLK
P1[16]/ENET_MDC ENET_MDC
P1[17]/ENET_MDIO ENET_MDIO
P1[18]/USB_UP_LED/PWM1[1]/CAP1[0] GPSRST
P1[19]/MC0A/USB_PPWR/N_CAP1.1 GPSPPS
P1[20]/MCFB0/PWM1.2/SCK0 D13 PWM1.2/SCK0
P1[21]/MCABORT/PWM1.3/SSEL0 D10 PWM1.3/SSEL0
P1[22]/MC0B/USB-PWRD/MAT1.0 GPSINT
P1[23]/MCFB1/PWM1.4/MISO0 D12 PWM1.4/MISO0
P1[24]/MCFB2/PWM1.5/MOSI0 D11 PWM1.5/MOSI0
P1[25]/MC1A/MAT1.1 ETH_LED_LNK
P1[26]/MC1B/PWM1.6/CAP0.0 ETH_LED_SPD
P1[27]/CLKOUT/USB-OVRCR-N/CAP0.1 ETH_OSC_EN
P1[28]/MC2A/PCAP1.0/MAT0.0 ETH_RST
P1[29]/MC2B/PCAP1.1/MAT0.1 GPSEN
P1[30]/VBUS/AD0[4] A4 AD0.4
P1[31]/SCK1/AD0[5] A5 AD0.5
P2[0]/PWM1.1/TXD1 D3 PWM1.1
P2[1]/PWM1.2/RXD1 D5 PWM1.2
P2[2]/PWM1.3/CTS1/TRACEDATA[3] D6 PWM1.3
P2[3]/PWM1.4/DCD1/TRACEDATA[2] D9 PWM1.4
P2[4]/PWM1.5/DSR1/TRACEDATA[1] D8 PWM1.5
P2[5]/PWM1[6]/DTR1/TRACEDATA[0] MDMEN
P2[6]/PCAP1[0]/RI1/TRACECLK MDMPWRON
P2[7]/RD2/RTS1 MDMGPIO1
P2[8]/TD2/TXD2 MDMRST
P2[9]/USB_CONNECT/RXD2 MDMUSBCON
P2[10]/EINT0/NMI ISP_PAD
P2[11]/EINT1/I2STX_CLK D7 EINT1
P2[12]/EINT2/I2STX_WS D4 EINT2
P2[13]/EINT3/I2STX_SDA D2 EINT3
P3[25]/MAT0.0/PWM1.2 LED
P4[28]/RX-MCLK/MAT2.0/TXD3 D0 TXD3
P4[29]/TX-MCLK/MAT2.1/RXD3 D1 RXD3
Configurations
^^^^^^^^^^^^^^
nsh
---
The nsh configuration allows to test the modem and the GPS receiver. The modem
can be tested in either the internal TCP/IP stack mode or with the NuttX TCP/IP
stack and pppd.
Modem starts in power-down mode and has to be switched on, e.g., using the nsh
command:
nsh> ubloxmodem on
To connect using the NuttX TCP/IP stack, use pppd. At the time of writing the
pppd app is located in apps/examples/pppd and requires setting correct login
details in the source code.
To connect using the internal u-blox TCP/IP stack, use the chat app. Its
configuration is done in configs/u-blox-c027/nsh/defconfig and can be adjusted
using 'make menuconfig'.
The NuttX u-blox modem driver is included like this:
CONFIG_MODEM=y
CONFIG_MODEM_U_BLOX=y
The nsh app that allows power control is included with the default configuration
as follows:
CONFIG_EXAMPLES_UBLOXMODEM=y
CONFIG_EXAMPLES_UBLOXMODEM_TTY_DEVNODE="/dev/ttyS1"
CONFIG_EXAMPLES_UBLOXMODEM_DEVNODE="/dev/ubxmdm"
The modem driver uses two device nodes. The TTY device is the modem terminal,
while the other device is used for general control via GPIO such as power
control. At the moment only one modem is supported, and the corresponding device
control node is /dev/ubxmdm.
The chat app allows to run scripts. A few such scripts are preset in the
defconfig:
CONFIG_EXAMPLES_CHAT_PRESET[0..3]:
0 - set up the provider context with username and password,
1 - connect to the provider,
2 - open a TCP socket to the u-blox test server,
3 - test the TCP socket server operation and close the socket.
+295
View File
@@ -0,0 +1,295 @@
/************************************************************************************
* configs/u-blox-c027/include/board.h
*
* Copyright (C) 2016 Vladimir Komendantskiy. All rights reserved.
* Author: Vladimir Komendantskiy <vladimir@moixaenergy.com>
*
* 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_U_BLOX_C027_INCLUDE_BOARD_H
#define __CONFIGS_U_BLOX_C027_INCLUDE_BOARD_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Clocking *************************************************************************/
/* NOTE: The following definitions require lpc17_syscon.h. It is not included here
* because the including C file may not have that file in its include path.
*/
#define BOARD_XTAL_FREQUENCY (12000000) /* XTAL oscillator frequency */
#define BOARD_OSCCLK_FREQUENCY BOARD_XTAL_FREQUENCY /* Main oscillator frequency */
#define BOARD_RTCCLK_FREQUENCY (32768) /* RTC oscillator frequency */
#define BOARD_INTRCOSC_FREQUENCY (4000000) /* Internal RC oscillator frequency */
/* This is the clock setup we configure for:
*
* SYSCLK = BOARD_OSCCLK_FREQUENCY = 12MHz -> Select Main oscillator for source
* PLL0CLK = (2 * 20 * SYSCLK) / 1 = 480MHz -> PLL0 multipler=20, pre-divider=1
* CCLCK = 480MHz / 6 = 80MHz -> CCLK divider = 6
*/
#define LPC17_CCLK 80000000 /* 80Mhz */
/* Select the main oscillator as the frequency source. SYSCLK is then the frequency
* of the main oscillator.
*/
#undef CONFIG_LPC17_MAINOSC
#define CONFIG_LPC17_MAINOSC 1
#define BOARD_SCS_VALUE SYSCON_SCS_OSCEN
/* Select the main oscillator and CCLK divider. The output of the divider is CCLK.
* The input to the divider (PLLCLK) will be determined by the PLL output.
*/
#define BOARD_CCLKCFG_DIVIDER 6
#define BOARD_CCLKCFG_VALUE ((BOARD_CCLKCFG_DIVIDER-1) << SYSCON_CCLKCFG_SHIFT)
/* PLL0. PLL0 is used to generate the CPU clock divider input (PLLCLK).
*
* Source clock: Main oscillator
* PLL0 Multiplier value (M): 20
* PLL0 Pre-divider value (N): 1
*
* PLL0CLK = (2 * 20 * SYSCLK) / 1 = 480MHz
*/
#undef CONFIG_LPC17_PLL0
#define CONFIG_LPC17_PLL0 1
#define BOARD_CLKSRCSEL_VALUE SYSCON_CLKSRCSEL_MAIN
#define BOARD_PLL0CFG_MSEL 20
#define BOARD_PLL0CFG_NSEL 1
#define BOARD_PLL0CFG_VALUE \
(((BOARD_PLL0CFG_MSEL-1) << SYSCON_PLL0CFG_MSEL_SHIFT) | \
((BOARD_PLL0CFG_NSEL-1) << SYSCON_PLL0CFG_NSEL_SHIFT))
/* PLL1 -- Not used. */
#undef CONFIG_LPC17_PLL1
#define BOARD_PLL1CFG_MSEL 36
#define BOARD_PLL1CFG_NSEL 1
#define BOARD_PLL1CFG_VALUE \
(((BOARD_PLL1CFG_MSEL-1) << SYSCON_PLL1CFG_MSEL_SHIFT) | \
((BOARD_PLL1CFG_NSEL-1) << SYSCON_PLL1CFG_NSEL_SHIFT))
/* USB divider. This divider is used when PLL1 is not enabled to get the
* USB clock from PLL0:
*
* USBCLK = PLL0CLK / 10 = 48MHz
*/
#define BOARD_USBCLKCFG_VALUE SYSCON_USBCLKCFG_DIV10
/* FLASH Configuration */
#undef CONFIG_LPC17_FLASH
#define CONFIG_LPC17_FLASH 1
#define BOARD_FLASHCFG_VALUE 0x0000303a
/* Ethernet configuration */
#define ETH_MCFG_CLKSEL_DIV ETH_MCFG_CLKSEL_DIV20
/* u-blox C027 board pin usage ***************************************************/
/* Pin Description Connector On Board
* -------------------------------- --------- --------------
* P0[0]/RD1/TXD3/SDA1 D14 TXD3/SDA1
* P0[1]/TD1/RXD3/SCL1 D15 RXD3/SCL1
* P0[2]/TXD0/AD0[7] USBTXD
* P0[3]/RXD0/AD0[6] USBRXD
* P0[4]/I2SRX-CLK/RD2/CAP2.0 CANRD CAN_RX2
* P0[5]/I2SRX-WS/TD2/CAP2.1 CANTD CAN_TX2
* P0[6]/I2SRX_SDA/SSEL1/MAT2[0] CANS SSEL1
* P0[7]/I2STX_CLK/SCK1/MAT2[1] MDMUSBDET
* P0[8]/I2STX_WS/MISO1/MAT2[2] MDMLVLOE
* P0[9]/I2STX_SDA/MOSI1/MAT2[3] MDMILVLOE
* P0[10]/TXD2/SDA2 GPSTXD
* P0[11]/RXD2/SCL2 GPSRXD
* P0[15]/TXD1/SCK0/SCK MDMTXD
* P0[16]/RXD1/SSEL0/SSEL MDMRXD
* P0[17]/CTS1/MISO0/MISO MDMCTS
* P0[18]/DCD1/MOSI0/MOSI MDMDCD
* P0[19]/DSR1/SDA1 MDMDCR
* P0[20]/DTR1/SCL1 MDMDTR
* P0[21]/RI1/MCIPWR/RD1 MDMRI
* P0[22]/RTS1/TD1 MDMRTS
* P0[23]/AD0[0]/I2SRX_CLK/CAP3[0] A0 I2S_CLK
* P0[24]/AD0[1]/I2SRX_WS/CAP3[1] A1 I2S_WS
* P0[25]/AD0[2]/I2SRX_SDA/TXD3 A2 I2S_SDA
* P0[26]/AD0[3]/AOUT/RXD3 A3 AD0.3/AOUT
* P0[27]/SDA0/USB_SDA GPSSDA
* P0[28]/SCL0 GPSSCL
* P0[29]/USB_D+ MDMUSBDP
* P0[30]/USB_D- MDMUSBDM
*
* P1[0]/ENET_TXD0 ENET_TXD0
* P1[1]/ENET_TXD1 ENET_TXD1
* P1[4]/ENET_TX_EN ENET_TX_EN
* P1[8]/ENET_CRS ENET_CRS
* P1[9]/ENET_RXD0 ENET_RXD0
* P1[10]/ENET_RXD1 ENET_RXD1
* P1[14]/ENET_RX_ER ENET_RX_ER
* P1[15]/ENET_REF_CLK ENET_REF_CLK
* P1[16]/ENET_MDC ENET_MDC
* P1[17]/ENET_MDIO ENET_MDIO
* P1[18]/USB_UP_LED/PWM1[1]/CAP1[0] GPSRST
* P1[19]/MC0A/USB_PPWR/N_CAP1.1 GPSPPS
* P1[20]/MCFB0/PWM1.2/SCK0 D13 PWM1.2/SCK0
* P1[21]/MCABORT/PWM1.3/SSEL0 D10 PWM1.3/SSEL0
* P1[22]/MC0B/USB-PWRD/MAT1.0 GPSINT
* P1[23]/MCFB1/PWM1.4/MISO0 D12 PWM1.4/MISO0
* P1[24]/MCFB2/PWM1.5/MOSI0 D11 PWM1.5/MOSI0
* P1[25]/MC1A/MAT1.1 ETH_LED_LNK
* P1[26]/MC1B/PWM1.6/CAP0.0 ETH_LED_SPD
* P1[27]/CLKOUT/USB-OVRCR-N/CAP0.1 ETH_OSC_EN
* P1[28]/MC2A/PCAP1.0/MAT0.0 ETH_RST
* P1[29]/MC2B/PCAP1.1/MAT0.1 GPSEN
* P1[30]/VBUS/AD0[4] A4 AD0.4
* P1[31]/SCK1/AD0[5] A5 AD0.5
*
* P2[0]/PWM1.1/TXD1 D3 PWM1.1
* P2[1]/PWM1.2/RXD1 D5 PWM1.2
* P2[2]/PWM1.3/CTS1/TRACEDATA[3] D6 PWM1.3
* P2[3]/PWM1.4/DCD1/TRACEDATA[2] D9 PWM1.4
* P2[4]/PWM1.5/DSR1/TRACEDATA[1] D8 PWM1.5
* P2[5]/PWM1[6]/DTR1/TRACEDATA[0] MDMEN
* P2[6]/PCAP1[0]/RI1/TRACECLK MDMPWRON
* P2[7]/RD2/RTS1 MDMGPIO1
* P2[8]/TD2/TXD2 MDMRST
* P2[9]/USB_CONNECT/RXD2 MDMUSBCON
* P2[10]/EINT0/NMI ISP_PAD
* P2[11]/EINT1/I2STX_CLK D7 EINT1
* P2[12]/EINT2/I2STX_WS D4 EINT2
* P2[13]/EINT3/I2STX_SDA D2 EINT3
*
* P3[25]/MAT0.0/PWM1.2 LED
*
* P4[28]/RX-MCLK/MAT2.0/TXD3 D0 TXD3
* P4[29]/TX-MCLK/MAT2.1/RXD3 D1 RXD3
*/
/* LED definitions ******************************************************************/
/* The u-blox C027 board has a single red LED (there are additional LEDs on the
* base board not considered here).
*/
/* ON OFF */
#define LED_STARTED 0 /* OFF ON (never happens) */
#define LED_HEAPALLOCATE 0 /* OFF ON (never happens) */
#define LED_IRQSENABLED 0 /* OFF ON (never happens) */
#define LED_STACKCREATED 1 /* ON ON (never happens) */
#define LED_INIRQ 2 /* OFF NC (momentary) */
#define LED_SIGNAL 2 /* OFF NC (momentary) */
#define LED_ASSERTION 2 /* OFF NC (momentary) */
#define LED_PANIC 0 /* OFF ON (1Hz flashing) */
#define GPIO_I2C1_SDA GPIO_I2C1_SDA_1
#define GPIO_I2C1_SCL GPIO_I2C1_SCL_1
#define GPIO_SSP1_SCK GPIO_SSP1_SCK_1
#define GPIO_SSP0_SCK GPIO_SSP0_SCK_1
#define GPIO_SSP0_SSEL GPIO_SSP0_SSEL_1
#define GPIO_SSP0_MISO GPIO_SSP0_MISO_1
#define GPIO_SSP0_MOSI GPIO_SSP0_MOSI_1
#define GPIO_UART1_TXD GPIO_UART1_TXD_1
#define GPIO_UART1_RXD GPIO_UART1_RXD_1
#define GPIO_UART1_CTS GPIO_UART1_CTS_1
#define GPIO_UART1_RTS GPIO_UART1_RTS_1
#define GPIO_UART1_DCD GPIO_UART1_DCD_1
#define GPIO_UART1_DSR GPIO_UART1_DSR_1
#define GPIO_UART1_DTR GPIO_UART1_DTR_1
#define GPIO_UART1_RI GPIO_UART1_RI_1
#define GPIO_UART2_TXD GPIO_UART2_TXD_1
#define GPIO_UART2_RXD GPIO_UART2_RXD_1
#define GPIO_UART3_TXD GPIO_UART3_TXD_3
#define GPIO_UART3_RXD GPIO_UART3_RXD_3
#define GPIO_ENET_MDC GPIO_ENET_MDC_1
#define GPIO_ENET_MDIO GPIO_ENET_MDIO_1
#define GPIO_PWM1p1 GPIO_PWM1p1_2
#define GPIO_PWM1p2 GPIO_PWM1p2_2
#define GPIO_PWM1p3 GPIO_PWM1p3_2
#define GPIO_PWM1p4 GPIO_PWM1p4_2
#define GPIO_PWM1p5 GPIO_PWM1p5_2
#define GPIO_PWM1p6 GPIO_PWM1p6_2
/************************************************************************************
* Public Types
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: lpc17_boardinitialize
*
* Description:
* All LPC17xx 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 lpc17_boardinitialize(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_U_BLOX_C027_INCLUDE_BOARD_H */
+110
View File
@@ -0,0 +1,110 @@
############################################################################
# configs/u-blox-c027/nsh/Make.defs
#
# Copyright (C) 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
ifeq ($(WINTOOL),y)
# Windows-native toolchains
DIRLINK = $(TOPDIR)/tools/copydir.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/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)/scripts/ld.script}"
else
# Linux/Cygwin-native toolchain
MKDEP = $(TOPDIR)/tools/mkdeps
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/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
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHDEFINES =
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
ASMEXT = .S
OBJEXT = .o
LIBEXT = .a
EXEEXT =
ifneq ($(CROSSDEV),arm-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
HOSTLDFLAGS =
File diff suppressed because it is too large Load Diff
+59
View File
@@ -0,0 +1,59 @@
#!/bin/bash
# configs/u-blox-c027/nsh/setenv.sh
#
# Copyright (C) 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
if [ "$(basename $0)" = "setenv.sh" ] ; 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`
# This is where the buildroot might reside on a Linux or Cygwin system
# export TOOLCHAIN_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin"
# This is the default install location for Code Red on Linux
export TOOLCHAIN_BIN="/usr/local/LPCXpresso/tools/bin"
# This is the Cygwin path to the LPCXpresso 3.6 install location under Windows
#export TOOLCHAIN_BIN="/cygdrive/c/nxp/lpcxpresso_3.6/Tools/bin"
# This is the path to the LPCXpression tool subdirectory
export LPCTOOL_DIR="${WD}/configs/u-blox-c027/tools"
# Add the path to the toolchain to the PATH varialble
export PATH="${TOOLCHAIN_BIN}:${LPCTOOL_DIR}:/sbin:/usr/sbin:${PATH_ORIG}"
echo "PATH : ${PATH}"
+117
View File
@@ -0,0 +1,117 @@
/****************************************************************************
* configs/u-blox-c027/scripts/ld.script
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/* The LPC1768 has 512Kb of FLASH beginning at address 0x0000:0000 and
* 64Kb of total SRAM: 32Kb of SRAM in the CPU block beginning at address
* 0x10000000 and 32Kb of AHB SRAM in two banks of 16Kb beginning at addresses
* 0x20070000 and 0x20080000. Here we assume that .data and .bss will all fit
* into the 32Kb CPU SRAM address range.
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00000000, LENGTH = 512K
sram (rwx) : ORIGIN = 0x10000000, LENGTH = 32K
}
OUTPUT_ARCH(arm)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab : {
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
_edata = ABSOLUTE(.);
} > sram AT > flash
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}
+2
View File
@@ -0,0 +1,2 @@
/.depend
/Make.dep
+53
View File
@@ -0,0 +1,53 @@
############################################################################
# configs/u-blox-c027/src/Makefile
#
# Copyright (C) 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
-include $(TOPDIR)/Make.defs
ASRCS =
CSRCS = lpc17_boot.c lpc17_leds.c lpc17_ssp.c lpc17_adc.c lpc17_dac.c lpc17_pwm.c
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += lpc17_nsh.c
endif
ifeq ($(CONFIG_MODEM_U_BLOX),y)
CSRCS += lpc17_ubxmdm.c
endif
ifeq ($(CONFIG_USBMSC),y)
CSRCS += lpc17_usbmsc.c
endif
include $(TOPDIR)/configs/Board.mk
+113
View File
@@ -0,0 +1,113 @@
/************************************************************************************
* configs/u-blox-c027/src/lpc17_adc.c
*
* Derives from configs/stm3220g-eval/src/lpc17_adc.c
*
* Copyright (C) 2013 Zilogic Systems. All rights reserved.
* Author: Kannan <code@nuttx.org>
*
* which, in turn, was based on configs/stm3220g-eval/src/lpc17_adc.c
*
* Copyright (C) 2012, 2014 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 <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h>
#include <arch/board/board.h>
#include "chip.h"
#include "up_arch.h"
#include "lpc17_adc.h"
#include "u-blox-c027.h"
#ifdef CONFIG_ADC
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: board_adc_setup
*
* Description:
* All LPC17 architectures must provide the following interface to work with
* examples/adc.
*
************************************************************************************/
int board_adc_setup(void)
{
static bool initialized = false;
struct adc_dev_s *adc;
int ret;
/* Check if we have already initialized */
if (!initialized)
{
/* Call lpc17_adcinitialize() to get an instance of the ADC interface */
adc = lpc17_adcinitialize();
if (adc == NULL)
{
adbg("ERROR: Failed to get ADC interface\n");
return -ENODEV;
}
/* Register the ADC driver at "/dev/adc0" */
ret = adc_register("/dev/adc0", adc);
if (ret < 0)
{
adbg("adc_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
}
return OK;
}
#endif /* CONFIG_ADC */
+117
View File
@@ -0,0 +1,117 @@
/************************************************************************************
* configs/u-blox-c027/src/lpc17_boot.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "up_internal.h"
#include "lpc17_gpio.h"
#include "lpc17_ssp.h"
#include "u-blox-c027.h"
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: lpc17_boardinitialize
*
* Description:
* All LPC17xx 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 lpc17_boardinitialize(void)
{
/* Configure SSP chip selects if 1) at least one SSP is enabled, and 2) the weak
* function c027_ssp_initialize() has been brought into the link.
*/
#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1)
if (c027_ssp_initialize)
{
c027_ssp_initialize();
}
#endif
/* Configure on-board LEDs if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
board_autoled_initialize();
#endif
}
/****************************************************************************
* Name: board_initialize
*
* Description:
* If CONFIG_BOARD_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_initialize(). board_initialize() will be
* called immediately after up_initialize() is called and just before the
* initial application is started. This additional initialization phase
* may be used, for example, to initialize board-specific device drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_INITIALIZE
void board_initialize(void)
{
lpc17_ubxmdm_init(false);
#if 0
lpc17_configgpio(C027_MDMEN | GPIO_VALUE_ZERO); /* Modem disabled */
lpc17_configgpio(C027_MDMRST | GPIO_VALUE_ONE); /* Modem reset on */
lpc17_configgpio(C027_MDMPWR | GPIO_VALUE_ONE); /* Modem power off */
lpc17_configgpio(C027_GPSEN | GPIO_VALUE_ZERO); /* GPS disabled */
lpc17_configgpio(C027_GPSRST | GPIO_VALUE_ONE); /* GPS reset on */
lpc17_configgpio(C027_MDMLVLOE | GPIO_VALUE_ONE); /* UART shifter disabled */
lpc17_configgpio(C027_MDMILVLOE | GPIO_VALUE_ZERO); /* I2C shifter disabled */
lpc17_configgpio(C027_MDMUSBDET | GPIO_VALUE_ZERO); /* USB sense off */
#endif
}
#endif /* CONFIG_BOARD_INITIALIZE */
+105
View File
@@ -0,0 +1,105 @@
/************************************************************************************
* configs/u-blox-c027/src/lpc17_dac.c
*
* Derives from configs/stm3220g-eval/src/lpc17_adc.c
*
* Copyright (C) 2013 Zilogic Systems. All rights reserved.
* Author: Kannan <code@nuttx.org>
*
* which, in turn, was based on configs/stm3220g-eval/src/lpc17_adc.c
*
* Copyright (C) 2012, 2014 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 <errno.h>
#include <debug.h>
#include <nuttx/analog/dac.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "up_internal.h"
#include "lpc17_dac.h"
#ifdef CONFIG_DAC
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: dac_devinit
*
* Description:
* All LPC17xx architectures must provide the following interface to work with
* examples/diag.
*
************************************************************************************/
int dac_devinit(void)
{
static bool initialized = false;
struct dac_dev_s *dac;
int ret;
if (!initialized)
{
/* Call lpc17_dacinitialize() to get an instance of the dac interface */
dac = lpc17_dacinitialize();
if (dac == NULL)
{
adbg("ERROR: Failed to get dac interface\n");
return -ENODEV;
}
ret = dac_register("/dev/dac0", dac);
if (ret < 0)
{
adbg("dac_register failed: %d\n", ret);
return ret;
}
initialized = true;
}
return OK;
}
#endif /* CONFIG_DAC */
+150
View File
@@ -0,0 +1,150 @@
/****************************************************************************
* configs/u-blox-c027/src/lpc17_leds.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include "up_arch.h"
#include "up_internal.h"
#include "lpc17_gpio.h"
#include "u-blox-c027.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
* with CONFIG_DEBUG_VERBOSE too)
*/
#ifdef CONFIG_DEBUG_LEDS
# define leddbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define ledvdbg lldbg
# else
# define ledvdbg(x...)
# endif
#else
# define leddbg(x...)
# define ledvdbg(x...)
#endif
/****************************************************************************
* Private Data
****************************************************************************/
static bool g_ncstate;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_autoled_initialize
****************************************************************************/
void board_autoled_initialize(void)
{
/* Configure all LED GPIO lines */
lpc17_configgpio(C027_LED);
g_ncstate = true;
}
/****************************************************************************
* Name: board_autoled_on
****************************************************************************/
void board_autoled_on(int led)
{
bool off;
switch (led)
{
case 0:
case 2:
off = true;
break;
case 1:
off = false;
g_ncstate = false;
break;
default:
return;
}
lpc17_gpiowrite(C027_LED, off);
}
/****************************************************************************
* Name: board_autoled_off
****************************************************************************/
void board_autoled_off(int led)
{
bool off;
switch (led)
{
case 0:
case 1:
off = false;
break;
case 2:
off = g_ncstate;
break;
default:
return;
}
lpc17_gpiowrite(C027_LED, off);
}
#endif /* CONFIG_ARCH_LEDS */
+175
View File
@@ -0,0 +1,175 @@
/****************************************************************************
* config/u-blox-c027/src/lpc17_nsh.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <syslog.h>
#include <errno.h>
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
#include <nuttx/mmcsd.h>
#include <sys/mount.h>
#include "lpc17_ssp.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifdef CONFIG_NSH_ARCHINIT
/* PORT and SLOT number probably depend on the board configuration */
#ifdef CONFIG_ARCH_BOARD_U_BLOX_C027
# define NSH_HAVEUSBDEV 1
# ifdef CONFIG_LPC17_SSP0
# define NSH_HAVEMMCSD 1
# else
# undef NSH_HAVEMMCSD
# endif
#else
# error "Unrecognized board"
# undef NSH_HAVEUSBDEV
# undef NSH_HAVEMMCSD
#endif
/* Do we have SPI support for MMC/SD? */
#ifdef NSH_HAVEMMCSD
# if !defined(CONFIG_NSH_MMCSDSPIPORTNO) || CONFIG_NSH_MMCSDSPIPORTNO != 0
# error "External MMC/SD on SSP0"
# undef CONFIG_NSH_MMCSDSPIPORTNO
# define CONFIG_NSH_MMCSDSPIPORTNO 0
# endif
# if !defined(CONFIG_NSH_MMCSDSLOTNO)
# error "Use MMC/SD slot 0 by default"
# undef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO 0
# endif
#endif
/* Can't support USB device features if USB device is not enabled */
#ifndef CONFIG_USBDEV
# undef NSH_HAVEUSBDEV
#endif
/* Can't support MMC/SD features if mountpoints are disabled */
#if defined(CONFIG_DISABLE_MOUNTPOINT)
# undef NSH_HAVEMMCSD
#endif
#ifndef CONFIG_NSH_MMCSDMINOR
# define CONFIG_NSH_MMCSDMINOR 0
#endif
/* Currnently MMC/SD support is available only for NSH configurations */
#else
# undef NSH_HAVEMMCSD
#endif /* CONFIG_NSH_ARCHINIT */
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int board_app_initialize(void)
{
int ret;
#ifdef CONFIG_FS_PROCFS
/* mount the proc filesystem */
syslog(LOG_INFO, "Mounting procfs to /proc\n");
ret = mount(NULL, "/proc", "procfs", 0, NULL);
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
ret, errno);
return ret;
}
#endif
#ifdef NSH_HAVEMMCSD
FAR struct spi_dev_s *ssp;
/* Get the SSP port */
ssp = lpc17_sspinitialize(CONFIG_NSH_MMCSDSPIPORTNO);
if (!ssp)
{
syslog(LOG_ERR, "ERROR: Failed to initialize SSP port %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
return -ENODEV;
}
syslog(LOG_INFO, "Successfully initialized SSP port %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
/* Bind the SSP port to the slot */
ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, ssp);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to bind SSP port %d to MMC/SD slot %d: %d\n",
CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO, ret);
return ret;
}
syslog(LOG_INFO, "Successfuly bound SSP port %d to MMC/SD slot %d\n",
CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO);
#endif
return OK;
}
+154
View File
@@ -0,0 +1,154 @@
/************************************************************************************
* configs/u-blox-c027/lpc17_pwm.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/pwm.h>
#include <arch/board/board.h>
#include "chip.h"
#include "up_arch.h"
#include "lpc17_pwm.h"
#include "lpc17_timer.h"
#include "u-blox-c027.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
#ifdef CONFIG_PWM
FAR struct pwm_lowerhalf_s *lpc17_pwminitialize(int timer);
FAR struct pwm_lowerhalf_s *lpc17_mcpwminitialize(int timer);
FAR struct pwm_lowerhalf_s *lpc17_timerinitialize(int timer);
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: board_pwm_setup
*
* Description:
* All LPC17 architectures must provide the following interface to work with
* examples/pwm.
*
************************************************************************************/
int board_pwm_setup(void)
{
static bool initialized = false;
struct pwm_lowerhalf_s *pwm;
struct pwm_lowerhalf_s *mcpwm;
struct pwm_lowerhalf_s *timer;
int ret;
/* Have we already initialized? */
if (!initialized)
{
/* Call lpc17_pwminitialize() to get an instance of the PWM interface */
pwm = lpc17_pwminitialize(0);
if (!pwm)
{
adbg("Failed to get the LPC17XX PWM lower half\n");
return -ENODEV;
}
/* Register the PWM driver at "/dev/pwm0" */
ret = pwm_register("/dev/pwm0", pwm);
if (ret < 0)
{
adbg("pwm_register failed: %d\n", ret);
return ret;
}
mcpwm = lpc17_mcpwminitialize(0);
if (!mcpwm)
{
adbg("Failed to get the LPC17XX MOTOR PWM lower half\n");
return -ENODEV;
}
/* Register the MOTOR CONTROL PWM driver at "/dev/mcpwm0" */
ret = pwm_register("/dev/mcpwm0", mcpwm);
if (ret < 0)
{
adbg("mcpwm_register failed: %d\n", ret);
return ret;
}
timer = lpc17_timerinitialize(0);
if (!timer)
{
adbg("Failed to get the LPC17XX TIMER lower half\n");
return -ENODEV;
}
/* Register the PWM driver at "/dev/timer0" */
ret = pwm_register("/dev/timer0", timer);
if (ret < 0)
{
adbg("timer_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
}
return OK;
}
#endif /* CONFIG_PWM */
+199
View File
@@ -0,0 +1,199 @@
/************************************************************************************
* configs/u-blox-c027/src/lpc17_ssp.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/spi/spi.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "chip.h"
#include "lpc17_gpio.h"
#include "lpc17_ssp.h"
#include "u-blox-c027.h"
#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1)
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Enables debug output from this file (needs CONFIG_DEBUG too) */
#undef SSP_DEBUG /* Define to enable debug */
#undef SSP_VERBOSE /* Define to enable verbose debug */
#ifdef SSP_DEBUG
# define sspdbg lldbg
# ifdef SSP_VERBOSE
# define sspvdbg lldbg
# else
# define sspvdbg(x...)
# endif
#else
# undef SSP_VERBOSE
# define sspdbg(x...)
# define sspvdbg(x...)
#endif
/* Dump GPIO registers */
#ifdef SSP_VERBOSE
# define ssp_dumpgpio(m) lpc17_dumpgpio(SDCCS_GPIO, m)
#else
# define ssp_dumpgpio(m)
#endif
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: c027_ssp_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the C027.
*
************************************************************************************/
void weak_function c027_ssp_initialize(void)
{
/* Configure the SPI-based microSD CS GPIO */
ssp_dumpgpio("c027_ssp_initialize() Entry)");
/* Configure card detect and chip select for the SD slot. */
#if defined(CONFIG_LPC17_SSP0) && defined(CONFIG_MMCSD_SPI)
(void)lpc17_configgpio(C027_SD_CS);
(void)lpc17_configgpio(C027_SD_CD);
#endif
ssp_dumpgpio("c027_ssp_initialize() Exit");
}
/************************************************************************************
* Name: lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status
*
* Description:
* The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status
* must be provided by board-specific logic. They are implementations of the select
* and status methods of the SPI interface defined by struct spi_ops_s (see
* include/nuttx/spi/spi.h). All other methods (including lpc17_sspinitialize())
* are provided by common LPC17xx logic. To use this common SPI logic on your
* board:
*
* 1. Provide logic in lpc17_boardinitialize() to configure SPI/SSP chip select
* pins.
* 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions
* in your board-specific logic. These functions will perform chip selection
* and status operations using GPIOs in the way your board is configured.
* 3. Add a calls to lpc17_sspinitialize() in your low level application
* initialization logic
* 4. The handle returned by lpc17_sspinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
************************************************************************************/
#ifdef CONFIG_LPC17_SSP0
void lpc17_ssp0select(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");
ssp_dumpgpio("lpc17_ssp0select() Entry");
#warning "Assert CS here (false)"
ssp_dumpgpio("lpc17_ssp0select() Exit");
}
uint8_t lpc17_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
sspdbg("Returning SPI_STATUS_PRESENT\n");
return SPI_STATUS_PRESENT;
}
#endif
#ifdef CONFIG_LPC17_SSP1
void lpc17_ssp1select(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");
ssp_dumpgpio("lpc17_ssp1select() Entry");
if (devid == SPIDEV_MMCSD)
{
/* Assert/de-assert the CS pin to the card */
(void)lpc17_gpiowrite(C027_SD_CS, !selected);
}
#ifdef CONFIG_NX_LCDDRIVER
else if (devid == SPIDEV_DISPLAY)
{
/* Assert the CS pin to the OLED display */
(void)lpc17_gpiowrite(C027_OLED_CS, !selected);
}
#endif
ssp_dumpgpio("lpc17_ssp1select() Exit");
}
uint8_t lpc17_ssp1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
if (devid == SPIDEV_MMCSD)
{
/* Read the state of the card-detect bit */
if (lpc17_gpioread(C027_SD_CD) == 0)
{
sspdbg("Returning SPI_STATUS_PRESENT\n");
return SPI_STATUS_PRESENT;
}
}
sspdbg("Returning zero\n");
return 0;
}
#endif
#endif /* CONFIG_LPC17_SSP0 || CONFIG_LPC17_SSP1 */
+310
View File
@@ -0,0 +1,310 @@
/****************************************************************************
* config/u-blox-c027/src/lpc17_ubxmdm.c
*
* Copyright (C) 2016 Vladimir Komendantskiy. All rights reserved.
* Author: Vladimir Komendantskiy <vladimir@moixaenergy.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdbool.h>
#include <string.h>
#include <poll.h>
#include <errno.h>
#include <unistd.h>
#include <nuttx/fs/fs.h>
#include <nuttx/irq.h>
#include <nuttx/kmalloc.h>
#include <nuttx/modem/u-blox.h>
#include <arch/board/board.h>
#include "lpc17_gpio.h"
#include "u-blox-c027.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Debug ********************************************************************/
/* Non-standard debug that may be enabled just for testing the modem driver */
#ifdef CONFIG_MODEM_U_BLOX_DEBUG
# define m_dbg dbg
# define m_vdbg vdbg
# define m_vlldbg lldbg
# define m_vllvdbg llvdbg
#else
# define m_dbg(x...)
# define m_vdbg(x...)
# define m_lldbg(x...)
# define m_llvdbg(x...)
#endif
#define UBXMDM_REGISTER_COUNT \
(sizeof(lpc17_ubxmdm_name_pins) / \
sizeof(struct lpc17_name_pin))
/****************************************************************************
* Private Types
****************************************************************************/
/* Core interface pin connections. These do not include UART or USB pins. */
struct lpc17_ubxmdm_pins
{
lpc17_pinset_t ldo_enable;
lpc17_pinset_t power_on_n;
lpc17_pinset_t reset_n;
lpc17_pinset_t shifter_en_n;
lpc17_pinset_t usb_detect;
};
/* This structure type provides the private representation of the "lower-half"
* driver state. This type must be coercible to type 'ubxmdm_lower'.
*/
struct lpc17_ubxmdm_lower
{
FAR const struct ubxmdm_ops* ops; /* Lower half operations */
/* Private, architecture-specific information. */
FAR const struct lpc17_ubxmdm_pins* pins;
bool usb_used;
};
/* Pair type for associating a register name to a pin. */
struct lpc17_name_pin
{
const char name[3];
const lpc17_pinset_t pin;
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* "Lower half" driver methods **********************************************/
static int lpc17_poweron (FAR struct ubxmdm_lower* lower);
static int lpc17_poweroff (FAR struct ubxmdm_lower* lower);
static int lpc17_reset (FAR struct ubxmdm_lower* lower);
static int lpc17_getstatus(FAR struct ubxmdm_lower* lower,
FAR struct ubxmdm_status* status);
static int lpc17_ioctl (FAR struct ubxmdm_lower* lower,
int cmd,
unsigned long arg);
/* "Lower half" driver state */
static struct lpc17_ubxmdm_lower lpc17_ubxmdm_lower;
/****************************************************************************
* Private Data
****************************************************************************/
/* "Lower half" driver methods */
static const struct lpc17_ubxmdm_pins lpc17_ubxmdm_pins =
{
.ldo_enable = C027_MDMLDOEN,
.power_on_n = C027_MDMPWR,
.reset_n = C027_MDMRST,
.shifter_en_n = C027_MDMLVLOE,
.usb_detect = C027_MDMUSBDET,
};
static const struct ubxmdm_ops lpc17_ubxmdm_ops =
{
.poweron = lpc17_poweron,
.poweroff = lpc17_poweroff,
.reset = lpc17_reset,
.getstatus = lpc17_getstatus,
.ioctl = lpc17_ioctl,
};
static const struct lpc17_name_pin lpc17_ubxmdm_name_pins[] =
{
{{'T','X','D'}, GPIO_UART1_TXD},
{{'R','X','D'}, GPIO_UART1_RXD},
{{'C','T','S'}, GPIO_UART1_CTS},
{{'R','T','S'}, GPIO_UART1_RTS},
{{'D','C','D'}, GPIO_UART1_DCD},
{{'D','S','R'}, GPIO_UART1_DSR},
{{'D','T','R'}, GPIO_UART1_DTR},
{{'R','I',' '}, GPIO_UART1_RI },
{{'I','O','1'}, C027_MDMGPIO1 },
{{'R','S','T'}, C027_MDMRST },
{{'P','W','R'}, C027_MDMPWR },
{{'D','E','T'}, C027_MDMUSBDET},
{{'L','D','O'}, C027_MDMLDOEN },
{{'L','V','L'}, C027_MDMLVLOE },
};
/****************************************************************************
* Private Functions
****************************************************************************/
static int lpc17_poweron(FAR struct ubxmdm_lower* lower)
{
FAR struct lpc17_ubxmdm_lower* priv =
(FAR struct lpc17_ubxmdm_lower*) lower;
lpc17_pinset_t usb_detect_val;
lpc17_configgpio(priv->pins->reset_n | GPIO_VALUE_ONE); /* Modem not in reset */
lpc17_configgpio(priv->pins->power_on_n | GPIO_VALUE_ZERO); /* Switch closed to GND */
usleep(10 * 1000); /* Min. time for power_on_n being low is 5 ms */
if (priv->usb_used)
{
usb_detect_val = GPIO_VALUE_ONE; /* USB sense on */
}
else
{
usb_detect_val = GPIO_VALUE_ZERO; /* USB sense off */
}
lpc17_configgpio(priv->pins->usb_detect | usb_detect_val);
lpc17_configgpio(priv->pins->ldo_enable | GPIO_VALUE_ONE); /* LDO enabled */
usleep(1 * 1000); /* Delay to obtain correct voltage on shifters
lpc17_configgpio(priv->pins->shifter_en_n | GPIO_VALUE_ZERO); /* UART shifter enabled */
/* lpc17_configgpio(priv->pins->power_on_n | GPIO_VALUE_ONE); * Stop current through switch */
return OK;
}
static int lpc17_poweroff(FAR struct ubxmdm_lower* lower)
{
FAR struct lpc17_ubxmdm_lower* priv =
(FAR struct lpc17_ubxmdm_lower*) lower;
lpc17_configgpio(priv->pins->ldo_enable | GPIO_VALUE_ZERO); /* LDO disabled */
lpc17_configgpio(priv->pins->reset_n | GPIO_VALUE_ONE); /* Modem not in reset */
lpc17_configgpio(priv->pins->power_on_n | GPIO_VALUE_ONE); /* Switch open */
lpc17_configgpio(priv->pins->shifter_en_n | GPIO_VALUE_ONE); /* UART shifter disabled */
lpc17_configgpio(priv->pins->usb_detect | GPIO_VALUE_ZERO); /* USB sense off */
return OK;
}
static int lpc17_reset(FAR struct ubxmdm_lower* lower)
{
FAR struct lpc17_ubxmdm_lower* priv =
(FAR struct lpc17_ubxmdm_lower*) lower;
lpc17_configgpio(priv->pins->reset_n | GPIO_VALUE_ZERO); /* Modem in reset */
usleep(75 * 1000); /* The minimum reset_n low time is 50 ms */
lpc17_configgpio(priv->pins->reset_n | GPIO_VALUE_ONE); /* Modem not in reset */
return OK;
}
static int lpc17_getstatus(FAR struct ubxmdm_lower* lower,
FAR struct ubxmdm_status* status)
{
FAR struct lpc17_ubxmdm_lower* priv =
(FAR struct lpc17_ubxmdm_lower*) lower;
int i;
status->on =
lpc17_gpioread(priv->pins->ldo_enable) &&
lpc17_gpioread(priv->pins->reset_n) &&
!lpc17_gpioread(priv->pins->shifter_en_n);
DEBUGASSERT(status->register_values_size >= UBXMDM_REGISTER_COUNT);
status->register_values_size = UBXMDM_REGISTER_COUNT;
for (i = 0; i < UBXMDM_REGISTER_COUNT; i++)
{
strncpy(status->register_values[i].name,
lpc17_ubxmdm_name_pins[i].name,
3);
status->register_values[i].val =
lpc17_gpioread(lpc17_ubxmdm_name_pins[i].pin);
}
return OK;
}
static int lpc17_ioctl(FAR struct ubxmdm_lower* lower,
int cmd,
unsigned long arg)
{
/* No platform-specific IOCTL at the moment. */
return -ENOSYS;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: lpc17_ubxmdm_init
*
* Description:
* Initialize the modem. The modem is initialized and
* registered at '/dev/ubxmdm'.
*
* Input Parameters:
* usb_used - enables the USB sense pin if 'true'
*
* Returned Values:
* None
*
****************************************************************************/
void lpc17_ubxmdm_init(bool usb_used)
{
FAR struct lpc17_ubxmdm_lower* priv = &lpc17_ubxmdm_lower;
DEBUGASSERT(priv->ops == NULL && priv->pins == NULL);
/* Initialize the driver state structure. Here we assume: (1) the state
* structure lies in .bss and was zeroed at reset time. (2) This function
* is only called once so it is never necessary to re-zero the structure.
*/
priv->ops = &lpc17_ubxmdm_ops;
priv->pins = &lpc17_ubxmdm_pins;
priv->usb_used = usb_used;
lpc17_poweroff((FAR struct ubxmdm_lower*) priv);
(void) ubxmdm_register("/dev/ubxmdm", (FAR struct ubxmdm_lower*) priv);
}
+125
View File
@@ -0,0 +1,125 @@
/****************************************************************************
* configs/u-blox-c027/src/lpc17_usbmsc.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Configure and register the LPC17xx MMC/SD SPI block driver.
*
* 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 <syslog.h>
#include <errno.h>
#include <nuttx/spi/spi.h>
#include <nuttx/mmcsd.h>
#include "lpc17_ssp.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_SYSTEM_USBMSC_DEVMINOR1
# define CONFIG_SYSTEM_USBMSC_DEVMINOR1 0
#endif
/* PORT and SLOT number probably depend on the board configuration */
#ifdef CONFIG_ARCH_BOARD_U_BLOX_C027
# undef LPC17XX_MMCSDSPIPORTNO
# define LPC17XX_MMCSDSPIPORTNO 0
# undef LPC17XX_MMCSDSLOTNO
# define LPC17XX_MMCSDSLOTNO 0
#else
/* Add configuration for new LPC17xx boards here */
# error "Unrecognized LPC17xx board"
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: usbmsc_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int usbmsc_archinitialize(void)
{
FAR struct spi_dev_s *spi;
int ret;
/* Get the SPI port */
syslog(LOG_INFO, "Initializing SPI port %d\n", LPC17XX_MMCSDSPIPORTNO);
spi = lpc17_sspinitialize(LPC17XX_MMCSDSPIPORTNO);
if (!spi)
{
syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n",
LPC17XX_MMCSDSPIPORTNO);
return -ENODEV;
}
syslog(LOG_INFO, "Successfully initialized SPI port %d\n",
LPC17XX_MMCSDSPIPORTNO);
/* Bind the SPI port to the slot */
syslog(LOG_INFO, "Binding SPI port %d to MMC/SD slot %d\n",
LPC17XX_MMCSDSPIPORTNO, LPC17XX_MMCSDSLOTNO);
ret = mmcsd_spislotinitialize(CONFIG_SYSTEM_USBMSC_DEVMINOR1, LPC17XX_MMCSDSLOTNO, spi);
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to bind SPI port %d to MMC/SD slot %d: %d\n",
LPC17XX_MMCSDSPIPORTNO, LPC17XX_MMCSDSLOTNO, ret);
return ret;
}
syslog(LOG_INFO, "Successfully bound SPI port %d to MMC/SD slot %d\n",
LPC17XX_MMCSDSPIPORTNO, LPC17XX_MMCSDSLOTNO);
return OK;
}
+103
View File
@@ -0,0 +1,103 @@
/************************************************************************************
* configs/u-blox-c027/src/u-blox-c027.h
*
* Copyright (C) 2016 Vladimir Komendantskiy. All rights reserved.
* Author: Vladimir Komendantskiy <vladimir@moixaenergy.com>
*
* 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_U_BLOX_C027_SRC_U_BLOX_C027_H
#define __CONFIGS_U_BLOX_C027_SRC_U_BLOX_C027_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
#define C027_LED (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT3 | GPIO_PIN25)
#define C027_SD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT2 | GPIO_PIN2)
#ifdef CONFIG_GPIO_IRQ
# define C027_SD_CD (GPIO_INTBOTH | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11)
#else
# define C027_SD_CD (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN11)
#endif
#define GPSADDR (66<<1) /* GPS I2C Address */
#define GPSBAUD 9600 /* Default GPS Baud Rate */
#define MDMBAUD 115200 /* Default Modem Baud Rate */
#define C027_MDMUSBDET (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN7)
#define C027_MDMILVLOE (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN8)
#define C027_MDMLVLOE (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN9)
#define C027_MDMLDOEN (GPIO_OUTPUT | GPIO_PORT2 | GPIO_PIN5)
#define C027_MDMPWR (GPIO_OUTPUT | GPIO_PORT2 | GPIO_PIN6)
#define C027_MDMGPIO1 (GPIO_INPUT | GPIO_PORT2 | GPIO_PIN7)
#define C027_MDMRST (GPIO_OUTPUT | GPIO_PORT2 | GPIO_PIN8)
#define C027_GPSEN (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN29)
#define C027_GPSRST (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN18)
/************************************************************************************
* Public data
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: c027_ssp_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the C027 board.
*
************************************************************************************/
void weak_function c027_ssp_initialize(void);
#if defined(CONFIG_MODEM_U_BLOX)
/*
* Initialisation function for the u-blox modem.
*/
void lpc17_ubxmdm_init(bool usb_used);
#endif /* CONFIG_MODEM_U_BLOX */
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_U_BLOX_C027_SRC_U_BLOX_C027_H */
+146
View File
@@ -0,0 +1,146 @@
#!/bin/bash
####################################################################################
# flash.sh
#
# Copyright (C) 2011 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.
#
####################################################################################
USAGE="$0 <nuttx-path>"
echo "############################################################################"
echo "# Assumptions:"
echo "#"
echo "# - Windows 7"
echo "# - LPCXpresso 3.6 installed at /cygdrive/c/nxp/lpcxpresso_3.6"
echo "# - AXF image built with Code Red"
echo "# - LPC1768"
echo "#"
echo "# You will need to edit this is any of the above are false"
echo "#"
echo "############################################################################"
echo ""
# This is the default install location for binaries on Windows (note that this
# path could change with the Code Red version number)
BINDIR="/cygdrive/c/nxp/lpcxpresso_3.6/bin"
if [ ! -d "${BINDIR}" ]; then
echo "Directory ${BINDIR} does not exist"
exit 1
fi
# This is the relative path to the booLPCXpresso utility
BOOTLPC="Scripts/bootLPCXpresso.cmd"
if [ ! -x "${BINDIR}/$BOOTLPC" ]; then
echo "No executable at ${BINDIR}/${BOOTLPC}"
exit 1
fi
# BOOTLPC_ARG=winusb # WinXP
BOOTLPC_ARG=hid # Win7
# FLASHUTIL="crt_emu_lpc11_13" # for LPC11xx or LPC13xx parts)
FLASHUTIL="crt_emu_cm3_nxp" # for LPC17xx parts
# FLASHUTIL="crt_emu_a7_nxp" # for LPC21/22/23/24 parts)
# FLASHUTIL="crt_emu_a9_nxp" # for LPC31/32 and LPC29xx parts)
# FLASHUTIL="crt_emu_cm3_lmi" # for TI Stellaris LM3S parts
if [ ! -x "${BINDIR}/${FLASHUTIL}" ]; then
echo "No executable file at ${BINDIR}/${FLASHUTIL}"
exit 1
fi
# unset WIRE # for Red Probe+, Red Probe, RDB1768v1, or TI Stellaris evaluation boards
# WIRE="-wire=hi" # for RDB1768v2 without upgraded firmware)
# WIRE="-wire=winusb" # for RDB1768v2 with upgraded firmware)
# WIRE="-wire=winusb" # for LPC-Link on Windows XP)
WIRE="-wire=hid" # for LPC-Link on Windows Vista/Windows 7)
TARGET=LPC1768
# The nuttx directory must be provided as an argument
NUTTX=$1
if [ -z "${NUTTX}" ]; then
echo "Missing argument"
echo $USAGE
exit 1
fi
if [ ! -d "${NUTTX}" ]; then
echo "Directory ${NUTTX} does not exist"
echo $USAGE
exit 1
fi
# The binary to download:
if [ ! -f "${NUTTX}/nuttx.axf" ]; then
if [ -f "${NUTTX}/nuttx" ]; then
echo "Renaming ${NUTTX}/nuttx to ${NUTTX}/nuttx.axf"
mv ${NUTTX}/nuttx ${NUTTX}/nuttx.axf
fi
else
if [ -f "${NUTTX}/nuttx" ]; then
echo "Both ${NUTTX}/nuttx ${NUTTX}/nuttx.axf exist.."
echo " Deleting ${NUTTX}/nuttx.axf"
rm -f ${NUTTX}/nuttx.axf
echo "Renaming ${NUTTX}/nuttx to ${NUTTX}/nuttx.axf"
mv ${NUTTX}/nuttx ${NUTTX}/nuttx.axf
fi
fi
NUTTXPATH=`cygpath -w "${NUTTX}/nuttx.axf"`
# First of all boot the LPC-Link using the script:
cd ${BINDIR} || \
{ echo "Failed to CD to ${BINDIR}"; exit 1; }
./${BOOTLPC} ${BOOTLPC_ARG} || \
{ echo "'${BOOTLPC} ${BOOTLPC_ARG}' Failed"; }
echo ""
echo "Wait a bit"
echo "5..."
sleep 1
echo "4..."
sleep 1
echo "3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
echo "0..."
echo ""
# Then program the FLASH
./${FLASHUTIL} ${WIRE} -p${TARGET} -flash-load-exec="${NUTTXPATH}"