Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions etc/ld/lpc4337_m4_semihost_lib.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* GENERATED FILE - DO NOT EDIT
* (c) Code Red Technologies Ltd, 2008-13
* (c) NXP Semiconductors 2013-2015
* Generated linker script file for LPC4337
* Created from LibIncTemplate.ld (LPCXpresso v7.6 (2 [Build 326] [2015-02-02] ))
* By LPCXpresso v7.6.2 [Build 326] [2015-02-02] on Wed Aug 26 15:59:13 ART 2015
*/


GROUP(
libcr_nohost.a
libcr_c.a
libcr_eabihelpers.a
)
14 changes: 12 additions & 2 deletions etc/target/lpc4337_m4.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,22 @@ LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \
-Wl,--gc-sections

# Linker scripts
ifndef LINK_RAM
LD_FILE := -Tetc/ld/lpc4337_m4_lib.ld -Tetc/ld/lpc4337_m4_mem.ld \
ifdef USE_DEBUG
LD_FILE := -Tetc/ld/lpc4337_m4_semihost_lib.ld -Tetc/ld/lpc4337_m4_mem.ld \
-Tetc/ld/lpc4337_m4.ld
else
ifdef USE_SEMIHOSTING
LD_FILE := -Tetc/ld/lpc4337_m4_semihost_lib.ld -Tetc/ld/lpc4337_m4_mem.ld \
-Tetc/ld/lpc4337_m4.ld
else
ifdef LINK_RAM
LD_FILE := -Tetc/ld/lpc4337_m4_lib.ld -Tetc/ld/lpc4337_m4_mem.ld \
-Tetc/ld/lpc4337_m4_RAM.ld
else
LD_FILE := -Tetc/ld/lpc4337_m4_lib.ld -Tetc/ld/lpc4337_m4_mem.ld \
-Tetc/ld/lpc4337_m4.ld
endif
endif
endif

# OpenOCD configuration file
Expand Down
48 changes: 48 additions & 0 deletions examples/blinky_debug/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2016, Pablo Ridolfi
# All rights reserved.
#
# This file is part of Workspace.
#
# 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 of the copyright holder 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 HOLDER 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.

# application name
PROJECT_NAME := $(notdir $(PROJECT))

# Modules needed by the application
PROJECT_MODULES := modules/$(TARGET)/base \
modules/$(TARGET)/board \
modules/$(TARGET)/chip

# source files folder
PROJECT_SRC_FOLDERS := $(PROJECT)/src

# header files folder
PROJECT_INC_FOLDERS := $(PROJECT)/inc

