ME 507 Romi++
Cylindrical Differential Drive Robot created for ME 507 at Cal Poly in Spring 2025
Loading...
Searching...
No Matches
command_parser.h
Go to the documentation of this file.
1/*
2 * command_parser.h
3 *
4 * Created on: Jun 10, 2025
5 * Author: jacka
6 */
7
8#ifndef INC_COMMAND_PARSER_H_
9#define INC_COMMAND_PARSER_H_
10
18
19#include "stm32f4xx_hal.h"
20#include <stdint.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
27#define BUFFER_SIZE 64
28
30extern uint8_t rx_buffer[BUFFER_SIZE];
31
33extern uint8_t buffer_index;
34
36extern volatile uint8_t command_ready;
37
38#ifdef __cplusplus
39}
40#endif
41
42#ifdef __cplusplus
43
50class COMMAND_PARSER {
51public:
55 COMMAND_PARSER();
56
60 void parse();
61
66 int16_t get_M1_set() const;
67
72 int16_t get_M2_set() const;
73
78 int16_t get_headset() const;
79
84 char get_mode() const;
85
86private:
87 int16_t M1_set;
88 int16_t M2_set;
89 int16_t headset;
90 char mode;
91
101 int16_t hex4_to_int16(char c1, char c2, char c3, char c4, int* valid);
102
108 int hex_char_to_val(char c);
109
117 int8_t hex_to_signed(char high, char low, int* valid);
118};
119
120#endif
121
122#endif /* INC_COMMAND_PARSER_H_ */
uint8_t buffer_index
Current write index into rx_buffer.
Definition main.cpp:106
#define BUFFER_SIZE
Maximum buffer size for incoming UART command stream.
Definition command_parser.h:27
volatile uint8_t command_ready
Flag indicating a complete command is available.
Definition main.cpp:107
uint8_t rx_buffer[BUFFER_SIZE]
DMA-compatible receive buffer for UART.
Definition main.cpp:105