Skip to content

Commit 799dbae

Browse files
committed
Removed unused builtin millis() from HALs
1 parent 88dacbb commit 799dbae

17 files changed

+2
-306
lines changed

README.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,6 @@ bool MINBASECLI_NEWDEV::hal_setup(void* iface, const uint32_t baud_rate)
8484
// should be written here
8585
}
8686

87-
void MINBASECLI_NEWDEV::hal_iface_print(const char* str)
88-
{
89-
// Specific device/framework interface print text
90-
// should be written here
91-
}
92-
93-
void MINBASECLI_NEWDEV::hal_iface_println(const char* str)
94-
{
95-
// Specific device/framework interface print text line
96-
// should be written here
97-
}
98-
9987
size_t MINBASECLI_NEWDEV::hal_iface_available()
10088
{
10189
// Specific device/framework return num bytes received from interface
@@ -108,15 +96,9 @@ uint8_t MINBASECLI_NEWDEV::hal_iface_read(void)
10896
// should be written here
10997
}
11098

111-
uint32_t MINBASECLI_NEWDEV::hal_millis_init()
99+
void MINBASECLI_ARDUINO::hal_iface_print(const uint8_t data_byte)
112100
{
113-
// Specific device/framework system tick count initialization
114-
// should be written here
115-
}
116-
117-
uint32_t MINBASECLI_NEWDEV::hal_millis()
118-
{
119-
// Specific device/framework return system tick milliseconds
101+
// Specific device/framework interface print text
120102
// should be written here
121103
}
122104

src/hal/arduino/minbasecli_arduino.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,6 @@ void MINBASECLI_ARDUINO::hal_iface_print(const uint8_t data_byte)
128128
_Serial->write(data_byte);
129129
}
130130

131-
/**
132-
* @brief Timer1 setup and initialization to count System Tick.
133-
*/
134-
void MINBASECLI_ARDUINO::hal_millis_init()
135-
{
136-
/* Nothing to be done, Arduino Core already initialize a Timer for system
137-
tick count. */
138-
}
139-
140-
/**
141-
* @brief Get system-tick in ms (number of ms since system boot).
142-
* @return The number of milliseconds.
143-
*/
144-
uint32_t MINBASECLI_ARDUINO::hal_millis()
145-
{
146-
return ((uint32_t) (millis()));
147-
}
148-
149131
/*****************************************************************************/
150132

151133
#endif /* defined(ARDUINO) */

src/hal/arduino/minbasecli_arduino.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class MINBASECLI_ARDUINO
6969
size_t hal_iface_available();
7070
uint8_t hal_iface_read();
7171
void hal_iface_print(const uint8_t data_byte);
72-
void hal_millis_init();
73-
uint32_t hal_millis();
7472
};
7573

7674
/*****************************************************************************/

src/hal/avr/minbasecli_avr.cpp

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@
4242
// Header Interface
4343
#include "minbasecli_avr.h"
4444

45-
// Device/Framework Libraries
46-
#if defined(MINBASECLI_USE_MILLIS)
47-
#include <avr/io.h>
48-
#include <avr/interrupt.h>
49-
#endif
50-
5145
// (UART Driver)
5246
#include "avr_uart.h"
5347

@@ -63,14 +57,6 @@
6357

6458
/*****************************************************************************/
6559

66-
/* In-Scope Global Elements */
67-
68-
#if defined(MINBASECLI_USE_MILLIS)
69-
volatile uint32_t systick;
70-
#endif
71-
72-
/*****************************************************************************/
73-
7460
/* Constructor */
7561

7662
/**
@@ -144,59 +130,6 @@ void MINBASECLI_AVR::hal_iface_print(const uint8_t data_byte)
144130
_Serial->write(data_byte);
145131
}
146132

147-
/**
148-
* @brief Timer1 setup and initialization to count System Tick.
149-
*/
150-
void MINBASECLI_AVR::hal_millis_init()
151-
{
152-
#if defined(MINBASECLI_USE_MILLIS)
153-
unsigned long t_overflow;
154-
155-
// Timer1 clock divisor 8 and clear at overflow
156-
TCCR1B |= (1 << WGM12) | (1 << CS11);
157-
158-
// Set timer overflow for 1ms
159-
t_overflow = ((F_CPU / 1000) / 8);
160-
OCR1AH = (t_overflow >> 8);
161-
OCR1AL = t_overflow;
162-
163-
// Enable Timer1 compare match interrupt
164-
TIMSK1 |= (1 << OCIE1A);
165-
166-
// Enbale Global Interrupts
167-
sei();
168-
#endif /* defined(MINBASECLI_USE_MILLIS) */
169-
}
170-
171-
/**
172-
* @brief Get system-tick in ms (number of ms since system boot).
173-
* @return The number of milliseconds.
174-
*/
175-
uint32_t MINBASECLI_AVR::hal_millis()
176-
{
177-
#if defined(MINBASECLI_USE_MILLIS)
178-
return systick;
179-
#else
180-
return 0;
181-
#endif /* defined(MINBASECLI_USE_MILLIS) */
182-
}
183-
184-
/*****************************************************************************/
185-
186-
/* Millis Implementation */
187-
188-
#if defined(MINBASECLI_USE_MILLIS)
189-
190-
/**
191-
* @brief Timer1 Interrupt Service Rutine for System Tick counter.
192-
*/
193-
ISR(TIMER1_COMPA_vect)
194-
{
195-
systick = systick + 1;
196-
}
197-
198-
#endif /* defined(MINBASECLI_USE_MILLIS) */
199-
200133
/*****************************************************************************/
201134

