mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
c5471 bringup changes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@41 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -34,9 +34,6 @@
|
|||||||
This port uses the <a href="http://www.pjrc.com/">PJRC</a> 87C52 development system
|
This port uses the <a href="http://www.pjrc.com/">PJRC</a> 87C52 development system
|
||||||
and the <a href="http://sdcc.sourceforge.net/">SDCC</a> toolchain.
|
and the <a href="http://sdcc.sourceforge.net/">SDCC</a> toolchain.
|
||||||
This port will require a few more weeks before it is ready for prime time.</li>
|
This port will require a few more weeks before it is ready for prime time.</li>
|
||||||
<li><b>Motorola (Freescale) MC68HC908GP32 Microcontroller</b>.
|
|
||||||
Using the Axiom CMS8GP32 development board.
|
|
||||||
This is next in the queue.</li>
|
|
||||||
<li><b>Other ports</b>.
|
<li><b>Other ports</b>.
|
||||||
I also have partial ports for the TI TMS320DM270 and for MIPS.
|
I also have partial ports for the TI TMS320DM270 and for MIPS.
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -226,10 +226,6 @@ arch/pjrc-8051
|
|||||||
8051 Microcontroller. This port uses the PJRC 87C52 development system
|
8051 Microcontroller. This port uses the PJRC 87C52 development system
|
||||||
and the SDCC toolchain. This port is not quite ready for prime time.
|
and the SDCC toolchain. This port is not quite ready for prime time.
|
||||||
|
|
||||||
arch/axiom-mc68
|
|
||||||
For the Motorola (Freescale) MC68HC908GP32 Microcontroller using the
|
|
||||||
Axiom CMS8GP32 development board. This has not yet been checked-in.
|
|
||||||
|
|
||||||
arch/sim
|
arch/sim
|
||||||
x86 Linux Simulation</b>. Fully functional.
|
x86 Linux Simulation</b>. Fully functional.
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,14 @@
|
|||||||
#
|
#
|
||||||
# CONFIG_ARCH - identifies the arch subdirectory
|
# CONFIG_ARCH - identifies the arch subdirectory
|
||||||
# CONFIG_ARCH_name - for use in C code
|
# CONFIG_ARCH_name - for use in C code
|
||||||
# CONFIG_ROM_VECTORS - unique to arm7tdmi
|
# CONFIG_ROM_VECTORS - unique to c5471
|
||||||
|
# CONFIG_DRAM_END - the size of installed DRAM.
|
||||||
|
# Unique to c5471
|
||||||
#
|
#
|
||||||
CONFIG_ARCH=c5471
|
CONFIG_ARCH=c5471
|
||||||
CONFIG_ARCH_C5471=y
|
CONFIG_ARCH_C5471=y
|
||||||
CONFIG_ROM_VECTORS=n
|
CONFIG_ROM_VECTORS=n
|
||||||
|
CONFIG_DRAM_END=0x11000000
|
||||||
|
|
||||||
#
|
#
|
||||||
# C5471 specific device driver settings
|
# C5471 specific device driver settings
|
||||||
@@ -59,8 +62,8 @@ CONFIG_ROM_VECTORS=n
|
|||||||
# CONFIG_UART_*_2STOP - Two stop bits
|
# CONFIG_UART_*_2STOP - Two stop bits
|
||||||
#
|
#
|
||||||
CONFIG_SERIAL_IRDA_CONSOLE=n
|
CONFIG_SERIAL_IRDA_CONSOLE=n
|
||||||
CONFIG_UART_IRDA_HWFLOWCONTROL=y
|
CONFIG_UART_IRDA_HWFLOWCONTROL=n
|
||||||
CONFIG_UART_MODEM_HWFLOWCONTROL=y
|
CONFIG_UART_MODEM_HWFLOWCONTROL=n
|
||||||
CONFIG_UART_IRDA_RXBUFSIZE=256
|
CONFIG_UART_IRDA_RXBUFSIZE=256
|
||||||
CONFIG_UART_MODEM_RXBUFSIZE=256
|
CONFIG_UART_MODEM_RXBUFSIZE=256
|
||||||
CONFIG_UART_IRDA_TXBUFSIZE=256
|
CONFIG_UART_IRDA_TXBUFSIZE=256
|
||||||
@@ -228,5 +231,5 @@ CONFIG_STACK_POINTER=
|
|||||||
CONFIG_PROC_STACK_SIZE=4096
|
CONFIG_PROC_STACK_SIZE=4096
|
||||||
CONFIG_PTHREAD_STACK_MIN=256
|
CONFIG_PTHREAD_STACK_MIN=256
|
||||||
CONFIG_PTHREAD_STACK_DEFAULT=4096
|
CONFIG_PTHREAD_STACK_DEFAULT=4096
|
||||||
CONFIG_HEAP_BASE=(0x10300000+90*1024+CONFIG_PROC_STACK_SIZE)
|
CONFIG_HEAP_BASE=
|
||||||
CONFIG_HEAP_SIZE=(0x11000000-CONFIG_HEAP_BASE)
|
CONFIG_HEAP_SIZE=
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ CSRCS = up_initialize.c up_initialstate.c up_idle.c up_doirq.c \
|
|||||||
up_createstack.c up_usestack.c up_releasestack.c \
|
up_createstack.c up_usestack.c up_releasestack.c \
|
||||||
up_exit.c up_assert.c up_blocktask.c up_unblocktask.c \
|
up_exit.c up_assert.c up_blocktask.c up_unblocktask.c \
|
||||||
up_releasepending.c up_reprioritizertr.c up_copystate.c \
|
up_releasepending.c up_reprioritizertr.c up_copystate.c \
|
||||||
up_schedulesigaction.c up_sigdeliver.c up_serial.c
|
up_schedulesigaction.c up_sigdeliver.c up_serial.c \
|
||||||
|
up_delay.c up_allocateheap.c
|
||||||
COBJS = $(CSRCS:.c=.o)
|
COBJS = $(CSRCS:.c=.o)
|
||||||
|
|
||||||
SRCS = $(ASRCS) $(CSRCS)
|
SRCS = $(ASRCS) $(CSRCS)
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/************************************************************
|
||||||
|
* up_allocateheap.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Included Files
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include "up_internal.h"
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Private Definitions
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Private Data
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Private Functions
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Public Functions
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Name: up_allocate_heap
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* The heap may be statically allocated by
|
||||||
|
* defining CONFIG_HEAP_BASE and CONFIG_HEAP_SIZE. If these
|
||||||
|
* are not defined, then this function will be called to
|
||||||
|
* dynamically set aside the heap region.
|
||||||
|
*
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
|
||||||
|
{
|
||||||
|
*heap_start = (FAR void*)g_heapstart;
|
||||||
|
*heap_size = CONFIG_DRAM_END - g_heapstart;
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
/************************************************************
|
||||||
|
* up_delay.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Included Files
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <semaphore.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/fs.h>
|
||||||
|
#include <arch/serial.h>
|
||||||
|
#include "c5471.h"
|
||||||
|
#include "os_internal.h"
|
||||||
|
#include "up_internal.h"
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Definitions
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
#define LOOPS_PER_MSEC 1250
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Private Types
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Private Function Prototypes
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Private Variables
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Private Functions
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Public Funtions
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Name: up_delay
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Delay inline for the requested number of milliseconds.
|
||||||
|
* NOT multi-tasking friendly.
|
||||||
|
*
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
void up_delay(int milliseconds)
|
||||||
|
{
|
||||||
|
volatile int i;
|
||||||
|
volatile int j;
|
||||||
|
|
||||||
|
for (i = 0; i < milliseconds; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < LOOPS_PER_MSEC; j++)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,6 +64,7 @@
|
|||||||
* us and that only leaves us having to do some os specific things
|
* us and that only leaves us having to do some os specific things
|
||||||
* below.
|
* below.
|
||||||
*/
|
*/
|
||||||
|
.text
|
||||||
.global __start
|
.global __start
|
||||||
.type __start, #function
|
.type __start, #function
|
||||||
__start:
|
__start:
|
||||||
@@ -122,7 +123,9 @@ __start:
|
|||||||
* _sbss is the start of the BSS region (see ld.script)
|
* _sbss is the start of the BSS region (see ld.script)
|
||||||
* _ebss is the end of the BSS regsion (see ld.script)
|
* _ebss is the end of the BSS regsion (see ld.script)
|
||||||
* The idle task stack starts at the end of BSS and is
|
* The idle task stack starts at the end of BSS and is
|
||||||
* of size CONFIG_PROC_STACK_SIZE
|
* of size CONFIG_PROC_STACK_SIZE. The heap continues
|
||||||
|
* from there until the end of memory. See g_heapstart
|
||||||
|
* below.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LC0: .long _sbss
|
LC0: .long _sbss
|
||||||
@@ -134,6 +137,20 @@ LC2: .long _eronly /* Where .data defaults are stored in FLASH */
|
|||||||
.long _sdata /* Where .data needs to reside in SDRAM */
|
.long _sdata /* Where .data needs to reside in SDRAM */
|
||||||
.long _edata
|
.long _edata
|
||||||
#endif
|
#endif
|
||||||
|
.size __start, .-__start
|
||||||
|
|
||||||
|
/* This global variable is unsigned long g_heapstart and is
|
||||||
|
* exported from here only because of its coupling to LCO
|
||||||
|
* above.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.data
|
||||||
|
.align 4
|
||||||
|
.globl g_heapstart
|
||||||
|
.type g_heapstart, object
|
||||||
|
g_heapstart:
|
||||||
|
.long _ebss+CONFIG_PROC_STACK_SIZE
|
||||||
|
.size g_heapstart, .-g_heapstart
|
||||||
|
|
||||||
.end
|
.end
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ void up_initialize(void)
|
|||||||
|
|
||||||
/* Initialize the system timer interrupt */
|
/* Initialize the system timer interrupt */
|
||||||
|
|
||||||
|
#ifndef CONFIG_SUPPRESS_INTERRUPTS
|
||||||
up_timerinit();
|
up_timerinit();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Register devices */
|
/* Register devices */
|
||||||
|
|
||||||
|
|||||||
@@ -83,5 +83,9 @@ void up_initial_state(_TCB *tcb)
|
|||||||
memset(xcp, 0, sizeof(struct xcptcontext));
|
memset(xcp, 0, sizeof(struct xcptcontext));
|
||||||
xcp->regs[REG_SP] = (uint32)tcb->adj_stack_ptr;
|
xcp->regs[REG_SP] = (uint32)tcb->adj_stack_ptr;
|
||||||
xcp->regs[REG_PC] = (uint32)tcb->start;
|
xcp->regs[REG_PC] = (uint32)tcb->start;
|
||||||
|
#ifdef CONFIG_SUPPRESS_INTERRUPTS
|
||||||
|
xcp->regs[REG_CPSR] = SVC_MODE | I_BIT | F_BIT;
|
||||||
|
#else
|
||||||
xcp->regs[REG_CPSR] = SVC_MODE | F_BIT;
|
xcp->regs[REG_CPSR] = SVC_MODE | F_BIT;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,11 @@
|
|||||||
* Definitions
|
* Definitions
|
||||||
************************************************************/
|
************************************************************/
|
||||||
|
|
||||||
|
/* Bring-up debug configurations */
|
||||||
|
|
||||||
|
#define CONFIG_SUPPRESS_INTERRUPTS 1 /* Do not enable interrupts */
|
||||||
|
#define CONFIG_SUPPRESS_UART_CONFIG 1 /* Do not reconfig UART */
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
************************************************************/
|
************************************************************/
|
||||||
@@ -57,7 +62,20 @@ typedef void (*up_vector_t)(void);
|
|||||||
************************************************************/
|
************************************************************/
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
|
/* This holds a references to the current interrupt level
|
||||||
|
* register storage structure. If is non-NULL only during
|
||||||
|
* interrupt processing.
|
||||||
|
*/
|
||||||
|
|
||||||
extern uint32 *current_regs;
|
extern uint32 *current_regs;
|
||||||
|
|
||||||
|
/* This is the beginning of heap as provided from up_head.S.
|
||||||
|
* This is the first address in DRAM after the loaded
|
||||||
|
* program+bss+idle stack. The end of the heap is
|
||||||
|
* CONFIG_DRAM_END
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern uint32 g_heapstart;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
@@ -75,6 +93,7 @@ extern uint32 *current_regs;
|
|||||||
|
|
||||||
extern void up_copystate(uint32 *dest, uint32 *src);
|
extern void up_copystate(uint32 *dest, uint32 *src);
|
||||||
extern void up_dataabort(uint32 *regs);
|
extern void up_dataabort(uint32 *regs);
|
||||||
|
extern void up_delay(int milliseconds);
|
||||||
extern void up_doirq(int irq, uint32* regs);
|
extern void up_doirq(int irq, uint32* regs);
|
||||||
extern void up_fullcontextrestore(uint32 *regs) __attribute__ ((noreturn));
|
extern void up_fullcontextrestore(uint32 *regs) __attribute__ ((noreturn));
|
||||||
extern void up_irqinitialize(void);
|
extern void up_irqinitialize(void);
|
||||||
|
|||||||
@@ -176,7 +176,9 @@ void up_irqinitialize(void)
|
|||||||
|
|
||||||
/* And finally, enable interrupts */
|
/* And finally, enable interrupts */
|
||||||
|
|
||||||
|
#ifndef CONFIG_SUPPRESS_INTERRUPTS
|
||||||
irqrestore(SVC_MODE | F_BIT);
|
irqrestore(SVC_MODE | F_BIT);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
|
|||||||
+82
-54
@@ -43,6 +43,7 @@
|
|||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
@@ -57,6 +58,10 @@
|
|||||||
|
|
||||||
#define BASE_BAUD 115200
|
#define BASE_BAUD 115200
|
||||||
|
|
||||||
|
#if defined(CONFIG_UART_IRDA_HWFLOWCONTROL) || defined(CONFIG_UART_MODEM_HWFLOWCONTROL)
|
||||||
|
# define CONFIG_UART_HWFLOWCONTROL
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
************************************************************/
|
************************************************************/
|
||||||
@@ -93,15 +98,17 @@ struct up_dev_s
|
|||||||
* this UART */
|
* this UART */
|
||||||
boolean parity; /* 0=none, 1=odd, 2=even */
|
boolean parity; /* 0=none, 1=odd, 2=even */
|
||||||
boolean bits; /* Number of bits (7 or 8) */
|
boolean bits; /* Number of bits (7 or 8) */
|
||||||
|
#ifdef CONFIG_UART_HWFLOWCONTROL
|
||||||
boolean flowcontrol; /* TRUE: Hardware flow control
|
boolean flowcontrol; /* TRUE: Hardware flow control
|
||||||
* is enabled. */
|
* is enabled. */
|
||||||
|
#endif
|
||||||
boolean stopbits2; /* TRUE: Configure with 2
|
boolean stopbits2; /* TRUE: Configure with 2
|
||||||
* stop bits instead of 1 */
|
* stop bits instead of 1 */
|
||||||
boolean xmitwaiting; /* TRUE: User is waiting
|
boolean xmitwaiting; /* TRUE: User is waiting
|
||||||
* for space in xmit.buffer */
|
* for space in xmit.buffer */
|
||||||
boolean recvwaiting; /* TRUE: User is waiting
|
boolean recvwaiting; /* TRUE: User is waiting
|
||||||
* for space in recv.buffer */
|
* for space in recv.buffer */
|
||||||
boolean isconsole; /* TRUE: This is the serila console */
|
boolean isconsole; /* TRUE: This is the serial console */
|
||||||
sem_t closesem; /* Looks out new opens while
|
sem_t closesem; /* Looks out new opens while
|
||||||
* close is in progress */
|
* close is in progress */
|
||||||
sem_t xmitsem; /* Used to wakeup user waiting
|
sem_t xmitsem; /* Used to wakeup user waiting
|
||||||
@@ -124,7 +131,6 @@ static ssize_t up_read(struct file *filep, char *buffer, size_t buflen);
|
|||||||
static ssize_t up_write(struct file *filep, const char *buffer, size_t buflen);
|
static ssize_t up_write(struct file *filep, const char *buffer, size_t buflen);
|
||||||
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
|
static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
|
||||||
static void up_uartsetup(up_dev_t *dev);
|
static void up_uartsetup(up_dev_t *dev);
|
||||||
static void up_delay(int milliseconds);
|
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* Private Variables
|
* Private Variables
|
||||||
@@ -150,7 +156,9 @@ static up_dev_t g_irdaport =
|
|||||||
.baud = CONFIG_UART_IRDA_BAUD,
|
.baud = CONFIG_UART_IRDA_BAUD,
|
||||||
.parity = CONFIG_UART_IRDA_PARITY,
|
.parity = CONFIG_UART_IRDA_PARITY,
|
||||||
.bits = CONFIG_UART_IRDA_BITS,
|
.bits = CONFIG_UART_IRDA_BITS,
|
||||||
.flowcontrol = CONFIG_UART_IRDA_HWFLOWCONTROL,
|
#ifdef CONFIG_UART_IRDA_HWFLOWCONTROL
|
||||||
|
.flowcontrol = TRUE,
|
||||||
|
#endif
|
||||||
.stopbits2 = CONFIG_UART_IRDA_2STOP,
|
.stopbits2 = CONFIG_UART_IRDA_2STOP,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -165,7 +173,9 @@ static up_dev_t g_modemport =
|
|||||||
.baud = CONFIG_UART_MODEM_BAUD,
|
.baud = CONFIG_UART_MODEM_BAUD,
|
||||||
.parity = CONFIG_UART_MODEM_PARITY,
|
.parity = CONFIG_UART_MODEM_PARITY,
|
||||||
.bits = CONFIG_UART_MODEM_BITS,
|
.bits = CONFIG_UART_MODEM_BITS,
|
||||||
.flowcontrol = CONFIG_UART_MODEM_HWFLOWCONTROL,
|
#ifdef CONFIG_UART_MODEM_HWFLOWCONTROL
|
||||||
|
.flowcontrol = TRUE,
|
||||||
|
#endif
|
||||||
.stopbits2 = CONFIG_UART_MODEM_2STOP,
|
.stopbits2 = CONFIG_UART_MODEM_2STOP,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -464,22 +474,13 @@ static inline void up_saveregisters(up_dev_t *dev)
|
|||||||
{
|
{
|
||||||
dev->regs.ier = up_inserial(dev, UART_IER_OFFS);
|
dev->regs.ier = up_inserial(dev, UART_IER_OFFS);
|
||||||
dev->regs.lcr = up_inserial(dev, UART_LCR_OFFS);
|
dev->regs.lcr = up_inserial(dev, UART_LCR_OFFS);
|
||||||
|
#ifdef CONFIG_UART_HWFLOWCONTROL
|
||||||
if (dev->flowcontrol)
|
if (dev->flowcontrol)
|
||||||
{
|
{
|
||||||
dev->regs.efr = up_inserial(dev, UART_EFR_OFFS);
|
dev->regs.efr = up_inserial(dev, UART_EFR_OFFS);
|
||||||
dev->regs.tcr = up_inserial(dev, UART_TCR_OFFS);
|
dev->regs.tcr = up_inserial(dev, UART_TCR_OFFS);
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
#define LOOPS_PER_MSEC 1250
|
|
||||||
|
|
||||||
static void up_delay(int milliseconds)
|
|
||||||
{
|
|
||||||
volatile int i, j;
|
|
||||||
for (i = 0; i < milliseconds; i++) {
|
|
||||||
for (j = 0; j < LOOPS_PER_MSEC; j++) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
@@ -581,6 +582,51 @@ static void up_xmitchars(up_dev_t *dev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* Name: up_putxmitchar
|
||||||
|
************************************************************/
|
||||||
|
|
||||||
|
static void up_putxmitchar(up_dev_t *dev, int ch)
|
||||||
|
{
|
||||||
|
int nexthead = dev->xmit.head + 1;
|
||||||
|
if (nexthead >= dev->xmit.size)
|
||||||
|
{
|
||||||
|
nexthead = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nexthead != dev->xmit.tail)
|
||||||
|
{
|
||||||
|
dev->xmit.buffer[dev->xmit.head] = ch;
|
||||||
|
dev->xmit.head = nexthead;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Transfer some characters with interrupts disabled */
|
||||||
|
|
||||||
|
up_xmitchars(dev);
|
||||||
|
|
||||||
|
/* If we unsuccessful in making room in the buffer.
|
||||||
|
* then transmit the characters with interrupts
|
||||||
|
* enabled and wait for result.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (nexthead == dev->xmit.tail)
|
||||||
|
{
|
||||||
|
/* Still no space */
|
||||||
|
|
||||||
|
dev->xmitwaiting = TRUE;
|
||||||
|
|
||||||
|
/* Wait for some characters to be sent from the buffer
|
||||||
|
* with the TX interrupt disabled.
|
||||||
|
*/
|
||||||
|
|
||||||
|
up_enabletxint(dev);
|
||||||
|
up_takesem(&dev->xmitsem);
|
||||||
|
up_disabletxint(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* Name: up_interrupt
|
* Name: up_interrupt
|
||||||
************************************************************/
|
************************************************************/
|
||||||
@@ -665,6 +711,7 @@ static int up_interrupt(int irq, void *context)
|
|||||||
|
|
||||||
static void up_uartsetup(up_dev_t *dev)
|
static void up_uartsetup(up_dev_t *dev)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_SUPPRESS_UART_CONFIG
|
||||||
unsigned int cval;
|
unsigned int cval;
|
||||||
uint16 mrs;
|
uint16 mrs;
|
||||||
|
|
||||||
@@ -701,14 +748,17 @@ static void up_uartsetup(up_dev_t *dev)
|
|||||||
up_setrate(dev, dev->baud);
|
up_setrate(dev, dev->baud);
|
||||||
up_setmode(dev, cval);
|
up_setmode(dev, cval);
|
||||||
|
|
||||||
|
#ifdef CONFIG_UART_HWFLOWCONTROL
|
||||||
if (dev->flowcontrol)
|
if (dev->flowcontrol)
|
||||||
{
|
{
|
||||||
serial_enable_hw_flow_control(dev);
|
serial_enable_hw_flow_control(dev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
serial_disable_hw_flow_control(dev);
|
serial_disable_hw_flow_control(dev);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
@@ -749,46 +799,20 @@ static ssize_t up_write(struct file *filep, const char *buffer, size_t buflen)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
up_disabletxint(dev);
|
up_disabletxint(dev);
|
||||||
while (buflen)
|
for (; buflen; buflen--)
|
||||||
{
|
{
|
||||||
int nexthead = dev->xmit.head + 1;
|
int ch = *buffer++;
|
||||||
if (nexthead >= dev->xmit.size)
|
|
||||||
|
/* Put the character into the transmit buffer */
|
||||||
|
|
||||||
|
up_putxmitchar(dev, ch);
|
||||||
|
|
||||||
|
/* If this is the console, then we should replace LF with LF-CR */
|
||||||
|
|
||||||
|
if (ch == '\n')
|
||||||
{
|
{
|
||||||
nexthead = 0;
|
up_putxmitchar(dev, '\r');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nexthead != dev->xmit.tail)
|
|
||||||
{
|
|
||||||
dev->xmit.buffer[dev->xmit.head] = *buffer++;
|
|
||||||
dev->xmit.head = nexthead;
|
|
||||||
buflen--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Transfer some characters with interrupts disabled */
|
|
||||||
|
|
||||||
up_xmitchars(dev);
|
|
||||||
|
|
||||||
/* If we unsuccessful in making room in the buffer.
|
|
||||||
* then transmit the characters with interrupts
|
|
||||||
* enabled and wait for result.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (nexthead == dev->xmit.tail)
|
|
||||||
{
|
|
||||||
/* Still no space */
|
|
||||||
|
|
||||||
dev->xmitwaiting = TRUE;
|
|
||||||
|
|
||||||
/* Wait for some characters to be sent from the buffer
|
|
||||||
* with the TX interrupt disabled.
|
|
||||||
*/
|
|
||||||
|
|
||||||
up_enabletxint(dev);
|
|
||||||
up_takesem(&dev->xmitsem);
|
|
||||||
up_disabletxint(dev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->xmit.head != dev->xmit.tail)
|
if (dev->xmit.head != dev->xmit.tail)
|
||||||
@@ -924,6 +948,10 @@ static int up_close(struct file *filep)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* There are no more references to the port */
|
||||||
|
|
||||||
|
dev->open_count = 0;
|
||||||
|
|
||||||
/* Stop accepting input */
|
/* Stop accepting input */
|
||||||
|
|
||||||
up_disablerxint(dev);
|
up_disablerxint(dev);
|
||||||
@@ -1100,12 +1128,12 @@ int up_putc(int ch)
|
|||||||
|
|
||||||
/* Check for LF */
|
/* Check for LF */
|
||||||
|
|
||||||
if (ch == 10)
|
if (ch == '\n')
|
||||||
{
|
{
|
||||||
/* Add CR */
|
/* Add CR */
|
||||||
|
|
||||||
up_waittxfifonotfull(&CONSOLE_DEV);
|
up_waittxfifonotfull(&CONSOLE_DEV);
|
||||||
up_outserialchar(&CONSOLE_DEV, 13);
|
up_outserialchar(&CONSOLE_DEV, '\r');
|
||||||
}
|
}
|
||||||
|
|
||||||
up_waittxfifonotfull(&CONSOLE_DEV);
|
up_waittxfifonotfull(&CONSOLE_DEV);
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
pjrc-8051 README
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This port uses the PJRC 87C52 development system and the SDCC toolchain.
|
||||||
|
|
||||||
|
The PJRC 87C52 development system can be obtained from http://www.pjrc.com/.
|
||||||
|
|
||||||
|
The SDCC toolchain is available from http://sdcc.sourceforge.net/. All
|
||||||
|
testing has been performed using verison 2.6.0 of the SDDC toolchain.
|
||||||
|
|
||||||
|
Building the SDCC toolchain
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
The SDCC toolchain is built with the standard configure/make/make install
|
||||||
|
sequence. However, some special actions are required to generate libraries
|
||||||
|
compatible with this build. First start with the usual steps
|
||||||
|
|
||||||
|
download
|
||||||
|
unpack
|
||||||
|
cd sdcc
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
|
||||||
|
But before installing,
|
||||||
|
|
||||||
|
Apply sdcc-2.6.0.patch
|
||||||
|
cd sdcc/device/lib
|
||||||
|
make model-mcs51-stack-auto
|
||||||
|
|
||||||
|
Then
|
||||||
|
|
||||||
|
cd sdcc
|
||||||
|
make install
|
||||||
|
|
||||||
Reference in New Issue
Block a user