aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-04 15:25:26 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-05 17:10:23 +0200
commit1a507d65ea1f7cf6918eddc1554176579f7892b1 (patch)
treeb02084afeee6faa9740bcd74612192b019b15853
parent54b86809942e247648511bab04ea793bcfda2f2c (diff)
downloadglutte-o-matic-1a507d65ea1f7cf6918eddc1554176579f7892b1.tar.gz
glutte-o-matic-1a507d65ea1f7cf6918eddc1554176579f7892b1.tar.bz2
glutte-o-matic-1a507d65ea1f7cf6918eddc1554176579f7892b1.zip
Fix cosmetic delay.[ch] issues
-rw-r--r--src/common/includes/Core/delay.h5
-rw-r--r--src/stm32f/src/Core/delay.c22
2 files changed, 10 insertions, 17 deletions
diff --git a/src/common/includes/Core/delay.h b/src/common/includes/Core/delay.h
index 73ed669..67ff3b7 100644
--- a/src/common/includes/Core/delay.h
+++ b/src/common/includes/Core/delay.h
@@ -22,11 +22,12 @@
* SOFTWARE.
*/
+#pragma once
+#include <stdint.h>
// High-precisions delay (with approximations)
-
-// Thoses functions works only if interupts are disabled
+// These functions only work if interupts are disabled
void delay_us(uint32_t micros);
void delay_ms(uint32_t millis);
diff --git a/src/stm32f/src/Core/delay.c b/src/stm32f/src/Core/delay.c
index 8c9d24c..59030c4 100644
--- a/src/stm32f/src/Core/delay.c
+++ b/src/stm32f/src/Core/delay.c
@@ -1,4 +1,3 @@
-
/*
* The MIT License (MIT)
*
@@ -23,37 +22,30 @@
* SOFTWARE.
*/
-
-#include <stdint.h>
+#include "delay.h"
#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"
-#ifndef __DELAY_H
-#define __DELAY_H
-
-
uint32_t delay_multiplier = 1;
-void delay_us(uint32_t micros) {
-
+void delay_us(uint32_t micros)
+{
micros = micros * delay_multiplier - 10;
while (micros--);
}
-void delay_ms(uint32_t millis) {
-
+void delay_ms(uint32_t millis)
+{
for (int i = 0; i < 1000; i++) {
delay_us(millis);
}
}
-void delay_init() {
-
+void delay_init()
+{
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);
delay_multiplier = RCC_Clocks.HCLK_Frequency / 4000000;
-
}
-#endif