202135
#endif /* defined(__AVR) && !defined(ARDUINO) */

src/hal/avr/minbasecli_avr.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ class MINBASECLI_AVR
7070
size_t hal_iface_available();
7171
uint8_t hal_iface_read();
7272
void hal_iface_print(const uint8_t data_byte);
73-
void hal_millis_init();
74-
uint32_t hal_millis();
7573

7674
private:
7775
void* iface;

src/hal/espidf/minbasecli_espidf.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,6 @@ void MINBASECLI_ESPIDF::hal_iface_print(const uint8_t data_byte)
141141
printf("%c", (char)(data_byte));
142142
}
143143

144-
/**
145-
* @brief Timer setup and initialization to count System Tick.
146-
*/
147-
void MINBASECLI_ESPIDF::hal_millis_init()
148-
{
149-
150-
/* Nothing to be done, ESP-IDF already call esp_timer_init() to
151-
initialize system tick count. */
152-
}
153-
154-
/**
155-
* @brief Get system-tick in ms (number of ms since system boot).
156-
* @return The number of milliseconds.
157-
*/
158-
uint32_t MINBASECLI_ESPIDF::hal_millis()
159-
{
160-
return (uint32_t)(esp_timer_get_time() / 1000);
161-
}
162-
163144
/*****************************************************************************/
164145

165146
/* Private Methods */

src/hal/espidf/minbasecli_espidf.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ class MINBASECLI_ESPIDF
7171
size_t hal_iface_available();
7272
uint8_t hal_iface_read();
7373
void hal_iface_print(const uint8_t data_byte);
74-
void hal_millis_init();
75-
uint32_t hal_millis();
7674

7775
private:
7876
void* iface;

src/hal/linux/minbasecli_linux.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
// Standard Libraries
5050
#include <string.h>
5151
#include <stdio.h> // getchar(), printf()
52-
#include <time.h> // millis()
5352
#include <unistd.h> // async stdin-stdout interface
5453

5554
/*****************************************************************************/
@@ -71,9 +70,6 @@ MINBASECLI_LINUX::MINBASECLI_LINUX()
7170
this->th_rx_read_head = 0;
7271
this->th_rx_read_tail = 0;
7372
this->th_rx_read[0] = '\0';
74-
75-
// Initialize millis count
76-
hal_millis_init();
7773
}
7874

7975
/*****************************************************************************/
@@ -129,41 +125,6 @@ void MINBASECLI_LINUX::hal_iface_print(const uint8_t data_byte)
129125
printf("%c", (char)(data_byte));
130126
}
131127

132-
/**
133-
* @brief Initialize System-Tick count.
134-
*/
135-
void MINBASECLI_LINUX::hal_millis_init()
136-
{
137-
hal_millis();
138-
}
139-
140-
/**
141-
* @brief Get system-tick in ms (number of ms since system boot).
142-
* @return The number of milliseconds.
143-
*/
144-
uint32_t MINBASECLI_LINUX::hal_millis()
145-
{
146-
static bool first_execution = true;
147-
static struct timespec t_start;
148-
static struct timespec t_now;
149-
uint32_t ms = 0;
150-
151-
if (first_execution)
152-
{
153-
first_execution = false;
154-
if (clock_gettime(CLOCK_MONOTONIC_RAW, &t_start) != 0)
155-
return 0;
156-
}
157-
158-
if (clock_gettime(CLOCK_MONOTONIC_RAW, &t_now) != 0)
159-
return (t_start.tv_nsec / 1000000);
160-
161-
ms = (uint32_t) ((((t_now.tv_sec - t_start.tv_sec) * 1000000000) +
162-
(t_now.tv_nsec - t_start.tv_nsec)) / 1000000);
163-
164-
return ms;
165-
}
166-
167128
/*****************************************************************************/
168129

169130
/* Private Methods */

src/hal/linux/minbasecli_linux.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ class MINBASECLI_LINUX
7171
size_t hal_iface_available();
7272
uint8_t hal_iface_read();
7373
void hal_iface_print(const uint8_t data_byte);
74-
void hal_millis_init();
75-
uint32_t hal_millis();
7674

7775
private:
7876
void* iface;

src/hal/none/minbasecli_none.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,6 @@ void MINBASECLI_NONE::hal_iface_print(const uint8_t data_byte)
122122
return;
123123
}
124124

125-
/**
126-
* @brief Initialize System-Tick count.
127-
*/
128-
void MINBASECLI_NONE::hal_millis_init()
129-
{
130-
return;
131-
}
132-
133-
/**
134-
* @brief Get system-tick in ms (number of ms since system boot).
135-
* @return The number of milliseconds.
136-
*/
137-
uint32_t MINBASECLI_NONE::hal_millis()
138-
{
139-
return 0;
140-
}
141-
142125
/*****************************************************************************/
143126

144127
#endif /* !ARDUINO !ESP_PLATFORM !__linux__ !_WIN32 ... */

0 commit comments

Comments
 (0)