aboutsummaryrefslogtreecommitdiff
path: root/02-usart/src
diff options
context:
space:
mode:
Diffstat (limited to '02-usart/src')
-rw-r--r--02-usart/src/main.c5
-rw-r--r--02-usart/src/usart.c12
2 files changed, 9 insertions, 8 deletions
diff --git a/02-usart/src/main.c b/02-usart/src/main.c
index 5af52ed..862676c 100644
--- a/02-usart/src/main.c
+++ b/02-usart/src/main.c
@@ -1,4 +1,5 @@
+#include "arch.h"
#include "clock.h"
#include "delay.h"
#include "gpio.h"
@@ -70,7 +71,7 @@ int enable_usart1(uint32_t baud_rate)
/* Enable the transmitter and the receiver. */
usart_set_enabled(&USART1, USART_ENABLE_TX);
- asm volatile(" cpsie i ");
+ enable_interrupts();
}
/* Main function. This gets executed from the interrupt vector defined above. */
@@ -88,6 +89,6 @@ int main()
enable_usart2(115200);
pin_on(pin3);
- usart_transmit_str(&USART2, "Hello, World\n");
+ usart_transmit_str_sync(&USART2, "Hello, World\n");
for(;;);
}
diff --git a/02-usart/src/usart.c b/02-usart/src/usart.c
index eddfbe7..42297a8 100644
--- a/02-usart/src/usart.c
+++ b/02-usart/src/usart.c
@@ -51,7 +51,7 @@ void usart_set_enabled(__IO usart_t* usart, usart_enable_t enabled)
}
}
-void usart_transmit_byte(__IO usart_t* usart, uint8_t byte)
+void usart_transmit_byte_sync(__IO usart_t* usart, uint8_t byte)
{
usart->td_r = byte;
/* Per the manual, when bit 7 of the IS register is set, then the usart
@@ -62,19 +62,19 @@ void usart_transmit_byte(__IO usart_t* usart, uint8_t byte)
;
}
-void usart_transmit_bytes(__IO usart_t* usart, const uint8_t* bytes, uint32_t n)
+void usart_transmit_bytes_sync(__IO usart_t* usart, const uint8_t* bytes, uint32_t n)
{
while (n --) {
- usart_transmit_byte(usart, *(bytes ++));
+ usart_transmit_byte_sync(usart, *(bytes ++));
}
}
-void usart_transmit_str(__IO usart_t* usart, const char* str)
+void usart_transmit_str_sync(__IO usart_t* usart, const char* str)
{
while (*str) {
if (*str == '\n') {
- usart_transmit_byte(usart, '\r');
+ usart_transmit_byte_sync(usart, '\r');
}
- usart_transmit_byte(usart, *(str ++));
+ usart_transmit_byte_sync(usart, *(str ++));
}
}