cbed-svn-commit Mailing List for cbed
Status: Planning
Brought to you by:
stl-ajk
You can subscribe to this list here.
2011 |
Jan
|
Feb
|
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: <st...@us...> - 2011-03-20 09:37:38
|
Revision: 9 http://cbed.svn.sourceforge.net/cbed/?rev=9&view=rev Author: stl-ajk Date: 2011-03-20 09:37:32 +0000 (Sun, 20 Mar 2011) Log Message: ----------- Modified Paths: -------------- trunk/cbed/inc/cbedopts.h Added Paths: ----------- trunk/cbed/inc/cbedinc.h Added: trunk/cbed/inc/cbedinc.h =================================================================== --- trunk/cbed/inc/cbedinc.h (rev 0) +++ trunk/cbed/inc/cbedinc.h 2011-03-20 09:37:32 UTC (rev 9) @@ -0,0 +1,33 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file cbedinc.h + * @purpose The main cbed library option definitions. + * @version $Id$ + * @date Mar 2011 + * @author Andy Kirkham + */ + +#define CBED_TARGET_MBED 0 +#define CBED_TARGET_LPCXPRESSO 1 + Property changes on: trunk/cbed/inc/cbedinc.h ___________________________________________________________________ Added: svn:keywords + Id Modified: trunk/cbed/inc/cbedopts.h =================================================================== --- trunk/cbed/inc/cbedopts.h 2011-03-20 09:33:16 UTC (rev 8) +++ trunk/cbed/inc/cbedopts.h 2011-03-20 09:37:32 UTC (rev 9) @@ -28,13 +28,15 @@ * @author Andy Kirkham */ +#include "cbedinc.h" + /** Defines the target board. * * Values can be:- - * Mbed 0 - * LPCXPRESSO 1 + * CBED_TARGET_MBED + * CBED_TARGET_LPCXPRESSO */ -#define CBED_TARGET 0 +#define CBED_TARGET CBED_TARGET_MBED /** Define which target to use. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2011-03-20 09:33:22
|
Revision: 8 http://cbed.svn.sourceforge.net/cbed/?rev=8&view=rev Author: stl-ajk Date: 2011-03-20 09:33:16 +0000 (Sun, 20 Mar 2011) Log Message: ----------- Modified Paths: -------------- trunk/cbed/inc/cbedopts.h Modified: trunk/cbed/inc/cbedopts.h =================================================================== --- trunk/cbed/inc/cbedopts.h 2011-03-20 09:31:33 UTC (rev 7) +++ trunk/cbed/inc/cbedopts.h 2011-03-20 09:33:16 UTC (rev 8) @@ -23,7 +23,7 @@ /** * @file cbedopts.h * @purpose The main cbed library option definitions. - * @version $Id:& + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ @@ -31,12 +31,10 @@ /** Defines the target board. * * Values can be:- - * CBED_MBED - * CBED_LPCXPRESSO + * Mbed 0 + * LPCXPRESSO 1 */ -#define CBED_MBED 0 -#define CBED_LPCXPRESSO 1 -#define CBED_TARGET CBED_MBED +#define CBED_TARGET 0 /** Define which target to use. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2011-03-20 09:31:40
|
Revision: 7 http://cbed.svn.sourceforge.net/cbed/?rev=7&view=rev Author: stl-ajk Date: 2011-03-20 09:31:33 +0000 (Sun, 20 Mar 2011) Log Message: ----------- Modified Paths: -------------- trunk/cbed/inc/cbed.h trunk/cbed/inc/cbedopts.h trunk/cbed/inc/iomacros.h trunk/cbed/inc/ticker.h trunk/cbed/src/ticker.c trunk/cbed/src/uart0.c trunk/cbed/src/uart1.c trunk/cbed/src/uart2.c trunk/cbed/src/uart3.c trunk/cbed/src/uartx.h Modified: trunk/cbed/inc/cbed.h =================================================================== --- trunk/cbed/inc/cbed.h 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/inc/cbed.h 2011-03-20 09:31:33 UTC (rev 7) @@ -23,13 +23,11 @@ /** * @file cbed.h * @purpose The main cbed library header. - * @version see ChangeLog.h + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ - - #ifndef CBED_CBED_H #define CBED_CBED_H Modified: trunk/cbed/inc/cbedopts.h =================================================================== --- trunk/cbed/inc/cbedopts.h 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/inc/cbedopts.h 2011-03-20 09:31:33 UTC (rev 7) @@ -1,80 +1,85 @@ +/* + Copyright (c) 2011 Andy Kirkham -#define CBED_TARGET CBED_MBED -/* #define CBED_TARGET CBED_LPCXPRESSO */ + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: -/* Use TIMER2 for our system rather than the default TIMER3 */ -/* #define TICKERSYS_TIMER_CUSTOM - #define TICKERSYS_TIMER_IRQHandler TIMER2_IRQHandler - #define TICKERSYS_TIMER_PCONP (1UL << 22) - #define TICKERSYS_TIMER_PCLKSEL LPC_SC->PCLKSEL1 - #define TICKERSYS_TIMER_PCLKSEL_VALUE (3UL << 12) - #define TICKERSYS_TIMER_TCR LPC_TIM2->TCR - #define TICKERSYS_TIMER_PR LPC_TIM2->PR - #define TICKERSYS_TIMER_MCR LPC_TIM2->MCR - #define TICKERSYS_TIMER_MR0 LPC_TIM2->MR0 - #define TICKERSYS_TIMER_TC LPC_TIM2->TC - #define TICKERSYS_TIMER_IR LPC_TIM2->IR - #define TICKERSYS_TIMER_IRQn TIMER2_IRQn - #define TICKERSYS_TIMER_TICK 1000 */ + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. -/* Use TIMER1 for our system rather than the default TIMER3 */ -/* #define TICKERSYS_TIMER_CUSTOM - #define TICKERSYS_TIMER_IRQHandler TIMER1_IRQHandler - #define TICKERSYS_TIMER_PCONP (1UL << 2) - #define TICKERSYS_TIMER_PCLKSEL LPC_SC->PCLKSEL0 - #define TICKERSYS_TIMER_PCLKSEL_VALUE (3UL << 4) - #define TICKERSYS_TIMER_TCR LPC_TIM1->TCR - #define TICKERSYS_TIMER_PR LPC_TIM1->PR - #define TICKERSYS_TIMER_MCR LPC_TIM1->MCR - #define TICKERSYS_TIMER_MR0 LPC_TIM1->MR0 - #define TICKERSYS_TIMER_TC LPC_TIM1->TC - #define TICKERSYS_TIMER_IR LPC_TIM1->IR - #define TICKERSYS_TIMER_IRQn TIMER1_IRQn - #define TICKERSYS_TIMER_TICK 1000 */ + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ -/* Use TIMER0 for our system rather than the default TIMER3 */ -/* #define TICKERSYS_TIMER_CUSTOM - #define TICKERSYS_TIMER_IRQHandler TIMER0_IRQHandler - #define TICKERSYS_TIMER_PCONP (1UL << 1) - #define TICKERSYS_TIMER_PCLKSEL LPC_SC->PCLKSEL0 - #define TICKERSYS_TIMER_PCLKSEL_VALUE (3UL << 2) - #define TICKERSYS_TIMER_TCR LPC_TIM0->TCR - #define TICKERSYS_TIMER_PR LPC_TIM0->PR - #define TICKERSYS_TIMER_MCR LPC_TIM0->MCR - #define TICKERSYS_TIMER_MR0 LPC_TIM0->MR0 - #define TICKERSYS_TIMER_TC LPC_TIM0->TC - #define TICKERSYS_TIMER_IR LPC_TIM0->IR - #define TICKERSYS_TIMER_IRQn TIMER0_IRQn - #define TICKERSYS_TIMER_TICK 1000 */ +/** + * @file cbedopts.h + * @purpose The main cbed library option definitions. + * @version $Id:& + * @date Mar 2011 + * @author Andy Kirkham + */ -/* Uncomment as required to build drivers for Uarts. - Optionally, if you want to add circular buffer - support then define the additional requires to match - the buffer size you would like. */ -#define CBED_BUILD_UART0 -#define CBED_BUILD_UART0_WITH_TX_BUFFER 512 -#define CBED_BUILD_UART0_WITH_RX_BUFFER 32 +/** Defines the target board. + * + * Values can be:- + * CBED_MBED + * CBED_LPCXPRESSO + */ +#define CBED_MBED 0 +#define CBED_LPCXPRESSO 1 +#define CBED_TARGET CBED_MBED -#define CBED_BUILD_UART1 -#define CBED_BUILD_UART1_WITH_TX_BUFFER 512 -#define CBED_BUILD_UART1_WITH_RX_BUFFER 32 +/** Define which target to use. + * + * Value values can be 0, 1, 2, 3. + * 3 is the default if not defined. + */ +#define TICKERSYS_USE_TIMER 3 -#define CBED_BUILD_UART2 -#define CBED_BUILD_UART2_WITH_TX_BUFFER 512 -#define CBED_BUILD_UART2_WITH_RX_BUFFER 32 +/** Define if a UART0 device driver should be built. + * Optionally, specify if TX and/or RX circular buffers + * should be used. The number used after the buffer definition + * is the required number of bytes in the buffer. Must be + * equal to or greater than 1. */ +//#define CBED_BUILD_UART0 +//#define CBED_BUILD_UART0_WITH_TX_BUFFER 512 +//#define CBED_BUILD_UART0_WITH_RX_BUFFER 32 -#define CBED_BUILD_UART3 -#define CBED_BUILD_UART3_WITH_TX_BUFFER 512 -#define CBED_BUILD_UART3_WITH_RX_BUFFER 32 +/** Define if a UART1 device driver should be built. + * Optionally, specify if TX and/or RX circular buffers + * should be used. The number used after the buffer definition + * is the required number of bytes in the buffer. Must be + * equal to or greater than 1. */ +//#define CBED_BUILD_UART1 +//#define CBED_BUILD_UART1_WITH_TX_BUFFER 512 +//#define CBED_BUILD_UART1_WITH_RX_BUFFER 32 -/* #define CBED_BUILD_UART1 - #define CBED_BUILD_UART1_WITH_TX_BUFFER nnn - #define CBED_BUILD_UART1_WITH_RX_BUFFER nn */ -/* #define CBED_BUILD_UART2 - #define CBED_BUILD_UART2_WITH_TX_BUFFER nnn - #define CBED_BUILD_UART2_WITH_RX_BUFFER nn */ -/* #define CBED_BUILD_UART3 - #define CBED_BUILD_UART3_WITH_TX_BUFFER nnn - #define CBED_BUILD_UART3_WITH_RX_BUFFER nn */ +/** Define if a UART2 device driver should be built. + * Optionally, specify if TX and/or RX circular buffers + * should be used. The number used after the buffer definition + * is the required number of bytes in the buffer. Must be + * equal to or greater than 1. */ +//#define CBED_BUILD_UART2 +//#define CBED_BUILD_UART2_WITH_TX_BUFFER 512 +//#define CBED_BUILD_UART2_WITH_RX_BUFFER 32 +/** Define if a UART3 device driver should be built. + * Optionally, specify if TX and/or RX circular buffers + * should be used. The number used after the buffer definition + * is the required number of bytes in the buffer. Must be + * equal to or greater than 1. */ +//#define CBED_BUILD_UART3 +//#define CBED_BUILD_UART3_WITH_TX_BUFFER 512 +//#define CBED_BUILD_UART3_WITH_RX_BUFFER 32 + + Modified: trunk/cbed/inc/iomacros.h =================================================================== --- trunk/cbed/inc/iomacros.h 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/inc/iomacros.h 2011-03-20 09:31:33 UTC (rev 7) @@ -23,7 +23,7 @@ /** * @file iomacros.h * @purpose Handles GPIO pins. - * @version see ChangeLog.h + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ Modified: trunk/cbed/inc/ticker.h =================================================================== --- trunk/cbed/inc/ticker.h 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/inc/ticker.h 2011-03-20 09:31:33 UTC (rev 7) @@ -23,7 +23,7 @@ /** * @file ticker.h * @purpose Handles tickers, timeouts, timers and wait api. - * @version see ChangeLog.h + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ Modified: trunk/cbed/src/ticker.c =================================================================== --- trunk/cbed/src/ticker.c 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/src/ticker.c 2011-03-20 09:31:33 UTC (rev 7) @@ -22,8 +22,8 @@ /** * @file ticker.c - * @purpose Handles tickers, timeouts, timers and wait api. - * @version see ChangeLog.h + * @purpose Handles tickers, timeouts, timers and wait API. + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ @@ -37,8 +37,13 @@ #include "ticker.h" #include "iomacros.h" #include "LPC17xx.h" +#include "cbedopts.h" -#ifndef TICKERSYS_TIMER_CUSTOM +#ifndef TICKERSYS_USE_TIMER +#define TICKERSYS_USE_TIMER 3 +#endif + +#if TICKERSYS_USE_TIMER == 3 #define TICKERSYS_TIMER_ISR TIMER3_IRQHandler #define TICKERSYS_PCONP (1UL << 23) #define TICKERSYS_PCLKSEL LPC_SC->PCLKSEL1 @@ -51,21 +56,50 @@ #define TICKERSYS_IR LPC_TIM3->IR #define TICKERSYS_IRQn TIMER3_IRQn #define TICKERSYS_TICK 1000 +#elif TICKERSYS_USE_TIMER == 2 +#define TICKERSYS_IRQHandler TIMER2_IRQHandler +#define TICKERSYS_PCONP (1UL << 22) +#define TICKERSYS_PCLKSEL LPC_SC->PCLKSEL1 +#define TICKERSYS_PCLKSEL_VALUE (3UL << 12) +#define TICKERSYS_TCR LPC_TIM2->TCR +#define TICKERSYS_PR LPC_TIM2->PR +#define TICKERSYS_MCR LPC_TIM2->MCR +#define TICKERSYS_MR0 LPC_TIM2->MR0 +#define TICKERSYS_TC LPC_TIM2->TC +#define TICKERSYS_IR LPC_TIM2->IR +#define TICKERSYS_IRQn TIMER2_IRQn +#define TICKERSYS_TICK 1000 +#elif TICKERSYS_USE_TIMER == 1 +#define TICKERSYS_IRQHandler TIMER1_IRQHandler +#define TICKERSYS_PCONP (1UL << 2) +#define TICKERSYS_PCLKSEL LPC_SC->PCLKSEL0 +#define TICKERSYS_PCLKSEL_VALUE (3UL << 4) +#define TICKERSYS_TCR LPC_TIM1->TCR +#define TICKERSYS_PR LPC_TIM1->PR +#define TICKERSYS_MCR LPC_TIM1->MCR +#define TICKERSYS_MR0 LPC_TIM1->MR0 +#define TICKERSYS_TC LPC_TIM1->TC +#define TICKERSYS_IR LPC_TIM1->IR +#define TICKERSYS_IRQn TIMER1_IRQn +#define TICKERSYS_TICK 1000 +#elif TICKERSYS_USE_TIMER == 0 +#define TICKERSYS_IRQHandler TIMER0_IRQHandler +#define TICKERSYS_PCONP (1UL << 1) +#define TICKERSYS_PCLKSEL LPC_SC->PCLKSEL0 +#define TICKERSYS_PCLKSEL_VALUE (3UL << 2) +#define TICKERSYS_TCR LPC_TIM0->TCR +#define TICKERSYS_PR LPC_TIM0->PR +#define TICKERSYS_MCR LPC_TIM0->MCR +#define TICKERSYS_MR0 LPC_TIM0->MR0 +#define TICKERSYS_TC LPC_TIM0->TC +#define TICKERSYS_IR LPC_TIM0->IR +#define TICKERSYS_IRQn TIMER0_IRQn +#define TICKERSYS_TICK 1000 #else -#define TICKERSYS_TIMER_ISR TICKERSYS_TIMER_IRQHandler -#define TICKERSYS_PCONP TICKERSYS_TIMER_PCONP -#define TICKERSYS_PCLKSEL TICKERSYS_TIMER_PCLKSEL -#define TICKERSYS_PCLKSEL_VALUE TICKERSYS_TIMER_PCLKSEL_VALUE -#define TICKERSYS_TCR TICKERSYS_TIMER_TCR -#define TICKERSYS_PR TICKERSYS_TIMER_PR -#define TICKERSYS_MCR TICKERSYS_TIMER_MCR -#define TICKERSYS_MR0 TICKERSYS_TIMER_MR0 -#define TICKERSYS_TC TICKERSYS_TIMER_TC -#define TICKERSYS_IR TICKERSYS_TIMER_IR -#define TICKERSYS_IRQn TICKERSYS_TIMER_IRQn -#define TICKERSYS_TICK TICKERSYS_TIMER_TICK +#error "No TIMER specified" #endif + #ifdef __cplusplus extern "C" { #endif Modified: trunk/cbed/src/uart0.c =================================================================== --- trunk/cbed/src/uart0.c 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/src/uart0.c 2011-03-20 09:31:33 UTC (rev 7) @@ -22,8 +22,8 @@ /** * @file ticker.h - * @purpose Handles tickers, timeouts, timers and wait api. - * @version see ChangeLog.h + * @purpose Handles tickers, timeouts, timers and wait API. + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ Modified: trunk/cbed/src/uart1.c =================================================================== --- trunk/cbed/src/uart1.c 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/src/uart1.c 2011-03-20 09:31:33 UTC (rev 7) @@ -23,7 +23,7 @@ /** * @file uart1.c * @purpose Builds the uart1 instance - * @version see ChangeLog.h + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ Modified: trunk/cbed/src/uart2.c =================================================================== --- trunk/cbed/src/uart2.c 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/src/uart2.c 2011-03-20 09:31:33 UTC (rev 7) @@ -23,7 +23,7 @@ /** * @file uart2.c * @purpose Creates an instance of uart2 - * @version see ChangeLog.h + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ Modified: trunk/cbed/src/uart3.c =================================================================== --- trunk/cbed/src/uart3.c 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/src/uart3.c 2011-03-20 09:31:33 UTC (rev 7) @@ -23,7 +23,7 @@ /** * @file uart3.c * @purpose Creates an instance of uart3 - * @version see ChangeLog.h + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ Modified: trunk/cbed/src/uartx.h =================================================================== --- trunk/cbed/src/uartx.h 2011-03-20 01:37:34 UTC (rev 6) +++ trunk/cbed/src/uartx.h 2011-03-20 09:31:33 UTC (rev 7) @@ -22,8 +22,8 @@ /** * @file uartx.h - * @purpose General file that exapnds to create a UART instance. - * @version see ChangeLog.h + * @purpose General file that expands to create a UART instance. + * @version $Id$ * @date Mar 2011 * @author Andy Kirkham */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2011-03-19 20:22:17
|
Revision: 5 http://cbed.svn.sourceforge.net/cbed/?rev=5&view=rev Author: stl-ajk Date: 2011-03-19 20:22:11 +0000 (Sat, 19 Mar 2011) Log Message: ----------- Fixed some typos Modified Paths: -------------- trunk/cbed/.cproject trunk/cbed/.project trunk/cbed/src/uart0.c trunk/cbed/src/uartx.h Modified: trunk/cbed/.cproject =================================================================== --- trunk/cbed/.cproject 2011-03-19 19:35:58 UTC (rev 4) +++ trunk/cbed/.cproject 2011-03-19 20:22:11 UTC (rev 5) @@ -36,7 +36,7 @@ <listOptionValue builtIn="false" value="__CODE_RED"/> </option> <option id="gnu.c.compiler.option.misc.other.834748474" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/> -<option id="gnu.c.compiler.option.include.paths.837228785" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> +<option id="gnu.c.compiler.option.include.paths.837228785" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <listOptionValue builtIn="false" value="../inc"/> </option> <inputType id="com.crt.advproject.compiler.input.1007998830" superClass="com.crt.advproject.compiler.input"/> @@ -170,6 +170,7 @@ </profile> </storageModule> <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> +<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> </cconfiguration> <cconfiguration id="com.crt.advproject.config.lib.release.447398816"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.release.447398816" moduleId="org.eclipse.cdt.core.settings" name="Release"> @@ -205,7 +206,7 @@ </option> <option id="gnu.c.compiler.option.misc.other.1921869647" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/> <option id="gnu.c.compiler.option.optimization.flags.232568468" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-Os" valueType="string"/> -<option id="gnu.c.compiler.option.include.paths.1031404249" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> +<option id="gnu.c.compiler.option.include.paths.1031404249" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <listOptionValue builtIn="false" value="../inc"/> </option> <inputType id="com.crt.advproject.compiler.input.1774429324" superClass="com.crt.advproject.compiler.input"/> @@ -339,6 +340,7 @@ </profile> </storageModule> <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> +<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> </cconfiguration> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> Modified: trunk/cbed/.project =================================================================== --- trunk/cbed/.project 2011-03-19 19:35:58 UTC (rev 4) +++ trunk/cbed/.project 2011-03-19 20:22:11 UTC (rev 5) @@ -3,6 +3,7 @@ <name>cbed</name> <comment></comment> <projects> + <project>CMSISv1p30_LPC17xx</project> </projects> <buildSpec> <buildCommand> Modified: trunk/cbed/src/uart0.c =================================================================== --- trunk/cbed/src/uart0.c 2011-03-19 19:35:58 UTC (rev 4) +++ trunk/cbed/src/uart0.c 2011-03-19 20:22:11 UTC (rev 5) @@ -54,7 +54,7 @@ #define UARTX_callback_rx cbed_uart0_callback_rx #define UARTX_callback_rx_overflow cbed_uart0_callback_rx_overflow -#define UARTX_isr cbed_uart0_isr +#define UARTX_IRQHandler UART0_IRQHandlr #define UARTX_isr_tx cbed_uart0_isr_tx #define UARTX_isr_rx cbed_uart0_isr_rx #define UARTX__getc uart0__get Modified: trunk/cbed/src/uartx.h =================================================================== --- trunk/cbed/src/uartx.h 2011-03-19 19:35:58 UTC (rev 4) +++ trunk/cbed/src/uartx.h 2011-03-19 20:22:11 UTC (rev 5) @@ -34,7 +34,6 @@ #include <math.h> #include <time.h> #include <stdint.h> -#include "cmsis_nvic.h" #include "LPC17xx.h" #ifdef __cplusplus @@ -129,7 +128,7 @@ UARTX_IER |= 2; } #else - while(!(UARTX_LSR & (1UL << 5)); + while(!(UARTX_LSR & (1UL << 5))); UARTX_THR = (uint32_t)c; #endif return 0; @@ -154,11 +153,11 @@ return c; #else if (block) { - while (!(UARTX_LSR & (1UL << 0)) ; + while (!(UARTX_LSR & (1UL << 0))) ; return (int)(UARTX_RBR & 0xFF); } else { - if (!(UARTX_LSR & (1UL << 0)) return -1; + if (!(UARTX_LSR & (1UL << 0))) return -1; return (int)(UARTX_RBR & 0xFF); } #endif @@ -168,7 +167,7 @@ return UARTX__getc(true); } -extern "C" void UARTX_isr(void) __irq +void UARTX_IRQHandler(void) { volatile uint32_t iir, lsr; @@ -238,4 +237,4 @@ #ifdef __cplusplus } -#endif \ No newline at end of file +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2011-03-19 19:36:05
|
Revision: 4 http://cbed.svn.sourceforge.net/cbed/?rev=4&view=rev Author: stl-ajk Date: 2011-03-19 19:35:58 +0000 (Sat, 19 Mar 2011) Log Message: ----------- Add Code Red project files Added Paths: ----------- trunk/cbed/.cproject trunk/cbed/.project Added: trunk/cbed/.cproject =================================================================== --- trunk/cbed/.cproject (rev 0) +++ trunk/cbed/.cproject 2011-03-19 19:35:58 UTC (rev 4) @@ -0,0 +1,422 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?> + +<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> +<storageModule moduleId="org.eclipse.cdt.core.settings"> +<cconfiguration id="com.crt.advproject.config.lib.debug.365333231"> +<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.debug.365333231" moduleId="org.eclipse.cdt.core.settings" name="Debug"> +<externalSettings> +<externalSetting> +<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/cbed"/> +<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/cbed/Debug"/> +</externalSetting> +</externalSettings> +<extensions> +<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> +<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/> +<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +</extensions> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<configuration artifactExtension="a" artifactName="cbed" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Debug build" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.debug.365333231" name="Debug" parent="com.crt.advproject.config.lib.debug" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size lib${BuildArtifactFileName} ; # arm-none-eabi-objdump -h -S lib${BuildArtifactFileName} >${BuildArtifactFileBaseName}.lss"> +<folderInfo id="com.crt.advproject.config.lib.debug.365333231." name="/" resourcePath=""> +<toolChain id="com.crt.advproject.toolchain.lib.debug.1570720683" name="Code Red MCU Tools" superClass="com.crt.advproject.toolchain.lib.debug"> +<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.debug.787672146" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.debug"/> +<builder buildPath="${workspace_loc:/cbed/Debug}" id="com.crt.advproject.builder.lib.debug.19736343" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.debug"/> +<tool id="com.crt.advproject.cpp.lib.debug.955376588" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.debug"/> +<tool id="com.crt.advproject.gcc.lib.debug.1764588854" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.debug"> +<option id="com.crt.advproject.gcc.arch.1527291128" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/> +<option id="com.crt.advproject.gcc.thumb.1029245407" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/> +<option id="gnu.c.compiler.option.preprocessor.def.symbols.79954739" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> +<listOptionValue builtIn="false" value="__REDLIB__"/> +<listOptionValue builtIn="false" value="DEBUG"/> +<listOptionValue builtIn="false" value="__CODE_RED"/> +</option> +<option id="gnu.c.compiler.option.misc.other.834748474" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/> +<option id="gnu.c.compiler.option.include.paths.837228785" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> +<listOptionValue builtIn="false" value="../inc"/> +</option> +<inputType id="com.crt.advproject.compiler.input.1007998830" superClass="com.crt.advproject.compiler.input"/> +</tool> +<tool id="com.crt.advproject.gas.lib.debug.802793484" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.debug"> +<option id="com.crt.advproject.gas.arch.48653251" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/> +<option id="com.crt.advproject.gas.thumb.1251583329" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/> +<option id="gnu.both.asm.option.flags.crt.438679270" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -D__REDLIB__ -DDEBUG -D__CODE_RED " valueType="string"/> +<inputType id="com.crt.advproject.assembler.input.901625468" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/> +</tool> +<tool id="com.crt.advproject.ar.lib.debug.1060160908" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.debug"/> +</toolChain> +</folderInfo> +<sourceEntries> +<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> +<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> +</sourceEntries> +</configuration> +</storageModule> +<storageModule moduleId="scannerConfiguration"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/> +<profile id="com.crt.advproject.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="false" filePath=""/> +<parser enabled="false"/> +</buildOutputProvider> +<scannerInfoProvider id="com.crt.advproject.specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-c++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="com.crt.advproject.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="false" filePath=""/> +<parser enabled="false"/> +</buildOutputProvider> +<scannerInfoProvider id="com.crt.advproject.specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file} " command="arm-none-eabi-gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="com.crt.advproject.GASManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="false" filePath=""/> +<parser enabled="false"/> +</buildOutputProvider> +<scannerInfoProvider id="com.crt.advproject.specsFile"> +<runAction arguments="-x assembler-with-cpp -E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</storageModule> +<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> +</cconfiguration> +<cconfiguration id="com.crt.advproject.config.lib.release.447398816"> +<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.release.447398816" moduleId="org.eclipse.cdt.core.settings" name="Release"> +<externalSettings> +<externalSetting> +<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/cbed"/> +<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/cbed/Release"/> +</externalSetting> +</externalSettings> +<extensions> +<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> +<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/> +<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +</extensions> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<configuration artifactExtension="a" artifactName="cbed" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Release build" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.release.447398816" name="Release" parent="com.crt.advproject.config.lib.release" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size lib${BuildArtifactFileName} ; # arm-none-eabi-objdump -h -S lib${BuildArtifactFileName} >${BuildArtifactFileBaseName}.lss"> +<folderInfo id="com.crt.advproject.config.lib.release.447398816." name="/" resourcePath=""> +<toolChain id="com.crt.advproject.toolchain.lib.release.519471292" name="Code Red MCU Tools" superClass="com.crt.advproject.toolchain.lib.release"> +<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.release.1812602523" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.release"/> +<builder buildPath="${workspace_loc:/cbed/Release}" id="com.crt.advproject.builder.lib.release.966459664" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.release"/> +<tool id="com.crt.advproject.cpp.lib.release.908514041" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.release"/> +<tool id="com.crt.advproject.gcc.lib.release.261708960" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.release"> +<option id="com.crt.advproject.gcc.arch.115546772" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/> +<option id="com.crt.advproject.gcc.thumb.1594466735" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/> +<option id="gnu.c.compiler.option.preprocessor.def.symbols.1067230360" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> +<listOptionValue builtIn="false" value="__REDLIB__"/> +<listOptionValue builtIn="false" value="NDEBUG"/> +<listOptionValue builtIn="false" value="__CODE_RED"/> +</option> +<option id="gnu.c.compiler.option.misc.other.1921869647" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/> +<option id="gnu.c.compiler.option.optimization.flags.232568468" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-Os" valueType="string"/> +<option id="gnu.c.compiler.option.include.paths.1031404249" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> +<listOptionValue builtIn="false" value="../inc"/> +</option> +<inputType id="com.crt.advproject.compiler.input.1774429324" superClass="com.crt.advproject.compiler.input"/> +</tool> +<tool id="com.crt.advproject.gas.lib.release.1501417075" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.release"> +<option id="com.crt.advproject.gas.arch.90698263" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/> +<option id="com.crt.advproject.gas.thumb.1149857464" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/> +<option id="gnu.both.asm.option.flags.crt.2112546736" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -D__REDLIB__ -DNDEBUG -D__CODE_RED " valueType="string"/> +<inputType id="com.crt.advproject.assembler.input.1742727674" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/> +</tool> +<tool id="com.crt.advproject.ar.lib.release.352667383" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.release"/> +</toolChain> +</folderInfo> +<sourceEntries> +<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> +<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> +</sourceEntries> +</configuration> +</storageModule> +<storageModule moduleId="scannerConfiguration"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/> +<profile id="com.crt.advproject.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="false" filePath=""/> +<parser enabled="false"/> +</buildOutputProvider> +<scannerInfoProvider id="com.crt.advproject.specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-c++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="com.crt.advproject.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="false" filePath=""/> +<parser enabled="false"/> +</buildOutputProvider> +<scannerInfoProvider id="com.crt.advproject.specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file} " command="arm-none-eabi-gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="com.crt.advproject.GASManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="false" filePath=""/> +<parser enabled="false"/> +</buildOutputProvider> +<scannerInfoProvider id="com.crt.advproject.specsFile"> +<runAction arguments="-x assembler-with-cpp -E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</storageModule> +<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> +</cconfiguration> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<project id="cbed.com.crt.advproject.projecttype.lib.476666337" name="Static Library" projectType="com.crt.advproject.projecttype.lib"/> +</storageModule> +<storageModule moduleId="com.crt.config"> +<projectStorage><?xml version="1.0" encoding="UTF-8"?> +<TargetConfig> +<Properties property_0="" property_1="" property_2="" property_3="NXP" property_4="LPC1768" property_count="5" version="1"/> +<infoList vendor="NXP"> +<info chip="LPC1768" match_id="0x00013f37,0x26013F37,0x26113F37" name="LPC1768" package="lpc17_lqfp100.xml"> +<chip> +<name>LPC1768</name> +<family>LPC17xx</family> +<vendor>NXP (formerly Philips)</vendor> +<reset board="None" core="Real" sys="Real"/> +<clock changeable="TRUE" freq="20MHz" is_accurate="TRUE"/> +<memory can_program="true" id="Flash" is_ro="true" type="Flash"/> +<memory id="RAM" type="RAM"/> +<memory id="Periph" is_volatile="true" type="Peripheral"/> +<memoryInstance derived_from="Flash" id="MFlash512" location="0x00000000" size="0x80000"/> +<memoryInstance derived_from="RAM" id="RamLoc32" location="0x10000000" size="0x8000"/> +<memoryInstance derived_from="RAM" id="RamAHB32" location="0x2007c000" size="0x8000"/> +<prog_flash blocksz="0x1000" location="0" maxprgbuff="0x1000" progwithcode="TRUE" size="0x10000"/> +<prog_flash blocksz="0x8000" location="0x10000" maxprgbuff="0x1000" progwithcode="TRUE" size="0x70000"/> +<peripheralInstance derived_from="LPC17_NVIC" determined="infoFile" id="NVIC" location="0xE000E000"/> +<peripheralInstance derived_from="TIMER" determined="infoFile" enable="SYSCTL.PCONP.PCTIM0&amp;0x1" id="TIMER0" location="0x40004000"/> +<peripheralInstance derived_from="TIMER" determined="infoFile" enable="SYSCTL.PCONP.PCTIM1&amp;0x1" id="TIMER1" location="0x40008000"/> +<peripheralInstance derived_from="TIMER" determined="infoFile" enable="SYSCTL.PCONP.PCTIM2&amp;0x1" id="TIMER2" location="0x40090000"/> +<peripheralInstance derived_from="TIMER" determined="infoFile" enable="SYSCTL.PCONP.PCTIM3&amp;0x1" id="TIMER3" location="0x40094000"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO0" location="0x2009C000"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO1" location="0x2009C020"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO2" location="0x2009C040"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO3" location="0x2009C060"/> +<peripheralInstance derived_from="FGPIO" determined="infoFile" enable="SYSCTL.PCONP.PCGPIO&amp;0x1" id="GPIO4" location="0x2009C080"/> +<peripheralInstance derived_from="LPC17_I2S" determined="infoFile" enable="SYSCTL.PCONP&amp;0x08000000" id="I2S" location="0x400A8000"/> +<peripheralInstance derived_from="LPC17_SYSCTL" determined="infoFile" id="SYSCTL" location="0x400FC000"/> +<peripheralInstance derived_from="LPC17_DAC" determined="infoFile" enable="PCB.PINSEL1.P0_26&amp;0x2=2" id="DAC" location="0x4008C000"/> +<peripheralInstance derived_from="LPC17xx_UART" determined="infoFile" enable="SYSCTL.PCONP.PCUART0&amp;0x1" id="UART0" location="0x4000C000"/> +<peripheralInstance derived_from="LPC17xx_UART_MODEM" determined="infoFile" enable="SYSCTL.PCONP.PCUART1&amp;0x1" id="UART1" location="0x40010000"/> +<peripheralInstance derived_from="LPC17xx_UART" determined="infoFile" enable="SYSCTL.PCONP.PCUART2&amp;0x1" id="UART2" location="0x40098000"/> +<peripheralInstance derived_from="LPC17xx_UART" determined="infoFile" enable="SYSCTL.PCONP.PCUART3&amp;0x1" id="UART3" location="0x4009C000"/> +<peripheralInstance derived_from="SPI" determined="infoFile" enable="SYSCTL.PCONP.PCSPI&amp;0x1" id="SPI" location="0x40020000"/> +<peripheralInstance derived_from="LPC17_SSP" determined="infoFile" enable="SYSCTL.PCONP.PCSSP0&amp;0x1" id="SSP0" location="0x40088000"/> +<peripheralInstance derived_from="LPC17_SSP" determined="infoFile" enable="SYSCTL.PCONP.PCSSP1&amp;0x1" id="SSP1" location="0x40030000"/> +<peripheralInstance derived_from="LPC17_ADC" determined="infoFile" enable="SYSCTL.PCONP.PCAD&amp;0x1" id="ADC" location="0x40034000"/> +<peripheralInstance derived_from="LPC17_USBINTST" determined="infoFile" enable="USBCLKCTL.USBClkCtrl&amp;0x12" id="USBINTSTAT" location="0x400fc1c0"/> +<peripheralInstance derived_from="LPC17_USB_CLK_CTL" determined="infoFile" id="USBCLKCTL" location="0x5000cff4"/> +<peripheralInstance derived_from="LPC17_USBDEV" determined="infoFile" enable="USBCLKCTL.USBClkSt&amp;0x12=0x12" id="USBDEV" location="0x5000C200"/> +<peripheralInstance derived_from="LPC17_PWM" determined="infoFile" enable="SYSCTL.PCONP.PWM1&amp;0x1" id="PWM" location="0x40018000"/> +<peripheralInstance derived_from="LPC17_I2C" determined="infoFile" enable="SYSCTL.PCONP.PCI2C0&amp;0x1" id="I2C0" location="0x4001C000"/> +<peripheralInstance derived_from="LPC17_I2C" determined="infoFile" enable="SYSCTL.PCONP.PCI2C1&amp;0x1" id="I2C1" location="0x4005C000"/> +<peripheralInstance derived_from="LPC17_I2C" determined="infoFile" enable="SYSCTL.PCONP.PCI2C2&amp;0x1" id="I2C2" location="0x400A0000"/> +<peripheralInstance derived_from="LPC17_DMA" determined="infoFile" enable="SYSCTL.PCONP.PCGPDMA&amp;0x1" id="DMA" location="0x50004000"/> +<peripheralInstance derived_from="LPC17_ENET" determined="infoFile" enable="SYSCTL.PCONP.PCENET&amp;0x1" id="ENET" location="0x50000000"/> +<peripheralInstance derived_from="CM3_DCR" determined="infoFile" id="DCR" location="0xE000EDF0"/> +<peripheralInstance derived_from="LPC17_PCB" determined="infoFile" id="PCB" location="0x4002c000"/> +<peripheralInstance derived_from="LPC17_QEI" determined="infoFile" enable="SYSCTL.PCONP.PCQEI&amp;0x1" id="QEI" location="0x400bc000"/> +<peripheralInstance derived_from="LPC17_USBHOST" determined="infoFile" enable="USBCLKCTL.USBClkSt&amp;0x11=0x11" id="USBHOST" location="0x5000C000"/> +<peripheralInstance derived_from="LPC17_USBOTG" determined="infoFile" enable="USBCLKCTL.USBClkSt&amp;0x1c=0x1c" id="USBOTG" location="0x5000C000"/> +<peripheralInstance derived_from="LPC17_RTC" determined="infoFile" enable="SYSCTL.PCONP.PCRTC&amp;0x1" id="RTC" location="0x40024000"/> +<peripheralInstance derived_from="MPU" determined="infoFile" id="MPU" location="0xE000ED90"/> +<peripheralInstance derived_from="LPC1x_WDT" determined="infoFile" id="WDT" location="0x40000000"/> +<peripheralInstance derived_from="LPC17_FLASHCFG" determined="infoFile" id="FLASHACCEL" location="0x400FC000"/> +<peripheralInstance derived_from="GPIO_INT" determined="infoFile" id="GPIOINTMAP" location="0x40028080"/> +<peripheralInstance derived_from="LPC17_CANAFR" determined="infoFile" enable="SYSCTL.PCONP.PCCAN1&amp;0x1|SYSCTL.PCONP.PCCAN2&amp;0x1" id="CANAFR" location="0x4003C000"/> +<peripheralInstance derived_from="LPC17_CANCEN" determined="infoFile" enable="SYSCTL.PCONP.PCCAN1&amp;0x1|SYSCTL.PCONP.PCCAN2&amp;0x1" id="CANCEN" location="0x40040000"/> +<peripheralInstance derived_from="LPC17_CANWAKESLEEP" determined="infoFile" id="CANWAKESLEEP" location="0x400FC110"/> +<peripheralInstance derived_from="LPC17_CANCON" determined="infoFile" enable="SYSCTL.PCONP.PCCAN1&amp;0x1" id="CANCON1" location="0x40044000"/> +<peripheralInstance derived_from="LPC17_CANCON" determined="infoFile" enable="SYSCTL.PCONP.PCCAN2&amp;0x1" id="CANCON2" location="0x40048000"/> +</chip> +<processor> +<name gcc_name="cortex-m3">Cortex-M3</name> +<family>Cortex-M</family> +</processor> +<link href="nxp_lpcxxxx_peripheral.xme" show="embed" type="simple"/> +</info> +</infoList> +</TargetConfig></projectStorage> +</storageModule> +</cproject> Added: trunk/cbed/.project =================================================================== --- trunk/cbed/.project (rev 0) +++ trunk/cbed/.project 2011-03-19 19:35:58 UTC (rev 4) @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>cbed</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + <dictionary> + <key>?name?</key> + <value></value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.append_environment</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.autoBuildTarget</key> + <value>all</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildArguments</key> + <value></value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildCommand</key> + <value>make</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildLocation</key> + <value>${workspace_loc:/cbed/Debug}</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.cleanBuildTarget</key> + <value>clean</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.contents</key> + <value>org.eclipse.cdt.make.core.activeConfigSettings</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableAutoBuild</key> + <value>false</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableCleanBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableFullBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.fullBuildTarget</key> + <value>all</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.stopOnError</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key> + <value>true</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2011-03-19 19:33:45
|
Revision: 3 http://cbed.svn.sourceforge.net/cbed/?rev=3&view=rev Author: stl-ajk Date: 2011-03-19 19:33:38 +0000 (Sat, 19 Mar 2011) Log Message: ----------- Initial import Added Paths: ----------- trunk/ trunk/cbed/ trunk/cbed/cbed.h trunk/cbed/inc/ trunk/cbed/inc/iomacros.h trunk/cbed/inc/ticker.h trunk/cbed/src/ trunk/cbed/src/ticker.c trunk/cbed/src/uart0.c trunk/cbed/src/uart1.c trunk/cbed/src/uart2.c trunk/cbed/src/uart3.c trunk/cbed/src/uartx.h Added: trunk/cbed/cbed.h =================================================================== --- trunk/cbed/cbed.h (rev 0) +++ trunk/cbed/cbed.h 2011-03-19 19:33:38 UTC (rev 3) @@ -0,0 +1,53 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file cbed.h + * @purpose The main cbed library header. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + + + +#ifndef CBED_CBED_H +#define CBED_CBED_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <time.h> + +#include "iomacros.h" +#include "ticker.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif Added: trunk/cbed/inc/iomacros.h =================================================================== --- trunk/cbed/inc/iomacros.h (rev 0) +++ trunk/cbed/inc/iomacros.h 2011-03-19 19:33:38 UTC (rev 3) @@ -0,0 +1,426 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file iomacros.h + * @purpose Handles GPIO pins. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#ifndef CBED_IOMACROS_H +#define CBED_IOMACROS_H + +#ifndef __LPC17xx_H__ +#include "LPC17xx.h" +#endif + +#define PIN_PULLUP 0UL +#define PIN_REPEAT 1UL +#define PIN_NONE 2UL +#define PIN_PULLDOWN 3UL + +/* p5 is P0.9 */ +#define p5_SEL_MASK ~(3UL << 18) +#define p5_SET_MASK (1UL << 9) +#define p5_CLR_MASK ~(p5_SET_MASK) +#define p5_AS_OUTPUT LPC_PINCON->PINSEL0&=p5_SEL_MASK;LPC_GPIO0->FIODIR|=p5_SET_MASK +#define p5_AS_INPUT LPC_GPIO0->FIOMASK &= p5_CLR_MASK; +#define p5_SET LPC_GPIO0->FIOSET = p5_SET_MASK +#define p5_CLR LPC_GPIO0->FIOCLR = p5_SET_MASK +#define p5_IS_SET (bool)(LPC_GPIO0->FIOPIN & p5_SET_MASK) +#define p5_IS_CLR !(p5_IS_SET) +#define p5_MODE(x) LPC_PINCON->PINMODE0&=p5_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<18) + +/* p6 is P0.8 */ +#define p6_SEL_MASK ~(3UL << 16) +#define p6_SET_MASK (1UL << 8) +#define p6_CLR_MASK ~(p6_SET_MASK) +#define p6_AS_OUTPUT LPC_PINCON->PINSEL0&=p6_SEL_MASK;LPC_GPIO0->FIODIR|=p6-SET_MASK +#define p6_AS_INPUT LPC_GPIO0->FIOMASK &= p6_CLR_MASK; +#define p6_SET LPC_GPIO0->FIOSET = p6_SET_MASK +#define p6_CLR LPC_GPIO0->FIOCLR = p6_SET_MASK +#define p6_IS_SET (bool)(LPC_GPIO0->FIOPIN & p6_SET_MASK) +#define p6_IS_CLR !(p6_IS_SET) +#define p6_MODE(x) LPC_PINCON->PINMODE0&=p6_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<16) + +/* p7 is P0.7 */ +#define p7_SEL_MASK ~(3UL << 14) +#define p7_SET_MASK (1UL << 7) +#define p7_CLR_MASK ~(p7_SET_MASK) +#define p7_AS_OUTPUT LPC_PINCON->PINSEL0&=p7_SEL_MASK;LPC_GPIO0->FIODIR|=p7_SET_MASK +#define p7_AS_INPUT LPC_GPIO0->FIOMASK &= p7_CLR_MASK; +#define p7_SET LPC_GPIO0->FIOSET = p7_SET_MASK +#define p7_CLR LPC_GPIO0->FIOCLR = p7_SET_MASK +#define p7_IS_SET (bool)(LPC_GPIO0->FIOPIN & p7_SET_MASK) +#define p7_IS_CLR !(p7_IS_SET) +#define p7_MODE(x) LPC_PINCON->PINMODE0&=p7_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<14) + +/* p8 is P0.6 */ +#define p8_SEL_MASK ~(3UL << 12) +#define p8_SET_MASK (1UL << 6) +#define p8_CLR_MASK ~(p8_SET_MASK) +#define p8_AS_OUTPUT LPC_PINCON->PINSEL0&=p8_SEL_MASK;LPC_GPIO0->FIODIR|=p8_SET_MASK +#define p8_AS_INPUT LPC_GPIO0->FIOMASK &= p8_CLR_MASK; +#define p8_SET LPC_GPIO0->FIOSET = p8_SET_MASK +#define p8_CLR LPC_GPIO0->FIOCLR = p8_SET_MASK +#define p8_IS_SET (bool)(LPC_GPIO0->FIOPIN & p8_SET_MASK) +#define p8_IS_CLR !(p8_IS_SET) +#define p8_MODE(x) LPC_PINCON->PINMODE0&=p8_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<12) + +/* p9 is P0.0 */ +#define p9_SEL_MASK ~(3UL << 0) +#define p9_SET_MASK (1UL << 0) +#define p9_CLR_MASK ~(p9_SET_MASK) +#define p9_AS_OUTPUT LPC_PINCON->PINSEL0&=p9_SEL_MASK;LPC_GPIO0->FIODIR|=p9_SET_MASK +#define p9_AS_INPUT LPC_GPIO0->FIOMASK &= p9_CLR_MASK; +#define p9_SET LPC_GPIO0->FIOSET = p9_SET_MASK +#define p9_CLR LPC_GPIO0->FIOCLR = p9_SET_MASK +#define p9_IS_SET (bool)(LPC_GPIO0->FIOPIN & p9_SET_MASK) +#define p9_IS_CLR !(p9_IS_SET) +#define p9_MODE(x) LPC_PINCON->PINMODE0&=p9_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<0) + +/* p10 is P0.1 */ +#define p10_SEL_MASK ~(3UL << 2) +#define p10_SET_MASK (1UL << 1) +#define p10_CLR_MASK ~(p10_SET_MASK) +#define p10_AS_OUTPUT LPC_PINCON->PINSEL0&=p10_SEL_MASK;LPC_GPIO0->FIODIR|=p10_SET_MASK +#define p10_AS_INPUT LPC_GPIO0->FIOMASK &= p10_CLR_MASK; +#define p10_SET LPC_GPIO0->FIOSET = p10_SET_MASK +#define p10_CLR LPC_GPIO0->FIOCLR = p10_SET_MASK +#define p10_IS_SET (bool)(LPC_GPIO0->FIOPIN & p10_SET_MASK) +#define p10_IS_CLR !(p10_IS_SET) +#define p10_MODE(x) LPC_PINCON->PINMODE0&=p10_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<2) + +/* p11 is P0.18 */ +#define p11_SEL_MASK ~(3UL << 4) +#define p11_SET_MASK (1UL << 18) +#define p11_CLR_MASK ~(p11_SET_MASK) +#define p11_AS_OUTPUT LPC_PINCON->PINSEL1&=p11_SEL_MASK;LPC_GPIO0->FIODIR|=p11_SET_MASK +#define p11_AS_INPUT LPC_GPIO0->FIOMASK &= p11_CLR_MASK; +#define p11_SET LPC_GPIO0->FIOSET = p11_SET_MASK +#define p11_CLR LPC_GPIO0->FIOCLR = p11_SET_MASK +#define p11_IS_SET (bool)(LPC_GPIO0->FIOPIN & p11_SET_MASK) +#define p11_IS_CLR !(p11_IS_SET) +#define p11_MODE(x) LPC_PINCON->PINMODE1&=p11_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<4) + +/* p12 is P0.17 */ +#define p12_SEL_MASK ~(3UL << 2) +#define p12_SET_MASK (1UL << 17) +#define p12_CLR_MASK ~(p12_SET_MASK) +#define p12_AS_OUTPUT LPC_PINCON->PINSEL1&=p12_SEL_MASK;LPC_GPIO0->FIODIR|=p12_SET_MASK +#define p12_AS_INPUT LPC_GPIO0->FIOMASK &= p12_CLR_MASK; +#define p12_SET LPC_GPIO0->FIOSET = p12_SET_MASK +#define p12_CLR LPC_GPIO0->FIOCLR = p12_SET_MASK +#define p12_IS_SET (bool)(LPC_GPIO0->FIOPIN & p12_SET_MASK) +#define p12_IS_CLR !(p12_IS_SET) +#define p12_MODE(x) LPC_PINCON->PINMODE1&=p12_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<2) + +/* p13 is P0.15 */ +#define p13_SEL_MASK ~(3UL << 30) +#define p13_SET_MASK (1UL << 15) +#define p13_CLR_MASK ~(p13_SET_MASK) +#define p13_AS_OUTPUT LPC_PINCON->PINSEL0&=p13_SEL_MASK;LPC_GPIO0->FIODIR|=p13_SET_MASK +#define p13_AS_INPUT LPC_GPIO0->FIOMASK &= p13_CLR_MASK; +#define p13_SET LPC_GPIO0->FIOSET = p13_SET_MASK +#define p13_CLR LPC_GPIO0->FIOCLR = p13_SET_MASK +#define p13_IS_SET (bool)(LPC_GPIO0->FIOPIN & p13_SET_MASK) +#define p13_IS_CLR !(p13_IS_SET) +#define p13_MODE(x) LPC_PINCON->PINMODE0&=p13_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<30) + +/* p14 is P0.16 */ +#define p14_SEL_MASK ~(3UL << 0) +#define p14_SET_MASK (1UL << 16) +#define p14_CLR_MASK ~(p14_SET_MASK) +#define p14_AS_OUTPUT LPC_PINCON->PINSEL1&=p14_SEL_MASK;LPC_GPIO0->FIODIR|=p14_SET_MASK +#define p14_AS_INPUT LPC_GPIO0->FIOMASK &= p14_CLR_MASK; +#define p14_SET LPC_GPIO0->FIOSET = p14_SET_MASK +#define p14_CLR LPC_GPIO0->FIOCLR = p14_SET_MASK +#define p14_IS_SET (bool)(LPC_GPIO0->FIOPIN & p14_SET_MASK) +#define p14_IS_CLR !(p14_IS_SET) +#define p14_MODE(x) LPC_PINCON->PINMODE1&=p14_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<0) + +/* p15 is P0.23 */ +#define p15_SEL_MASK ~(3UL << 14) +#define p15_SET_MASK (1UL << 23) +#define p15_CLR_MASK ~(p15_SET_MASK) +#define p15_AS_OUTPUT LPC_PINCON->PINSEL1&=p15_SEL_MASK;LPC_GPIO0->FIODIR|=p15_SET_MASK +#define p15_AS_INPUT LPC_GPIO0->FIOMASK &= p15_CLR_MASK; +#define p15_SET LPC_GPIO0->FIOSET = p15_SET_MASK +#define p15_CLR LPC_GPIO0->FIOCLR = p15_SET_MASK +#define p15_IS_SET (bool)(LPC_GPIO0->FIOPIN & p15_SET_MASK) +#define p15_IS_CLR !(p15_IS_SET) +#define p15_MODE(x) LPC_PINCON->PINMODE1&=p15_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<14) + +/* p16 is P0.24 */ +#define p16_SEL_MASK ~(3UL << 16) +#define p16_SET_MASK (1UL << 24) +#define p16_CLR_MASK ~(p16_SET_MASK) +#define p16_AS_OUTPUT LPC_PINCON->PINSEL1&=p16_SEL_MASK;LPC_GPIO0->FIODIR|=p16_SET_MASK +#define p16_AS_INPUT LPC_GPIO0->FIOMASK &= p16_CLR_MASK; +#define p16_SET LPC_GPIO0->FIOSET = p16_SET_MASK +#define p16_CLR LPC_GPIO0->FIOCLR = p16_SET_MASK +#define p16_IS_SET (bool)(LPC_GPIO0->FIOPIN & p16_SET_MASK) +#define p16_IS_CLR !(p16_IS_SET) +#define p16_MODE(x) LPC_PINCON->PINMODE1&=p16_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<16) + +/* p17 is P0.25 */ +#define p17_SEL_MASK ~(3UL << 18) +#define p17_SET_MASK (1UL << 25) +#define p17_CLR_MASK ~(p17_SET_MASK) +#define p17_AS_OUTPUT LPC_PINCON->PINSEL1&=p17_SEL_MASK;LPC_GPIO0->FIODIR|=p17_SET_MASK +#define p17_AS_INPUT LPC_GPIO0->FIOMASK &= p17_CLR_MASK; +#define p17_SET LPC_GPIO0->FIOSET = p17_SET_MASK +#define p17_CLR LPC_GPIO0->FIOCLR = p17_SET_MASK +#define p17_IS_SET (bool)(LPC_GPIO0->FIOPIN & p17_SET_MASK) +#define p17_IS_CLR !(p17_IS_SET) +#define p17_MODE(x) LPC_PINCON->PINMODE1&=p17_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<18) + +/* p18 is P0.26 */ +#define p18_SEL_MASK ~(3UL << 20) +#define p18_SET_MASK (1UL << 26) +#define p18_CLR_MASK ~(p18_SET_MASK) +#define p18_AS_OUTPUT LPC_PINCON->PINSEL1&=p18_SEL_MASK;LPC_GPIO0->FIODIR|=p18_SET_MASK +#define p18_AS_INPUT LPC_GPIO0->FIOMASK &= p18_CLR_MASK; +#define p18_SET LPC_GPIO0->FIOSET = p18_SET_MASK +#define p18_CLR LPC_GPIO0->FIOCLR = p18_SET_MASK +#define p18_IS_SET (bool)(LPC_GPIO0->FIOPIN & p18_SET_MASK) +#define p18_IS_CLR !(p18_IS_SET) +#define p18_MODE(x) LPC_PINCON->PINMODE1&=p18_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<20) + +/* p19 is P1.30 */ +#define p19_SEL_MASK ~(3UL << 28) +#define p19_SET_MASK (1UL << 30) +#define p19_AS_OUTPUT LPC_PINCON->PINSEL3&=p19_SEL_MASK;LPC_GPIO1->FIODIR|=p19_SET_MASK +#define p19_AS_INPUT LPC_GPIO1->FIOMASK &= p19_CLR_MASK; +#define p19_SET LPC_GPIO1->FIOSET = p19_SET_MASK +#define p19_CLR LPC_GPIO1->FIOCLR = p19_SET_MASK +#define p19_IS_SET (bool)(LPC_GPIO1->FIOPIN & p19_SET_MASK) +#define p19_IS_CLR !(p19_IS_SET) +#define p19_MODE(x) LPC_PINCON->PINMODE3&=p19_SEL_MASK;LPC_PINCON->PINMODE3|=((x&0x3)<<28) + +/* p20 is P1.31 */ +#define p20_SEL_MASK ~(3UL << 30) +#define p20_SET_MASK (1UL << 31) +#define p20_CLR_MASK ~(p20_SET_MASK) +#define p20_AS_OUTPUT LPC_PINCON->PINSEL3&=p20_SEL_MASK;LPC_GPIO1->FIODIR|=p20_SET_MASK +#define p20_AS_INPUT LPC_GPIO1->FIOMASK &= p20_CLR_MASK; +#define p20_SET LPC_GPIO1->FIOSET = p20_SET_MASK +#define p20_CLR LPC_GPIO1->FIOCLR = p20_SET_MASK +#define p20_IS_SET (bool)(LPC_GPIO1->FIOPIN & p20_SET_MASK) +#define p20_IS_CLR !(p20_IS_SET) +#define p20_MODE(x) LPC_PINCON->PINMODE3&=p20_SEL_MASK;LPC_PINCON->PINMODE3|=((x&0x3)<<30) + +/* p21 is P2.5 */ +#define p21_SEL_MASK ~(3UL << 10) +#define p21_SET_MASK (1UL << 5) +#define p21_CLR_MASK ~(p21_SET_MASK) +#define p21_AS_OUTPUT LPC_PINCON->PINSEL4&=p21_SEL_MASK;LPC_GPIO2->FIODIR|=p21_SET_MASK +#define p21_AS_INPUT LPC_GPIO2->FIOMASK &= p21_CLR_MASK; +#define p21_SET LPC_GPIO2->FIOSET = p21_SET_MASK +#define p21_CLR LPC_GPIO2->FIOCLR = p21_SET_MASK +#define p21_IS_SET (bool)(LPC_GPIO2->FIOPIN & p21_SET_MASK) +#define p21_IS_CLR !(p21_IS_SET) +#define p21_TOGGLE p21_IS_SET?p21_CLR:p21_SET +#define p21_MODE(x) LPC_PINCON->PINMODE4&=p21_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<10) + +/* p22 is P2.4 */ +#define p22_SEL_MASK ~(3UL << 8) +#define p22_SET_MASK (1UL << 4) +#define p22_CLR_MASK ~(p22_SET_MASK) +#define p22_AS_OUTPUT LPC_PINCON->PINSEL4&=p22_SEL_MASK;LPC_GPIO2->FIODIR|=p22_SET_MASK +#define p22_AS_INPUT LPC_GPIO2->FIOMASK &= p22_CLR_MASK; +#define p22_SET LPC_GPIO2->FIOSET = p22_SET_MASK +#define p22_CLR LPC_GPIO2->FIOCLR = p22_SET_MASK +#define p22_IS_SET (bool)(LPC_GPIO2->FIOPIN & p22_SET_MASK) +#define p22_IS_CLR !(p22_IS_SET) +#define p22_TOGGLE p22_IS_SET?p22_CLR:p22_SET +#define p22_MODE(x) LPC_PINCON->PINMODE4&=p22_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<8) + +/* p23 is P2.3 */ +#define p23_SEL_MASK ~(3UL << 6) +#define p23_SET_MASK (1UL << 3) +#define p23_CLR_MASK ~(p23_SET_MASK) +#define p23_AS_OUTPUT LPC_PINCON->PINSEL4&=p23_SEL_MASK;LPC_GPIO2->FIODIR|=p23_SET_MASK +#define p23_AS_INPUT LPC_GPIO2->FIOMASK &= p23_CLR_MASK; +#define p23_SET LPC_GPIO2->FIOSET = p23_SET_MASK +#define p23_CLR LPC_GPIO2->FIOCLR = p23_SET_MASK +#define p23_IS_SET (bool)(LPC_GPIO2->FIOPIN & p23_SET_MASK) +#define p23_IS_CLR !(p23_IS_SET) +#define p23_TOGGLE p23_IS_SET?p23_CLR:p23_SET +#define p23_MODE(x) LPC_PINCON->PINMODE4&=p23_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<6) + +/* p24 is P2.2 */ +#define p24_SEL_MASK ~(3UL << 4) +#define p24_SET_MASK (1UL << 2) +#define p24_CLR_MASK ~(p24_SET_MASK) +#define p24_AS_OUTPUT LPC_PINCON->PINSEL4&=p24_SEL_MASK;LPC_GPIO2->FIODIR|=p24_SET_MASK +#define p24_AS_INPUT LPC_GPIO2->FIOMASK &= p24_CLR_MASK; +#define p24_SET LPC_GPIO2->FIOSET = p24_SET_MASK +#define p24_CLR LPC_GPIO2->FIOCLR = p24_SET_MASK +#define p24_IS_SET (bool)(LPC_GPIO2->FIOPIN & p24_SET_MASK) +#define p24_IS_CLR !(p24_IS_SET) +#define p24_TOGGLE p24_IS_SET?p24_CLR:p24_SET +#define p24_MODE(x) LPC_PINCON->PINMODE4&=p24_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<4) + +/* p25 is P2.1 */ +#define p25_SEL_MASK ~(3UL << 2) +#define p25_SET_MASK (1UL << 1) +#define p25_CLR_MASK ~(p25_SET_MASK) +#define p25_AS_OUTPUT LPC_PINCON->PINSEL4&=p25_SEL_MASK;LPC_GPIO2->FIODIR|=p25_SET_MASK +#define p25_AS_INPUT LPC_GPIO2->FIOMASK &= p25_CLR_MASK; +#define p25_SET LPC_GPIO2->FIOSET = p25_SET_MASK +#define p25_CLR LPC_GPIO2->FIOCLR = p25_SET_MASK +#define p25_IS_SET (bool)(LPC_GPIO2->FIOPIN & p25_SET_MASK) +#define p25_IS_CLR !(p25_IS_SET) +#define p25_MODE(x) LPC_PINCON->PINMODE4&=p25_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<2) + +/* p26 is P2.0 */ +#define p26_SEL_MASK ~(3UL << 0) +#define p26_SET_MASK (1UL << 0) +#define p26_CLR_MASK ~(p26_SET_MASK) +#define p26_AS_OUTPUT LPC_PINCON->PINSEL4&=p26_SEL_MASK;LPC_GPIO2->FIODIR|=p26_SET_MASK +#define p26_AS_INPUT LPC_GPIO2->FIOMASK &= p26_CLR_MASK; +#define p26_SET LPC_GPIO2->FIOSET = p26_SET_MASK +#define p26_CLR LPC_GPIO2->FIOCLR = p26_SET_MASK +#define p26_IS_SET (bool)(LPC_GPIO2->FIOPIN & p26_SET_MASK) +#define p26_IS_CLR !(p26_IS_SET) +#define p26_MODE(x) LPC_PINCON->PINMODE4&=p26_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<0) + +/* p27 is P0.11 */ +#define p27_SEL_MASK ~(3UL << 22) +#define p27_SET_MASK (1UL << 11) +#define p27_CLR_MASK ~(p27_SET_MASK) +#define p27_AS_OUTPUT LPC_PINCON->PINSEL0&=p27_SEL_MASK;LPC_GPIO0->FIODIR|=p27_SET_MASK +#define p27_AS_INPUT LPC_GPIO0->FIOMASK &= p27_CLR_MASK; +#define p27_SET LPC_GPIO0->FIOSET = p27_SET_MASK +#define p27_CLR LPC_GPIO0->FIOCLR = p27_SET_MASK +#define p27_IS_SET (bool)(LPC_GPIO0->FIOPIN & p27_SET_MASK) +#define p27_IS_CLR !(p27_IS_SET) +#define p27_MODE(x) LPC_PINCON->PINMODE0&=p27_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<22) + +/* p28 is P0.10 */ +#define p28_SEL_MASK ~(3UL << 20) +#define p28_SET_MASK (1UL << 10) +#define p28_CLR_MASK ~(p28_SET_MASK) +#define p28_AS_OUTPUT LPC_PINCON->PINSEL0&=p28_SEL_MASK;LPC_GPIO0->FIODIR|=p28_SET_MASK +#define p28_AS_INPUT LPC_GPIO0->FIOMASK &= p28_CLR_MASK; +#define p28_SET LPC_GPIO0->FIOSET = p28_SET_MASK +#define p28_CLR LPC_GPIO0->FIOCLR = p28_SET_MASK +#define p28_IS_SET (bool)(LPC_GPIO0->FIOPIN & p28_SET_MASK) +#define p28_IS_CLR !(p28_IS_SET) +#define p28_MODE(x) LPC_PINCON->PINMODE0&=p28_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<20) + +/* p29 is P0.5 */ +#define p29_SEL_MASK ~(3UL << 10) +#define p29_SET_MASK (1UL << 5) +#define p29_CLR_MASK ~(p29_SET_MASK) +#define p29_AS_OUTPUT LPC_PINCON->PINSEL0&=p29_SEL_MASK;LPC_GPIO0->FIODIR|=p29_SET_MASK +#define p29_AS_INPUT LPC_GPIO0->FIOMASK &= p29_CLR_MASK; +#define p29_SET LPC_GPIO0->FIOSET = p29_SET_MASK +#define p29_CLR LPC_GPIO0->FIOCLR = p29_SET_MASK +#define p29_IS_SET (bool)(LPC_GPIO0->FIOPIN & p29_SET_MASK) +#define p29_IS_CLR !(p29_IS_SET) +#define p29_TOGGLE p29_IS_SET?p29_CLR:p29_SET +#define p29_MODE(x) LPC_PINCON->PINMODE0&=p29_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<10) + +/* p30 is P0.4 */ +#define p30_SEL_MASK ~(3UL << 8) +#define p30_SET_MASK (1UL << 4) +#define p30_CLR_MASK ~(p30_SET_MASK) +#define p30_AS_OUTPUT LPC_PINCON->PINSEL0&=p30_SEL_MASK;LPC_GPIO0->FIODIR|=p30_SET_MASK +#define p30_AS_INPUT LPC_GPIO0->FIOMASK &= p30_CLR_MASK; +#define p30_SET LPC_GPIO0->FIOSET = p30_SET_MASK +#define p30_CLR LPC_GPIO0->FIOCLR = p30_SET_MASK +#define p30_IS_SET (bool)(LPC_GPIO0->FIOPIN & p30_SET_MASK) +#define p30_IS_CLR !(p30_IS_SET) +#define p30_MODE(x) LPC_PINCON->PINMODE0&=p30_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<8) + +/* The following definitions are for the four Mbed LEDs. + LED1 = P1.18 + LED2 = P1.20 + LED3 = P1.21 + LED4 = P1.23 */ + +#define P1_18_SEL_MASK ~(3UL << 4) +#define P1_18_SET_MASK (1UL << 18) +#define P1_18_CLR_MASK ~(P1_18_SET_MASK) +#define P1_18_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_18_SEL_MASK;LPC_GPIO1->FIODIR|=P1_18_SET_MASK +#define P1_18_AS_INPUT LPC_GPIO1->FIOMASK &= P1_18_CLR_MASK; +#define P1_18_SET LPC_GPIO1->FIOSET = P1_18_SET_MASK +#define P1_18_CLR LPC_GPIO1->FIOCLR = P1_18_SET_MASK +#define P1_18_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_18_SET_MASK) +#define P1_18_IS_CLR !(P1_18_IS_SET) +#define LED1_USE P1_18_AS_OUTPUT;P1_18_AS_INPUT +#define LED1_ON P1_18_SET +#define LED1_OFF P1_18_CLR +#define LED1_IS_ON P1_18_IS_SET +#define LED1_TOGGLE P1_18_IS_SET?LED1_OFF:LED1_ON + +#define P1_20_SEL_MASK ~(3UL << 8) +#define P1_20_SET_MASK (1UL << 20) +#define P1_20_CLR_MASK ~(P1_20_SET_MASK) +#define P1_20_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_20_SEL_MASK;LPC_GPIO1->FIODIR|=P1_20_SET_MASK +#define P1_20_AS_INPUT LPC_GPIO1->FIOMASK &= P1_20_CLR_MASK; +#define P1_20_SET LPC_GPIO1->FIOSET = P1_20_SET_MASK +#define P1_20_CLR LPC_GPIO1->FIOCLR = P1_20_SET_MASK +#define P1_20_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_20_SET_MASK) +#define P1_20_IS_CLR !(P1_20_IS_SET) +#define LED2_USE P1_20_AS_OUTPUT;P1_20_AS_INPUT +#define LED2_ON P1_20_SET +#define LED2_OFF P1_20_CLR +#define LED2_IS_ON P1_20_IS_SET +#define LED2_TOGGLE P1_20_IS_SET?LED2_OFF:LED2_ON + +#define P1_21_SEL_MASK ~(3UL << 10) +#define P1_21_SET_MASK (1UL << 21) +#define P1_21_CLR_MASK ~(P1_21_SET_MASK) +#define P1_21_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_21_SEL_MASK;LPC_GPIO1->FIODIR|=P1_21_SET_MASK +#define P1_21_AS_INPUT LPC_GPIO1->FIOMASK &= P1_21_CLR_MASK; +#define P1_21_SET LPC_GPIO1->FIOSET = P1_21_SET_MASK +#define P1_21_CLR LPC_GPIO1->FIOCLR = P1_21_SET_MASK +#define P1_21_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_21_SET_MASK) +#define P1_21_IS_CLR !(P1_21_IS_SET) +#define LED3_USE P1_21_AS_OUTPUT;P1_21_AS_INPUT +#define LED3_ON P1_21_SET +#define LED3_OFF P1_21_CLR +#define LED3_IS_ON P1_21_IS_SET +#define LED3_TOGGLE P1_21_IS_SET?LED3_OFF:LED3_ON + +#define P1_23_SEL_MASK ~(3UL << 14) +#define P1_23_SET_MASK (1UL << 23) +#define P1_23_CLR_MASK ~(P1_23_SET_MASK) +#define P1_23_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_23_SEL_MASK;LPC_GPIO1->FIODIR|=P1_23_SET_MASK +#define P1_23_AS_INPUT LPC_GPIO1->FIOMASK &= P1_23_CLR_MASK; +#define P1_23_SET LPC_GPIO1->FIOSET = P1_23_SET_MASK +#define P1_23_CLR LPC_GPIO1->FIOCLR = P1_23_SET_MASK +#define P1_23_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_23_SET_MASK) +#define P1_23_IS_CLR !(P1_23_IS_SET) +#define LED4_USE P1_23_AS_OUTPUT;P1_23_AS_INPUT +#define LED4_ON P1_23_SET +#define LED4_OFF P1_23_CLR +#define LED4_IS_ON P1_23_IS_SET +#define LED4_TOGGLE P1_23_IS_SET?LED4_OFF:LED4_ON + +#endif + Added: trunk/cbed/inc/ticker.h =================================================================== --- trunk/cbed/inc/ticker.h (rev 0) +++ trunk/cbed/inc/ticker.h 2011-03-19 19:33:38 UTC (rev 3) @@ -0,0 +1,98 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file ticker.h + * @purpose Handles tickers, timeouts, timers and wait api. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#ifndef CBED_TICKER_H +#define CBED_TICKER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <time.h> +#include <stdint.h> +#include "LPC17xx.h" +#include "../cbedopts.h" + +#define CBED_TICKER 1 +#define CBED_TIMER 2 + +#define CBED_TIME_RUN (1UL << 0) +#define CBED_TIME_WRAPPED (1UL << 1) + +typedef struct _ticker_t { + _ticker_t *next; + union { + struct { + void (*callback)(_ticker_t *); + uint32_t counter; + uint32_t reload; + } ticker; + struct { + uint32_t unused; /* Aligns with "ticker.callback" */ + uint64_t time; + uint64_t start; + } timer; + } data; +} ticker_t; + +#define timeout_t ticker_t +#define timer_t ticker_t + +#define timer_value(x) ((x)->data.timer.time) + +void ticker_attach(ticker_t *p, void (*f)(_ticker_t *), uint32_t ms); +void ticker_detach(ticker_t *p); + +void timeout_attach(ticker_t *p, void (*f)(_ticker_t *), uint32_t ms); +void timeout_detach(ticker_t *p); + +void timer_setup(timer_t *p); +void timer_begin(timer_t *p); +void timer_stall(timer_t *p); +void timer_run(timer_t *p); +void timer_reset(timer_t *p); +uint64_t timer_get(timer_t *p); + +uint64_t time_since(void); + +void cbed_wait_us(uint32_t us); +void cbed_wait_ms(uint32_t ms); +void cbed_wait(double s); + +#ifdef __cplusplus +} +#endif + +#endif + Added: trunk/cbed/src/ticker.c =================================================================== --- trunk/cbed/src/ticker.c (rev 0) +++ trunk/cbed/src/ticker.c 2011-03-19 19:33:38 UTC (rev 3) @@ -0,0 +1,520 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file ticker.c + * @purpose Handles tickers, timeouts, timers and wait api. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +/** @defgroup API The CBED API */ +/** @defgroup CBedTimer The CBED Timer functions */ +/** @defgroup MISC Misc CBED functions */ +/** @defgroup INTERNALS CBED Internals */ + +#include "stdlib.h" +#include "cmsis_nvic.h" +#include "ticker.h" +#include "iomacros.h" + +#ifndef TICKERSYS_TIMER_CUSTOM +#define TICKERSYS_PCONP (1UL << 23) +#define TICKERSYS_PCLKSEL LPC_SC->PCLKSEL1 +#define TICKERSYS_PCLKSEL_VALUE (3UL << 14) +#define TICKERSYS_TCR LPC_TIM3->TCR +#define TICKERSYS_PR LPC_TIM3->PR +#define TICKERSYS_MCR LPC_TIM3->MCR +#define TICKERSYS_MR0 LPC_TIM3->MR0 +#define TICKERSYS_TC LPC_TIM3->TC +#define TICKERSYS_IR LPC_TIM3->IR +#define TICKERSYS_IRQn TIMER3_IRQn +#define TICKERSYS_TICK 1000 +#else +#define TICKERSYS_PCONP TICKERSYS_TIMER_PCONP +#define TICKERSYS_PCLKSEL TICKERSYS_TIMER_PCLKSEL +#define TICKERSYS_PCLKSEL_VALUE TICKERSYS_TIMER_PCLKSEL_VALUE +#define TICKERSYS_TCR TICKERSYS_TIMER_TCR +#define TICKERSYS_PR TICKERSYS_TIMER_PR +#define TICKERSYS_MCR TICKERSYS_TIMER_MCR +#define TICKERSYS_MR0 TICKERSYS_TIMER_MR0 +#define TICKERSYS_TC TICKERSYS_TIMER_TC +#define TICKERSYS_IR TICKERSYS_TIMER_IR +#define TICKERSYS_IRQn TICKERSYS_TIMER_IRQn +#define TICKERSYS_TICK TICKERSYS_TIMER_TICK +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +static ticker_t *_header_pointer; +static int _ticker_system_live; +static uint64_t _ticker_time; +static uint32_t _ticker_last_tc; + +static void _ticker_system_remove(ticker_t *p); + +void TIMERx_IRQHandler(void) __irq +{ + ticker_t *p, *q; + + _ticker_time += 1000UL; + _ticker_last_tc = TICKERSYS_TC; + + TICKERSYS_MR0 += TICKERSYS_TICK; + p = _header_pointer; + + while(p) { + if (p->data.ticker.callback != NULL && p->data.ticker.counter > 0) { + p->data.ticker.counter--; + if (p->data.ticker.counter == 0) { + (p->data.ticker.callback)(p); + if (p->data.ticker.reload) p->data.ticker.counter = p->data.ticker.reload; + else { + q = p; + p = p->next; + _ticker_system_remove(q); + continue; + } + } + } + p = p->next; + } + + TICKERSYS_IR |= 4; +} + +static void _ticker_system_init(void) +{ + if (_ticker_system_live) return; + + _ticker_system_live = 1; + + _header_pointer = (ticker_t *)NULL; + + _ticker_last_tc = 0; + _ticker_time = 0; + + // Set-up a timer as a periodic 1ms int. + LPC_SC->PCONP |= TICKERSYS_PCONP; + TICKERSYS_PCLKSEL &= ~TICKERSYS_PCLKSEL_VALUE; + TICKERSYS_PCLKSEL |= TICKERSYS_PCLKSEL_VALUE; + TICKERSYS_PR = 11; + TICKERSYS_MCR = 1; + TICKERSYS_MR0 = TICKERSYS_TICK; + TICKERSYS_TCR = 2; + TICKERSYS_TCR = 1; + + NVIC_SetVector(TICKERSYS_IRQn, (uint32_t)TIMERx_IRQHandler); + NVIC_EnableIRQ(TICKERSYS_IRQn); +} + +/** _ticker_system_add - Add a struct instance to the linked list. + * + * @ingroup INTERNALS + * @param[in] p A pointer the data structure. + */ +static void _ticker_system_add(ticker_t *p) +{ + if (!_ticker_system_live) _ticker_system_init(); + + ticker_t *q; + + /* Ensure only one instance of this structure in the list. */ + for (q = _header_pointer; q; q = q->next) if (q == p) return; + + /* Add at the head of the list. Faster than adding at the + tail and list order is not important. */ + p->next = _header_pointer; + _header_pointer = p; +} + +/** _ticker_system_remove - Remove a struct instance from the linked list. + * + * @ingroup INTERNALS + * @param[in] p A pointer the data structure. + */ +static void _ticker_system_remove(ticker_t *p) +{ + ticker_t *q; + + /* If it's the head being removed handle that */ + if (_header_pointer == p) { + _header_pointer = p->next; + } + /* Otherwise look through the list and find it. */ + else { + q = _header_pointer; + while(q) { + if (q->next == p) { + q->next = p->next; + break; + } + q = q->next; + } + } +} + +/** ticker_attach - Attach a callback to a ticker_t data structure. + * + * Used to attach a ticker_t to a callback. + * + * @ingroup API + * @ingroup CBedTimer + * + * @code + * #include "cbed.h" + * + * ticker_t t; + * + * void toggle_led2(ticker_t *p) { LED2_TOGGLE; } + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * LED2_USE; //!< @see iomacros.h + * ticker_attach(&t, &toggle_led2, 100); + * while(1) { + * LED1_ON; + * cbed_wait(1.0); + * LED1_OFF; + * cbed_wait(1.0); + * } + * } + * @endcode + * + * @param[in] p A pointer the data structure for the ticker + * @param[in] f A function pointer to callback to. + * @param[in] ms The time period, in milliseconds, to invoke the callback. + */ +void ticker_attach(ticker_t *p, void (*f)(_ticker_t *), uint32_t ms) +{ + p->data.ticker.callback = f; + p->data.ticker.counter = ms; + p->data.ticker.reload = ms; + _ticker_system_add(p); +} + +/** ticker_detach - Detach a ticker_t data structure. + * + * Used to detach a ticker_t to a callback. + * + * @ingroup API + * @ingroup CBedTimer + * + * @param[in] p A pointer the data structure for the ticker + */ +void ticker_detach(ticker_t *p) +{ + _ticker_system_remove(p); +} + +/** timeout_attach - Attach a callback to a timeout_t data structure. + * + * Used to attach a timeout_t to a callback. <b>Note</b>, when the timeout occurs + * and after the callback has been invoked the timeout_t is automatically + * detached from the system (as though you had called <i>timeout_detact(p);</i> + * + * @ingroup API + * @ingroup CBedTimer + * + * @code + * #include "cbed.h" + * + * timeout_t t; + * + * void toggle_led2(timeout_t *p) { LED2_ON; } + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * LED2_USE; //!< @see iomacros.h + * timeout_attach(&t, &toggle_led2, 5000); + * while(1) { + * LED1_ON; + * cbed_wait(1.0); + * LED1_OFF; + * cbed_wait(1.0); + * } + * } + * @endcode + * + * @param[in] p A pointer the data structure for the timeout + * @param[in] f A function pointer to callback to. + * @param[in] ms The time period, in milliseconds, until invoking the callback. + */ +void timeout_attach(ticker_t *p, void (*f)(_ticker_t *), uint32_t ms) +{ + p->data.ticker.callback = f; + p->data.ticker.counter = ms; + p->data.ticker.reload = 0; + _ticker_system_add(p); +} + +/** timeout_detach - Detach a timeout_t data structure. + * + * Used to detach a timeout_t to a callback. Use this to + * disable a pending timeout that was set to prevent the + * callback from being made. + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timeout. + */ +void timeout_detach(ticker_t *p) +{ + _ticker_system_remove(p); +} + +/** timer_setup - Setup a timer_t structure ready for use. + * + * @code + * #include "cbed.h" + * + * timer_t t; + * + * int main() { + * LED1_USE; + * timer_setup(&t); + * while(1) { + * timer_begin(&t); + * LED1_ON; + * cbed_wait(0.5); + * LED1_OFF; + * cbed_wait(0.5); + * timer_stall(&t); + * printf("Time accumulated so far = %lld\n", timer_get(&t)); + * } + * } + * @endcode + * @see timer_begin + * @see timer_stall + * @see timer_get + * @see timer_reset + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_setup(timer_t *p) +{ + p->data.timer.unused = 0; + p->data.timer.time = 0; + _ticker_system_add(p); +} + +/** timer_reset - Reset the timer. + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_reset(timer_t *p) +{ + p->data.timer.unused = 0; + p->data.timer.time = 0; +} + +/** timer_run - Start the timer. + * + * @see timer_setup + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_run(timer_t *p) +{ + NVIC_DisableIRQ(TICKERSYS_IRQn); + p->data.timer.start = _ticker_time + (uint64_t)(TICKERSYS_TC - _ticker_last_tc); + NVIC_EnableIRQ(TICKERSYS_IRQn); +} + +/** timer_begin - Start the timer. + * + * Same as timer_run() + * + * @see timer_setup + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_begin(timer_t *p) +{ + NVIC_DisableIRQ(TICKERSYS_IRQn); + p->data.timer.start = _ticker_time + (uint64_t)(TICKERSYS_TC - _ticker_last_tc); + NVIC_EnableIRQ(TICKERSYS_IRQn); +} + +/** timer_get - Get the timer time so far as a 64bit unisgned long. + * + * This function returns the current value of the timer_t pointed to by p. + * The return type is uint64_t in microseconds. + * + * @see timer_setup + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + * @return[out] uint64_t microseconds timer_t value. + */ +uint64_t timer_get(timer_t *p) +{ + return p->data.timer.time; +} + +/** timer_stall - Halt the timer pointed to by p. + * + * This function halts the timer. Note, it does n't reset it so + * if the timer is restarted it continues accumulating the time. + * + * @see timer_setup + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_stall(timer_t *p) +{ + uint64_t diff; + NVIC_DisableIRQ(TICKERSYS_IRQn); + diff = _ticker_time - p->data.timer.start + p->data.timer.time; + p->data.timer.time = diff + (uint64_t)(TICKERSYS_TC - _ticker_last_tc); + NVIC_EnableIRQ(TICKERSYS_IRQn); +} + +/** time_since_reset - Return the number of microseconds since power-on/reset. + * + * This function returns the current numer of microseconds since the + * power-on/reset epoch. + * + * @ingroup API + * @ingroup CBedTimer + * @param[out] Number of microseconds since power-on/reset. + */ +uint64_t time_since_reset(void) +{ + return _ticker_time; +} + +/** cbed_wait_us - Wait for a period of microseconds + * + * Cause your program to delay for a period of microseconds. + * Please note, this function is generally only useable with any + * accuracy down to around 10 to 20us or so due mainly to function + * call overhead. If you require accurate microsecond timing you + * should be using a dedicated timer/capture usint and suitable + * implementation. + * + * @code + * #include "cbed.h" + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * while(1) { + * LED1_ON; + * cbed_wait_us(1000000); + * LED1_OFF; + * cbed_wait_us(1000000); + * } + * } + * @endcode + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] us The number of microseconds to wait. + */ +void cbed_wait_us(uint32_t us) +{ + volatile uint32_t x, y; + if (!_ticker_system_live) _ticker_system_init(); + x = TICKERSYS_TC + (us); + do { + y = TICKERSYS_TC; + } + while(x > y); +} + +/** cbed_wait_ms - Wait for a period of milliseconds + * + * Cause your program to delay for a period of milliseconds. + * Please note, this function is generally only useable with any + * accuracy down to around 10 to 20us or so due mainly to function + * call overhead. If you require accurate microsecond timing you + * should be using a dedicated timer/capture usint and suitable + * implementation. + * + * @code + * #include "cbed.h" + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * while(1) { + * LED1_ON; + * cbed_wait_ms(100000); + * LED1_OFF; + * cbed_wait_ms(100000); + * } + * } + * @endcode + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] ms The number of milliseconds to wait. + */ +void cbed_wait_ms(uint32_t ms) +{ + cbed_wait_us(ms * 1000); +} + +/** cbed_wait - Wait for a period of seconds + * + * Cause your program to delay for a period of seconds. + * Please note, this function is generally only useable with any + * accuracy down to around 10 to 20us or so due mainly to function + * call overhead. If you require accurate microsecond timing you + * should be using a dedicated timer/capture and suitable + * implementation. + * + * @code + * #include "cbed.h" + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * while(1) { + * LED1_ON; + * cbed_wait(1.0); + * LED1_OFF; + * cbed_wait(1.0); + * } + * } + * @endcode + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] d The number of seconds to wait (is double, fractional seconds) + */ +void cbed_wait(double d) +{ + cbed_wait_us((uint32_t)(d * 1000000.0)); +} + +#ifdef __cplusplus +} +#endif + Added: trunk/cbed/src/uart0.c =================================================================== --- trunk/cbed/src/uart0.c (rev 0) +++ trunk/cbed/src/uart0.c 2011-03-19 19:33:38 UTC (rev 3) @@ -0,0 +1,100 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file ticker.h + * @purpose Handles tickers, timeouts, timers and wait api. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include "../cbedopts.h" + +#ifdef CBED_BUILD_UART0 + +#ifdef CBED_BUILD_UART0_WITH_TX_BUFFER +#define CBED_BUILD_UARTx_WITH_TX_BUFFER CBED_BUILD_UART0_WITH_TX_BUFFER +#endif + +#ifdef CBED_BUILD_UART0_WITH_RX_BUFFER +#define CBED_BUILD_UARTx_WITH_RX_BUFFER CBED_BUILD_UART0_WITH_RX_BUFFER +#endif + +#define UARTX_tx_buffer cbed_uart0_tx_buffer +#define UARTX_tx_buffer_in cbed_uart0_tx_buffer_in +#define UARTX_tx_buffer_out cbed_uart0_tx_buffer_out +#define UARTX_tx_buffer_count cbed_uart0_tx_buffer_count + +#define UARTX_rx_buffer cbed_uart0_rx_buffer +#define UARTX_rx_buffer_in cbed_uart0_rx_buffer_in +#define UARTX_rx_buffer_out cbed_uart0_rx_buffer_out +#define UARTX_rx_buffer_count cbed_uart0_rx_buffer_count + +#define UARTX_callback_tx cbed_uart0_callback_tx +#define UARTX_callback_rx cbed_uart0_callback_rx +#define UARTX_callback_rx_overflow cbed_uart0_callback_rx_overflow + +#define UARTX_isr cbed_uart0_isr +#define UARTX_isr_tx cbed_uart0_isr_tx +#define UARTX_isr_rx cbed_uart0_isr_rx +#define UARTX__getc uart0__get +#define UARTX_getc uart0_getc +#define UARTX_putc uart0_putc + +#define UARTX_init cbed_uart0_init + +#define UARTX_IRQn UART0_IRQn + +#define UARTX_IIR LPC_UART0->IIR +#define UARTX_IER LPC_UART0->IER +#define UARTX_RBR LPC_UART0->RBR +#define UARTX_THR LPC_UART0->THR +#define UARTX_LSR LPC_UART0->LSR +#define UARTX_FCR LPC_UART0->FCR + +#define UARTX_PCONP LPC_SC->PCONP +#define UARTX_PCONP_VALUE (1UL << 3) +#define UARTX_PCLKSEL LPC_SC->PCLKSEL0 +#define UARTX_PCLKSEL_VALUE (3UL << 6) +#define UARTX_PINSEL_TX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_TX_VAL (1UL << 4) +#define UARTX_PINSEL_RX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_RX_VAL (1UL << 6) + +/* Pull in the common core uart code. */ +#include "uartx.h" + +/* For UART0 only, handle stdout/stdin redirection. */ + +#if CBED_TARGET == CBED_MBED +int __putc(int c) +{ + return 0; +} +#endif + +#if CBED_TARGET == CBED_LPCXPRESSO + +#endif + +#endif Added: trunk/cbed/src/uart1.c =================================================================== --- trunk/cbed/src/uart1.c (rev 0) +++ trunk/cbed/src/uart1.c 2011-03-19 19:33:38 UTC (rev 3) @@ -0,0 +1,87 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file uart1.c + * @purpose Builds the uart1 instance + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include "../cbedopts.h" + +#ifdef CBED_BUILD_UART1 + +#ifdef CBED_BUILD_UART1_WITH_TX_BUFFER +#define CBED_BUILD_UARTx_WITH_TX_BUFFER CBED_BUILD_UART1_WITH_TX_BUFFER +#endif + +#ifdef CBED_BUILD_UART1_WITH_RX_BUFFER +#define CBED_BUILD_UARTx_WITH_RX_BUFFER CBED_BUILD_UART1_WITH_RX_BUFFER +#endif + +#define UARTX_tx_buffer cbed_uart1_tx_buffer +#define UARTX_tx_buffer_in cbed_uart1_tx_buffer_in +#define UARTX_tx_buffer_out cbed_uart1_tx_buffer_out +#define UARTX_tx_buffer_count cbed_uart1_tx_buffer_count + +#define UARTX_rx_buffer cbed_uart1_rx_buffer +#define UARTX_rx_buffer_in cbed_uart1_rx_buffer_in +#define UARTX_rx_buffer_out cbed_uart1_rx_buffer_out +#define UARTX_rx_buffer_count cbed_uart1_rx_buffer_count + +#define UARTX_callback_tx cbed_uart1_callback_tx +#define UARTX_callback_rx cbed_uart1_callback_rx +#define UARTX_callback_rx_overflow cbed_uart1_callback_rx_overflow + +#define UARTX_isr cbed_uart1_isr +#define UARTX_isr_tx cbed_uart1_isr_tx +#define UARTX_isr_rx cbed_uart1_isr_rx +#define UARTX__getc uart1__get +#define UARTX_getc uart1_getc +#define UARTX_putc uart1_putc + +#define UARTX_init cbed_uart1_init + +#define UARTX_IRQn UART1_IRQn + +#define UARTX_IIR LPC_UART1->IIR +#define UARTX_IER LPC_UART1->IER +#define UARTX_RBR LPC_UART1->RBR +#define UARTX_THR LPC_UART1->THR +#define UARTX_LSR LPC_UART1->LSR +#define UARTX_FCR LPC_UART1->FCR + +#define UARTX_PCONP LPC_SC->PCONP +#define UARTX_PCONP_VALUE (1UL << 4) +#define UARTX_PCLKSEL LPC_SC->PCLKSEL0 +#define UARTX_PCLKSEL_VALUE (3UL << 8) +#define UARTX_PINSEL_TX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_TX_VAL (1UL << 30) +#define UARTX_PINSEL_RX LPC_PINCON->PINSEL1 +#define UARTX_PINSEL_RX_VAL (1UL << 0) + +/* Pull in the common core uart code. */ +#include "uartx.h" + +#endif Added: trunk/cbed/src/uart2.c =================================================================== --- trunk/cbed/src/uart2.c (rev 0) +++ trunk/cbed/src/uart2.c 2011-03-19 19:33:38 UTC (rev 3) @@ -0,0 +1,87 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file uart2.c + * @purpose Creates an instance of uart2 + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include "../cbedopts.h" + +#ifdef CBED_BUILD_UART2 + +#ifdef CBED_BUILD_UART2_WITH_TX_BUFFER +#define CBED_BUILD_UARTx_WITH_TX_BUFFER CBED_BUILD_UART2_WITH_TX_BUFFER +#endif + +#ifdef CBED_BUILD_UART2_WITH_RX_BUFFER +#define CBED_BUILD_UARTx_WITH_RX_BUFFER CBED_BUILD_UART2_WITH_RX_BUFFER +#endif + +#define UARTX_tx_buffer cbed_uart2_tx_buffer +#define UARTX_tx_buffer_in cbed_uart2_tx_buffer_in +#define UARTX_tx_buffer_out cbed_uart2_tx_buffer_out +#define UARTX_tx_buffer_count cbed_uart2_tx_buffer_count + +#define UARTX_rx_buffer cbed_uart2_rx_buffer +#define UARTX_rx_buffer_in cbed_uart2_rx_buffer_in +#define UARTX_rx_buffer_out cbed_uart2_rx_buffer_out +#define UARTX_rx_buffer_count cbed_uart2_rx_buffer_count + +#define UARTX_callback_tx cbed_uart2_callback_tx +#define UARTX_callback_rx cbed_uart2_callback_rx +#define UARTX_callback_rx_overflow cbed_uart2_callback_rx_overflow + +#define UARTX_isr cbed_uart2_isr +#define UARTX_isr_tx cbed_uart2_isr_tx +#define UARTX_isr_rx cbed_uart2_isr_rx +#define UARTX__getc uart2__get +#define UARTX_getc uart2_getc +#define UARTX_putc uart2_putc + +#define UARTX_init cbed_uart2_init + +#define UARTX_IRQn UART2_IRQn + +#define UARTX_IIR LPC_UART2->IIR +#define UARTX_IER LPC_UART2->IER +#define UARTX_RBR LPC_UART2->RBR +#define UARTX_THR LPC_UART2->THR +#define UARTX_LSR LPC_UART2->LSR +#define UARTX_FCR LPC_UART2->FCR + +#define UARTX_PCONP LPC_SC->PCONP +#define UARTX_PCONP_VALUE (1UL << 24) +#define UARTX_PCLKSEL LPC_SC->PCLKSEL1 +#define UARTX_PCLKSEL_VALUE (3UL << 16) +#define UARTX_PINSEL_TX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_TX_VAL (1UL << 20) +#define UARTX_PINSEL_RX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_RX_VAL (1UL << 22) + +/* Pull in the common core uart code. */ +#include "uartx.h" + +#endif Added: trunk/cbed/src/uart3.c =================================================================== --- trunk/cbed/src/uart3.c (rev 0) +++ trunk/cbed/src/uart3.c 2011-03-19 19:33:38 UTC (rev 3) @@ -0,0 +1,87 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file uart3.c + * @purpose Creates an instance of uart3 + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include "../cbedopts.h" + +#ifdef CBED_BUILD_UART3 + +#ifdef CBED_BUILD_UART3_WITH_TX_BUFFER +#define CBED_BUILD_UARTx_WITH_TX_BUFFER CBED_BUILD_UART3_WITH_TX_BUFFER +#endif + +#ifdef CBED_BUILD_UART3_WITH_RX_BUFFER +#define CBED_BUILD_UARTx_WITH_RX_BUFFER CBED_BUILD_UART3_WITH_RX_BUFFER +#endif + +#define UARTX_tx_buffer cbed_uart3_tx_buffer +#define UARTX_tx_buffer_in cbed_uart3_tx_buffer_in +#define UARTX_tx_buffer_out cbed_uart3_tx_buffer_out +#define UARTX_tx_buffer_count cbed_uart3_tx_buffer_count + +#define UARTX_rx_buffer cbed_uart3_rx_buffer +#define UARTX_rx_buffer_in cbed_uart3_rx_buffer_in +#define UARTX_rx_buffer_out cbed_uart3_rx_buffer_out +#define UARTX_rx_buffer_count cbed_uart3_rx_buffer_count + +#define UARTX_callback_tx cbed_uart3_callback_tx +#define UARTX_callback_rx cbed_uart3_callback_rx +#define UARTX_callback_rx_overflow cbed_uart3_callback_rx_overflow + +#define UARTX_isr cbed_uart3_isr +#define UARTX_isr_tx cbed_uart3_isr_tx +#define UARTX_isr_rx cbed_uart3_isr_rx +#define UARTX__getc uart3__get +#define UARTX_getc uart3_getc +#define UARTX_putc uart3_putc + +#define UARTX_init cbed_uart3_init + +#define UARTX_IRQn UART3_IRQn + +#define UARTX_IIR LPC_UART3->IIR +#define UARTX_IER LPC_UART3->IER +#define UARTX_RBR LPC_UART3->RBR +#define UARTX_THR LPC_UART3->THR +#define UARTX_LSR LPC_UART3->LSR +#define UARTX_FCR LPC_UART3->FCR + +#define UARTX_PCONP LPC_SC->PCONP +#define UARTX_PCONP_VALUE (1UL << 25) +#define UARTX_PCLKSEL LPC_SC->PCLKSEL1 +#define UARTX_PCLKSEL_VALUE (3UL << 18) +#define UARTX_PINSEL_TX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_TX_VAL (1UL << 0) +#define UARTX_PINSEL_RX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_RX_VAL (1UL << 2) + +/* Pull in the common core uart code. */ +#include "uartx.h" + +#endif Added: trunk/cbed/src/uartx.h =================================================================== --- trunk/cbed/src/uartx.h (rev 0) +++ trunk/cbed/src/uartx.h 2011-03-19 19:33:38 UTC (rev 3) @@ -0,0 +1,241 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file uartx.h + * @purpose General file that exapnds to create a UART instance. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <time.h> +#include <stdint.h> +#include "cmsis_nvic.h" +#include "LPC17xx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CBED_BUILD_UARTx_WITH_TX_BUFFER +static char UARTX_tx_buffer[CBED_BUILD_UARTx_WITH_TX_BUFFER]; +static int UARTX_tx_buffer_in; +static int UARTX_tx_buffer_out; +static int UARTX_tx_buffer_count; +#endif + +#ifdef CBED_BUILD_UARTx_WITH_RX_BUFFER +static char UARTX_rx_buffer[CBED_BUILD_UARTx_WITH_RX_BUFFER]; +static int UARTX_rx_buffer_in; +static int UARTX_rx_buffer_out; +static int UARTX_rx_buffer_count; +#endif + +void (*UARTX_callback_tx)(void); +void (*UARTX_callback_rx)(void); +void (*UARTX_callback_rx_overflow)(char c); + +void UARTX_isr_tx(bool doCallback) +{ + #ifdef CBED_BUILD_UARTx_WITH_TX_BUFFER + if (UARTX_tx_buffer_in != UARTX_tx_buffer_out || UARTX_tx_buffer_count == CBED_BUILD_UARTx_WITH_TX_BUFFER) { + UARTX_THR = (uint32_t)UARTX_tx_buffer[UARTX_tx_buffer_out]; + UARTX_tx_buffer_count--; + UARTX_tx_buffer_out++; + if (UARTX_tx_buffer_out == CBED_BUILD_UARTx_WITH_TX_BUFFER) { + UARTX_tx_buffer_out = 0; + } + if (UARTX_tx_buffer_count == 0) { + UARTX_IER = 1; + } + if (doCallback && UARTX_callback_tx) (UARTX_callback_tx)(); + } + #else + UARTX_IER = 1; + if (UARTX_callback_tx) (UARTX_callback_tx)(); + #endif +} + +void UARTX_isr_rx(void) +{ + #ifdef CBED_BUILD_UARTx_WITH_RX_BUFFER + char c __attribute__((unused)); + while(UARTX_LSR & 0x1) { + if (UARTX_rx_buffer_count == CBED_BUILD_UARTx_WITH_RX_BUFFER) { + c = UARTX_RBR; + if (UARTX_callback_rx_overflow) (UARTX_callback_rx_overflow)(c); + } + else { + UARTX_rx_buffer[UARTX_rx_buffer_in] = UARTX_RBR; + UARTX_rx_buffer_in++; + if (UARTX_rx_buffer_in == CBED_BUILD_UARTx_WITH_RX_BUFFER) { + UARTX_rx_buffer_in = 0; + } + UARTX_rx_buffer_count++; + if (UARTX_callback_rx) (UARTX_callback_rx)(); + } + } + #else + if (UARTX_callback_rx) (UARTX_callback_rx)(); + #endif +} + +int UARTX_putc(int c, bool block) +{ + #ifdef CBED_BUILD_UARTx_WITH_TX_BUFFER + uint32_t ier; + if (UARTX_LSR & (1UL << 5) && UARTX_tx_buffer_count == 0) { + UARTX_THR = (uint32_t)c; + } + else { + if (block) { + ier = UARTX_IER; UARTX_IER = 1; + while(UARTX_tx_buffer_count == CBED_BUILD_UARTx_WITH_TX_BUFFER) { + UARTX_isr_tx(false); + } + UARTX_IER = ier; + } + else if (UARTX_tx_buffer_count == CBED_BUILD_UARTx_WITH_TX_BUFFER) { + return -1; + } + UARTX_IER &= ~2; + UARTX_tx_buffer[UARTX_tx_buffer_in] = c; + UARTX_tx_buffer_in++; + if (UARTX_tx_buffer_in == CBED_BUILD_UARTx_WITH_TX_BUFFER) UARTX_tx_buffer_in = 0; + UARTX_IER |= 2; + } + #else + while(!(UARTX_LSR & (1UL << 5)); + UARTX_THR = (uint32_t)c; + #endif + return 0; +} + +int UARTX__getc(bool block) { + #ifdef CBED_BUILD_UARTx_WITH_RX_BUFFER + uint32_t ier; + int c; + if (block) { while (UARTX_rx_buffer_count == 0) ; } /* blocks. */ + else if (UARTX_rx_buffer_count == 0) return -1; + c = UARTX_rx_buffer[UARTX_rx_buffer_out]; + UARTX_rx_buffer_out++; + if (UARTX_rx_buffer_out == CBED_BUILD_UARTx_WITH_RX_BUFFER) UARTX_rx_buffer_out = 0; + if (UARTX_rx_buffer_count != CBED_BUILD_UARTx_WITH_RX_BUFFER) { + ier = UARTX_IER; + UARTX_IER &= ~(1UL << 0); + UARTX_isr_rx(); + UARTX_IER = ier; + } + UARTX_rx_buffer_count--; + return c; + #else + if (block) { + while (!(UARTX_LSR & (1UL << 0)) ; + return (int)(UARTX_RBR & 0xFF); + } + else { + if (!(UARTX_LSR & (1UL << 0)) return -1; + return (int)(UARTX_RBR & 0xFF); + } + #endif +} + +int UARTX_getc(void) { + return UARTX... [truncated message content] |
From: <st...@us...> - 2011-03-19 19:32:51
|
Revision: 2 http://cbed.svn.sourceforge.net/cbed/?rev=2&view=rev Author: stl-ajk Date: 2011-03-19 19:32:45 +0000 (Sat, 19 Mar 2011) Log Message: ----------- remove bad import Removed Paths: ------------- cbed/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2011-03-19 19:30:29
|
Revision: 1 http://cbed.svn.sourceforge.net/cbed/?rev=1&view=rev Author: stl-ajk Date: 2011-03-19 19:30:22 +0000 (Sat, 19 Mar 2011) Log Message: ----------- initial import Added Paths: ----------- cbed/ cbed/cbed.h cbed/inc/ cbed/inc/iomacros.h cbed/inc/ticker.h cbed/src/ cbed/src/ticker.c cbed/src/uart0.c cbed/src/uart1.c cbed/src/uart2.c cbed/src/uart3.c cbed/src/uartx.h Added: cbed/cbed.h =================================================================== --- cbed/cbed.h (rev 0) +++ cbed/cbed.h 2011-03-19 19:30:22 UTC (rev 1) @@ -0,0 +1,53 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file cbed.h + * @purpose The main cbed library header. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + + + +#ifndef CBED_CBED_H +#define CBED_CBED_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <time.h> + +#include "iomacros.h" +#include "ticker.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif Added: cbed/inc/iomacros.h =================================================================== --- cbed/inc/iomacros.h (rev 0) +++ cbed/inc/iomacros.h 2011-03-19 19:30:22 UTC (rev 1) @@ -0,0 +1,426 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file iomacros.h + * @purpose Handles GPIO pins. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#ifndef CBED_IOMACROS_H +#define CBED_IOMACROS_H + +#ifndef __LPC17xx_H__ +#include "LPC17xx.h" +#endif + +#define PIN_PULLUP 0UL +#define PIN_REPEAT 1UL +#define PIN_NONE 2UL +#define PIN_PULLDOWN 3UL + +/* p5 is P0.9 */ +#define p5_SEL_MASK ~(3UL << 18) +#define p5_SET_MASK (1UL << 9) +#define p5_CLR_MASK ~(p5_SET_MASK) +#define p5_AS_OUTPUT LPC_PINCON->PINSEL0&=p5_SEL_MASK;LPC_GPIO0->FIODIR|=p5_SET_MASK +#define p5_AS_INPUT LPC_GPIO0->FIOMASK &= p5_CLR_MASK; +#define p5_SET LPC_GPIO0->FIOSET = p5_SET_MASK +#define p5_CLR LPC_GPIO0->FIOCLR = p5_SET_MASK +#define p5_IS_SET (bool)(LPC_GPIO0->FIOPIN & p5_SET_MASK) +#define p5_IS_CLR !(p5_IS_SET) +#define p5_MODE(x) LPC_PINCON->PINMODE0&=p5_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<18) + +/* p6 is P0.8 */ +#define p6_SEL_MASK ~(3UL << 16) +#define p6_SET_MASK (1UL << 8) +#define p6_CLR_MASK ~(p6_SET_MASK) +#define p6_AS_OUTPUT LPC_PINCON->PINSEL0&=p6_SEL_MASK;LPC_GPIO0->FIODIR|=p6-SET_MASK +#define p6_AS_INPUT LPC_GPIO0->FIOMASK &= p6_CLR_MASK; +#define p6_SET LPC_GPIO0->FIOSET = p6_SET_MASK +#define p6_CLR LPC_GPIO0->FIOCLR = p6_SET_MASK +#define p6_IS_SET (bool)(LPC_GPIO0->FIOPIN & p6_SET_MASK) +#define p6_IS_CLR !(p6_IS_SET) +#define p6_MODE(x) LPC_PINCON->PINMODE0&=p6_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<16) + +/* p7 is P0.7 */ +#define p7_SEL_MASK ~(3UL << 14) +#define p7_SET_MASK (1UL << 7) +#define p7_CLR_MASK ~(p7_SET_MASK) +#define p7_AS_OUTPUT LPC_PINCON->PINSEL0&=p7_SEL_MASK;LPC_GPIO0->FIODIR|=p7_SET_MASK +#define p7_AS_INPUT LPC_GPIO0->FIOMASK &= p7_CLR_MASK; +#define p7_SET LPC_GPIO0->FIOSET = p7_SET_MASK +#define p7_CLR LPC_GPIO0->FIOCLR = p7_SET_MASK +#define p7_IS_SET (bool)(LPC_GPIO0->FIOPIN & p7_SET_MASK) +#define p7_IS_CLR !(p7_IS_SET) +#define p7_MODE(x) LPC_PINCON->PINMODE0&=p7_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<14) + +/* p8 is P0.6 */ +#define p8_SEL_MASK ~(3UL << 12) +#define p8_SET_MASK (1UL << 6) +#define p8_CLR_MASK ~(p8_SET_MASK) +#define p8_AS_OUTPUT LPC_PINCON->PINSEL0&=p8_SEL_MASK;LPC_GPIO0->FIODIR|=p8_SET_MASK +#define p8_AS_INPUT LPC_GPIO0->FIOMASK &= p8_CLR_MASK; +#define p8_SET LPC_GPIO0->FIOSET = p8_SET_MASK +#define p8_CLR LPC_GPIO0->FIOCLR = p8_SET_MASK +#define p8_IS_SET (bool)(LPC_GPIO0->FIOPIN & p8_SET_MASK) +#define p8_IS_CLR !(p8_IS_SET) +#define p8_MODE(x) LPC_PINCON->PINMODE0&=p8_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<12) + +/* p9 is P0.0 */ +#define p9_SEL_MASK ~(3UL << 0) +#define p9_SET_MASK (1UL << 0) +#define p9_CLR_MASK ~(p9_SET_MASK) +#define p9_AS_OUTPUT LPC_PINCON->PINSEL0&=p9_SEL_MASK;LPC_GPIO0->FIODIR|=p9_SET_MASK +#define p9_AS_INPUT LPC_GPIO0->FIOMASK &= p9_CLR_MASK; +#define p9_SET LPC_GPIO0->FIOSET = p9_SET_MASK +#define p9_CLR LPC_GPIO0->FIOCLR = p9_SET_MASK +#define p9_IS_SET (bool)(LPC_GPIO0->FIOPIN & p9_SET_MASK) +#define p9_IS_CLR !(p9_IS_SET) +#define p9_MODE(x) LPC_PINCON->PINMODE0&=p9_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<0) + +/* p10 is P0.1 */ +#define p10_SEL_MASK ~(3UL << 2) +#define p10_SET_MASK (1UL << 1) +#define p10_CLR_MASK ~(p10_SET_MASK) +#define p10_AS_OUTPUT LPC_PINCON->PINSEL0&=p10_SEL_MASK;LPC_GPIO0->FIODIR|=p10_SET_MASK +#define p10_AS_INPUT LPC_GPIO0->FIOMASK &= p10_CLR_MASK; +#define p10_SET LPC_GPIO0->FIOSET = p10_SET_MASK +#define p10_CLR LPC_GPIO0->FIOCLR = p10_SET_MASK +#define p10_IS_SET (bool)(LPC_GPIO0->FIOPIN & p10_SET_MASK) +#define p10_IS_CLR !(p10_IS_SET) +#define p10_MODE(x) LPC_PINCON->PINMODE0&=p10_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<2) + +/* p11 is P0.18 */ +#define p11_SEL_MASK ~(3UL << 4) +#define p11_SET_MASK (1UL << 18) +#define p11_CLR_MASK ~(p11_SET_MASK) +#define p11_AS_OUTPUT LPC_PINCON->PINSEL1&=p11_SEL_MASK;LPC_GPIO0->FIODIR|=p11_SET_MASK +#define p11_AS_INPUT LPC_GPIO0->FIOMASK &= p11_CLR_MASK; +#define p11_SET LPC_GPIO0->FIOSET = p11_SET_MASK +#define p11_CLR LPC_GPIO0->FIOCLR = p11_SET_MASK +#define p11_IS_SET (bool)(LPC_GPIO0->FIOPIN & p11_SET_MASK) +#define p11_IS_CLR !(p11_IS_SET) +#define p11_MODE(x) LPC_PINCON->PINMODE1&=p11_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<4) + +/* p12 is P0.17 */ +#define p12_SEL_MASK ~(3UL << 2) +#define p12_SET_MASK (1UL << 17) +#define p12_CLR_MASK ~(p12_SET_MASK) +#define p12_AS_OUTPUT LPC_PINCON->PINSEL1&=p12_SEL_MASK;LPC_GPIO0->FIODIR|=p12_SET_MASK +#define p12_AS_INPUT LPC_GPIO0->FIOMASK &= p12_CLR_MASK; +#define p12_SET LPC_GPIO0->FIOSET = p12_SET_MASK +#define p12_CLR LPC_GPIO0->FIOCLR = p12_SET_MASK +#define p12_IS_SET (bool)(LPC_GPIO0->FIOPIN & p12_SET_MASK) +#define p12_IS_CLR !(p12_IS_SET) +#define p12_MODE(x) LPC_PINCON->PINMODE1&=p12_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<2) + +/* p13 is P0.15 */ +#define p13_SEL_MASK ~(3UL << 30) +#define p13_SET_MASK (1UL << 15) +#define p13_CLR_MASK ~(p13_SET_MASK) +#define p13_AS_OUTPUT LPC_PINCON->PINSEL0&=p13_SEL_MASK;LPC_GPIO0->FIODIR|=p13_SET_MASK +#define p13_AS_INPUT LPC_GPIO0->FIOMASK &= p13_CLR_MASK; +#define p13_SET LPC_GPIO0->FIOSET = p13_SET_MASK +#define p13_CLR LPC_GPIO0->FIOCLR = p13_SET_MASK +#define p13_IS_SET (bool)(LPC_GPIO0->FIOPIN & p13_SET_MASK) +#define p13_IS_CLR !(p13_IS_SET) +#define p13_MODE(x) LPC_PINCON->PINMODE0&=p13_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<30) + +/* p14 is P0.16 */ +#define p14_SEL_MASK ~(3UL << 0) +#define p14_SET_MASK (1UL << 16) +#define p14_CLR_MASK ~(p14_SET_MASK) +#define p14_AS_OUTPUT LPC_PINCON->PINSEL1&=p14_SEL_MASK;LPC_GPIO0->FIODIR|=p14_SET_MASK +#define p14_AS_INPUT LPC_GPIO0->FIOMASK &= p14_CLR_MASK; +#define p14_SET LPC_GPIO0->FIOSET = p14_SET_MASK +#define p14_CLR LPC_GPIO0->FIOCLR = p14_SET_MASK +#define p14_IS_SET (bool)(LPC_GPIO0->FIOPIN & p14_SET_MASK) +#define p14_IS_CLR !(p14_IS_SET) +#define p14_MODE(x) LPC_PINCON->PINMODE1&=p14_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<0) + +/* p15 is P0.23 */ +#define p15_SEL_MASK ~(3UL << 14) +#define p15_SET_MASK (1UL << 23) +#define p15_CLR_MASK ~(p15_SET_MASK) +#define p15_AS_OUTPUT LPC_PINCON->PINSEL1&=p15_SEL_MASK;LPC_GPIO0->FIODIR|=p15_SET_MASK +#define p15_AS_INPUT LPC_GPIO0->FIOMASK &= p15_CLR_MASK; +#define p15_SET LPC_GPIO0->FIOSET = p15_SET_MASK +#define p15_CLR LPC_GPIO0->FIOCLR = p15_SET_MASK +#define p15_IS_SET (bool)(LPC_GPIO0->FIOPIN & p15_SET_MASK) +#define p15_IS_CLR !(p15_IS_SET) +#define p15_MODE(x) LPC_PINCON->PINMODE1&=p15_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<14) + +/* p16 is P0.24 */ +#define p16_SEL_MASK ~(3UL << 16) +#define p16_SET_MASK (1UL << 24) +#define p16_CLR_MASK ~(p16_SET_MASK) +#define p16_AS_OUTPUT LPC_PINCON->PINSEL1&=p16_SEL_MASK;LPC_GPIO0->FIODIR|=p16_SET_MASK +#define p16_AS_INPUT LPC_GPIO0->FIOMASK &= p16_CLR_MASK; +#define p16_SET LPC_GPIO0->FIOSET = p16_SET_MASK +#define p16_CLR LPC_GPIO0->FIOCLR = p16_SET_MASK +#define p16_IS_SET (bool)(LPC_GPIO0->FIOPIN & p16_SET_MASK) +#define p16_IS_CLR !(p16_IS_SET) +#define p16_MODE(x) LPC_PINCON->PINMODE1&=p16_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<16) + +/* p17 is P0.25 */ +#define p17_SEL_MASK ~(3UL << 18) +#define p17_SET_MASK (1UL << 25) +#define p17_CLR_MASK ~(p17_SET_MASK) +#define p17_AS_OUTPUT LPC_PINCON->PINSEL1&=p17_SEL_MASK;LPC_GPIO0->FIODIR|=p17_SET_MASK +#define p17_AS_INPUT LPC_GPIO0->FIOMASK &= p17_CLR_MASK; +#define p17_SET LPC_GPIO0->FIOSET = p17_SET_MASK +#define p17_CLR LPC_GPIO0->FIOCLR = p17_SET_MASK +#define p17_IS_SET (bool)(LPC_GPIO0->FIOPIN & p17_SET_MASK) +#define p17_IS_CLR !(p17_IS_SET) +#define p17_MODE(x) LPC_PINCON->PINMODE1&=p17_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<18) + +/* p18 is P0.26 */ +#define p18_SEL_MASK ~(3UL << 20) +#define p18_SET_MASK (1UL << 26) +#define p18_CLR_MASK ~(p18_SET_MASK) +#define p18_AS_OUTPUT LPC_PINCON->PINSEL1&=p18_SEL_MASK;LPC_GPIO0->FIODIR|=p18_SET_MASK +#define p18_AS_INPUT LPC_GPIO0->FIOMASK &= p18_CLR_MASK; +#define p18_SET LPC_GPIO0->FIOSET = p18_SET_MASK +#define p18_CLR LPC_GPIO0->FIOCLR = p18_SET_MASK +#define p18_IS_SET (bool)(LPC_GPIO0->FIOPIN & p18_SET_MASK) +#define p18_IS_CLR !(p18_IS_SET) +#define p18_MODE(x) LPC_PINCON->PINMODE1&=p18_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<20) + +/* p19 is P1.30 */ +#define p19_SEL_MASK ~(3UL << 28) +#define p19_SET_MASK (1UL << 30) +#define p19_AS_OUTPUT LPC_PINCON->PINSEL3&=p19_SEL_MASK;LPC_GPIO1->FIODIR|=p19_SET_MASK +#define p19_AS_INPUT LPC_GPIO1->FIOMASK &= p19_CLR_MASK; +#define p19_SET LPC_GPIO1->FIOSET = p19_SET_MASK +#define p19_CLR LPC_GPIO1->FIOCLR = p19_SET_MASK +#define p19_IS_SET (bool)(LPC_GPIO1->FIOPIN & p19_SET_MASK) +#define p19_IS_CLR !(p19_IS_SET) +#define p19_MODE(x) LPC_PINCON->PINMODE3&=p19_SEL_MASK;LPC_PINCON->PINMODE3|=((x&0x3)<<28) + +/* p20 is P1.31 */ +#define p20_SEL_MASK ~(3UL << 30) +#define p20_SET_MASK (1UL << 31) +#define p20_CLR_MASK ~(p20_SET_MASK) +#define p20_AS_OUTPUT LPC_PINCON->PINSEL3&=p20_SEL_MASK;LPC_GPIO1->FIODIR|=p20_SET_MASK +#define p20_AS_INPUT LPC_GPIO1->FIOMASK &= p20_CLR_MASK; +#define p20_SET LPC_GPIO1->FIOSET = p20_SET_MASK +#define p20_CLR LPC_GPIO1->FIOCLR = p20_SET_MASK +#define p20_IS_SET (bool)(LPC_GPIO1->FIOPIN & p20_SET_MASK) +#define p20_IS_CLR !(p20_IS_SET) +#define p20_MODE(x) LPC_PINCON->PINMODE3&=p20_SEL_MASK;LPC_PINCON->PINMODE3|=((x&0x3)<<30) + +/* p21 is P2.5 */ +#define p21_SEL_MASK ~(3UL << 10) +#define p21_SET_MASK (1UL << 5) +#define p21_CLR_MASK ~(p21_SET_MASK) +#define p21_AS_OUTPUT LPC_PINCON->PINSEL4&=p21_SEL_MASK;LPC_GPIO2->FIODIR|=p21_SET_MASK +#define p21_AS_INPUT LPC_GPIO2->FIOMASK &= p21_CLR_MASK; +#define p21_SET LPC_GPIO2->FIOSET = p21_SET_MASK +#define p21_CLR LPC_GPIO2->FIOCLR = p21_SET_MASK +#define p21_IS_SET (bool)(LPC_GPIO2->FIOPIN & p21_SET_MASK) +#define p21_IS_CLR !(p21_IS_SET) +#define p21_TOGGLE p21_IS_SET?p21_CLR:p21_SET +#define p21_MODE(x) LPC_PINCON->PINMODE4&=p21_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<10) + +/* p22 is P2.4 */ +#define p22_SEL_MASK ~(3UL << 8) +#define p22_SET_MASK (1UL << 4) +#define p22_CLR_MASK ~(p22_SET_MASK) +#define p22_AS_OUTPUT LPC_PINCON->PINSEL4&=p22_SEL_MASK;LPC_GPIO2->FIODIR|=p22_SET_MASK +#define p22_AS_INPUT LPC_GPIO2->FIOMASK &= p22_CLR_MASK; +#define p22_SET LPC_GPIO2->FIOSET = p22_SET_MASK +#define p22_CLR LPC_GPIO2->FIOCLR = p22_SET_MASK +#define p22_IS_SET (bool)(LPC_GPIO2->FIOPIN & p22_SET_MASK) +#define p22_IS_CLR !(p22_IS_SET) +#define p22_TOGGLE p22_IS_SET?p22_CLR:p22_SET +#define p22_MODE(x) LPC_PINCON->PINMODE4&=p22_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<8) + +/* p23 is P2.3 */ +#define p23_SEL_MASK ~(3UL << 6) +#define p23_SET_MASK (1UL << 3) +#define p23_CLR_MASK ~(p23_SET_MASK) +#define p23_AS_OUTPUT LPC_PINCON->PINSEL4&=p23_SEL_MASK;LPC_GPIO2->FIODIR|=p23_SET_MASK +#define p23_AS_INPUT LPC_GPIO2->FIOMASK &= p23_CLR_MASK; +#define p23_SET LPC_GPIO2->FIOSET = p23_SET_MASK +#define p23_CLR LPC_GPIO2->FIOCLR = p23_SET_MASK +#define p23_IS_SET (bool)(LPC_GPIO2->FIOPIN & p23_SET_MASK) +#define p23_IS_CLR !(p23_IS_SET) +#define p23_TOGGLE p23_IS_SET?p23_CLR:p23_SET +#define p23_MODE(x) LPC_PINCON->PINMODE4&=p23_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<6) + +/* p24 is P2.2 */ +#define p24_SEL_MASK ~(3UL << 4) +#define p24_SET_MASK (1UL << 2) +#define p24_CLR_MASK ~(p24_SET_MASK) +#define p24_AS_OUTPUT LPC_PINCON->PINSEL4&=p24_SEL_MASK;LPC_GPIO2->FIODIR|=p24_SET_MASK +#define p24_AS_INPUT LPC_GPIO2->FIOMASK &= p24_CLR_MASK; +#define p24_SET LPC_GPIO2->FIOSET = p24_SET_MASK +#define p24_CLR LPC_GPIO2->FIOCLR = p24_SET_MASK +#define p24_IS_SET (bool)(LPC_GPIO2->FIOPIN & p24_SET_MASK) +#define p24_IS_CLR !(p24_IS_SET) +#define p24_TOGGLE p24_IS_SET?p24_CLR:p24_SET +#define p24_MODE(x) LPC_PINCON->PINMODE4&=p24_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<4) + +/* p25 is P2.1 */ +#define p25_SEL_MASK ~(3UL << 2) +#define p25_SET_MASK (1UL << 1) +#define p25_CLR_MASK ~(p25_SET_MASK) +#define p25_AS_OUTPUT LPC_PINCON->PINSEL4&=p25_SEL_MASK;LPC_GPIO2->FIODIR|=p25_SET_MASK +#define p25_AS_INPUT LPC_GPIO2->FIOMASK &= p25_CLR_MASK; +#define p25_SET LPC_GPIO2->FIOSET = p25_SET_MASK +#define p25_CLR LPC_GPIO2->FIOCLR = p25_SET_MASK +#define p25_IS_SET (bool)(LPC_GPIO2->FIOPIN & p25_SET_MASK) +#define p25_IS_CLR !(p25_IS_SET) +#define p25_MODE(x) LPC_PINCON->PINMODE4&=p25_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<2) + +/* p26 is P2.0 */ +#define p26_SEL_MASK ~(3UL << 0) +#define p26_SET_MASK (1UL << 0) +#define p26_CLR_MASK ~(p26_SET_MASK) +#define p26_AS_OUTPUT LPC_PINCON->PINSEL4&=p26_SEL_MASK;LPC_GPIO2->FIODIR|=p26_SET_MASK +#define p26_AS_INPUT LPC_GPIO2->FIOMASK &= p26_CLR_MASK; +#define p26_SET LPC_GPIO2->FIOSET = p26_SET_MASK +#define p26_CLR LPC_GPIO2->FIOCLR = p26_SET_MASK +#define p26_IS_SET (bool)(LPC_GPIO2->FIOPIN & p26_SET_MASK) +#define p26_IS_CLR !(p26_IS_SET) +#define p26_MODE(x) LPC_PINCON->PINMODE4&=p26_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<0) + +/* p27 is P0.11 */ +#define p27_SEL_MASK ~(3UL << 22) +#define p27_SET_MASK (1UL << 11) +#define p27_CLR_MASK ~(p27_SET_MASK) +#define p27_AS_OUTPUT LPC_PINCON->PINSEL0&=p27_SEL_MASK;LPC_GPIO0->FIODIR|=p27_SET_MASK +#define p27_AS_INPUT LPC_GPIO0->FIOMASK &= p27_CLR_MASK; +#define p27_SET LPC_GPIO0->FIOSET = p27_SET_MASK +#define p27_CLR LPC_GPIO0->FIOCLR = p27_SET_MASK +#define p27_IS_SET (bool)(LPC_GPIO0->FIOPIN & p27_SET_MASK) +#define p27_IS_CLR !(p27_IS_SET) +#define p27_MODE(x) LPC_PINCON->PINMODE0&=p27_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<22) + +/* p28 is P0.10 */ +#define p28_SEL_MASK ~(3UL << 20) +#define p28_SET_MASK (1UL << 10) +#define p28_CLR_MASK ~(p28_SET_MASK) +#define p28_AS_OUTPUT LPC_PINCON->PINSEL0&=p28_SEL_MASK;LPC_GPIO0->FIODIR|=p28_SET_MASK +#define p28_AS_INPUT LPC_GPIO0->FIOMASK &= p28_CLR_MASK; +#define p28_SET LPC_GPIO0->FIOSET = p28_SET_MASK +#define p28_CLR LPC_GPIO0->FIOCLR = p28_SET_MASK +#define p28_IS_SET (bool)(LPC_GPIO0->FIOPIN & p28_SET_MASK) +#define p28_IS_CLR !(p28_IS_SET) +#define p28_MODE(x) LPC_PINCON->PINMODE0&=p28_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<20) + +/* p29 is P0.5 */ +#define p29_SEL_MASK ~(3UL << 10) +#define p29_SET_MASK (1UL << 5) +#define p29_CLR_MASK ~(p29_SET_MASK) +#define p29_AS_OUTPUT LPC_PINCON->PINSEL0&=p29_SEL_MASK;LPC_GPIO0->FIODIR|=p29_SET_MASK +#define p29_AS_INPUT LPC_GPIO0->FIOMASK &= p29_CLR_MASK; +#define p29_SET LPC_GPIO0->FIOSET = p29_SET_MASK +#define p29_CLR LPC_GPIO0->FIOCLR = p29_SET_MASK +#define p29_IS_SET (bool)(LPC_GPIO0->FIOPIN & p29_SET_MASK) +#define p29_IS_CLR !(p29_IS_SET) +#define p29_TOGGLE p29_IS_SET?p29_CLR:p29_SET +#define p29_MODE(x) LPC_PINCON->PINMODE0&=p29_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<10) + +/* p30 is P0.4 */ +#define p30_SEL_MASK ~(3UL << 8) +#define p30_SET_MASK (1UL << 4) +#define p30_CLR_MASK ~(p30_SET_MASK) +#define p30_AS_OUTPUT LPC_PINCON->PINSEL0&=p30_SEL_MASK;LPC_GPIO0->FIODIR|=p30_SET_MASK +#define p30_AS_INPUT LPC_GPIO0->FIOMASK &= p30_CLR_MASK; +#define p30_SET LPC_GPIO0->FIOSET = p30_SET_MASK +#define p30_CLR LPC_GPIO0->FIOCLR = p30_SET_MASK +#define p30_IS_SET (bool)(LPC_GPIO0->FIOPIN & p30_SET_MASK) +#define p30_IS_CLR !(p30_IS_SET) +#define p30_MODE(x) LPC_PINCON->PINMODE0&=p30_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<8) + +/* The following definitions are for the four Mbed LEDs. + LED1 = P1.18 + LED2 = P1.20 + LED3 = P1.21 + LED4 = P1.23 */ + +#define P1_18_SEL_MASK ~(3UL << 4) +#define P1_18_SET_MASK (1UL << 18) +#define P1_18_CLR_MASK ~(P1_18_SET_MASK) +#define P1_18_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_18_SEL_MASK;LPC_GPIO1->FIODIR|=P1_18_SET_MASK +#define P1_18_AS_INPUT LPC_GPIO1->FIOMASK &= P1_18_CLR_MASK; +#define P1_18_SET LPC_GPIO1->FIOSET = P1_18_SET_MASK +#define P1_18_CLR LPC_GPIO1->FIOCLR = P1_18_SET_MASK +#define P1_18_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_18_SET_MASK) +#define P1_18_IS_CLR !(P1_18_IS_SET) +#define LED1_USE P1_18_AS_OUTPUT;P1_18_AS_INPUT +#define LED1_ON P1_18_SET +#define LED1_OFF P1_18_CLR +#define LED1_IS_ON P1_18_IS_SET +#define LED1_TOGGLE P1_18_IS_SET?LED1_OFF:LED1_ON + +#define P1_20_SEL_MASK ~(3UL << 8) +#define P1_20_SET_MASK (1UL << 20) +#define P1_20_CLR_MASK ~(P1_20_SET_MASK) +#define P1_20_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_20_SEL_MASK;LPC_GPIO1->FIODIR|=P1_20_SET_MASK +#define P1_20_AS_INPUT LPC_GPIO1->FIOMASK &= P1_20_CLR_MASK; +#define P1_20_SET LPC_GPIO1->FIOSET = P1_20_SET_MASK +#define P1_20_CLR LPC_GPIO1->FIOCLR = P1_20_SET_MASK +#define P1_20_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_20_SET_MASK) +#define P1_20_IS_CLR !(P1_20_IS_SET) +#define LED2_USE P1_20_AS_OUTPUT;P1_20_AS_INPUT +#define LED2_ON P1_20_SET +#define LED2_OFF P1_20_CLR +#define LED2_IS_ON P1_20_IS_SET +#define LED2_TOGGLE P1_20_IS_SET?LED2_OFF:LED2_ON + +#define P1_21_SEL_MASK ~(3UL << 10) +#define P1_21_SET_MASK (1UL << 21) +#define P1_21_CLR_MASK ~(P1_21_SET_MASK) +#define P1_21_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_21_SEL_MASK;LPC_GPIO1->FIODIR|=P1_21_SET_MASK +#define P1_21_AS_INPUT LPC_GPIO1->FIOMASK &= P1_21_CLR_MASK; +#define P1_21_SET LPC_GPIO1->FIOSET = P1_21_SET_MASK +#define P1_21_CLR LPC_GPIO1->FIOCLR = P1_21_SET_MASK +#define P1_21_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_21_SET_MASK) +#define P1_21_IS_CLR !(P1_21_IS_SET) +#define LED3_USE P1_21_AS_OUTPUT;P1_21_AS_INPUT +#define LED3_ON P1_21_SET +#define LED3_OFF P1_21_CLR +#define LED3_IS_ON P1_21_IS_SET +#define LED3_TOGGLE P1_21_IS_SET?LED3_OFF:LED3_ON + +#define P1_23_SEL_MASK ~(3UL << 14) +#define P1_23_SET_MASK (1UL << 23) +#define P1_23_CLR_MASK ~(P1_23_SET_MASK) +#define P1_23_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_23_SEL_MASK;LPC_GPIO1->FIODIR|=P1_23_SET_MASK +#define P1_23_AS_INPUT LPC_GPIO1->FIOMASK &= P1_23_CLR_MASK; +#define P1_23_SET LPC_GPIO1->FIOSET = P1_23_SET_MASK +#define P1_23_CLR LPC_GPIO1->FIOCLR = P1_23_SET_MASK +#define P1_23_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_23_SET_MASK) +#define P1_23_IS_CLR !(P1_23_IS_SET) +#define LED4_USE P1_23_AS_OUTPUT;P1_23_AS_INPUT +#define LED4_ON P1_23_SET +#define LED4_OFF P1_23_CLR +#define LED4_IS_ON P1_23_IS_SET +#define LED4_TOGGLE P1_23_IS_SET?LED4_OFF:LED4_ON + +#endif + Added: cbed/inc/ticker.h =================================================================== --- cbed/inc/ticker.h (rev 0) +++ cbed/inc/ticker.h 2011-03-19 19:30:22 UTC (rev 1) @@ -0,0 +1,98 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file ticker.h + * @purpose Handles tickers, timeouts, timers and wait api. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#ifndef CBED_TICKER_H +#define CBED_TICKER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <time.h> +#include <stdint.h> +#include "LPC17xx.h" +#include "../cbedopts.h" + +#define CBED_TICKER 1 +#define CBED_TIMER 2 + +#define CBED_TIME_RUN (1UL << 0) +#define CBED_TIME_WRAPPED (1UL << 1) + +typedef struct _ticker_t { + _ticker_t *next; + union { + struct { + void (*callback)(_ticker_t *); + uint32_t counter; + uint32_t reload; + } ticker; + struct { + uint32_t unused; /* Aligns with "ticker.callback" */ + uint64_t time; + uint64_t start; + } timer; + } data; +} ticker_t; + +#define timeout_t ticker_t +#define timer_t ticker_t + +#define timer_value(x) ((x)->data.timer.time) + +void ticker_attach(ticker_t *p, void (*f)(_ticker_t *), uint32_t ms); +void ticker_detach(ticker_t *p); + +void timeout_attach(ticker_t *p, void (*f)(_ticker_t *), uint32_t ms); +void timeout_detach(ticker_t *p); + +void timer_setup(timer_t *p); +void timer_begin(timer_t *p); +void timer_stall(timer_t *p); +void timer_run(timer_t *p); +void timer_reset(timer_t *p); +uint64_t timer_get(timer_t *p); + +uint64_t time_since(void); + +void cbed_wait_us(uint32_t us); +void cbed_wait_ms(uint32_t ms); +void cbed_wait(double s); + +#ifdef __cplusplus +} +#endif + +#endif + Added: cbed/src/ticker.c =================================================================== --- cbed/src/ticker.c (rev 0) +++ cbed/src/ticker.c 2011-03-19 19:30:22 UTC (rev 1) @@ -0,0 +1,520 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file ticker.c + * @purpose Handles tickers, timeouts, timers and wait api. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +/** @defgroup API The CBED API */ +/** @defgroup CBedTimer The CBED Timer functions */ +/** @defgroup MISC Misc CBED functions */ +/** @defgroup INTERNALS CBED Internals */ + +#include "stdlib.h" +#include "cmsis_nvic.h" +#include "ticker.h" +#include "iomacros.h" + +#ifndef TICKERSYS_TIMER_CUSTOM +#define TICKERSYS_PCONP (1UL << 23) +#define TICKERSYS_PCLKSEL LPC_SC->PCLKSEL1 +#define TICKERSYS_PCLKSEL_VALUE (3UL << 14) +#define TICKERSYS_TCR LPC_TIM3->TCR +#define TICKERSYS_PR LPC_TIM3->PR +#define TICKERSYS_MCR LPC_TIM3->MCR +#define TICKERSYS_MR0 LPC_TIM3->MR0 +#define TICKERSYS_TC LPC_TIM3->TC +#define TICKERSYS_IR LPC_TIM3->IR +#define TICKERSYS_IRQn TIMER3_IRQn +#define TICKERSYS_TICK 1000 +#else +#define TICKERSYS_PCONP TICKERSYS_TIMER_PCONP +#define TICKERSYS_PCLKSEL TICKERSYS_TIMER_PCLKSEL +#define TICKERSYS_PCLKSEL_VALUE TICKERSYS_TIMER_PCLKSEL_VALUE +#define TICKERSYS_TCR TICKERSYS_TIMER_TCR +#define TICKERSYS_PR TICKERSYS_TIMER_PR +#define TICKERSYS_MCR TICKERSYS_TIMER_MCR +#define TICKERSYS_MR0 TICKERSYS_TIMER_MR0 +#define TICKERSYS_TC TICKERSYS_TIMER_TC +#define TICKERSYS_IR TICKERSYS_TIMER_IR +#define TICKERSYS_IRQn TICKERSYS_TIMER_IRQn +#define TICKERSYS_TICK TICKERSYS_TIMER_TICK +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +static ticker_t *_header_pointer; +static int _ticker_system_live; +static uint64_t _ticker_time; +static uint32_t _ticker_last_tc; + +static void _ticker_system_remove(ticker_t *p); + +void TIMERx_IRQHandler(void) __irq +{ + ticker_t *p, *q; + + _ticker_time += 1000UL; + _ticker_last_tc = TICKERSYS_TC; + + TICKERSYS_MR0 += TICKERSYS_TICK; + p = _header_pointer; + + while(p) { + if (p->data.ticker.callback != NULL && p->data.ticker.counter > 0) { + p->data.ticker.counter--; + if (p->data.ticker.counter == 0) { + (p->data.ticker.callback)(p); + if (p->data.ticker.reload) p->data.ticker.counter = p->data.ticker.reload; + else { + q = p; + p = p->next; + _ticker_system_remove(q); + continue; + } + } + } + p = p->next; + } + + TICKERSYS_IR |= 4; +} + +static void _ticker_system_init(void) +{ + if (_ticker_system_live) return; + + _ticker_system_live = 1; + + _header_pointer = (ticker_t *)NULL; + + _ticker_last_tc = 0; + _ticker_time = 0; + + // Set-up a timer as a periodic 1ms int. + LPC_SC->PCONP |= TICKERSYS_PCONP; + TICKERSYS_PCLKSEL &= ~TICKERSYS_PCLKSEL_VALUE; + TICKERSYS_PCLKSEL |= TICKERSYS_PCLKSEL_VALUE; + TICKERSYS_PR = 11; + TICKERSYS_MCR = 1; + TICKERSYS_MR0 = TICKERSYS_TICK; + TICKERSYS_TCR = 2; + TICKERSYS_TCR = 1; + + NVIC_SetVector(TICKERSYS_IRQn, (uint32_t)TIMERx_IRQHandler); + NVIC_EnableIRQ(TICKERSYS_IRQn); +} + +/** _ticker_system_add - Add a struct instance to the linked list. + * + * @ingroup INTERNALS + * @param[in] p A pointer the data structure. + */ +static void _ticker_system_add(ticker_t *p) +{ + if (!_ticker_system_live) _ticker_system_init(); + + ticker_t *q; + + /* Ensure only one instance of this structure in the list. */ + for (q = _header_pointer; q; q = q->next) if (q == p) return; + + /* Add at the head of the list. Faster than adding at the + tail and list order is not important. */ + p->next = _header_pointer; + _header_pointer = p; +} + +/** _ticker_system_remove - Remove a struct instance from the linked list. + * + * @ingroup INTERNALS + * @param[in] p A pointer the data structure. + */ +static void _ticker_system_remove(ticker_t *p) +{ + ticker_t *q; + + /* If it's the head being removed handle that */ + if (_header_pointer == p) { + _header_pointer = p->next; + } + /* Otherwise look through the list and find it. */ + else { + q = _header_pointer; + while(q) { + if (q->next == p) { + q->next = p->next; + break; + } + q = q->next; + } + } +} + +/** ticker_attach - Attach a callback to a ticker_t data structure. + * + * Used to attach a ticker_t to a callback. + * + * @ingroup API + * @ingroup CBedTimer + * + * @code + * #include "cbed.h" + * + * ticker_t t; + * + * void toggle_led2(ticker_t *p) { LED2_TOGGLE; } + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * LED2_USE; //!< @see iomacros.h + * ticker_attach(&t, &toggle_led2, 100); + * while(1) { + * LED1_ON; + * cbed_wait(1.0); + * LED1_OFF; + * cbed_wait(1.0); + * } + * } + * @endcode + * + * @param[in] p A pointer the data structure for the ticker + * @param[in] f A function pointer to callback to. + * @param[in] ms The time period, in milliseconds, to invoke the callback. + */ +void ticker_attach(ticker_t *p, void (*f)(_ticker_t *), uint32_t ms) +{ + p->data.ticker.callback = f; + p->data.ticker.counter = ms; + p->data.ticker.reload = ms; + _ticker_system_add(p); +} + +/** ticker_detach - Detach a ticker_t data structure. + * + * Used to detach a ticker_t to a callback. + * + * @ingroup API + * @ingroup CBedTimer + * + * @param[in] p A pointer the data structure for the ticker + */ +void ticker_detach(ticker_t *p) +{ + _ticker_system_remove(p); +} + +/** timeout_attach - Attach a callback to a timeout_t data structure. + * + * Used to attach a timeout_t to a callback. <b>Note</b>, when the timeout occurs + * and after the callback has been invoked the timeout_t is automatically + * detached from the system (as though you had called <i>timeout_detact(p);</i> + * + * @ingroup API + * @ingroup CBedTimer + * + * @code + * #include "cbed.h" + * + * timeout_t t; + * + * void toggle_led2(timeout_t *p) { LED2_ON; } + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * LED2_USE; //!< @see iomacros.h + * timeout_attach(&t, &toggle_led2, 5000); + * while(1) { + * LED1_ON; + * cbed_wait(1.0); + * LED1_OFF; + * cbed_wait(1.0); + * } + * } + * @endcode + * + * @param[in] p A pointer the data structure for the timeout + * @param[in] f A function pointer to callback to. + * @param[in] ms The time period, in milliseconds, until invoking the callback. + */ +void timeout_attach(ticker_t *p, void (*f)(_ticker_t *), uint32_t ms) +{ + p->data.ticker.callback = f; + p->data.ticker.counter = ms; + p->data.ticker.reload = 0; + _ticker_system_add(p); +} + +/** timeout_detach - Detach a timeout_t data structure. + * + * Used to detach a timeout_t to a callback. Use this to + * disable a pending timeout that was set to prevent the + * callback from being made. + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timeout. + */ +void timeout_detach(ticker_t *p) +{ + _ticker_system_remove(p); +} + +/** timer_setup - Setup a timer_t structure ready for use. + * + * @code + * #include "cbed.h" + * + * timer_t t; + * + * int main() { + * LED1_USE; + * timer_setup(&t); + * while(1) { + * timer_begin(&t); + * LED1_ON; + * cbed_wait(0.5); + * LED1_OFF; + * cbed_wait(0.5); + * timer_stall(&t); + * printf("Time accumulated so far = %lld\n", timer_get(&t)); + * } + * } + * @endcode + * @see timer_begin + * @see timer_stall + * @see timer_get + * @see timer_reset + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_setup(timer_t *p) +{ + p->data.timer.unused = 0; + p->data.timer.time = 0; + _ticker_system_add(p); +} + +/** timer_reset - Reset the timer. + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_reset(timer_t *p) +{ + p->data.timer.unused = 0; + p->data.timer.time = 0; +} + +/** timer_run - Start the timer. + * + * @see timer_setup + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_run(timer_t *p) +{ + NVIC_DisableIRQ(TICKERSYS_IRQn); + p->data.timer.start = _ticker_time + (uint64_t)(TICKERSYS_TC - _ticker_last_tc); + NVIC_EnableIRQ(TICKERSYS_IRQn); +} + +/** timer_begin - Start the timer. + * + * Same as timer_run() + * + * @see timer_setup + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_begin(timer_t *p) +{ + NVIC_DisableIRQ(TICKERSYS_IRQn); + p->data.timer.start = _ticker_time + (uint64_t)(TICKERSYS_TC - _ticker_last_tc); + NVIC_EnableIRQ(TICKERSYS_IRQn); +} + +/** timer_get - Get the timer time so far as a 64bit unisgned long. + * + * This function returns the current value of the timer_t pointed to by p. + * The return type is uint64_t in microseconds. + * + * @see timer_setup + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + * @return[out] uint64_t microseconds timer_t value. + */ +uint64_t timer_get(timer_t *p) +{ + return p->data.timer.time; +} + +/** timer_stall - Halt the timer pointed to by p. + * + * This function halts the timer. Note, it does n't reset it so + * if the timer is restarted it continues accumulating the time. + * + * @see timer_setup + * @ingroup API + * @ingroup CBedTimer + * @param[in] p A pointer the data structure for the timer. + */ +void timer_stall(timer_t *p) +{ + uint64_t diff; + NVIC_DisableIRQ(TICKERSYS_IRQn); + diff = _ticker_time - p->data.timer.start + p->data.timer.time; + p->data.timer.time = diff + (uint64_t)(TICKERSYS_TC - _ticker_last_tc); + NVIC_EnableIRQ(TICKERSYS_IRQn); +} + +/** time_since_reset - Return the number of microseconds since power-on/reset. + * + * This function returns the current numer of microseconds since the + * power-on/reset epoch. + * + * @ingroup API + * @ingroup CBedTimer + * @param[out] Number of microseconds since power-on/reset. + */ +uint64_t time_since_reset(void) +{ + return _ticker_time; +} + +/** cbed_wait_us - Wait for a period of microseconds + * + * Cause your program to delay for a period of microseconds. + * Please note, this function is generally only useable with any + * accuracy down to around 10 to 20us or so due mainly to function + * call overhead. If you require accurate microsecond timing you + * should be using a dedicated timer/capture usint and suitable + * implementation. + * + * @code + * #include "cbed.h" + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * while(1) { + * LED1_ON; + * cbed_wait_us(1000000); + * LED1_OFF; + * cbed_wait_us(1000000); + * } + * } + * @endcode + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] us The number of microseconds to wait. + */ +void cbed_wait_us(uint32_t us) +{ + volatile uint32_t x, y; + if (!_ticker_system_live) _ticker_system_init(); + x = TICKERSYS_TC + (us); + do { + y = TICKERSYS_TC; + } + while(x > y); +} + +/** cbed_wait_ms - Wait for a period of milliseconds + * + * Cause your program to delay for a period of milliseconds. + * Please note, this function is generally only useable with any + * accuracy down to around 10 to 20us or so due mainly to function + * call overhead. If you require accurate microsecond timing you + * should be using a dedicated timer/capture usint and suitable + * implementation. + * + * @code + * #include "cbed.h" + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * while(1) { + * LED1_ON; + * cbed_wait_ms(100000); + * LED1_OFF; + * cbed_wait_ms(100000); + * } + * } + * @endcode + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] ms The number of milliseconds to wait. + */ +void cbed_wait_ms(uint32_t ms) +{ + cbed_wait_us(ms * 1000); +} + +/** cbed_wait - Wait for a period of seconds + * + * Cause your program to delay for a period of seconds. + * Please note, this function is generally only useable with any + * accuracy down to around 10 to 20us or so due mainly to function + * call overhead. If you require accurate microsecond timing you + * should be using a dedicated timer/capture and suitable + * implementation. + * + * @code + * #include "cbed.h" + * + * int main() { + * LED1_USE; //!< @see iomacros.h + * while(1) { + * LED1_ON; + * cbed_wait(1.0); + * LED1_OFF; + * cbed_wait(1.0); + * } + * } + * @endcode + * + * @ingroup API + * @ingroup CBedTimer + * @param[in] d The number of seconds to wait (is double, fractional seconds) + */ +void cbed_wait(double d) +{ + cbed_wait_us((uint32_t)(d * 1000000.0)); +} + +#ifdef __cplusplus +} +#endif + Added: cbed/src/uart0.c =================================================================== --- cbed/src/uart0.c (rev 0) +++ cbed/src/uart0.c 2011-03-19 19:30:22 UTC (rev 1) @@ -0,0 +1,100 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file ticker.h + * @purpose Handles tickers, timeouts, timers and wait api. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include "../cbedopts.h" + +#ifdef CBED_BUILD_UART0 + +#ifdef CBED_BUILD_UART0_WITH_TX_BUFFER +#define CBED_BUILD_UARTx_WITH_TX_BUFFER CBED_BUILD_UART0_WITH_TX_BUFFER +#endif + +#ifdef CBED_BUILD_UART0_WITH_RX_BUFFER +#define CBED_BUILD_UARTx_WITH_RX_BUFFER CBED_BUILD_UART0_WITH_RX_BUFFER +#endif + +#define UARTX_tx_buffer cbed_uart0_tx_buffer +#define UARTX_tx_buffer_in cbed_uart0_tx_buffer_in +#define UARTX_tx_buffer_out cbed_uart0_tx_buffer_out +#define UARTX_tx_buffer_count cbed_uart0_tx_buffer_count + +#define UARTX_rx_buffer cbed_uart0_rx_buffer +#define UARTX_rx_buffer_in cbed_uart0_rx_buffer_in +#define UARTX_rx_buffer_out cbed_uart0_rx_buffer_out +#define UARTX_rx_buffer_count cbed_uart0_rx_buffer_count + +#define UARTX_callback_tx cbed_uart0_callback_tx +#define UARTX_callback_rx cbed_uart0_callback_rx +#define UARTX_callback_rx_overflow cbed_uart0_callback_rx_overflow + +#define UARTX_isr cbed_uart0_isr +#define UARTX_isr_tx cbed_uart0_isr_tx +#define UARTX_isr_rx cbed_uart0_isr_rx +#define UARTX__getc uart0__get +#define UARTX_getc uart0_getc +#define UARTX_putc uart0_putc + +#define UARTX_init cbed_uart0_init + +#define UARTX_IRQn UART0_IRQn + +#define UARTX_IIR LPC_UART0->IIR +#define UARTX_IER LPC_UART0->IER +#define UARTX_RBR LPC_UART0->RBR +#define UARTX_THR LPC_UART0->THR +#define UARTX_LSR LPC_UART0->LSR +#define UARTX_FCR LPC_UART0->FCR + +#define UARTX_PCONP LPC_SC->PCONP +#define UARTX_PCONP_VALUE (1UL << 3) +#define UARTX_PCLKSEL LPC_SC->PCLKSEL0 +#define UARTX_PCLKSEL_VALUE (3UL << 6) +#define UARTX_PINSEL_TX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_TX_VAL (1UL << 4) +#define UARTX_PINSEL_RX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_RX_VAL (1UL << 6) + +/* Pull in the common core uart code. */ +#include "uartx.h" + +/* For UART0 only, handle stdout/stdin redirection. */ + +#if CBED_TARGET == CBED_MBED +int __putc(int c) +{ + return 0; +} +#endif + +#if CBED_TARGET == CBED_LPCXPRESSO + +#endif + +#endif Added: cbed/src/uart1.c =================================================================== --- cbed/src/uart1.c (rev 0) +++ cbed/src/uart1.c 2011-03-19 19:30:22 UTC (rev 1) @@ -0,0 +1,87 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file uart1.c + * @purpose Builds the uart1 instance + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include "../cbedopts.h" + +#ifdef CBED_BUILD_UART1 + +#ifdef CBED_BUILD_UART1_WITH_TX_BUFFER +#define CBED_BUILD_UARTx_WITH_TX_BUFFER CBED_BUILD_UART1_WITH_TX_BUFFER +#endif + +#ifdef CBED_BUILD_UART1_WITH_RX_BUFFER +#define CBED_BUILD_UARTx_WITH_RX_BUFFER CBED_BUILD_UART1_WITH_RX_BUFFER +#endif + +#define UARTX_tx_buffer cbed_uart1_tx_buffer +#define UARTX_tx_buffer_in cbed_uart1_tx_buffer_in +#define UARTX_tx_buffer_out cbed_uart1_tx_buffer_out +#define UARTX_tx_buffer_count cbed_uart1_tx_buffer_count + +#define UARTX_rx_buffer cbed_uart1_rx_buffer +#define UARTX_rx_buffer_in cbed_uart1_rx_buffer_in +#define UARTX_rx_buffer_out cbed_uart1_rx_buffer_out +#define UARTX_rx_buffer_count cbed_uart1_rx_buffer_count + +#define UARTX_callback_tx cbed_uart1_callback_tx +#define UARTX_callback_rx cbed_uart1_callback_rx +#define UARTX_callback_rx_overflow cbed_uart1_callback_rx_overflow + +#define UARTX_isr cbed_uart1_isr +#define UARTX_isr_tx cbed_uart1_isr_tx +#define UARTX_isr_rx cbed_uart1_isr_rx +#define UARTX__getc uart1__get +#define UARTX_getc uart1_getc +#define UARTX_putc uart1_putc + +#define UARTX_init cbed_uart1_init + +#define UARTX_IRQn UART1_IRQn + +#define UARTX_IIR LPC_UART1->IIR +#define UARTX_IER LPC_UART1->IER +#define UARTX_RBR LPC_UART1->RBR +#define UARTX_THR LPC_UART1->THR +#define UARTX_LSR LPC_UART1->LSR +#define UARTX_FCR LPC_UART1->FCR + +#define UARTX_PCONP LPC_SC->PCONP +#define UARTX_PCONP_VALUE (1UL << 4) +#define UARTX_PCLKSEL LPC_SC->PCLKSEL0 +#define UARTX_PCLKSEL_VALUE (3UL << 8) +#define UARTX_PINSEL_TX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_TX_VAL (1UL << 30) +#define UARTX_PINSEL_RX LPC_PINCON->PINSEL1 +#define UARTX_PINSEL_RX_VAL (1UL << 0) + +/* Pull in the common core uart code. */ +#include "uartx.h" + +#endif Added: cbed/src/uart2.c =================================================================== --- cbed/src/uart2.c (rev 0) +++ cbed/src/uart2.c 2011-03-19 19:30:22 UTC (rev 1) @@ -0,0 +1,87 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file uart2.c + * @purpose Creates an instance of uart2 + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include "../cbedopts.h" + +#ifdef CBED_BUILD_UART2 + +#ifdef CBED_BUILD_UART2_WITH_TX_BUFFER +#define CBED_BUILD_UARTx_WITH_TX_BUFFER CBED_BUILD_UART2_WITH_TX_BUFFER +#endif + +#ifdef CBED_BUILD_UART2_WITH_RX_BUFFER +#define CBED_BUILD_UARTx_WITH_RX_BUFFER CBED_BUILD_UART2_WITH_RX_BUFFER +#endif + +#define UARTX_tx_buffer cbed_uart2_tx_buffer +#define UARTX_tx_buffer_in cbed_uart2_tx_buffer_in +#define UARTX_tx_buffer_out cbed_uart2_tx_buffer_out +#define UARTX_tx_buffer_count cbed_uart2_tx_buffer_count + +#define UARTX_rx_buffer cbed_uart2_rx_buffer +#define UARTX_rx_buffer_in cbed_uart2_rx_buffer_in +#define UARTX_rx_buffer_out cbed_uart2_rx_buffer_out +#define UARTX_rx_buffer_count cbed_uart2_rx_buffer_count + +#define UARTX_callback_tx cbed_uart2_callback_tx +#define UARTX_callback_rx cbed_uart2_callback_rx +#define UARTX_callback_rx_overflow cbed_uart2_callback_rx_overflow + +#define UARTX_isr cbed_uart2_isr +#define UARTX_isr_tx cbed_uart2_isr_tx +#define UARTX_isr_rx cbed_uart2_isr_rx +#define UARTX__getc uart2__get +#define UARTX_getc uart2_getc +#define UARTX_putc uart2_putc + +#define UARTX_init cbed_uart2_init + +#define UARTX_IRQn UART2_IRQn + +#define UARTX_IIR LPC_UART2->IIR +#define UARTX_IER LPC_UART2->IER +#define UARTX_RBR LPC_UART2->RBR +#define UARTX_THR LPC_UART2->THR +#define UARTX_LSR LPC_UART2->LSR +#define UARTX_FCR LPC_UART2->FCR + +#define UARTX_PCONP LPC_SC->PCONP +#define UARTX_PCONP_VALUE (1UL << 24) +#define UARTX_PCLKSEL LPC_SC->PCLKSEL1 +#define UARTX_PCLKSEL_VALUE (3UL << 16) +#define UARTX_PINSEL_TX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_TX_VAL (1UL << 20) +#define UARTX_PINSEL_RX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_RX_VAL (1UL << 22) + +/* Pull in the common core uart code. */ +#include "uartx.h" + +#endif Added: cbed/src/uart3.c =================================================================== --- cbed/src/uart3.c (rev 0) +++ cbed/src/uart3.c 2011-03-19 19:30:22 UTC (rev 1) @@ -0,0 +1,87 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file uart3.c + * @purpose Creates an instance of uart3 + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include "../cbedopts.h" + +#ifdef CBED_BUILD_UART3 + +#ifdef CBED_BUILD_UART3_WITH_TX_BUFFER +#define CBED_BUILD_UARTx_WITH_TX_BUFFER CBED_BUILD_UART3_WITH_TX_BUFFER +#endif + +#ifdef CBED_BUILD_UART3_WITH_RX_BUFFER +#define CBED_BUILD_UARTx_WITH_RX_BUFFER CBED_BUILD_UART3_WITH_RX_BUFFER +#endif + +#define UARTX_tx_buffer cbed_uart3_tx_buffer +#define UARTX_tx_buffer_in cbed_uart3_tx_buffer_in +#define UARTX_tx_buffer_out cbed_uart3_tx_buffer_out +#define UARTX_tx_buffer_count cbed_uart3_tx_buffer_count + +#define UARTX_rx_buffer cbed_uart3_rx_buffer +#define UARTX_rx_buffer_in cbed_uart3_rx_buffer_in +#define UARTX_rx_buffer_out cbed_uart3_rx_buffer_out +#define UARTX_rx_buffer_count cbed_uart3_rx_buffer_count + +#define UARTX_callback_tx cbed_uart3_callback_tx +#define UARTX_callback_rx cbed_uart3_callback_rx +#define UARTX_callback_rx_overflow cbed_uart3_callback_rx_overflow + +#define UARTX_isr cbed_uart3_isr +#define UARTX_isr_tx cbed_uart3_isr_tx +#define UARTX_isr_rx cbed_uart3_isr_rx +#define UARTX__getc uart3__get +#define UARTX_getc uart3_getc +#define UARTX_putc uart3_putc + +#define UARTX_init cbed_uart3_init + +#define UARTX_IRQn UART3_IRQn + +#define UARTX_IIR LPC_UART3->IIR +#define UARTX_IER LPC_UART3->IER +#define UARTX_RBR LPC_UART3->RBR +#define UARTX_THR LPC_UART3->THR +#define UARTX_LSR LPC_UART3->LSR +#define UARTX_FCR LPC_UART3->FCR + +#define UARTX_PCONP LPC_SC->PCONP +#define UARTX_PCONP_VALUE (1UL << 25) +#define UARTX_PCLKSEL LPC_SC->PCLKSEL1 +#define UARTX_PCLKSEL_VALUE (3UL << 18) +#define UARTX_PINSEL_TX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_TX_VAL (1UL << 0) +#define UARTX_PINSEL_RX LPC_PINCON->PINSEL0 +#define UARTX_PINSEL_RX_VAL (1UL << 2) + +/* Pull in the common core uart code. */ +#include "uartx.h" + +#endif Added: cbed/src/uartx.h =================================================================== --- cbed/src/uartx.h (rev 0) +++ cbed/src/uartx.h 2011-03-19 19:30:22 UTC (rev 1) @@ -0,0 +1,241 @@ +/* + Copyright (c) 2011 Andy Kirkham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/** + * @file uartx.h + * @purpose General file that exapnds to create a UART instance. + * @version see ChangeLog.h + * @date Mar 2011 + * @author Andy Kirkham + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <time.h> +#include <stdint.h> +#include "cmsis_nvic.h" +#include "LPC17xx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CBED_BUILD_UARTx_WITH_TX_BUFFER +static char UARTX_tx_buffer[CBED_BUILD_UARTx_WITH_TX_BUFFER]; +static int UARTX_tx_buffer_in; +static int UARTX_tx_buffer_out; +static int UARTX_tx_buffer_count; +#endif + +#ifdef CBED_BUILD_UARTx_WITH_RX_BUFFER +static char UARTX_rx_buffer[CBED_BUILD_UARTx_WITH_RX_BUFFER]; +static int UARTX_rx_buffer_in; +static int UARTX_rx_buffer_out; +static int UARTX_rx_buffer_count; +#endif + +void (*UARTX_callback_tx)(void); +void (*UARTX_callback_rx)(void); +void (*UARTX_callback_rx_overflow)(char c); + +void UARTX_isr_tx(bool doCallback) +{ + #ifdef CBED_BUILD_UARTx_WITH_TX_BUFFER + if (UARTX_tx_buffer_in != UARTX_tx_buffer_out || UARTX_tx_buffer_count == CBED_BUILD_UARTx_WITH_TX_BUFFER) { + UARTX_THR = (uint32_t)UARTX_tx_buffer[UARTX_tx_buffer_out]; + UARTX_tx_buffer_count--; + UARTX_tx_buffer_out++; + if (UARTX_tx_buffer_out == CBED_BUILD_UARTx_WITH_TX_BUFFER) { + UARTX_tx_buffer_out = 0; + } + if (UARTX_tx_buffer_count == 0) { + UARTX_IER = 1; + } + if (doCallback && UARTX_callback_tx) (UARTX_callback_tx)(); + } + #else + UARTX_IER = 1; + if (UARTX_callback_tx) (UARTX_callback_tx)(); + #endif +} + +void UARTX_isr_rx(void) +{ + #ifdef CBED_BUILD_UARTx_WITH_RX_BUFFER + char c __attribute__((unused)); + while(UARTX_LSR & 0x1) { + if (UARTX_rx_buffer_count == CBED_BUILD_UARTx_WITH_RX_BUFFER) { + c = UARTX_RBR; + if (UARTX_callback_rx_overflow) (UARTX_callback_rx_overflow)(c); + } + else { + UARTX_rx_buffer[UARTX_rx_buffer_in] = UARTX_RBR; + UARTX_rx_buffer_in++; + if (UARTX_rx_buffer_in == CBED_BUILD_UARTx_WITH_RX_BUFFER) { + UARTX_rx_buffer_in = 0; + } + UARTX_rx_buffer_count++; + if (UARTX_callback_rx) (UARTX_callback_rx)(); + } + } + #else + if (UARTX_callback_rx) (UARTX_callback_rx)(); + #endif +} + +int UARTX_putc(int c, bool block) +{ + #ifdef CBED_BUILD_UARTx_WITH_TX_BUFFER + uint32_t ier; + if (UARTX_LSR & (1UL << 5) && UARTX_tx_buffer_count == 0) { + UARTX_THR = (uint32_t)c; + } + else { + if (block) { + ier = UARTX_IER; UARTX_IER = 1; + while(UARTX_tx_buffer_count == CBED_BUILD_UARTx_WITH_TX_BUFFER) { + UARTX_isr_tx(false); + } + UARTX_IER = ier; + } + else if (UARTX_tx_buffer_count == CBED_BUILD_UARTx_WITH_TX_BUFFER) { + return -1; + } + UARTX_IER &= ~2; + UARTX_tx_buffer[UARTX_tx_buffer_in] = c; + UARTX_tx_buffer_in++; + if (UARTX_tx_buffer_in == CBED_BUILD_UARTx_WITH_TX_BUFFER) UARTX_tx_buffer_in = 0; + UARTX_IER |= 2; + } + #else + while(!(UARTX_LSR & (1UL << 5)); + UARTX_THR = (uint32_t)c; + #endif + return 0; +} + +int UARTX__getc(bool block) { + #ifdef CBED_BUILD_UARTx_WITH_RX_BUFFER + uint32_t ier; + int c; + if (block) { while (UARTX_rx_buffer_count == 0) ; } /* blocks. */ + else if (UARTX_rx_buffer_count == 0) return -1; + c = UARTX_rx_buffer[UARTX_rx_buffer_out]; + UARTX_rx_buffer_out++; + if (UARTX_rx_buffer_out == CBED_BUILD_UARTx_WITH_RX_BUFFER) UARTX_rx_buffer_out = 0; + if (UARTX_rx_buffer_count != CBED_BUILD_UARTx_WITH_RX_BUFFER) { + ier = UARTX_IER; + UARTX_IER &= ~(1UL << 0); + UARTX_isr_rx(); + UARTX_IER = ier; + } + UARTX_rx_buffer_count--; + return c; + #else + if (block) { + while (!(UARTX_LSR & (1UL << 0)) ; + return (int)(UARTX_RBR & 0xFF); + } + else { + if (!(UARTX_LSR & (1UL << 0)) return -1; + return (int)(UARTX_RBR & 0xFF); + } + #endif +} + +int UARTX_getc(void) { + return UARTX__getc(true); +} + +extern "C" void UARTX_isr(void) __irq +{ + volatile uint32_t iir, lsr; + + iir = UARTX_IIR; + + if (iir & 1) return; + + iir = (iir >> 1) & 0x3; + + if (iir == 2) { + UARTX_isr_rx(); ... [truncated message content] |