Prusa MINI Firmware overview
uartslave.h
Go to the documentation of this file.
1 // uartslave.h
2 #ifndef _UARTSLAVE_H
3 #define _UARTSLAVE_H
4 
5 #include "uartrxbuff.h"
6 
7 #define UARTSLAVE_FLG_ECHO 0x01
8 
9 #define UARTSLAVE_MOD_MSK_0 0x0000
10 
11 #define UARTSLAVE_CMD_ID_0 0x0000
12 #define UARTSLAVE_CMD_ID_UNK 0xffff
13 
14 #define UARTSLAVE_OK 0 //ok - success
15 #define UARTSLAVE_ERR_UNK -1 //error 1 - unknown/unspecified failure
16 #define UARTSLAVE_ERR_BSY -2 //error 2 - busy
17 #define UARTSLAVE_ERR_SYN -3 //error 3 - syntax error
18 #define UARTSLAVE_ERR_OOR -4 //error 4 - parameter out of range
19 #define UARTSLAVE_ERR_ONP -5 //error 5 - operation not permitted
20 #define UARTSLAVE_ERR_NUL -6 //error 6 - null pointer
21 #define UARTSLAVE_ERR_CNF -7 //error 7 - command not found
22 
23 typedef struct _uartslave_t uartslave_t;
24 
25 typedef int(uartslave_parse_mod_mask_t)(uartslave_t *pslave, char *pstr, uint16_t *pmod_msk);
26 typedef int(uartslave_parse_cmd_id_t)(uartslave_t *pslave, char *pstr, uint16_t *pcmd_id);
27 typedef int(uartslave_do_cmd_t)(uartslave_t *pslave, uint16_t mod_msk, char cmd, uint16_t pcmd_id, char *pstr);
28 
29 #pragma pack(push)
30 #pragma pack(1)
31 
32 typedef struct _uartslave_t {
35  int count;
36  int size;
37  char *pline;
41 } uartslave_t;
42 
43 #pragma pack(pop)
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif //__cplusplus
48 
49 extern void uartslave_init(uartslave_t *pslave, uartrxbuff_t *prxbuff, int size, char *pline);
50 
51 extern void uartslave_cycle(uartslave_t *pslave);
52 
53 int uartslave_printf(uartslave_t *pslave, const char *fmt, ...);
54 
55 #ifdef __cplusplus
56 }
57 #endif //__cplusplus
58 
59 #endif // _UARTSLAVE_H
_uartslave_t::parse_mod_mask
uartslave_parse_mod_mask_t * parse_mod_mask
Definition: uartslave.h:38
uartslave_parse_cmd_id_t
int() uartslave_parse_cmd_id_t(uartslave_t *pslave, char *pstr, uint16_t *pcmd_id)
Definition: uartslave.h:26
_uartslave_t::count
int count
Definition: uartslave.h:35
uartslave_printf
int uartslave_printf(uartslave_t *pslave, const char *fmt,...)
Definition: uartslave.c:129
UARTSLAVE_ERR_SYN
#define UARTSLAVE_ERR_SYN
Definition: uartslave.h:17
HAL_OK
Definition: stm32f4xx_hal_def.h:57
uartslave.h
uartslave_cycle
void uartslave_cycle(uartslave_t *pslave)
Definition: uartslave.c:68
uartslave_parse_mod_mask_t
int() uartslave_parse_mod_mask_t(uartslave_t *pslave, char *pstr, uint16_t *pmod_msk)
Definition: uartslave.h:25
_uartslave_t
Definition: uartslave.h:32
_dbg0
#define _dbg0
Definition: dbg.h:31
uartslave_cycle
void uartslave_cycle(uartslave_t *pslave)
Definition: uartslave.c:68
_uartslave_t::flags
uint8_t flags
Definition: uartslave.h:34
UARTSLAVE_MOD_MSK_0
#define UARTSLAVE_MOD_MSK_0
Definition: uartslave.h:9
uartslave_printf
int uartslave_printf(uartslave_t *pslave, const char *fmt,...)
Definition: uartslave.c:129
dbg.h
uartslave_do_cmd
int uartslave_do_cmd(uartslave_t *pslave, uint16_t mod_msk, char cmd, uint16_t cmd_id, char *pstr)
Definition: uartslave.c:52
uartslave_init
void uartslave_init(uartslave_t *pslave, uartrxbuff_t *prxbuff, int size, char *pline)
Definition: uartslave.c:57
_uartrxbuff_t::phuart
UART_HandleTypeDef * phuart
Definition: uartrxbuff.h:17
UARTSLAVE_CMD_ID_UNK
#define UARTSLAVE_CMD_ID_UNK
Definition: uartslave.h:12
_uartslave_t::size
int size
Definition: uartslave.h:36
uartrxbuff_getchar
int uartrxbuff_getchar(uartrxbuff_t *prxbuff)
Definition: uartrxbuff.c:38
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32f4xx_hal_def.h:55
_uartslave_t::prxbuff
uartrxbuff_t * prxbuff
Definition: uartslave.h:33
UARTSLAVE_FLG_ECHO
#define UARTSLAVE_FLG_ECHO
Definition: uartslave.h:7
uint8_t
const uint8_t[]
Definition: 404_html.c:3
_uartslave_t::pline
char * pline
Definition: uartslave.h:37
uartrxbuff.h
uartslave_do_cmd_t
int() uartslave_do_cmd_t(uartslave_t *pslave, uint16_t mod_msk, char cmd, uint16_t pcmd_id, char *pstr)
Definition: uartslave.h:27
stm32f4xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
_uartslave_t::do_cmd
uartslave_do_cmd_t * do_cmd
Definition: uartslave.h:40
uartslave_parse_mod_mask
int uartslave_parse_mod_mask(uartslave_t *pslave, char *pstr, uint16_t *pmod_msk)
Definition: uartslave.c:10
UARTSLAVE_OK
#define UARTSLAVE_OK
Definition: uartslave.h:14
createSpeedLookupTable.int
int
Definition: createSpeedLookupTable.py:15
uartslave_t
struct _uartslave_t uartslave_t
Definition: uartslave.h:23
uartslave_parse_cmd_id
int uartslave_parse_cmd_id(uartslave_t *pslave, char *pstr, uint16_t *pcmd_id)
Definition: uartslave.c:34
uartslave_init
void uartslave_init(uartslave_t *pslave, uartrxbuff_t *prxbuff, int size, char *pline)
Definition: uartslave.c:57
HAL_MAX_DELAY
#define HAL_MAX_DELAY
Definition: stm32f4xx_hal_def.h:76
UARTSLAVE_CMD_ID_0
#define UARTSLAVE_CMD_ID_0
Definition: uartslave.h:11
_uartslave_t::parse_cmd_id
uartslave_parse_cmd_id_t * parse_cmd_id
Definition: uartslave.h:39
_uartrxbuff_t
Definition: uartrxbuff.h:16
size
static png_bytep size_t size
Definition: pngwrite.c:2170
HAL_UART_Transmit
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)