projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix default values in kbd_map.
[bertos.git]
/
bertos
/
cpu
/
arm
/
drv
/
ser_at91.c
diff --git
a/bertos/cpu/arm/drv/ser_at91.c
b/bertos/cpu/arm/drv/ser_at91.c
index 902ccc2f6ff692546cc09d41ea89a3e72937c48c..bc5551602f0f7a2941e7ca2545e9350d870af429 100644
(file)
--- a/
bertos/cpu/arm/drv/ser_at91.c
+++ b/
bertos/cpu/arm/drv/ser_at91.c
@@
-34,12
+34,12
@@
* \brief ARM UART and SPI I/O driver
*
*
* \brief ARM UART and SPI I/O driver
*
*
- * \version $Id
: ser_at91.c 20881 2008-03-04 14:07:02Z batt
$
+ * \version $Id$
* \author Daniele Basile <asterix@develer.com>
*/
#include "hw/hw_ser.h" /* Required for bus macros overrides */
* \author Daniele Basile <asterix@develer.com>
*/
#include "hw/hw_ser.h" /* Required for bus macros overrides */
-#include
"hw/hw_cpu.h" /* CLOCK
_FREQ */
+#include
<hw/hw_cpufreq.h> /* CPU
_FREQ */
#include "cfg/cfg_ser.h"
#include <cfg/debug.h>
#include "cfg/cfg_ser.h"
#include <cfg/debug.h>
@@
-84,7
+84,7
@@
*
* - Disable GPIO on USART0 tx/rx pins
*/
*
* - Disable GPIO on USART0 tx/rx pins
*/
- #if !CPU_ARM_
AT91SAM7S256 && !CPU_ARM_AT91SAM7X256 && !CPU_ARM_AT91SAM7X128
+ #if !CPU_ARM_
SAM7S_LARGE && !CPU_ARM_SAM7X
#warning Check USART0 pins!
#endif
#define SER_UART0_BUS_TXINIT do { \
#warning Check USART0 pins!
#endif
#define SER_UART0_BUS_TXINIT do { \
@@
-124,7
+124,7
@@
*
* - Disable GPIO on USART1 tx/rx pins
*/
*
* - Disable GPIO on USART1 tx/rx pins
*/
- #if !CPU_ARM_
AT91SAM7S256 && !CPU_ARM_AT91SAM7X256 && !CPU_ARM_AT91SAM7X128
+ #if !CPU_ARM_
SAM7S_LARGE && !CPU_ARM_SAM7X
#warning Check USART1 pins!
#endif
#define SER_UART1_BUS_TXINIT do { \
#warning Check USART1 pins!
#endif
#define SER_UART1_BUS_TXINIT do { \
@@
-181,7
+181,7
@@
#define SER_SPI0_BUS_TXCLOSE
#endif
#define SER_SPI0_BUS_TXCLOSE
#endif
-#if CPU_ARM_
AT91SAM7X128 || CPU_ARM_AT91SAM7X256
+#if CPU_ARM_
SAM7X
#ifndef SER_SPI1_BUS_TXINIT
/**
#ifndef SER_SPI1_BUS_TXINIT
/**
@@
-231,7
+231,7
@@
static unsigned char uart1_rxbuffer[CONFIG_UART1_RXBUFSIZE];
static unsigned char spi0_txbuffer[CONFIG_SPI0_TXBUFSIZE];
static unsigned char spi0_rxbuffer[CONFIG_SPI0_RXBUFSIZE];
static unsigned char spi0_txbuffer[CONFIG_SPI0_TXBUFSIZE];
static unsigned char spi0_rxbuffer[CONFIG_SPI0_RXBUFSIZE];
-#if CPU_ARM_
AT91SAM7X128 || CPU_ARM_AT91SAM7X256
+#if CPU_ARM_
SAM7X
static unsigned char spi1_txbuffer[CONFIG_SPI1_TXBUFSIZE];
static unsigned char spi1_rxbuffer[CONFIG_SPI1_RXBUFSIZE];
#endif
static unsigned char spi1_txbuffer[CONFIG_SPI1_TXBUFSIZE];
static unsigned char spi1_rxbuffer[CONFIG_SPI1_RXBUFSIZE];
#endif
@@
-258,16
+258,10
@@
struct ArmSerial
volatile bool sending;
};
volatile bool sending;
};
-
-
-#if CPU_ARM_AT91SAM7X128 || CPU_ARM_AT91SAM7X256
-struct Serial *ser_spi1 = &ser_handles[SER_SPI1];
-#endif
-
static void uart0_irq_dispatcher(void);
static void uart1_irq_dispatcher(void);
static void spi0_irq_handler(void);
static void uart0_irq_dispatcher(void);
static void uart1_irq_dispatcher(void);
static void spi0_irq_handler(void);
-#if CPU_ARM_
AT91SAM7X128 || CPU_ARM_AT91SAM7X256
+#if CPU_ARM_
SAM7X
static void spi1_irq_handler(void);
#endif
/*
static void spi1_irq_handler(void);
#endif
/*
@@
-332,7
+326,7
@@
static void uart0_enabletxirq(struct SerialHardware *_hw)
static void uart0_setbaudrate(UNUSED_ARG(struct SerialHardware *, _hw), unsigned long rate)
{
/* Compute baud-rate period */
static void uart0_setbaudrate(UNUSED_ARG(struct SerialHardware *, _hw), unsigned long rate)
{
/* Compute baud-rate period */
- US0_BRGR = C
LOCK
_FREQ / (16 * rate);
+ US0_BRGR = C
PU
_FREQ / (16 * rate);
//DB(kprintf("uart0_setbaudrate(rate=%lu): period=%d\n", rate, period);)
}
//DB(kprintf("uart0_setbaudrate(rate=%lu): period=%d\n", rate, period);)
}
@@
-427,7
+421,7
@@
static void uart1_enabletxirq(struct SerialHardware *_hw)
static void uart1_setbaudrate(UNUSED_ARG(struct SerialHardware *, _hw), unsigned long rate)
{
/* Compute baud-rate period */
static void uart1_setbaudrate(UNUSED_ARG(struct SerialHardware *, _hw), unsigned long rate)
{
/* Compute baud-rate period */
- US1_BRGR = C
LOCK
_FREQ / (16 * rate);
+ US1_BRGR = C
PU
_FREQ / (16 * rate);
//DB(kprintf("uart0_setbaudrate(rate=%lu): period=%d\n", rate, period);)
}
//DB(kprintf("uart0_setbaudrate(rate=%lu): period=%d\n", rate, period);)
}
@@
-523,7
+517,7
@@
static void spi0_starttx(struct SerialHardware *_hw)
{
struct ArmSerial *hw = (struct ArmSerial *)_hw;
{
struct ArmSerial *hw = (struct ArmSerial *)_hw;
- cpuflags_t flags;
+ cpu
_
flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Send data only if the SPI is not already transmitting */
IRQ_SAVE_DISABLE(flags);
/* Send data only if the SPI is not already transmitting */
@@
-540,11
+534,11
@@
static void spi0_setbaudrate(UNUSED_ARG(struct SerialHardware *, _hw), unsigned
{
SPI0_CSR0 &= ~SPI_SCBR;
{
SPI0_CSR0 &= ~SPI_SCBR;
- ASSERT((uint8_t)DIV_ROUND(C
LOCK
_FREQ, rate));
- SPI0_CSR0 |= DIV_ROUND(C
LOCK
_FREQ, rate) << SPI_SCBR_SHIFT;
+ ASSERT((uint8_t)DIV_ROUND(C
PU
_FREQ, rate));
+ SPI0_CSR0 |= DIV_ROUND(C
PU
_FREQ, rate) << SPI_SCBR_SHIFT;
}
}
-#if CPU_ARM_
AT91SAM7X128 || CPU_ARM_AT91SAM7X256
+#if CPU_ARM_
SAM7X
/* SPI driver */
static void spi1_init(UNUSED_ARG(struct SerialHardware *, _hw), UNUSED_ARG(struct Serial *, ser))
{
/* SPI driver */
static void spi1_init(UNUSED_ARG(struct SerialHardware *, _hw), UNUSED_ARG(struct Serial *, ser))
{
@@
-607,14
+601,14
@@
static void spi1_starttx(struct SerialHardware *_hw)
{
struct ArmSerial *hw = (struct ArmSerial *)_hw;
{
struct ArmSerial *hw = (struct ArmSerial *)_hw;
- cpuflags_t flags;
+ cpu
_
flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Send data only if the SPI is not already transmitting */
IRQ_SAVE_DISABLE(flags);
/* Send data only if the SPI is not already transmitting */
- if (!hw->sending && !fifo_isempty(&ser_
spi1
->txfifo))
+ if (!hw->sending && !fifo_isempty(&ser_
handles[SER_SPI1]
->txfifo))
{
hw->sending = true;
{
hw->sending = true;
- SPI1_TDR = fifo_pop(&ser_
spi1
->txfifo);
+ SPI1_TDR = fifo_pop(&ser_
handles[SER_SPI1]
->txfifo);
}
IRQ_RESTORE(flags);
}
IRQ_RESTORE(flags);
@@
-624,8
+618,8
@@
static void spi1_setbaudrate(UNUSED_ARG(struct SerialHardware *, _hw), unsigned
{
SPI1_CSR0 &= ~SPI_SCBR;
{
SPI1_CSR0 &= ~SPI_SCBR;
- ASSERT((uint8_t)DIV_ROUND(C
LOCK
_FREQ, rate));
- SPI1_CSR0 |= DIV_ROUND(C
LOCK
_FREQ, rate) << SPI_SCBR_SHIFT;
+ ASSERT((uint8_t)DIV_ROUND(C
PU
_FREQ, rate));
+ SPI1_CSR0 |= DIV_ROUND(C
PU
_FREQ, rate) << SPI_SCBR_SHIFT;
}
#endif
}
#endif
@@
-683,7
+677,7
@@
static const struct SerialHardwareVT SPI0_VT =
C99INIT(txStart, spi0_starttx),
C99INIT(txSending, tx_sending),
};
C99INIT(txStart, spi0_starttx),
C99INIT(txSending, tx_sending),
};
-#if CPU_ARM_
AT91SAM7X128 || CPU_ARM_AT91SAM7X256
+#if CPU_ARM_
SAM7X
static const struct SerialHardwareVT SPI1_VT =
{
C99INIT(init, spi1_init),
static const struct SerialHardwareVT SPI1_VT =
{
C99INIT(init, spi1_init),
@@
-728,7
+722,7
@@
static struct ArmSerial UARTDescs[SER_CNT] =
},
C99INIT(sending, false),
},
},
C99INIT(sending, false),
},
- #if CPU_ARM_
AT91SAM7X128 || CPU_ARM_AT91SAM7X256
+ #if CPU_ARM_
SAM7X
{
C99INIT(hw, /**/) {
C99INIT(table, &SPI1_VT),
{
C99INIT(hw, /**/) {
C99INIT(table, &SPI1_VT),
@@
-909,7
+903,7
@@
static void spi0_irq_handler(void)
}
}
-#if CPU_ARM_
AT91SAM7X128 || CPU_ARM_AT91SAM7X256
+#if CPU_ARM_
SAM7X
/**
* SPI1 interrupt handler
*/
/**
* SPI1 interrupt handler
*/
@@
-920,17
+914,17
@@
static void spi1_irq_handler(void)
char c = SPI1_RDR;
/* Read incoming byte. */
char c = SPI1_RDR;
/* Read incoming byte. */
- if (!fifo_isfull(&ser_
spi1
->rxfifo))
- fifo_push(&ser_
spi1
->rxfifo, c);
+ if (!fifo_isfull(&ser_
handles[SER_SPI1]
->rxfifo))
+ fifo_push(&ser_
handles[SER_SPI1]
->rxfifo, c);
/*
* FIXME
else
/*
* FIXME
else
- ser_
spi1
->status |= SERRF_RXFIFOOVERRUN;
+ ser_
handles[SER_SPI1]
->status |= SERRF_RXFIFOOVERRUN;
*/
/* Send */
*/
/* Send */
- if (!fifo_isempty(&ser_
spi1
->txfifo))
- SPI1_TDR = fifo_pop(&ser_
spi1
->txfifo);
+ if (!fifo_isempty(&ser_
handles[SER_SPI1]
->txfifo))
+ SPI1_TDR = fifo_pop(&ser_
handles[SER_SPI1]
->txfifo);
else
UARTDescs[SER_SPI1].sending = false;
else
UARTDescs[SER_SPI1].sending = false;