sam3x8e: Use readl/writel instead of readb/writeb() in serial.c

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-06-16 14:15:43 -04:00
parent e92ce565dd
commit b310501970
1 changed files with 12 additions and 12 deletions

View File

@ -7,7 +7,7 @@
#include <string.h> // memmove #include <string.h> // memmove
#include "autoconf.h" // CONFIG_SERIAL_BAUD #include "autoconf.h" // CONFIG_SERIAL_BAUD
#include "board/gpio.h" // gpio_peripheral #include "board/gpio.h" // gpio_peripheral
#include "board/io.h" // readb #include "board/io.h" // readl
#include "board/irq.h" // irq_save #include "board/irq.h" // irq_save
#include "board/misc.h" // console_get_input #include "board/misc.h" // console_get_input
#include "command.h" // DECL_CONSTANT #include "command.h" // DECL_CONSTANT
@ -86,7 +86,7 @@ enable_tx_irq(void)
char * char *
console_get_input(uint8_t *plen) console_get_input(uint8_t *plen)
{ {
*plen = readb(&receive_pos); *plen = readl(&receive_pos);
return receive_buf; return receive_buf;
} }
@ -96,7 +96,7 @@ console_pop_input(uint8_t len)
{ {
uint32_t copied = 0; uint32_t copied = 0;
for (;;) { for (;;) {
uint32_t rpos = readb(&receive_pos); uint32_t rpos = readl(&receive_pos);
uint32_t needcopy = rpos - len; uint32_t needcopy = rpos - len;
if (needcopy) { if (needcopy) {
memmove(&receive_buf[copied], &receive_buf[copied + len] memmove(&receive_buf[copied], &receive_buf[copied + len]
@ -104,7 +104,7 @@ console_pop_input(uint8_t len)
copied = needcopy; copied = needcopy;
} }
irqstatus_t flag = irq_save(); irqstatus_t flag = irq_save();
if (rpos != readb(&receive_pos)) { if (rpos != readl(&receive_pos)) {
// Raced with irq handler - retry // Raced with irq handler - retry
irq_restore(flag); irq_restore(flag);
continue; continue;
@ -119,23 +119,23 @@ console_pop_input(uint8_t len)
char * char *
console_get_output(uint8_t len) console_get_output(uint8_t len)
{ {
uint32_t tpos = readb(&transmit_pos), tmax = readb(&transmit_max); uint32_t tpos = readl(&transmit_pos), tmax = readl(&transmit_max);
if (tpos >= tmax) { if (tpos >= tmax) {
tpos = tmax = 0; tpos = tmax = 0;
writeb(&transmit_max, 0); writel(&transmit_max, 0);
writeb(&transmit_pos, 0); writel(&transmit_pos, 0);
} }
if (tmax + len <= sizeof(transmit_buf)) if (tmax + len <= sizeof(transmit_buf))
return &transmit_buf[tmax]; return &transmit_buf[tmax];
if (tmax - tpos + len > sizeof(transmit_buf)) if (tmax - tpos + len > sizeof(transmit_buf))
return NULL; return NULL;
// Disable TX irq and move buffer // Disable TX irq and move buffer
writeb(&transmit_max, 0); writel(&transmit_max, 0);
tpos = readb(&transmit_pos); tpos = readl(&transmit_pos);
tmax -= tpos; tmax -= tpos;
memmove(&transmit_buf[0], &transmit_buf[tpos], tmax); memmove(&transmit_buf[0], &transmit_buf[tpos], tmax);
writeb(&transmit_pos, 0); writel(&transmit_pos, 0);
writeb(&transmit_max, tmax); writel(&transmit_max, tmax);
enable_tx_irq(); enable_tx_irq();
return &transmit_buf[tmax]; return &transmit_buf[tmax];
} }
@ -144,6 +144,6 @@ console_get_output(uint8_t len)
void void
console_push_output(uint8_t len) console_push_output(uint8_t len)
{ {
writeb(&transmit_max, readb(&transmit_max) + len); writel(&transmit_max, readl(&transmit_max) + len);
enable_tx_irq(); enable_tx_irq();
} }