Skip to content

Commit e5e22af

Browse files
committed
Use inheritance for HAL
1 parent 0eea2d7 commit e5e22af

16 files changed

Lines changed: 985 additions & 2829 deletions

src/hal/arduino/minbasecli_arduino.cpp

Lines changed: 38 additions & 352 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
/**
3-
* @file minbasecli.h
3+
* @file minbasecli_arduino.h
44
* @author Jose Miguel Rios Rubio <jrios.github@gmail.com>
5-
* @date 26-05-2021
6-
* @version 1.0.0
5+
* @date 08-02-2022
6+
* @version 1.0.1
77
*
88
* @section DESCRIPTION
99
*
@@ -33,10 +33,10 @@
3333

3434
/* Include Guard */
3535

36-
#ifdef ARDUINO
36+
#if defined(ARDUINO)
3737

38-
#ifndef MINBASECLI_H_
39-
#define MINBASECLI_H_
38+
#ifndef MINBASECLI_ARDUINO_H_
39+
#define MINBASECLI_ARDUINO_H_
4040

4141
/*****************************************************************************/
4242

@@ -51,61 +51,31 @@
5151

5252
/* Constants & Defines */
5353

54-
#define SIMPLECLI_READ_TIMEOUT_MS 100
55-
#define SIMPLECLI_READ_INTERCHAR_TIMEOUT_MS 10
56-
#define SIMPLECLI_MAX_READ_SIZE 64
57-
#define SIMPLECLI_MAX_CMD_LEN 24
58-
#define SIMPLECLI_MAX_ARGV_LEN 32
59-
#define SIMPLECLI_MAX_ARGV 4
60-
6154
/*****************************************************************************/
6255

63-
/* Data Types */
64-
65-
typedef struct t_cli_result
66-
{
67-
char cmd[SIMPLECLI_MAX_CMD_LEN];
68-
char argv[SIMPLECLI_MAX_ARGV][SIMPLECLI_MAX_ARGV_LEN];
69-
uint8_t argc;
70-
} t_cli_result;
71-
72-
/*****************************************************************************/
56+
/* CLass Interface */
7357

74-
class MINBASECLI
58+
class MINBASECLI_ARDUINO
7559
{
7660
public:
77-
MINBASECLI();
78-
79-
bool setup();
80-
bool setup(void* iface);
81-
bool manage(t_cli_result* cli_result);
82-
uint32_t get_received_bytes();
61+
MINBASECLI_ARDUINO();
8362

8463
private:
8564
void* iface;
86-
bool initialized;
87-
uint32_t received_bytes;
88-
char rx_read[SIMPLECLI_MAX_READ_SIZE];
89-
90-
void set_default_result(t_cli_result* cli_result);
91-
bool iface_is_not_initialized();
92-
bool iface_read_data(char* rx_read, const size_t rx_read_size);
93-
size_t iface_read_data_t(char* rx_read, const size_t rx_read_size);
94-
uint32_t str_count_words(const char* str_in, const size_t str_in_len);
95-
bool str_read_until_char(char* str, const size_t str_len,
96-
const char until_c, char* str_read,
97-
const size_t str_read_size);
98-
99-
bool hal_uart_setup();
100-
uint32_t hal_millis();
65+
66+
protected:
67+
bool hal_setup(const uint32_t baud_rate);
68+
bool hal_setup(void* iface, const uint32_t baud_rate);
10169
void hal_iface_print(const char* str);
10270
void hal_iface_println(const char* str);
10371
size_t hal_iface_available();
10472
uint8_t hal_iface_read();
73+
void hal_millis_init();
74+
uint32_t hal_millis();
10575
};
10676

10777
/*****************************************************************************/
10878

109-
#endif /* MINBASECLI_H_ */
79+
#endif /* MINBASECLI_ARDUINO_H_ */
11080

111-
#endif /* ARDUINO */
81+
#endif /* defined(ARDUINO) */

0 commit comments

Comments
 (0)