projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altoslib: Use symbols in AltosRomconfig instead of fixed offsets
[fw/altos]
/
src
/
stm
/
ao_serial_stm.c
diff --git
a/src/stm/ao_serial_stm.c
b/src/stm/ao_serial_stm.c
index 94138edc3f4bda884a07555584e8d0d962ca99fa..2133c5845e0ca33233332ffc7717ad87ab49b6be 100644
(file)
--- a/
src/stm/ao_serial_stm.c
+++ b/
src/stm/ao_serial_stm.c
@@
-59,24
+59,11
@@
ao_usart_isr(struct ao_stm_usart *usart, int stdin)
}
}
}
}
-char
-ao_usart_getchar(struct ao_stm_usart *usart)
-{
- char c;
- ao_arch_block_interrupts();
- while (ao_fifo_empty(usart->rx_fifo))
- ao_sleep(&usart->rx_fifo);
- ao_fifo_remove(usart->rx_fifo, c);
- ao_arch_release_interrupts();
- return c;
-}
-
int
int
-ao_usart_pollchar(struct ao_stm_usart *usart)
+
_
ao_usart_pollchar(struct ao_stm_usart *usart)
{
int c;
{
int c;
- ao_arch_block_interrupts();
if (ao_fifo_empty(usart->rx_fifo))
c = AO_READ_AGAIN;
else {
if (ao_fifo_empty(usart->rx_fifo))
c = AO_READ_AGAIN;
else {
@@
-84,10
+71,20
@@
ao_usart_pollchar(struct ao_stm_usart *usart)
ao_fifo_remove(usart->rx_fifo,u);
c = u;
}
ao_fifo_remove(usart->rx_fifo,u);
c = u;
}
- ao_arch_release_interrupts();
return c;
}
return c;
}
+char
+ao_usart_getchar(struct ao_stm_usart *usart)
+{
+ int c;
+ ao_arch_block_interrupts();
+ while ((c = _ao_usart_pollchar(usart)) == AO_READ_AGAIN)
+ ao_sleep(&usart->rx_fifo);
+ ao_arch_release_interrupts();
+ return (char) c;
+}
+
void
ao_usart_putchar(struct ao_stm_usart *usart, char c)
{
void
ao_usart_putchar(struct ao_stm_usart *usart, char c)
{
@@
-123,12
+120,15
@@
static const struct {
[AO_SERIAL_SPEED_57600] = {
AO_PCLK1 / 57600
},
[AO_SERIAL_SPEED_57600] = {
AO_PCLK1 / 57600
},
+ [AO_SERIAL_SPEED_115200] = {
+ AO_PCLK1 / 115200
+ },
};
void
ao_usart_set_speed(struct ao_stm_usart *usart, uint8_t speed)
{
};
void
ao_usart_set_speed(struct ao_stm_usart *usart, uint8_t speed)
{
- if (speed > AO_SERIAL_SPEED_
576
00)
+ if (speed > AO_SERIAL_SPEED_
1152
00)
return;
usart->reg->brr = ao_usart_speeds[speed].brr;
}
return;
usart->reg->brr = ao_usart_speeds[speed].brr;
}
@@
-198,9
+198,9
@@
ao_serial1_putchar(char c)
}
int
}
int
-ao_serial1_pollchar(void)
+
_
ao_serial1_pollchar(void)
{
{
- return ao_usart_pollchar(&ao_stm_usart1);
+ return
_
ao_usart_pollchar(&ao_stm_usart1);
}
void
}
void
@@
-229,9
+229,9
@@
ao_serial2_putchar(char c)
}
int
}
int
-ao_serial2_pollchar(void)
+
_
ao_serial2_pollchar(void)
{
{
- return ao_usart_pollchar(&ao_stm_usart2);
+ return
_
ao_usart_pollchar(&ao_stm_usart2);
}
void
}
void
@@
-260,9
+260,9
@@
ao_serial3_putchar(char c)
}
int
}
int
-ao_serial3_pollchar(void)
+
_
ao_serial3_pollchar(void)
{
{
- return ao_usart_pollchar(&ao_stm_usart3);
+ return
_
ao_usart_pollchar(&ao_stm_usart3);
}
void
}
void
@@
-306,7
+306,7
@@
ao_serial_init(void)
stm_nvic_set_enable(STM_ISR_USART1_POS);
stm_nvic_set_priority(STM_ISR_USART1_POS, 4);
#if USE_SERIAL_1_STDIN
stm_nvic_set_enable(STM_ISR_USART1_POS);
stm_nvic_set_priority(STM_ISR_USART1_POS, 4);
#if USE_SERIAL_1_STDIN
- ao_add_stdio(ao_serial1_pollchar,
+ ao_add_stdio(
_
ao_serial1_pollchar,
ao_serial1_putchar,
NULL);
#endif
ao_serial1_putchar,
NULL);
#endif
@@
-343,7
+343,7
@@
ao_serial_init(void)
stm_nvic_set_enable(STM_ISR_USART2_POS);
stm_nvic_set_priority(STM_ISR_USART2_POS, 4);
#if USE_SERIAL_2_STDIN
stm_nvic_set_enable(STM_ISR_USART2_POS);
stm_nvic_set_priority(STM_ISR_USART2_POS, 4);
#if USE_SERIAL_2_STDIN
- ao_add_stdio(ao_serial2_pollchar,
+ ao_add_stdio(
_
ao_serial2_pollchar,
ao_serial2_putchar,
NULL);
#endif
ao_serial2_putchar,
NULL);
#endif
@@
-387,7
+387,7
@@
ao_serial_init(void)
stm_nvic_set_enable(STM_ISR_USART3_POS);
stm_nvic_set_priority(STM_ISR_USART3_POS, 4);
#if USE_SERIAL_3_STDIN
stm_nvic_set_enable(STM_ISR_USART3_POS);
stm_nvic_set_priority(STM_ISR_USART3_POS, 4);
#if USE_SERIAL_3_STDIN
- ao_add_stdio(ao_serial3_pollchar,
+ ao_add_stdio(
_
ao_serial3_pollchar,
ao_serial3_putchar,
NULL);
#endif
ao_serial3_putchar,
NULL);
#endif