mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Add basic lm3s6918 gpio support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1778 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -827,7 +827,8 @@
|
||||
<p>
|
||||
<b>STATUS:</b>
|
||||
This port is in progress. Coding is complete on the basic port (timer, serial console, SPI).
|
||||
Verified support for the i.MX1 will be announced in a future release of NuttX.
|
||||
Verified support for the i.MX1 will be announced in a future release of NuttX (work has
|
||||
been temporarily stopped to support the Luminary LM3S6918).
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -851,10 +852,32 @@
|
||||
<b>STATUS:</b>
|
||||
The basic port (timer interrupts, serial ports, network, framebuffer, etc.) is complete.
|
||||
All implemented features have been verified with the exception of the USB device-side
|
||||
driver; that implementation is complete but completely untested.
|
||||
driver; that implementation is complete but untested.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td bgcolor="#5eaee1">
|
||||
<b>ARM Cortex-M3</b>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<p>
|
||||
<b>Luminary LM3S6918</b>.
|
||||
This port uses theMicromint Eagle-10 development board with a GNU arm-elf toolchain*
|
||||
under either Linux or Cygwin.
|
||||
</p>
|
||||
<p>
|
||||
<b>STATUS:</b>
|
||||
This port is in progress. Coding is complete on the basic port (timer, serial console, SPI).
|
||||
Verified support for the Cortex-M3 will be announced in a future release of NuttX.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td bgcolor="#5eaee1">
|
||||
|
||||
@@ -43,11 +43,11 @@ CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copystate.c \
|
||||
up_prefetchabort.c up_releasepending.c up_releasestack.c \
|
||||
up_reprioritizertr.c up_schedulesigaction.c \
|
||||
up_sigdeliver.c up_syscall.c up_unblocktask.c \
|
||||
up_undefinedinsn.c up_usestack.c
|
||||
up_undefinedinsn.c up_usestack.c up_doirq.c
|
||||
|
||||
CHIP_ASRCS = lm3s_context.S
|
||||
CHIP_CSRCS = lm3s_start.c lm3s_syscontrol.c lm3s_irq.c lm3s_pendsv.c \
|
||||
lm3s_timerisr.c lm3s_lowputc.c lm3s_serial.c
|
||||
lm3s_gpio.c lm3s_timerisr.c lm3s_lowputc.c lm3s_serial.c
|
||||
|
||||
ifdef CONFIG_NET
|
||||
CHIP_CSRCS += lm3s_ethernet.c
|
||||
|
||||
@@ -565,14 +565,10 @@ int lm3s_initialize(void)
|
||||
/* Enable Port F for Ethernet LEDs: LED0=Bit 3; LED1=Bit 2 */
|
||||
|
||||
#ifdef CONFIG_LM3S_ETHLEDS
|
||||
/* Make sure that the GPIOF peripheral is enabled */
|
||||
|
||||
modifyreg32(LM3S_SYSCON_RCGC2_OFFSET, 0, SYSCON_RCGC2_GPIOF);
|
||||
|
||||
/* Configure the pins for the peripheral function */
|
||||
|
||||
lm3s_configgpio(GPIO_FUNC_PERIPHERAL | GPIO_STRENGTH_2MA | GPIO_PADTYPE_STD | GPIO_PORTF | 2);
|
||||
lm3s_configgpio(GPIO_FUNC_PERIPHERAL | GPIO_STRENGTH_2MA | GPIO_PADTYPE_STD | GPIO_PORTF | 3);
|
||||
lm3s_configgpio(GPIO_ETHPHY_LED0 | GPIO_STRENGTH_2MA | GPIO_PADTYPE_STD);
|
||||
lm3s_configgpio(GPIO_ETHPHY_LED1 | GPIO_STRENGTH_2MA | GPIO_PADTYPE_STD);
|
||||
#endif
|
||||
|
||||
#warning "Missing logic"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -57,12 +57,19 @@
|
||||
* The default priority level is set to the middle value
|
||||
*/
|
||||
|
||||
#define NVIC_SYSH_PRIORITY_MIN 0x00
|
||||
#define NVIC_SYSH_PRIORITY_DEFAULT 0x80
|
||||
#define NVIC_SYSH_PRIORITY_MAX 0xe0
|
||||
#define NVIC_SYSH_PRIORITY_MIN 0xe0 /* All bits set in minimum priority */
|
||||
#define NVIC_SYSH_PRIORITY_DEFAULT 0x80 /* Midpoint is the default */
|
||||
#define NVIC_SYSH_PRIORITY_MAX 0x00 /* Zero is maximum priority */
|
||||
|
||||
/* Bit-encoded input to lm3s_configgpio() *******************************************/
|
||||
|
||||
/* Encoding:
|
||||
* FFFS SPPP IIIn nnnn nnnn nnnn nVPP PBBB
|
||||
*
|
||||
* These bits set the primary function of the pin:
|
||||
* FFFn nnnn nnnn nnnn nnnn nnnn nnnn nnnn
|
||||
*/
|
||||
|
||||
#define GPIO_FUNC_SHIFT 29 /* Bit 31-29: GPIO function */
|
||||
#define GPIO_FUNC_MASK (7 << GPIO_FUNC_SHIFT) /* (See table 9-1 in data sheet) */
|
||||
#define GPIO_FUNC_INPUT (0 << GPIO_FUNC_SHIFT) /* Digital GPIO input */
|
||||
@@ -75,23 +82,21 @@
|
||||
#define GPIO_FUNC_PFIO (5 << GPIO_FUNC_SHIFT) /* Digital input/output (SSI, UART) */
|
||||
#define GPIO_FUNC_ANINPUT (6 << GPIO_FUNC_SHIFT) /* Analog input (Comparator) */
|
||||
#define GPIO_FUNC_INTERRUPT (7 << GPIO_FUNC_SHIFT) /* Interrupt function */
|
||||
#define GPIO_FUNC_MAX GPIO_FUNC_INTERRUPT
|
||||
|
||||
#define GPIO_INT_SHIFT 26 /* Bits 28-26: Interrupt type */
|
||||
#define GPIO_INT_MASK (7 << GPIO_INT_SHIFT)
|
||||
#define GPIO_INT_FALLINGEDGE (0 << GPIO_INT_SHIFT) /* Interrupt on falling edge */
|
||||
#define GPIO_INT_RISINGEDGE (1 << GPIO_INT_SHIFT) /* Interrupt on rising edge */
|
||||
#define GPIO_INT_BOTHEDGES (2 << GPIO_INT_SHIFT) /* Interrupt on both edges */
|
||||
#define GPIO_INT_LOWLEVEL (3 << GPIO_INT_SHIFT) /* Interrupt on low level */
|
||||
#define GPIO_INT_HIGHLEVEL (4 << GPIO_INT_SHIFT) /* Interrupt on high level */
|
||||
/* That primary may be modified by the following options
|
||||
* nnnS SPPP nnnn nnnn nnnn nnnn nnnn nnnn
|
||||
*/
|
||||
|
||||
#define GPIO_STRENGTH_SHIFT 24 /* Bits 25-24: Pad drive strength */
|
||||
#define GPIO_STRENGTH_SHIFT 27 /* Bits 28-27: Pad drive strength */
|
||||
#define GPIO_STRENGTH_MASK (3 << GPIO_STRENGTH_SHIFT)
|
||||
#define GPIO_STRENGTH_2MA (0 << GPIO_STRENGTH_SHIFT) /* 2mA pad drive strength */
|
||||
#define GPIO_STRENGTH_4MA (1 << GPIO_STRENGTH_SHIFT) /* 4mA pad drive strength */
|
||||
#define GPIO_STRENGTH_8MA (2 << GPIO_STRENGTH_SHIFT) /* 8mA pad drive strength */
|
||||
#define GPIO_STRENGTH_8MASC (3 << GPIO_STRENGTH_SHIFT) /* 8mA Pad drive with slew rate control */
|
||||
#define GPIO_STRENGTH_MAX GPIO_STRENGTH_8MASC
|
||||
|
||||
#define GPIO_PADTYPE_SHIFT 21 /* Bits 21-23: Pad type */
|
||||
#define GPIO_PADTYPE_SHIFT 24 /* Bits 26-24: Pad type */
|
||||
#define GPIO_PADTYPE_MASK (7 << GPIO_PADTYPE_SHIFT)
|
||||
#define GPIO_PADTYPE_STD (0 << GPIO_PADTYPE_SHIFT) /* Push-pull */
|
||||
#define GPIO_PADTYPE_STDWPU (1 << GPIO_PADTYPE_SHIFT) /* Push-pull with weak pull-up */
|
||||
@@ -101,11 +106,31 @@
|
||||
#define GPIO_PADTYPE_ODWPD (5 << GPIO_PADTYPE_SHIFT) /* Open-drain with weak pull-down */
|
||||
#define GPIO_PADTYPE_ANALOG (6 << GPIO_PADTYPE_SHIFT) /* Analog comparator */
|
||||
|
||||
/* If the pin is an interrupt, then the following options apply
|
||||
* nnnn nnnn IIIn nnnn nnnn nnnn nnnn nnnn
|
||||
*/
|
||||
|
||||
#define GPIO_INT_SHIFT 21 /* Bits 23-21: Interrupt type */
|
||||
#define GPIO_INT_MASK (7 << GPIO_INT_SHIFT)
|
||||
#define GPIO_INT_FALLINGEDGE (0 << GPIO_INT_SHIFT) /* Interrupt on falling edge */
|
||||
#define GPIO_INT_RISINGEDGE (1 << GPIO_INT_SHIFT) /* Interrupt on rising edge */
|
||||
#define GPIO_INT_BOTHEDGES (2 << GPIO_INT_SHIFT) /* Interrupt on both edges */
|
||||
#define GPIO_INT_LOWLEVEL (3 << GPIO_INT_SHIFT) /* Interrupt on low level */
|
||||
#define GPIO_INT_HIGHLEVEL (4 << GPIO_INT_SHIFT) /* Interrupt on high level */
|
||||
|
||||
/* If the pin is an GPIO digital output, then this identifies the initial output value:
|
||||
* nnnn nnnn nnnn nnnn nnnn nnnn nVnn nnnn
|
||||
*/
|
||||
|
||||
#define GPIO_VALUE_SHIFT 6 /* Bit 6: If output, inital value of output */
|
||||
#define GPIO_VALUE_MASK (1 << GPIO_VALUE_SHIFT)
|
||||
#define GPIO_VALUE_ZERO (0 << GPIO_VALUE_SHIFT) /* Initial value is zero */
|
||||
#define GPIO_VALUE_ONE (1 << GPIO_VALUE_SHIFT) /* Initial value is one */
|
||||
|
||||
/* This identifies the GPIO port
|
||||
* nnnn nnnn nnnn nnnn nnnn nnnn nnPP Pnnn
|
||||
*/
|
||||
|
||||
#define GPIO_PORT_SHIFT 3 /* Bit 3-5: Port number */
|
||||
#define GPIO_PORT_MASK (7 << GPIO_PORT_SHIFT)
|
||||
#define GPIO_PORTA (0 << GPIO_PORT_SHIFT) /* GPIOA */
|
||||
@@ -117,6 +142,10 @@
|
||||
#define GPIO_PORTG (6 << GPIO_PORT_SHIFT) /* GPIOG */
|
||||
#define GPIO_PORTH (7 << GPIO_PORT_SHIFT) /* GPIOH */
|
||||
|
||||
/* This identifies the bit in the port:
|
||||
* nnnn nnnn nnnn nnnn nnnn nnnn nnnn nBBB
|
||||
*/
|
||||
|
||||
#define GPIO_NUMBER_SHIFT 0 /* Bits 0-2: GPIO number: 0-7 */
|
||||
#define GPIO_NUMBER_MASK (7 << GPIO_NUMBER_SHIFT)
|
||||
|
||||
@@ -172,24 +201,6 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
static inline uint32 lm3s_gpiobaseaddress(unsigned int port)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_CHIP_LM3S6918
|
||||
unsigned int portno = (port >> GPIO_PORT_SHIFT) & 7;
|
||||
if (portno < 4)
|
||||
{
|
||||
return LM3S_GPIOA_BASE + 0x1000 * portno;
|
||||
}
|
||||
else
|
||||
{
|
||||
return LM3S_GPIOE_BASE + 0x1000 * portno;
|
||||
}
|
||||
#else
|
||||
# error "GPIO register base addresses not known for this LM3S chip"
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
@@ -249,7 +260,7 @@ EXTERN void up_clockconfig(void);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int lm3s_configgpio(uint32 bitset);
|
||||
EXTERN int lm3s_configgpio(uint32 cfgset);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lm3s_pendsv
|
||||
@@ -261,6 +272,26 @@ EXTERN int lm3s_configgpio(uint32 bitset);
|
||||
|
||||
EXTERN int lm3s_pendsv(int irq, FAR void *context);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lm3s_gpiowrite
|
||||
*
|
||||
* Description:
|
||||
* Write one or zero to the selected GPIO pin
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void lm3s_gpiowrite(uint32 pinset, boolean value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lm3s_gpioread
|
||||
*
|
||||
* Description:
|
||||
* Read one or zero from the selected GPIO pin
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN boolean lm3s_gpioread(uint32 pinset, boolean value);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "os_internal.h"
|
||||
@@ -173,13 +175,17 @@ void up_irqinitialize(void)
|
||||
|
||||
current_regs = NULL;
|
||||
|
||||
/* Attach the PendSV exception handler. This is used for performing
|
||||
/* Attach the PendSV exception handler and set it to the minimum
|
||||
* prioirity. The PendSV exception is used for performing
|
||||
* context switches.
|
||||
*/
|
||||
|
||||
irq_attach(LMSB_IRQ_PENDSV, lm3s_pendsv);
|
||||
#ifdef CONFIG_ARCH_IRQPRIO
|
||||
up_prioritize_irq(LMSB_IRQ_PENDSV, NVIC_SYSH_PRIORITY_MIN);
|
||||
#endif
|
||||
|
||||
/* Attach all processor exceptions (except reset and sys tick) */
|
||||
/* Attach all other processor exceptions (except reset and sys tick) */
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
irq_attach(LMSB_IRQ_NMI, lm3s_nmi);
|
||||
@@ -285,7 +291,7 @@ int up_prioritize_irq(int irq, int priority)
|
||||
uint32 regval;
|
||||
int shift;
|
||||
|
||||
DEBUGASSERT(irq >= LMSB_IRQ_MPU && irq < NR_IRQS && (unsigned)priority <= NVIC_SYSH_PRIORITY_MAX);
|
||||
DEBUGASSERT(irq >= LMSB_IRQ_MPU && irq < NR_IRQS && (unsigned)priority <= NVIC_SYSH_PRIORITY_MIN);
|
||||
|
||||
if (irq < LM3S_IRQ_INTERRUPTS)
|
||||
{
|
||||
|
||||
@@ -249,22 +249,6 @@ void up_lowsetup(void)
|
||||
putreg32(ctl, LM3S_CONSOLE_BASE+LM3S_UART_CTL_OFFSET);
|
||||
#endif
|
||||
|
||||
/* Peripheral clocking to the selected UART modules and to the GPIO
|
||||
* modules used for the pin configuration. NOTE: this function is
|
||||
* called very early in the boot sequence so we do not need to be
|
||||
* concerned about exclusive access to registers.
|
||||
*/
|
||||
|
||||
rcgc1 = getreg32(LM3S_SYSCON_RCGC1);
|
||||
#if !defined(CONFIG_UART0_DISABLE) && !defined(CONFIG_UART1_DISABLE)
|
||||
rcgc1 |= (SYSCON_RCGC1_UART0|SYSCON_RCGC2_GPIOA|SYSCON_RCGC1_UART1|SYSCON_RCGC2_GPIOD);
|
||||
#elif !defined(CONFIG_UART0_DISABLE)
|
||||
rcgc1 |= (SYSCON_RCGC1_UART0|SYSCON_RCGC2_GPIOA);
|
||||
#elif !defined(CONFIG_UART1_DISABLE)
|
||||
rcgc1 |= (SYSCON_RCGC1_UART1|SYSCON_RCGC2_GPIOD);
|
||||
#endif
|
||||
putreg32(rcgc1, LM3S_SYSCON_RCGC1);
|
||||
|
||||
/* Then configure GPIO pins to enable the selected UARTs. NOTE: The
|
||||
* serial driver later depends on this pin configuration.
|
||||
*/
|
||||
|
||||
@@ -102,7 +102,7 @@ extern void lm3s_vectors(void);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void _start(void)
|
||||
void __start(void)
|
||||
{
|
||||
const uint32 *src;
|
||||
uint32 *dest;
|
||||
|
||||
@@ -210,6 +210,7 @@
|
||||
|
||||
/* Device Capabilities 4 (DC4), offset 0x01c */
|
||||
|
||||
#define SYSCON_DC4_GPIO(n) (1 << (n))
|
||||
#define SYSCON_DC4_GPIOA (1 << 0) /* Bit 0: GPIO Port A Present */
|
||||
#define SYSCON_DC4_GPIOB (1 << 1) /* Bit 1: GPIO Port B Present */
|
||||
#define SYSCON_DC4_GPIOC (1 << 2) /* Bit 2: GPIO Port C Present */
|
||||
@@ -264,6 +265,7 @@
|
||||
|
||||
/* Software Reset Control 2 (SRCR2), offset 0x048 */
|
||||
|
||||
#define SYSCON_SRCR2_GPIO(n) (1 << (n))
|
||||
#define SYSCON_SRCR2_GPIOA (1 << 0) /* Bit 0: Port A Reset Control */
|
||||
#define SYSCON_SRCR2_GPIOB (1 << 1) /* Bit 1: Port B Reset Control */
|
||||
#define SYSCON_SRCR2_GPIOC (1 << 2) /* Bit 2: Port C Reset Control */
|
||||
@@ -382,6 +384,7 @@
|
||||
|
||||
/* Run Mode Clock Gating Control Register 2 (RCGC2), offset 0x108 */
|
||||
|
||||
#define SYSCON_RCGC2_GPIO(n) (1 << (n))
|
||||
#define SYSCON_RCGC2_GPIOA (1 << 0) /* Bit 0: Port A Clock Gating Control */
|
||||
#define SYSCON_RCGC2_GPIOB (1 << 1) /* Bit 1: Port B Clock Gating Control */
|
||||
#define SYSCON_RCGC2_GPIOC (1 << 2) /* Bit 2: Port C Clock Gating Control */
|
||||
@@ -418,6 +421,7 @@
|
||||
|
||||
/* Sleep Mode Clock Gating Control Register 2 (SCGC2), offset 0x118 */
|
||||
|
||||
#define SYSCON_SCGC2_GPIO(n) (1 << (n))
|
||||
#define SYSCON_SCGC2_GPIOA (1 << 0) /* Bit 0: Port A Clock Gating Control */
|
||||
#define SYSCON_SCGC2_GPIOB (1 << 1) /* Bit 1: Port B Clock Gating Control */
|
||||
#define SYSCON_SCGC2_GPIOC (1 << 2) /* Bit 2: Port C Clock Gating Control */
|
||||
@@ -454,6 +458,7 @@
|
||||
|
||||
/* Deep Sleep Mode Clock Gating Control Register 2 (DCGC2), offset 0x128 */
|
||||
|
||||
#define SYSCON_DCGC2_GPIO(n) (1 << (n))
|
||||
#define SYSCON_DCGC2_GPIOA (1 << 0) /* Bit 0: Port A Clock Gating Control */
|
||||
#define SYSCON_DCGC2_GPIOB (1 << 1) /* Bit 1: Port B Clock Gating Control */
|
||||
#define SYSCON_DCGC2_GPIOC (1 << 2) /* Bit 2: Port C Clock Gating Control */
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
* Global Symbols
|
||||
************************************************************************************/
|
||||
|
||||
.globl __start
|
||||
.globl dispach_irq
|
||||
|
||||
.syntax unified
|
||||
@@ -99,7 +100,7 @@
|
||||
lm3s_vectors:
|
||||
/* Processor Exceptions */
|
||||
.word IDLE_STACK /* Vector 0: Reset stack pointer */
|
||||
.word _start /* Vector 1: Reset vector */
|
||||
.word __start /* Vector 1: Reset vector */
|
||||
.word lm3s_nmi /* Vector 2: Non-Maskable Interrupt (NMI) */
|
||||
.word lm3s_hardfault /* Vector 3: Hard fault */
|
||||
.word lm3s_mpu /* Vector 4: Memory management (MPU) */
|
||||
|
||||
@@ -474,6 +474,11 @@ configs/c5471evm
|
||||
NuttX runs on the ARM core and is built with a GNU arm-elf toolchain*.
|
||||
This port is complete, verified, and included in the NuttX release.
|
||||
|
||||
configs/eagle100
|
||||
Micromint Eagle-100 Development board. This board is based on the
|
||||
an ARM Cortex-M3 MCU, the Luminary LM3S6918. This OS is built with the
|
||||
arm-elf toolchain*. STATUS: This port is currently under development.
|
||||
|
||||
configs/ez80f0910200kitg
|
||||
ez80Acclaim! Microcontroller. This port use the Zilog ez80f0910200kitg
|
||||
development kit, eZ80F091 part, and the Zilog ZDS-II Windows command line
|
||||
@@ -493,6 +498,12 @@ configs/mcu123-lpc214x
|
||||
lpc214x development board. This OS is also built with the arm-elf
|
||||
toolchain*. The port supports serial, timer0, spi, and usb.
|
||||
|
||||
configs/mx1ads
|
||||
This is a port to the Motorola MX1ADS development board. That board
|
||||
is based on the Freescale i.MX1 processor. The i.MX1 is an ARM920T.
|
||||
STATUS: This port is nearly code complete but still under development
|
||||
(work is stalled until I devote time to the Micromint Eagle-100)
|
||||
|
||||
configs/ntosd-dm320
|
||||
This port uses the Neuros OSD with a GNU arm-elf toolchain*:
|
||||
see http://wiki.neurostechnology.com/index.php/Developer_Welcome .
|
||||
|
||||
Reference in New Issue
Block a user