aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple/util.c')
-rw-r--r--libmaple/util.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/libmaple/util.c b/libmaple/util.c
index a747948..3325d2b 100644
--- a/libmaple/util.c
+++ b/libmaple/util.c
@@ -68,7 +68,7 @@ void _fail(const char* file, int line, const char* exp) {
usart_putudec(ERROR_USART_NUM, line);
usart_putc(ERROR_USART_NUM, '\n');
usart_putc(ERROR_USART_NUM, '\r');
-
+
/* Turn on the error LED */
gpio_set_mode(ERROR_LED_PORT, ERROR_LED_PIN, GPIO_MODE_OUTPUT_PP);
@@ -77,24 +77,35 @@ void _fail(const char* file, int line, const char* exp) {
nvic_irq_enable(NVIC_INT_USBLP);
/* Error fade */
- while (1) {
- if (CC == TOP_CNT) {
- slope = -1;
- } else if (CC == 0) {
- slope = 1;
- }
-
- if (i == TOP_CNT) {
- CC += slope;
- i = 0;
- }
-
- if (i < CC) {
- gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 1);
- } else {
- gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 0);
- }
- i++;
- }
+ throb();
+}
+
+void throb(void) {
+ int32 slope = 1;
+ uint32 CC = 0x0000;
+ uint32 TOP_CNT = 0x0200;
+ uint32 i = 0;
+
+ gpio_set_mode(ERROR_LED_PORT, ERROR_LED_PIN, GPIO_MODE_OUTPUT_PP);
+ /* Error fade */
+ while (1) {
+ if (CC == TOP_CNT) {
+ slope = -1;
+ } else if (CC == 0) {
+ slope = 1;
+ }
+
+ if (i == TOP_CNT) {
+ CC += slope;
+ i = 0;
+ }
+
+ if (i < CC) {
+ gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 1);
+ } else {
+ gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 0);
+ }
+ i++;
+ }
}