X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=cpu%2Farm%2Fdrv%2Fser_at91.c;h=37a4f1b695470b281c1e61188d32159bd5928a3c;hb=1fc31f45bcec8bc23a5924ae5b288439abca8ded;hp=e9804c206ee1c306f21ac68552f51fbd329bcf93;hpb=c87c2e081c5f1aae9e6c1cc62ae612fd47fd5ebe;p=bertos.git diff --git a/cpu/arm/drv/ser_at91.c b/cpu/arm/drv/ser_at91.c index e9804c20..37a4f1b6 100644 --- a/cpu/arm/drv/ser_at91.c +++ b/cpu/arm/drv/ser_at91.c @@ -101,17 +101,17 @@ * * - Disable GPIO on USART0 tx/rx pins * - Reset USART0 - * - Set serial param: mode Normal, 8bit data, 1bit stop + * - Set serial param: mode Normal, 8bit data, 1bit stop, parity none * - Enable both the receiver and the transmitter * - Enable only the RX complete interrupt */ - #if !CPU_ARM_AT91SAM7S256 + #if !CPU_ARM_AT91SAM7S256 && !CPU_ARM_AT91SAM7X256 #warning Check USART0 pins! #endif #define SER_UART0_BUS_TXINIT do { \ PIOA_PDR = BV(RXD0) | BV(TXD0); \ US0_CR = BV(US_RSTRX) | BV(US_RSTTX); \ - US0_MR = US_CHMODE_NORMAL | US_CHRL_8 | US_NBSTOP_1; \ + US0_MR = US_CHMODE_NORMAL | US_CHRL_8 | US_NBSTOP_1 | US_PAR_NO; \ US0_CR = BV(US_RXEN) | BV(US_TXEN); \ US0_IER = BV(US_RXRDY); \ } while (0) @@ -173,13 +173,13 @@ #ifndef SER_UART1_BUS_TXINIT /** \sa SER_UART1_BUS_TXINIT */ - #if !CPU_ARM_AT91SAM7S256 + #if !CPU_ARM_AT91SAM7S256 && !CPU_ARM_AT91SAM7X256 #warning Check USART1 pins! #endif #define SER_UART1_BUS_TXINIT do { \ PIOA_PDR = BV(RXD1) | BV(TXD1); \ US1_CR = BV(US_RSTRX) | BV(US_RSTTX); \ - US1_MR = US_CHMODE_NORMAL | US_CHRL_8 | US_NBSTOP_1; \ + US1_MR = US_CHMODE_NORMAL | US_CHRL_8 | US_NBSTOP_1 | US_PAR_NO; \ US1_CR = BV(US_RXEN) | BV(US_TXEN); \ US1_IER = BV(US_RXRDY); \ } while (0) @@ -209,6 +209,7 @@ } while (0) #endif +#ifdef NOT_FOR_ARM_PORT_IT /** * \name Overridable SPI hooks * @@ -233,7 +234,7 @@ #define SER_SPI_BUS_TXCLOSE #endif /*\}*/ - +#endif /** * \def CONFIG_SER_STROBE @@ -262,8 +263,10 @@ static unsigned char uart0_rxbuffer[CONFIG_UART0_RXBUFSIZE]; static unsigned char uart1_txbuffer[CONFIG_UART1_TXBUFSIZE]; static unsigned char uart1_rxbuffer[CONFIG_UART1_RXBUFSIZE]; +#ifdef NOT_FOR_ARM_PORT_IT static unsigned char spi_txbuffer[CONFIG_SPI_TXBUFSIZE]; static unsigned char spi_rxbuffer[CONFIG_SPI_RXBUFSIZE]; +#endif /** * Internal hardware state structure @@ -297,7 +300,10 @@ struct ArmSerial */ struct Serial *ser_uart0 = &ser_handles[SER_UART0]; struct Serial *ser_uart1 = &ser_handles[SER_UART1]; + +#ifdef NOT_FOR_ARM_PORT_IT struct Serial *ser_spi = &ser_handles[SER_SPI]; +#endif static void uart0_irq_dispatcher(void); static void uart1_irq_dispatcher(void); @@ -441,7 +447,7 @@ static void uart1_setparity(UNUSED_ARG(struct SerialHardware *, _hw), int parity } /* SPI driver */ - +#ifdef NOT_FOR_ARM_PORT_IT static void spi_init(UNUSED_ARG(struct SerialHardware *, _hw), UNUSED_ARG(struct Serial *, ser)) { /* @@ -554,7 +560,7 @@ static void spi_setparity(UNUSED_ARG(struct SerialHardware *, _hw), UNUSED_ARG(i { // nop } - +#endif static bool tx_sending(struct SerialHardware* _hw) @@ -596,6 +602,7 @@ static const struct SerialHardwareVT UART1_VT = C99INIT(txSending, tx_sending), }; +#ifdef NOT_FOR_ARM_PORT_IT static const struct SerialHardwareVT SPI_VT = { C99INIT(init, spi_init), @@ -605,6 +612,7 @@ static const struct SerialHardwareVT SPI_VT = C99INIT(txStart, spi_starttx), C99INIT(txSending, tx_sending), }; +#endif static struct ArmSerial UARTDescs[SER_CNT] = { @@ -628,6 +636,7 @@ static struct ArmSerial UARTDescs[SER_CNT] = }, C99INIT(sending, false), }, +#ifdef NOT_FOR_ARM_PORT_IT { C99INIT(hw, /**/) { C99INIT(table, &SPI_VT), @@ -638,6 +647,7 @@ static struct ArmSerial UARTDescs[SER_CNT] = }, C99INIT(sending, false), } +#endif }; struct SerialHardware *ser_hw_getdesc(int unit) @@ -693,18 +703,17 @@ static void uart0_irq_rx(void) /** * Serial IRQ dispatcher for USART0. */ -static void uart0_irq_dispatcher(void) __attribute__ ((naked)); +static void uart0_irq_dispatcher(void) __attribute__ ((interrupt)); static void uart0_irq_dispatcher(void) { - IRQ_ENTRY(); - - if (US0_IMR & BV(US_RXRDY)) + if (US0_CSR & BV(US_RXRDY)) uart0_irq_rx(); - if (US0_IMR & BV(US_TXRDY)) + if (US0_CSR & BV(US_TXRDY)) uart0_irq_tx(); - IRQ_EXIT(); + /* Inform hw that we have served the IRQ */ + AIC_EOICR = 0; } /** @@ -754,16 +763,15 @@ static void uart1_irq_rx(void) /** * Serial IRQ dispatcher for USART1. */ -static void uart1_irq_dispatcher(void) __attribute__ ((naked)); +static void uart1_irq_dispatcher(void) __attribute__ ((interrupt)); static void uart1_irq_dispatcher(void) { - IRQ_ENTRY(); - - if (US1_IMR & BV(US_RXRDY)) + if (US1_CSR & BV(US_RXRDY)) uart1_irq_rx(); - if (US1_IMR & BV(US_TXRDY)) + if (US1_CSR & BV(US_TXRDY)) uart1_irq_tx(); - IRQ_EXIT(); + /* Inform hw that we have served the IRQ */ + AIC_EOICR = 0; }