# source files
PROJECT_C_FILES := $(wildcard $(PROJECT)/src/*.c)
PROJECT_ASM_FILES := $(wildcard $(PROJECT)/src/*.S)
75 changes: 75 additions & 0 deletions examples/blinky_debug/inc/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* Copyright 2016, Pablo Ridolfi
* All rights reserved.
*
* This file is part of Workspace.
*
* 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 of the copyright holder 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 HOLDER 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 _MAIN_H_
#define _MAIN_H_

/** \addtogroup blink Bare-metal blink example
** @{ */

/*==================[inclusions]=============================================*/

/*==================[cplusplus]==============================================*/

#ifdef __cplusplus
extern "C" {
#endif

/*==================[macros]=================================================*/

/** delay in milliseconds */
#define DELAY_MS 500

/** led number to toggle */
#define LED 0

/*==================[typedef]================================================*/

/*==================[external data declaration]==============================*/

/*==================[external functions declaration]=========================*/

/** @brief main function
* @return main function should never return
*/
int main(void);

/*==================[cplusplus]==============================================*/

#ifdef __cplusplus
}
#endif

/** @} doxygen end group definition */
/*==================[end of file]============================================*/
#endif /* #ifndef _MAIN_H_ */
109 changes: 109 additions & 0 deletions examples/blinky_debug/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* Copyright 2016, Pablo Ridolfi
* All rights reserved.
*
* This file is part of Workspace.
*
* 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 of the copyright holder 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 HOLDER 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.
*
*/

/** @brief This is a simple blink example.
*/

/** \addtogroup blink Bare-metal blink example
** @{ */

/*==================[inclusions]=============================================*/

#include "main.h"
#include "board.h"

/*==================[macros and definitions]=================================*/

/*==================[internal data declaration]==============================*/

/*==================[internal functions declaration]=========================*/

/** @brief hardware initialization function
* @return none
*/
static void initHardware(void);

/** @brief delay function
* @param t desired milliseconds to wait
*/
static void pausems(uint32_t t);

/*==================[internal data definition]===============================*/

/** @brief used for delay counter */
static uint32_t pausems_count;

static char WelcomeMenu[] = "\r\nHello - DEBUG DEMO \r\n";
/*==================[external data definition]===============================*/

/*==================[internal functions definition]==========================*/

static void initHardware(void)
{
Board_Init();
SystemCoreClockUpdate();
SysTick_Config(SystemCoreClock / 1000);
}

static void pausems(uint32_t t)
{
pausems_count = t;
while (pausems_count != 0) {
__WFI();
}
}

/*==================[external functions definition]==========================*/

void SysTick_Handler(void)
{
if(pausems_count > 0) pausems_count--;
}

int main(void)
{
initHardware();

DEBUGOUT(WelcomeMenu);
while (1)
{
Board_LED_Toggle(LED);
pausems(DELAY_MS);

DEBUGOUT("\r\nDEBUG DEMO running!");
}
}

/** @} doxygen end group definition */

/*==================[end of file]============================================*/
4 changes: 2 additions & 2 deletions modules/lpc4337_m4/board/inc/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extern "C" {
DEBUGIN macros. If not defined, DEBUG* functions will be optimized
out of the code at build time.
*/
//#define DEBUG_ENABLE
#define DEBUG_ENABLE

/** Define DEBUG_SEMIHOSTING along with DEBUG_ENABLE to enable IO support
via semihosting. You may need to use a C library that supports
Expand All @@ -67,7 +67,7 @@ extern "C" {
/** Board UART used for debug output and input using the DEBUG* macros. This
is also the port used for Board_UARTPutChar, Board_UARTGetChar, and
Board_UARTPutSTR functions. */
#define DEBUG_UART LPC_USART0
#define DEBUG_UART LPC_USART2

/**
* @}
Expand Down
8 changes: 6 additions & 2 deletions modules/lpc4337_m4/board/src/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,24 @@ typedef struct {
} io_port_t;

static const io_port_t gpioLEDBits[] = {{5,0},{5,1},{5,2},{0,14},{1,11},{1,12}};
static uint32_t lcd_cfg_val;
static const io_port_t gpioBtnBits[] = {{0,4},{0,8},{0,9},{1,9}};
static const uint8_t gpioBtnIDs[] = {TEC1_PRESSED, TEC2_PRESSED, TEC3_PRESSED, TEC4_PRESSED};

void Board_UART_Init(LPC_USART_T *pUART)
{
if (pUART == LPC_USART0) {
Chip_SCU_PinMuxSet(0x6, 4, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC2)); /* P6.5 : UART0_TXD */
Chip_SCU_PinMuxSet(0x6, 4, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC2)); /* P6.5 : UART0_TXD */
Chip_SCU_PinMuxSet(0x6, 5, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2));/* P6.4 : UART0_RXD */
}
else if (pUART == LPC_UART1) {
Chip_SCU_PinMuxSet(0x1, 13, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC2)); /* P1.13 : UART1_TXD */
Chip_SCU_PinMuxSet(0x1, 14, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)); /* P1.14 : UART1_RX */
}
else if (pUART == LPC_USART2) {
Chip_SCU_PinMuxSet(0x7, 1, (SCU_MODE_INACT | SCU_MODE_FUNC6)); /* P7.1 : UART2_TXD */
Chip_SCU_PinMuxSet(0x7, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC6));/* P7.2 : UART2_RXD */
}

}

/* Initialize debug output via UART for board */
Expand Down
6 changes: 5 additions & 1 deletion project.mk.template
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

# current project
PROJECT = examples/blinky
#PROJECT = examples/blinky_debug
#PROJECT = examples/blinky_rit
#PROJECT = examples/adc_fir_dac
#PROJECT = examples/freertos_blinky
Expand All @@ -57,5 +58,8 @@ BOARD = edu_ciaa_nxp
# you need to add an lpc54102_m0 program). For example:
#SLAVE_OBJ_FILE = out/lpc54102_m0/blinky_m0.axf.o

# If you want to use debug libraries (LPCXpresso) then define
#USE_DEBUG = 1

# If you want to use semihosting libraries (LPCXpresso) then define
# USE_SEMIHOSTING = 1
#USE_SEMIHOSTING = 1