aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple/util.c')
-rw-r--r--libmaple/util.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/libmaple/util.c b/libmaple/util.c
index 3325d2b..be29e7e 100644
--- a/libmaple/util.c
+++ b/libmaple/util.c
@@ -1,4 +1,4 @@
-/* *****************************************************************************
+/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 Perry Hung.
@@ -20,13 +20,13 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
- * ****************************************************************************/
+ *****************************************************************************/
/**
- * @file util.h
+ * @file util.h
*
- * @brief Utility procedures for debugging, mostly an error LED fade and
- * messages dumped over a uart for failed asserts.
+ * @brief Utility procedures for debugging, mostly an error LED fade
+ * and messages dumped over a uart for failed asserts.
*/
#include "libmaple.h"
@@ -52,14 +52,14 @@ void _fail(const char* file, int line, const char* exp) {
/* Turn off ADC */
adc_disable();
- /* Turn off all usarts */
+ /* Turn off all usarts */
usart_disable_all();
/* Initialize the error usart */
gpio_set_mode(ERROR_TX_PORT, ERROR_TX_PIN, GPIO_MODE_AF_OUTPUT_PP);
usart_init(ERROR_USART_NUM, ERROR_USART_BAUD);
- /* Print failed assert message */
+ /* Print failed assert message */
usart_putstr(ERROR_USART_NUM, "ERROR: FAILED ASSERT(");
usart_putstr(ERROR_USART_NUM, exp);
usart_putstr(ERROR_USART_NUM, "): ");
@@ -69,43 +69,43 @@ void _fail(const char* file, int line, const char* exp) {
usart_putc(ERROR_USART_NUM, '\n');
usart_putc(ERROR_USART_NUM, '\r');
- /* Turn on the error LED */
+ /* Turn on the error LED */
gpio_set_mode(ERROR_LED_PORT, ERROR_LED_PIN, GPIO_MODE_OUTPUT_PP);
- /* Turn the USB interrupt back on so the bootloader keeps on functioning */
+ /* Turn the USB interrupt back on so the bootloader keeps on functioning */
nvic_irq_enable(NVIC_INT_USBHP);
nvic_irq_enable(NVIC_INT_USBLP);
- /* Error fade */
+ /* Error fade */
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++;
- }
+ 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++;
+ }
}